Whamcloud - gitweb
LU-3285 lfs: handle -L option alphabetically 09/29809/2
authorMikhal Pershin <mike.pershin@intel.com>
Thu, 26 Oct 2017 19:08:31 +0000 (22:08 +0300)
committerMike Pershin <mike.pershin@intel.com>
Fri, 27 Oct 2017 08:56:29 +0000 (08:56 +0000)
Move -L option handling in lfs.c to handle it
alphabetically.

Signed-off-by: Mikhal Pershin <mike.pershin@intel.com>
Change-Id: I6ade41eb8e75df82f0306c89d446955e546f810c
Reviewed-on: https://review.whamcloud.com/29809
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/utils/lfs.c

index 00ac0b1..515f169 100644 (file)
@@ -127,8 +127,8 @@ static int lfs_list_commands(int argc, char **argv);
        "\t              respectively)\n"                               \
        "\tstart_ost_idx: OST index of first stripe (-1 default)\n"     \
        "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n" \
-       "\tlayout:       stripe pattern type: raid0, mdt (default raid0)\n"\
        "\tpool_name:    Name of OST pool to use (default none)\n"      \
+       "\tlayout:       stripe pattern type: raid0, mdt (default raid0)\n"\
        "\tost_indices:  List of OST indices, can be repeated multiple times\n"\
        "\t              Indices be specified in a format of:\n"        \
        "\t                -o <ost_1>,<ost_i>-<ost_j>,<ost_n>\n"        \
@@ -1417,6 +1417,7 @@ static int lfs_setstripe(int argc, char **argv)
        { .val = 'i',   .name = "stripe_index", .has_arg = required_argument},
        { .val = 'I',   .name = "comp-id",      .has_arg = required_argument},
        { .val = 'I',   .name = "component-id", .has_arg = required_argument},
+       { .val = 'L',   .name = "layout",       .has_arg = required_argument },
        { .val = 'm',   .name = "mdt",          .has_arg = required_argument},
        { .val = 'm',   .name = "mdt-index",    .has_arg = required_argument},
        { .val = 'm',   .name = "mdt_index",    .has_arg = required_argument},
@@ -1434,7 +1435,6 @@ static int lfs_setstripe(int argc, char **argv)
         * the consistent "--stripe-size|-S" for all commands. */
        { .val = 's',   .name = "size",         .has_arg = required_argument },
 #endif
-       { .val = 'L',   .name = "layout",       .has_arg = required_argument },
        { .val = 'S',   .name = "stripe-size",  .has_arg = required_argument },
        { .val = 'S',   .name = "stripe_size",  .has_arg = required_argument },
        /* dirstripe {"mdt-count",    required_argument, 0, 'T'}, */
@@ -1530,47 +1530,50 @@ static int lfs_setstripe(int argc, char **argv)
                                }
                        }
                        break;
+               case 'i':
+                       if (strcmp(argv[optind - 1], "--index") == 0)
+                               fprintf(stderr, "warning: '--index' deprecated"
+                                       ", use '--stripe-index' instead\n");
+                       lsa.lsa_stripe_off = strtol(optarg, &end, 0);
+                       if (*end != '\0') {
+                               fprintf(stderr, "error: %s: bad stripe offset "
+                                       "'%s'\n", argv[0], optarg);
+                               goto error;
+                       }
+                       break;
+               case 'I':
+                       comp_id = strtoul(optarg, &end, 0);
+                       if (*end != '\0' || comp_id == 0 ||
+                           comp_id > LCME_ID_MAX) {
+                               fprintf(stderr, "error: %s: bad comp ID "
+                                       "'%s'\n", argv[0], optarg);
+                               goto error;
+                       }
+                       break;
                case 'L':
                        if (strcmp(argv[optind - 1], "mdt") == 0) {
                                /* Can be only the first component */
                                if (layout != NULL) {
+                                       result = -EINVAL;
                                        fprintf(stderr, "error: 'mdt' layout "
                                                "can be only the first one\n");
                                        goto error;
                                }
                                if (lsa.lsa_comp_end > (1ULL << 30)) { /* 1Gb */
+                                       result = -EFBIG;
                                        fprintf(stderr, "error: 'mdt' layout "
                                                "size is too big\n");
                                        goto error;
                                }
                                lsa.lsa_pattern = LLAPI_LAYOUT_MDT;
                        } else if (strcmp(argv[optind - 1], "raid0") != 0) {
+                               result = -EINVAL;
                                fprintf(stderr, "error: layout '%s' is "
                                        "unknown, supported layouts are: "
                                        "'mdt', 'raid0'\n", argv[optind]);
                                goto error;
                        }
                        break;
-               case 'i':
-                       if (strcmp(argv[optind - 1], "--index") == 0)
-                               fprintf(stderr, "warning: '--index' deprecated"
-                                       ", use '--stripe-index' instead\n");
-                       lsa.lsa_stripe_off = strtol(optarg, &end, 0);
-                       if (*end != '\0') {
-                               fprintf(stderr, "error: %s: bad stripe offset "
-                                       "'%s'\n", argv[0], optarg);
-                               goto error;
-                       }
-                       break;
-               case 'I':
-                       comp_id = strtoul(optarg, &end, 0);
-                       if (*end != '\0' || comp_id == 0 ||
-                           comp_id > LCME_ID_MAX) {
-                               fprintf(stderr, "error: %s: bad comp ID "
-                                       "'%s'\n", argv[0], optarg);
-                               goto error;
-                       }
-                       break;
                case 'm':
                        if (!migrate_mode) {
                                fprintf(stderr, "--mdt-index is valid only for"