Whamcloud - gitweb
LU-5319 tests: testcases for multiple modify RPCs feature
[fs/lustre-release.git] / lustre / utils / lustre_lfsck.c
index bbaed41..4cf35d1 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * lustre/utils/lustre_lfsck.c
 #include "obdctl.h"
 
 #include <lustre/lustre_lfsck_user.h>
-#include <libcfs/libcfsutil.h>
 #include <lnet/lnetctl.h>
 #include <lustre_ioctl.h>
+/* Needs to be last to avoid clashes */
+#include <libcfs/util/ioctl.h>
 
 static struct option long_opt_start[] = {
        {"device",              required_argument, 0, 'M'},
        {"all",                 no_argument,       0, 'A'},
        {"create_ostobj",       optional_argument, 0, 'c'},
+       {"create_mdtobj",       optional_argument, 0, 'C'},
        {"error",               required_argument, 0, 'e'},
        {"help",                no_argument,       0, 'h'},
        {"dryrun",              optional_argument, 0, 'n'},
@@ -75,7 +77,6 @@ struct lfsck_type_name {
 static struct lfsck_type_name lfsck_types_names[] = {
        { "scrub",      LFSCK_TYPE_SCRUB },
        { "layout",     LFSCK_TYPE_LAYOUT },
-/*     { "dne",        LFSCK_TYPE_DNE }, */
        { "namespace",  LFSCK_TYPE_NAMESPACE },
        { "default",    LFSCK_TYPES_DEF },
        { "all",        LFSCK_TYPES_SUPPORTED },
@@ -99,6 +100,7 @@ static void usage_start(void)
                "usage:\n"
                "lfsck_start <-M | --device {MDT,OST}_device>\n"
                "            [-A | --all] [-c | --create_ostobj [on | off]]\n"
+               "            [-C | --create_mdtobj [on | off]]\n"
                "            [-e | --error {continue | abort}] [-h | --help]\n"
                "            [-n | --dryrun [on | off]] [-o | --orphan]\n"
                "            [-r | --reset] [-s | --speed ops_per_sec_limit]\n"
@@ -109,10 +111,12 @@ static void usage_start(void)
                "-A: start LFSCK on all MDT devices\n"
                "-c: create the lost OST-object for dangling LOV EA "
                    "(default 'off', or 'on')\n"
+               "-C: create the lost MDT-object for dangling name entry "
+                   "(default 'off', or 'on')\n"
                "-e: error handle mode (default 'continue', or 'abort')\n"
                "-h: this help message\n"
                "-n: check with no modification (default 'off', or 'on')\n"
-               "-o: repair orphan objects\n"
+               "-o: repair orphan OST-objects\n"
                "-r: reset scanning to the start of the device\n"
                "-s: maximum items to be scanned per second "
                    "(default '%d' = no limit)\n"
@@ -156,7 +160,7 @@ int jt_lfsck_start(int argc, char **argv)
        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
        char device[MAX_OBD_NAME];
        struct lfsck_start start;
-       char *optstring = "Ac::e:hM:n::ors:t:w:";
+       char *optstring = "Ac::C::e:hM:n::ors:t:w:";
        int opt, index, rc, val, i;
 
        memset(&data, 0, sizeof(data));
@@ -187,6 +191,19 @@ int jt_lfsck_start(int argc, char **argv)
                        }
                        start.ls_valid |= LSV_CREATE_OSTOBJ;
                        break;
+               case 'C':
+                       if (optarg == NULL || strcmp(optarg, "on") == 0) {
+                               start.ls_flags |= LPF_CREATE_MDTOBJ;
+                       } else if (strcmp(optarg, "off") != 0) {
+                               fprintf(stderr, "invalid switch: -C '%s'. "
+                                       "valid switches are:\n"
+                                       "empty ('on'), or 'off' without space. "
+                                       "For example:\n"
+                                       "'-C', '-Con', '-Coff'\n", optarg);
+                               return -EINVAL;
+                       }
+                       start.ls_valid |= LSV_CREATE_MDTOBJ;
+                       break;
                case 'e':
                        if (strcmp(optarg, "abort") == 0) {
                                start.ls_flags |= LPF_FAILOUT;
@@ -221,7 +238,7 @@ int jt_lfsck_start(int argc, char **argv)
                        break;
                case 'o':
                        start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST |
-                                         LPF_ORPHAN;
+                                         LPF_OST_ORPHAN;
                        break;
                case 'r':
                        start.ls_flags |= LPF_RESET;
@@ -256,14 +273,11 @@ bad_type:
                }
                case 'w':
                        val = atoi(optarg);
-                       if (val < 0 || val > LFSCK_ASYNC_WIN_MAX) {
+                       if (val < 1 || val > LFSCK_ASYNC_WIN_MAX) {
                                fprintf(stderr,
-                                       "Too large async window size, "
-                                       "which may cause memory issues. "
-                                       "The valid range is [0 - %u]. "
-                                       "If you do not want to restrict "
-                                       "the window size for async reqeusts "
-                                       "pipeline, just set it as 0.\n",
+                                       "Invalid async window size that "
+                                       "may cause memory issues. The valid "
+                                       "range is [1 - %u].\n",
                                        LFSCK_ASYNC_WIN_MAX);
                                return -EINVAL;
                        }