From 9d383bbb167f572fde54c4ad3af4262abedfdd92 Mon Sep 17 00:00:00 2001 From: deen <deen> Date: Wed, 25 Jul 2007 23:18:32 +0000 Subject: [PATCH] Make lfs setstripe understand 'k', 'm' and 'g' for stripe size. i=adilger i=green b=12786 --- lustre/ChangeLog | 8 ++++++++ lustre/utils/lfs.c | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index e7acdf1732..a211ae2971 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,14 @@ * Recommended e2fsprogs version: 1.39.cfs8 * Note that reiserfs quotas are disabled on SLES 10 in this kernel. + +Severity : enhancement +Bugzilla : 12786 +Description: lfs setstripe enhancement +Details : Make lfs setstripe understand 'k', 'm' and 'g' for stripe size. + +-------------------------------------------------------------------------------- + 2007-07-30 Cluster File Systems, Inc. <info@clusterfs.com> * version 1.6.1 * Support for kernels: diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 6466cae5e6..16fc665084 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -84,6 +84,7 @@ command_t cmdlist[] = { " or \n" " setstripe -d <dirname> (to delete default striping)\n" "\tstripe_size: Number of bytes on each OST (0 filesystem default)\n" + "\t Can be specified with k, m or g (in KB, MB and GB respectively)\n" "\tstripe_index: OST index of first stripe (-1 filesystem default)\n" "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)"}, {"getstripe", lfs_getstripe, 0, @@ -150,7 +151,7 @@ static int lfs_setstripe(int argc, char **argv) { char *fname; int result; - long st_size; + unsigned long st_size; int st_offset, st_count; char *end; int c; @@ -243,9 +244,23 @@ static int lfs_setstripe(int argc, char **argv) if (stripe_size_arg != NULL) { st_size = strtoul(stripe_size_arg, &end, 0); if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe size '%s'\n", + if ((*end == 'k' || *end == 'K') && + *(end+1) == '\0' && + (st_size & (~0UL << (32 - 10))) == 0) { + st_size <<= 10; + } else if ((*end == 'm' || *end == 'M') && + *(end+1) == '\0' && + (st_size & (~0UL << (32 - 20))) == 0) { + st_size <<= 20; + } else if ((*end == 'g' || *end == 'G') && + *(end+1) == '\0' && + (st_size & (~0UL << (32 - 30))) == 0) { + st_size <<= 30; + } else { + fprintf(stderr, "error: %s: bad stripe size '%s'\n", argv[0], stripe_size_arg); - return CMD_HELP; + return CMD_HELP; + } } } /* get the stripe offset */ -- GitLab