Whamcloud - gitweb
LU-7503 utils: add “--verbose|-v” option to “lfs migrate -m” 20/17420/3
authorJian Yu <jian.yu@intel.com>
Wed, 2 Dec 2015 05:54:07 +0000 (21:54 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 9 Jan 2016 00:06:46 +0000 (00:06 +0000)
“lfs mv” has -v option to track the migration progress, which is
very useful for migrating big directory. However, the option is
missing while we changing “lfs mv” to “lfs migrate -m” in commit
849d7d5b1b4cabb7578c3ab5aaf271e90dd33864. This patch adds the option.

Signed-off-by: Jian Yu <jian.yu@intel.com>
Change-Id: I0729f74f46943736c6ed6ade46ca26aee905f550
Reviewed-on: http://review.whamcloud.com/17420
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
lustre/utils/lfs.c

index b08bbea..e5370e9 100644 (file)
@@ -358,7 +358,8 @@ command_t cmdlist[] = {
        {"migrate", lfs_setstripe, 0,
         "migrate file/directory between MDTs, or migrate file from one OST "
         "layout\nto another (may be not safe with concurent writes).\n"
-        "usage: migrate   [--mdt-index|-m <mdt_idx>] <directory|filename>]\n"
+        "usage: migrate   [--mdt-index|-m <mdt_idx>] [--verbose|-v] "
+        "<directory|filename>\n"
         "\tmdt_idx:      MDT index to migrate to\n"
         " or\n"
         MIGRATE_USAGE},
@@ -941,6 +942,8 @@ static int lfs_setstripe(int argc, char **argv)
 #endif
                {"stripe-size",  required_argument, 0, 'S'},
                {"stripe_size",  required_argument, 0, 'S'},
+               /* --verbose is only valid in migrate mode */
+               {"verbose",      no_argument,       0, 'v'},
                {0, 0, 0, 0}
        };
 
@@ -951,7 +954,7 @@ static int lfs_setstripe(int argc, char **argv)
        if (strcmp(argv[0], "migrate") == 0)
                migrate_mode = true;
 
-       while ((c = getopt_long(argc, argv, "bc:di:m:no:p:s:S:",
+       while ((c = getopt_long(argc, argv, "bc:di:m:no:p:s:S:v",
                                long_opts, NULL)) >= 0) {
                switch (c) {
                case 0:
@@ -1028,6 +1031,14 @@ static int lfs_setstripe(int argc, char **argv)
                case 'p':
                        pool_name_arg = optarg;
                        break;
+               case 'v':
+                       if (!migrate_mode) {
+                               fprintf(stderr, "--verbose is valid only for"
+                                               " migrate mode\n");
+                               return CMD_HELP;
+                       }
+                       migrate_mdt_param.fp_verbose = VERBOSE_DETAIL;
+                       break;
                default:
                        return CMD_HELP;
                }