[LU-17025] Invalid pool name does not return error Created: 10/Aug/23  Updated: 13/Dec/23

Status: Open
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.15.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Rajeev Mishra Assignee: Rajeev Mishra
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Related
is related to LU-11264 llapi_* routines demonstrate poor per... Open
Epic/Theme: llapi_file_open_pool
Story Points: 3
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Passing invalid striping parameters does not return error. In the below given test case the llapi_file_open_pool did not have right pool name and it did not fail

Below given is the test case that failed.

// compile with:
// cc llapi_noerr.c -llustreapi
//
// This program will produce a file ( ./test_file ) with invalid striping (in particular the pool) without raising an error.
//
// This can be verified with:
// lfs getstripe ./test_file 
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L 
#endif

#include <stdio.h>
#include <fcntl.h>
#include <lustre/lustreapi.h>
#include <stdlib.h> 
#include <string.h>

typedef struct {
   int64_t count;
   int64_t size;
   int64_t offset;
   int64_t pattern; 
   char *pool;
} lustrestripe; 

void f_get_lov_maxpoolname(int64_t *max) {
   *max = LOV_MAXPOOLNAME;
} 

static bool apply_stripe(lustrestripe *stripe_info, char *filename) {
   const mode_t perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; bool success = 0;
   int open_return;
   char *pool; pool = stripe_info->pool;

   printf("max poolname size = %i\n",LOV_MAXPOOLNAME); 
   if (pool != NULL) { 
     int64_t pool_max_size;
     f_get_lov_maxpoolname(&pool_max_size);
     if (strnlen(pool, (size_t)pool_max_size) == 0) { 
       pool = NULL; 
     }
   } 

   open_return = llapi_file_open_pool(filename, O_CREAT | O_WRONLY, (int)perm, 
            (unsigned long long)stripe_info->size, (int)stripe_info->offset,
            (int)stripe_info->count, (int)stripe_info->pattern, pool); 
   printf("open_return = %i\n",open_return);

   if (open_return < 0) {
     /* Something went wrong. */
     printf("open: lustreapi_pool: ERROR: %s\n", strerror(-open_return));  
     printf("open: lustreapi_pool: perm: %i\n", (int)perm); 
     printf("open: lustreapi_pool: size: %llu\n", (unsigned long long)stripe_info->size);
     printf("open: lustreapi_pool: offset: %i\n", (int)stripe_info->offset); 
     printf("open: lustreapi_pool: count: %i\n", (int)stripe_info->count); 
     printf("open: lustreapi_pool: pattern: %i\n", (int)stripe_info->pattern);

     if (pool == NULL) {
       printf("open: lustreapi_pool: pool: <default>\n"); 
     } else {
       printf("open: lustreapi_pool: pool: '%s'\n", pool); 
     } 
   } else {
     /* Striping information was set. */ 
     close(open_return); 
     success = 1;
     printf("No error from llapi_file_open_pool()\n"); 
   } 
  return success; 
}

int main() {
 bool res; 

 printf("open file with llapi\n");

 lustrestripe stripe_parms; 
 stripe_parms.size = 8388608; 
 stripe_parms.offset = -1; 
 stripe_parms.count = 10; 
 stripe_parms.pattern = LOV_PATTERN_RAID0; 
 stripe_parms.pool = calloc(LOV_MAXPOOLNAME,sizeof(char)); snprintf(stripe_parms.pool,LOV_MAXPOOLNAME,"stupidpool"); 

 char *filename = "./test_file"; 
 res = apply_stripe(&stripe_parms, filename);
 free(stripe_parms.pool); return (int)res; 
}

 



 Comments   
Comment by Rajeev Mishra [ 10/Aug/23 ]

Please assign the ticket to me for code push. Thanks

Comment by Gerrit Updater [ 16/Aug/23 ]

"Rajeev Mishra <rajeevm@hpe.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51962
Subject: LU-17025 test: Ensure pool exist before use
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: c41cf57e9d3f874112654907a19c41333192a8c1

Comment by Gerrit Updater [ 16/Aug/23 ]

"Rajeev Mishra <rajeevm@hpe.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51963
Subject: LU-17025 llapi: Verify stripe pool name
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: bc0770775c3335661213ae5311bc853b0265e521

Comment by Gerrit Updater [ 13/Dec/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51963/
Subject: LU-17025 llapi: Verify stripe pool name
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: ee7dfc5ad17d322e2e27ea2629c4a2d8e11a3507

Generated at Sat Feb 10 03:31:59 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.