Whamcloud - gitweb
LU-2430 utils: fix "lfs mv" command parsing 61/13161/2
authorAndreas Dilger <andreas.dilger@intel.com>
Sat, 20 Dec 2014 00:03:34 +0000 (17:03 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 3 Feb 2015 18:18:32 +0000 (18:18 +0000)
Fix the lfs_mv() long option parsing so that it uses "--mdt-index"
instead of incorrectly requiring "----mdt-index" for the short "-M"
option.

Fix up some error messages in lfs_mv() as well, and change a test
case to use the long option form.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I20ffde97fb5d31364e91d6b21d407eb3323ebbe5
Reviewed-on: http://review.whamcloud.com/13161
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity.sh
lustre/utils/lfs.c

index b22ccfe..c17769d 100644 (file)
@@ -664,7 +664,7 @@ test_17n() {
        check_fs_consistency_17n ||
                error "e2fsck report error after create files under remote dir"
 
-       for ((i=0;i<10;i++)); do
+       for ((i = 0; i < 10; i++)); do
                rm -rf $DIR/$tdir/remote_dir_${i} ||
                        error "destroy remote dir error $i"
        done
@@ -675,16 +675,16 @@ test_17n() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
                skip "lustre < 2.4.50 does not support migrate mv " && return
 
-       for ((i=0; i<10; i++)); do
+       for ((i = 0; i < 10; i++)); do
                mkdir -p $DIR/$tdir/remote_dir_${i}
                createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
                        error "create files under remote dir failed $i"
-               $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
+               $LFS mv --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
                        error "migrate remote dir error $i"
        done
        check_fs_consistency_17n || error "e2fsck report error after migration"
 
-       for ((i=0;i<10;i++)); do
+       for ((i = 0; i < 10; i++)); do
                rm -rf $DIR/$tdir/remote_dir_${i} ||
                        error "destroy remote dir error $i"
        done
@@ -12439,10 +12439,10 @@ test_230b() {
        ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
 
        $LFS mv -v -M $MDTIDX $migrate_dir ||
-                       error "migrate remote dir error"
+               error "migrate remote dir error"
 
        echo "migratate to MDT1, then checking.."
-       for ((i=0; i<10; i++)); do
+       for ((i = 0; i < 10; i++)); do
                for file in $(find $migrate_dir/dir_${i}); do
                        mdt_index=$($LFS getstripe -M $file)
                        [ $mdt_index == $MDTIDX ] ||
@@ -12494,16 +12494,16 @@ test_230b() {
 
        stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
        [ $stripe_count = 2 ] ||
-                       error "dir strpe_count $d != 2 after migration."
+               error "dir strpe_count $d != 2 after migration."
 
        stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
        [ $stripe_count = 2 ] ||
-                       error "file strpe_count $d != 2 after migration."
+               error "file strpe_count $d != 2 after migration."
 
        #migrate back to MDT0
        MDTIDX=0
        $LFS mv -v -M $MDTIDX $migrate_dir ||
-                       error "migrate remote dir error"
+               error "migrate remote dir error"
 
        echo "migrate back to MDT0, checking.."
        for file in $(find $migrate_dir); do
@@ -12576,10 +12576,10 @@ test_230c() {
        #OBD_FAIL_MIGRATE_ENTRIES       0x1801
        do_facet mds1 lctl set_param fail_loc=0x20001801
        do_facet mds1 lctl  set_param fail_val=5
-       local t=`ls $DIR/$tdir | wc -l`
-       $LFS mv -M $MDTIDX $DIR/$tdir &&
-               error "migrate should failed after 5 entries"
-       local u=`ls $DIR/$tdir | wc -l`
+       local t=$(ls $DIR/$tdir | wc -l)
+       $LFS mv --mdt-index $MDTIDX $DIR/$tdir &&
+               error "migrate should fail after 5 entries"
+       local u=$(ls $DIR/$tdir | wc -l)
        [ "$u" == "$t" ] || error "$u != $t during migration"
 
        for file in $(find $DIR/$tdir); do
index 4ab76a3..539c591 100644 (file)
@@ -1787,7 +1787,7 @@ static int lfs_mv(int argc, char **argv)
        int     c;
        int     rc = 0;
        struct option long_opts[] = {
-               {"--mdt-index", required_argument, 0, 'M'},
+               {"mdt-index", required_argument, 0, 'M'},
                {"verbose",     no_argument,       0, 'v'},
                {0, 0, 0, 0}
        };
@@ -1815,20 +1815,21 @@ static int lfs_mv(int argc, char **argv)
        }
 
        if (param.fp_mdt_index == -1) {
-               fprintf(stderr, "%s MDT index must be indicated\n", argv[0]);
+               fprintf(stderr, "%s: MDT index must be specified\n", argv[0]);
                return CMD_HELP;
        }
 
        if (optind >= argc) {
-               fprintf(stderr, "%s missing operand path\n", argv[0]);
+               fprintf(stderr, "%s: missing operand path\n", argv[0]);
                return CMD_HELP;
        }
 
        param.fp_migrate = 1;
        rc = llapi_mv(argv[optind], &param);
        if (rc != 0)
-               fprintf(stderr, "cannot migrate '%s' to MDT%04x: %s\n",
-                       argv[optind], param.fp_mdt_index, strerror(-rc));
+               fprintf(stderr, "%s: cannot migrate '%s' to MDT%04x: %s\n",
+                       argv[0], argv[optind], param.fp_mdt_index,
+                       strerror(-rc));
        return rc;
 }