Details
-
Bug
-
Resolution: Fixed
-
Major
-
Lustre 2.15.3
-
None
-
3
-
3
-
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; }