Skip to content

Commit

Permalink
Handle non-Lustre files gracefully in dstripe
Browse files Browse the repository at this point in the history
While filtering a list of files in dstripe, if a file
is not part of a lustre file system, simply skip it
for now.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Close #71
  • Loading branch information
dinatale2 committed Jun 15, 2017
1 parent 3736679 commit a4126ba
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/dstripe/dstripe.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ static void generate_suffix(char *suffix, const int len)
}

/* uses the lustre api to obtain stripe count and stripe size of a file */
static void get_file_stripe_info(const char *path, uint64_t *stripe_size, uint64_t *stripe_count)
static int get_file_stripe_info(const char *path, uint64_t *stripe_size, uint64_t *stripe_count)
{
#ifdef LUSTRE_SUPPORT
/* obtain the llapi_layout for a file by path */
struct llapi_layout *layout = llapi_layout_get_by_path(path, 0);

/* if no llapi_layout is returned, then some problem occured */
if (layout == NULL) {
printf("retrieving file stripe information for '%s' has failed, %s\n", path, strerror(errno));
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
return ENOENT;
}

/* obtain stripe count and stripe size */
Expand All @@ -98,6 +96,8 @@ static void get_file_stripe_info(const char *path, uint64_t *stripe_size, uint64
/* free the alloced llapi_layout */
llapi_layout_free(layout);
#endif

return 0;
}

/* create a striped lustre file at the path provided with the specified stripe size and count */
Expand Down Expand Up @@ -177,16 +177,20 @@ static void stripe_info_report(mfu_flist list)
char filesize[11];
char stripesize[9];

/* get the striping info and print it out */
get_file_stripe_info(in_path, &stripe_size, &stripe_count);
/*
* attempt to get striping info and print it out,
* skip the file if we can't get the striping info we seek
*/
if (get_file_stripe_info(in_path, &stripe_size, &stripe_count) != 0) {
continue;
}

/* format it nicely */
generate_pretty_size(filesize, sizeof(filesize), mfu_flist_file_get_size(list, idx));
generate_pretty_size(stripesize, sizeof(stripesize), stripe_size);

/* print the row */
printf("%10.10s %3" PRId64 " %8.8s %s\n", filesize, stripe_count, stripesize, in_path);

fflush(stdout);
}
}
Expand Down Expand Up @@ -215,8 +219,13 @@ static mfu_flist filter_list(mfu_flist list, int stripe_count, uint64_t stripe_s
uint64_t curr_stripe_size = 0;
uint64_t curr_stripe_count = 0;

/* obtain the file's current stripe size and stripe count */
get_file_stripe_info(in_path, &curr_stripe_size, &curr_stripe_count);
/*
* attempt to get striping info,
* skip the file if we can't get the striping info we seek
*/
if (get_file_stripe_info(in_path, &curr_stripe_size, &curr_stripe_count) != 0) {
continue;
}

/* TODO: this should probably be better */
/* if the current stripe size or stripe count doesn't match, then a restripe the file */
Expand Down

0 comments on commit a4126ba

Please sign in to comment.