From d6fea82d1431ec972c2661fa31223fb62498d953 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 19 Aug 2011 05:21:24 -0600 Subject: [PATCH] LU-611 utils: add restripe option to lfs_migrate Add the "-R" option to have lfs_migrate restripe a migrated file instead of keeping the original striping. This is useful of some directory got the wrong striping and a bunch of files were created with the wrong striping. Avoid possible confusion between the lfs_migrate and lfs setstripe command-line options. For now, deprecate the old "-c" option, since it is redundant in any case. Change-Id: I3a39bad93ef5c079678c65960e53d22e51431df3 Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/1265 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Yu Jian Reviewed-by: Oleg Drokin --- lustre/doc/lfs_migrate.1 | 22 ++++++++++------------ lustre/scripts/lfs_migrate | 23 ++++++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lustre/doc/lfs_migrate.1 b/lustre/doc/lfs_migrate.1 index bf65ebe..c59ac02 100644 --- a/lustre/doc/lfs_migrate.1 +++ b/lustre/doc/lfs_migrate.1 @@ -4,10 +4,11 @@ \- simple tool to migrate files between Lustre OSTs .SH SYNOPSIS .B lfs_migrate -.RB [ -c | -s ] .RB [ -h ] .RB [ -l ] .RB [ -n ] +.RB [ -R ] +.RB [ -s ] .RB [ -y ] .RI [ file | "directory ..." ] .br @@ -54,16 +55,6 @@ directory (potentially changing the stripe count, stripe size, OST pool, or OST index of a new file). .SH OPTIONS .TP -.B \\-c -Compare file data after migrate (default, use -.B \\-s -to disable). -.TP -.B \\-s -skip file data comparison after migrate (use -.B \\-c -to enable). -.TP .B \\-h Display help information. .TP @@ -79,8 +70,15 @@ Only print the names of files to be migrated .B \\-q Run quietly (don't print filenames or status) .TP +.B \\-R +Restripe file using default directory striping instead of keeping striping. +.TP +.B \\-s +skip file data comparison after migrate. Default is to compare migrated file +against original to verify correctness. +.TP .B \\-y -Answer 'y' to usage warning without prompting (for scripts) +Answer 'y' to usage warning without prompting (for scripts, use with caution). .SH EXAMPLES To rebalance all files within .IR /mnt/lustre/dir : diff --git a/lustre/scripts/lfs_migrate b/lustre/scripts/lfs_migrate index 7ec1051..0652879 100644 --- a/lustre/scripts/lfs_migrate +++ b/lustre/scripts/lfs_migrate @@ -20,13 +20,13 @@ LFS=${LFS:-lfs} usage() { cat -- <&2 -usage: lfs_migrate [-c|-s] [-h] [-l] [-n] [-y] [file|dir ...] - -c compare file data after migrate (default) - -s skip file data comparison after migrate +usage: lfs_migrate [-h] [-l] [-n] [-R] [-s] [-y] [file|dir ...] -h show this usage message -l migrate files with hard links (skip by default) -n only print the names of files to be migrated -q run quietly (don't print filenames or status) + -R restripe file using default directory striping + -s skip file data comparison after migrate -y answer 'y' to usage question If a directory is an argument, all files in the directory are migrated. @@ -40,12 +40,13 @@ USAGE OPT_CHECK=y -while getopts "chlnqsy" opt $*; do +while getopts "chlnRqsSy" opt $*; do case $opt in - c) OPT_CHECK=y;; + c) echo "'-c' option deprecated, checking enabled by default" 1>&2;; l) OPT_NLINK=y;; n) OPT_DRYRUN=n; OPT_YES=y;; q) ECHO=:;; + R) OPT_RESTRIPE=y;; s) OPT_CHECK="";; y) OPT_YES=y;; h|\?) usage;; @@ -104,13 +105,17 @@ lfs_migrate() { fi + if [ "$OPT_RESTRIPE" ]; then + UNLINK="" + else # if rsync copies Lustre xattrs properly in the future # (i.e. before the file data, so that it preserves striping) # then we don't need to do this getstripe/mktemp stuff. - UNLINK="-u" - COUNT=$($LFS getstripe -c "$OLDNAME" 2> /dev/null) - SIZE=$($LFS getstripe -s "$OLDNAME" 2> /dev/null) - [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK="" + UNLINK="-u" + COUNT=$($LFS getstripe -c "$OLDNAME" 2> /dev/null) + SIZE=$($LFS getstripe -s "$OLDNAME" 2> /dev/null) + [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK="" + fi NEWNAME=$(mktemp $UNLINK "$OLDNAME.tmp.XXXXXX") if [ $? -ne 0 -o -z "$NEWNAME" ]; then echo -e "\r$OLDNAME: can't make temp file, skipped" 1>&2 -- 1.8.3.1