From: girish Date: Wed, 1 Jul 2009 06:57:31 +0000 (+0000) Subject: b=18442 X-Git-Tag: v1_9_220~70 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=af5d6582a3fca5bb5f7e157fe0dc5bfe5cfcf743 b=18442 i=adilger i=rread o=james simmons integrate "ll_getstripe_info" into "lfs getstripe" --- diff --git a/lustre/include/lustre/liblustreapi.h b/lustre/include/lustre/liblustreapi.h index c65018c..f10e697 100644 --- a/lustre/include/lustre/liblustreapi.h +++ b/lustre/include/lustre/liblustreapi.h @@ -86,6 +86,14 @@ extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum); #define HAVE_LLAPI_FILE_LOOKUP extern int llapi_file_lookup(int dirfd, const char *name); +#define VERBOSE_COUNT 0x1 +#define VERBOSE_SIZE 0x2 +#define VERBOSE_OFFSET 0x4 +#define VERBOSE_POOL 0x8 +#define VERBOSE_DETAIL 0x10 +#define VERBOSE_ALL (VERBOSE_COUNT | VERBOSE_SIZE | VERBOSE_OFFSET | \ + VERBOSE_POOL) + struct find_param { unsigned int maxdepth; time_t atime; diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index b39cddb..5c84523 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -52,7 +52,7 @@ noinst_PROGRAMS += small_write multiop ll_sparseness_verify noinst_PROGRAMS += ll_sparseness_write mrename ll_dirstripe_verify mkdirmany noinst_PROGRAMS += openfilleddirunlink rename_many memhog iopentest1 iopentest2 noinst_PROGRAMS += mmap_sanity flock_test writemany reads flocks_test -noinst_PROGRAMS += ll_getstripe_info write_time_limit rwv +noinst_PROGRAMS += write_time_limit rwv # noinst_PROGRAMS += copy_attr mkdirdeep bin_PROGRAMS = mcreate munlink testdir = $(libdir)/lustre/tests @@ -66,7 +66,6 @@ endif # TESTS mmap_sanity_SOURCES= mmap_sanity.c LIBLUSTREAPI := $(top_builddir)/lustre/utils/liblustreapi.a -ll_getstripe_info_LDADD=$(LIBLUSTREAPI) multiop_LDADD=$(LIBLUSTREAPI) -lrt ll_dirstripe_verify_SOURCES= ll_dirstripe_verify.c diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 921691e..a482ad5 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -40,7 +40,6 @@ GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"} LSTRIPE=${LSTRIPE:-"$LFS setstripe"} LFIND=${LFIND:-"$LFS find"} LVERIFY=${LVERIFY:-ll_dirstripe_verify} -LSTRIPEINFO=${LSTRIPEINFO:-ll_getstripe_info} LCTL=${LCTL:-lctl} MCREATE=${MCREATE:-mcreate} OPENFILE=${OPENFILE:-openfile} @@ -1180,15 +1179,15 @@ run_test 27v "skip object creation on slow OST =================" test_27w() { # bug 10997 mkdir -p $DIR/d27w || error "mkdir failed" $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed" - size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}` + size=`$GETSTRIPE $DIR/d27w/f0 -qs` [ $size -ne 65536 ] && error "stripe size $size != 65536" || true [ "$OSTCOUNT" -lt "2" ] && skip "skipping multiple stripe count/offset test" && return for i in `seq 1 $OSTCOUNT`; do offset=$(($i-1)) $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed" - count=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $2'}` - index=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $3'}` + count=`$GETSTRIPE -qc $DIR/d27w/f$i` + index=`$GETSTRIPE -qo $DIR/d27w/f$i` [ $count -ne $i ] && error "stripe count $count != $i" || true [ $index -ne $offset ] && error "stripe offset $index != $offset" || true done diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 6d2ac85..044671a 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -132,6 +132,8 @@ command_t cmdlist[] = { "To list the striping info for a given file or files in a\n" "directory or recursively for all files in a directory tree.\n" "usage: getstripe [--obd|-O ] [--quiet | -q] [--verbose | -v]\n" + " [--count | -c ] [--size | -s ] [--index | -i ]\n" + " [--offset | -o ] [--pool | -p ]\n" " [--recursive | -r] ..."}, {"pool_list", lfs_poollist, 0, "List pools or pool OSTs\n" @@ -831,10 +833,15 @@ static int lfs_getstripe(int argc, char **argv) {"obd", 1, 0, 'O'}, {"quiet", 0, 0, 'q'}, {"recursive", 0, 0, 'r'}, + {"count", 0, 0, 'c'}, + {"size", 0, 0, 's'}, + {"index", 0, 0, 'i'}, + {"offset", 0, 0, 'o'}, + {"pool", 0, 0, 'p'}, {"verbose", 0, 0, 'v'}, {0, 0, 0, 0} }; - char short_opts[] = "hO:qrv"; + char short_opts[] = "hO:qrvcsiop"; int c, rc; struct find_param param = { 0 }; @@ -853,15 +860,27 @@ static int lfs_getstripe(int argc, char **argv) break; case 'q': param.quiet++; - param.verbose = 0; break; case 'r': param.recursive = 1; break; case 'v': - param.verbose++; + param.verbose = VERBOSE_ALL | VERBOSE_DETAIL; param.quiet = 0; break; + case 'c': + param.verbose |= VERBOSE_COUNT; + break; + case 's': + param.verbose |= VERBOSE_SIZE; + break; + case 'i': + case 'o': + param.verbose |= VERBOSE_OFFSET; + break; + case 'p': + param.verbose |= VERBOSE_POOL; + break; case '?': return CMD_HELP; default: diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index fb97e90..c0d96be 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -836,6 +836,61 @@ retry_get_uuids: return 0; } +static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, + int is_dir, int verbose, int quiet, + char *pool_name) +{ + char *prefix = is_dir ? "" : "lmm_"; + char nl = is_dir ? ' ' : '\n'; + + if (verbose && path) + llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path); + + if ((verbose & VERBOSE_DETAIL) && !is_dir) { + llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic: 0x%08X\n", + lum->lmm_magic); + llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_gr: "LPX64"\n", + lum->lmm_object_gr); + llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id: "LPX64"\n", + lum->lmm_object_id); + } + + if (verbose & VERBOSE_COUNT) { + if (!quiet) + llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_count: ", + prefix); + llapi_printf(LLAPI_MSG_NORMAL, "%u%c", + (int)lum->lmm_stripe_count, nl); + } + + if (verbose & VERBOSE_SIZE) { + if (!quiet) + llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_size: ", + prefix); + llapi_printf(LLAPI_MSG_NORMAL, "%u%c", lum->lmm_stripe_size, + nl); + } + + if ((verbose & VERBOSE_DETAIL) && !is_dir) { + llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x%c", + lum->lmm_pattern, nl); + } + + if (verbose & VERBOSE_OFFSET) { + if (!quiet) + llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset: ", + prefix); + llapi_printf(LLAPI_MSG_NORMAL, "%u%c", + lum->lmm_objects[0].l_ost_idx, nl); + } + + if ((verbose & VERBOSE_POOL) && (pool_name != NULL)) + llapi_printf(LLAPI_MSG_NORMAL, "pool: %s%c", pool_name, nl); + + if (is_dir) + llapi_printf(LLAPI_MSG_NORMAL, "\n"); +} + void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name, struct lov_user_ost_data_v1 *objects, char *path, int is_dir, @@ -851,8 +906,9 @@ void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name, break; } } - } else if (!quiet) { - llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path); + } else { + if (!quiet) + llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path); obdstripe = 1; } @@ -863,39 +919,20 @@ void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name, llapi_printf(LLAPI_MSG_NORMAL, "(Default) "); lum->lmm_object_gr = LOV_OBJECT_GROUP_CLEAR; } - llapi_printf(LLAPI_MSG_NORMAL, - "stripe_count: %d stripe_size: %u " - "stripe_offset: %d%s%s\n", - lum->lmm_stripe_count == (__u16)-1 ? -1 : - lum->lmm_stripe_count, - lum->lmm_stripe_size, - lum->lmm_stripe_offset == (__u16)-1 ? -1 : - lum->lmm_stripe_offset, - pool_name != NULL ? " pool: " : "", - pool_name != NULL ? pool_name : ""); + /* maintain original behavior */ + if (!header) + header |= VERBOSE_ALL; + lov_dump_user_lmm_header(lum, path, is_dir, header, + quiet, pool_name); } return; } - if (header && (obdstripe == 1)) { - llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic: 0x%08X\n", - lum->lmm_magic); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_gr: "LPX64"\n", - lum->lmm_object_gr); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id: "LPX64"\n", - lum->lmm_object_id); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_count: %u\n", - (int)lum->lmm_stripe_count); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_size: %u\n", - lum->lmm_stripe_size); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x\n", - lum->lmm_pattern); - if (pool_name != NULL) - llapi_printf(LLAPI_MSG_NORMAL, - "lmm_pool_name: %s\n", pool_name); - } + if (header && (obdstripe == 1)) + lov_dump_user_lmm_header(lum, NULL, is_dir, header, quiet, + pool_name); - if (body) { + if (body && !(header && VERBOSE_ALL)) { if ((!quiet) && (obdstripe == 1)) llapi_printf(LLAPI_MSG_NORMAL, "\tobdidx\t\t objid\t\tobjid\t\t group\n"); @@ -929,29 +966,20 @@ void lov_dump_user_lmm_join(struct lov_user_md_v1 *lum, char *path, break; } } - } else if (!quiet) { - llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path); + } else { + if (!quiet) + llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path); obdstripe = 1; } if (header && obdstripe == 1) { - llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic: 0x%08X\n", - lumj->lmm_magic); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_gr: "LPX64"\n", - lumj->lmm_object_gr); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id: "LPX64"\n", - lumj->lmm_object_id); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_count: %u\n", - (int)lumj->lmm_stripe_count); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_size: %u\n", - lumj->lmm_stripe_size); - llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x\n", - lumj->lmm_pattern); + lov_dump_user_lmm_header(lum, NULL, 0, header, quiet, NULL); + llapi_printf(LLAPI_MSG_NORMAL, "lmm_extent_count: %x\n", lumj->lmm_extent_count); } - if (body) { + if (body && !(header && VERBOSE_ALL)) { unsigned long long start = -1, end = 0; if (!quiet && obdstripe == 1) llapi_printf(LLAPI_MSG_NORMAL,