Whamcloud - gitweb
LU-611 utils: add restripe option to lfs_migrate
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 19 Aug 2011 11:21:24 +0000 (05:21 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 2 Nov 2011 23:46:40 +0000 (19:46 -0400)
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 <adilger@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1265
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs_migrate.1
lustre/scripts/lfs_migrate

index bf65ebe..c59ac02 100644 (file)
@@ -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 :
index 7ec1051..0652879 100644 (file)
@@ -20,13 +20,13 @@ LFS=${LFS:-lfs}
 
 usage() {
     cat -- <<USAGE 1>&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