Whamcloud - gitweb
LU-611 utils: lfs find --stripe-{count,size,index}
[fs/lustre-release.git] / lustre / utils / lfs.c
index a52bd08..7a0198f 100644 (file)
@@ -122,41 +122,45 @@ command_t cmdlist[] = {
          "Create a new file with a specific striping pattern or\n"
          "set the default striping pattern on an existing directory or\n"
          "delete the default striping pattern from an existing directory\n"
-         "usage: setstripe [--size|-s stripe_size] [--count|-c stripe_count]\n"
-         "                 [--index|-i|--offset|-o start_ost_index]\n"
-         "                 [--pool|-p <pool>] <directory|filename>\n"
-         "       or \n"
+         "usage: setstripe [--stripe-count|-c <stripe_count>]\n"
+         "                 [--stripe-index|-i <start_ost_idx>]\n"
+         "                 [--stripe-size|-S <stripe_size>]\n"
+         "                 [--pool|-p <pool_name>] <directory|filename>\n"
+         " or\n"
          "       setstripe -d <directory>   (to delete default striping)\n"
          "\tstripe_size:  Number of bytes on each OST (0 filesystem default)\n"
          "\t              Can be specified with k, m or g (in KB, MB and GB\n"
          "\t              respectively)\n"
-         "\tstart_ost_index: OST index of first stripe (-1 default)\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"
-         "\tpool:         Name of OST pool to use (default none)"},
+         "\tpool_name:    Name of OST pool to use (default none)"},
         {"getstripe", lfs_getstripe, 0,
          "To list the striping info for a given file or files in a\n"
          "directory or recursively for all files in a directory tree.\n"
-         "usage: getstripe [--obd|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
-         "                 [--count | -c ] [--index | -i | --offset | -o]\n"
-         "                 [--size | -s ] [--pool | -p ] [--directory | -d]\n"
-         "                 [--mdt | -M] [--recursive | -r] [--raw | -R]\n"
+         "usage: getstripe [--ost|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
+         "                 [--stripe-count|-c] [--stripe-index|-i]\n"
+         "                 [--pool|-p] [--stripe-size|-S] [--directory|-d]\n"
+         "                 [--mdt-index|-M] [--recursive|-r] [--raw|-R]\n"
          "                 <directory|filename> ..."},
         {"pool_list", lfs_poollist, 0,
          "List pools or pool OSTs\n"
          "usage: pool_list <fsname>[.<pool>] | <pathname>\n"},
         {"find", lfs_find, 0,
-         "To find files that match given parameters recursively in a directory tree.\n"
+         "find files matching given attributes recursively in directory tree.\n"
          "usage: find <directory|filename> ...\n"
-         "     [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n"
-         "     [--maxdepth|-D N] [[!] --name|-n <pattern>] [--print0|-P]\n"
-         "     [--print|-p] [[!] --obd|-O <uuid[s]>] [[!] --mdt|-m <uuid[s]]\n"
-         "     [[!] --size|-s [+-]N[bkMGTP]] [[!] --type|-t <filetype>]\n"
+         "     [[!] --atime|-A [+-]N] [[!] --ctime|-C [+-]N]\n"
+         "     [[!] --mtime|-M [+-]N] [[!] --mdt|-m <uuid|index,...>]\n"
+         "     [--maxdepth|-D N] [[!] --name|-n <pattern>]\n"
+         "     [[!] --ost|-O <uuid|index,...>] [--print|-p] [--print0|-P]\n"
+         "     [[!] --size|-s [+-]N[bkMGTPE]]\n"
+         "     [[!] --stripe-count|-c [+-]<stripes>]\n"
+         "     [[!] --stripe-index|-i <index,...>]\n"
+         "     [[!] --stripe-size|-S [+-]N[kMGT]] [[!] --type|-t <filetype>]\n"
          "     [[!] --gid|-g|--group|-G <gid>|<gname>]\n"
-         "     [[!] --uid|-u|--user|-U <uid>|<uname>]\n"
-         "     [[!] --pool <pool>]\n"
-         "\t !: used before an option indicates 'NOT' the requested attribute\n"
-         "\t -: used before an value indicates 'AT MOST' the requested value\n"
-         "\t +: used before an option indicates 'AT LEAST' the requested value\n"},
+         "     [[!] --uid|-u|--user|-U <uid>|<uname>] [[!] --pool <pool>]\n"
+         "\t !: used before an option indicates 'NOT' requested attribute\n"
+         "\t -: used before a value indicates 'AT MOST' requested value\n"
+         "\t +: used before a value indicates 'AT LEAST' requested value\n"},
         {"check", lfs_check, 0,
          "Display the status of MDS or OSTs (as specified in the command)\n"
          "or all the servers (MDS and OSTs).\n"
@@ -293,12 +297,46 @@ static int lfs_setstripe(int argc, char **argv)
         unsigned long long size_units = 1;
 
         struct option long_opts[] = {
-                {"count",       required_argument, 0, 'c'},
-                {"delete",      no_argument,       0, 'd'},
-                {"index",       required_argument, 0, 'i'},
-                {"offset",      required_argument, 0, 'o'},
-                {"pool",        required_argument, 0, 'p'},
-                {"size",        required_argument, 0, 's'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --count option"
+#else
+                /* This formerly implied "stripe-count", but was explicitly
+                 * made "stripe-count" for consistency with other options,
+                 * and to separate it from "mdt-count" when DNE arrives. */
+                {"count",        required_argument, 0, 'c'},
+#endif
+                {"stripe-count", required_argument, 0, 'c'},
+                {"stripe_count", required_argument, 0, 'c'},
+                {"delete",       no_argument,       0, 'd'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --index option"
+#else
+                /* This formerly implied "stripe-index", but was explicitly
+                 * made "stripe-index" for consistency with other options,
+                 * and to separate it from "mdt-index" when DNE arrives. */
+                {"index",        required_argument, 0, 'i'},
+#endif
+                {"stripe-index", required_argument, 0, 'i'},
+                {"stripe_index", required_argument, 0, 'i'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --offset option"
+#else
+                /* This formerly implied "stripe-index", but was confusing
+                 * with "file offset" (which will eventually be needed for
+                 * with different layouts by offset), so deprecate it. */
+                {"offset",       required_argument, 0, 'o'},
+#endif
+                {"pool",         required_argument, 0, 'p'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --size option"
+#else
+                /* This formerly implied "--stripe-size", but was confusing
+                 * with "lfs find --size|-s", which means "file size", so use
+                 * the consistent "--stripe-size|-S" for all commands. */
+                {"size",         required_argument, 0, 's'},
+#endif
+                {"stripe-size",  required_argument, 0, 'S'},
+                {"stripe_size",  required_argument, 0, 'S'},
                 {0, 0, 0, 0}
         };
 
@@ -310,45 +348,70 @@ static int lfs_setstripe(int argc, char **argv)
         if (argc == 5 && argv[1][0] != '-' &&
             isnumber(argv[2]) && isnumber(argv[3]) && isnumber(argv[4])) {
                 fprintf(stderr, "error: obsolete usage of setstripe "
-                        "positional parameters.  Use -c, -i, -s instead.\n");
+                        "positional parameters.  Use -c, -i, -S instead.\n");
                 return CMD_HELP;
         } else
 #else
-#warning "remove obsolete positional parameter code"
+#warning "remove obsolete positional parameter error"
 #endif
         {
                 optind = 0;
-                while ((c = getopt_long(argc, argv, "c:di:o:p:s:",
+                while ((c = getopt_long(argc, argv, "c:di:o:p:s:S:",
                                         long_opts, NULL)) >= 0) {
-                        switch (c) {
-                        case 0:
-                                /* Long options. */
-                                break;
-                        case 'c':
-                                stripe_count_arg = optarg;
-                                break;
-                        case 'd':
-                                /* delete the default striping pattern */
-                                delete = 1;
-                                break;
-                        case 'i':
-                        case 'o':
-                                stripe_off_arg = optarg;
-                                break;
-                        case 's':
-                                stripe_size_arg = optarg;
-                                break;
-                        case 'p':
-                                pool_name_arg = optarg;
-                                break;
-                        case '?':
-                                return CMD_HELP;
-                        default:
-                                fprintf(stderr, "error: %s: option '%s' "
-                                                "unrecognized\n",
-                                                argv[0], argv[optind - 1]);
-                                return CMD_HELP;
-                        }
+                switch (c) {
+                case 0:
+                        /* Long options. */
+                        break;
+                case 'c':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --count option"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        if (strcmp(argv[optind - 1], "--count") == 0)
+                                fprintf(stderr, "warning: '--count' deprecated"
+                                        ", use '--stripe-count' instead\n");
+#endif
+                        stripe_count_arg = optarg;
+                        break;
+                case 'd':
+                        /* delete the default striping pattern */
+                        delete = 1;
+                        break;
+                case 'o':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,4,50,0)
+                        fprintf(stderr, "warning: '--offset|-o' deprecated, "
+                                "use '--stripe-index|-i' instead\n");
+#else
+                        if (strcmp(argv[optind - 1], "--offset") == 0)
+                                /* need --stripe-index established first */
+                                fprintf(stderr, "warning: '--offset' deprecated"
+                                        ", use '--index' instead\n");
+#endif
+                case 'i':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --offset and --index options"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        if (strcmp(argv[optind - 1], "--index") == 0)
+                                fprintf(stderr, "warning: '--index' deprecated"
+                                        ", use '--stripe-index' instead\n");
+#endif
+                        stripe_off_arg = optarg;
+                        break;
+                case 's':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --size option"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        fprintf(stderr, "warning: '--size|-s' deprecated, "
+                                "use '--stripe-size|-S' instead\n");
+#endif
+                case 'S':
+                        stripe_size_arg = optarg;
+                        break;
+                case 'p':
+                        pool_name_arg = optarg;
+                        break;
+                default:
+                        return CMD_HELP;
+                }
                 }
 
                 fname = argv[optind];
@@ -357,7 +420,7 @@ static int lfs_setstripe(int argc, char **argv)
                     (stripe_size_arg != NULL || stripe_off_arg != NULL ||
                      stripe_count_arg != NULL || pool_name_arg != NULL)) {
                         fprintf(stderr, "error: %s: cannot specify -d with "
-                                        "-s, -c -o or -p options\n",
+                                        "-s, -c, -o, or -p options\n",
                                         argv[0]);
                         return CMD_HELP;
                 }
@@ -373,7 +436,7 @@ static int lfs_setstripe(int argc, char **argv)
         if (stripe_size_arg != NULL) {
                 result = parse_size(stripe_size_arg, &st_size, &size_units, 0);
                 if (result) {
-                        fprintf(stderr, "error: %s: bad size '%s'\n",
+                        fprintf(stderr, "error: %s: bad stripe size '%s'\n",
                                 argv[0], stripe_size_arg);
                         return result;
                 }
@@ -504,33 +567,34 @@ static int id2name(char **name, unsigned int id, int type)
 #define FIND_POOL_OPT 3
 static int lfs_find(int argc, char **argv)
 {
-        int new_fashion = 1;
         int c, ret;
         time_t t;
-        struct find_param param = { .maxdepth = -1, .size_units = 0 };
+        struct find_param param = { .maxdepth = -1, .quiet = 1 };
         struct option long_opts[] = {
-                {"atime",     required_argument, 0, 'A'},
-                {"ctime",     required_argument, 0, 'C'},
-                {"maxdepth",  required_argument, 0, 'D'},
-                {"gid",       required_argument, 0, 'g'},
-                {"group",     required_argument, 0, 'G'},
-                {"mtime",     required_argument, 0, 'M'},
-                {"mdt",       required_argument, 0, 'm'},
-                {"name",      required_argument, 0, 'n'},
-                /* --obd is considered as a new option. */
-                {"obd",       required_argument, 0, 'O'},
-                {"ost",       required_argument, 0, 'O'},
+                {"atime",        required_argument, 0, 'A'},
+                {"stripe-count", required_argument, 0, 'c'},
+                {"stripe_count", required_argument, 0, 'c'},
+                {"ctime",        required_argument, 0, 'C'},
+                {"maxdepth",     required_argument, 0, 'D'},
+                {"gid",          required_argument, 0, 'g'},
+                {"group",        required_argument, 0, 'G'},
+                {"stripe-index", required_argument, 0, 'i'},
+                {"stripe_index", required_argument, 0, 'i'},
+                {"mdt",          required_argument, 0, 'm'},
+                {"mtime",        required_argument, 0, 'M'},
+                {"name",         required_argument, 0, 'n'},
+                {"obd",          required_argument, 0, 'O'},
+                {"ost",          required_argument, 0, 'O'},
                 /* no short option for pool, p/P already used */
-                {"pool",      required_argument, 0, FIND_POOL_OPT},
-                {"print0",    no_argument,       0, 'p'},
-                {"print",     no_argument,       0, 'P'},
-                {"quiet",     no_argument,       0, 'q'},
-                {"recursive", no_argument,       0, 'r'},
-                {"size",      required_argument, 0, 's'},
-                {"type",      required_argument, 0, 't'},
-                {"uid",       required_argument, 0, 'u'},
-                {"user",      required_argument, 0, 'U'},
-                {"verbose",   no_argument,       0, 'v'},
+                {"pool",         required_argument, 0, FIND_POOL_OPT},
+                {"print0",       no_argument,       0, 'p'},
+                {"print",        no_argument,       0, 'P'},
+                {"size",         required_argument, 0, 's'},
+                {"stripe-size",  required_argument, 0, 'S'},
+                {"stripe_size",  required_argument, 0, 'S'},
+                {"type",         required_argument, 0, 't'},
+                {"uid",          required_argument, 0, 'u'},
+                {"user",         required_argument, 0, 'U'},
                 {0, 0, 0, 0}
         };
         int pathstart = -1;
@@ -545,8 +609,9 @@ static int lfs_find(int argc, char **argv)
 
         optind = 0;
         /* when getopt_long_only() hits '!' it returns 1, puts "!" in optarg */
-        while ((c = getopt_long_only(argc, argv, "-A:C:D:g:G:M:m:n:O:"
-                                     "Ppqrs:t:u:U:v", long_opts, NULL)) >= 0) {
+        while ((c = getopt_long_only(argc, argv,
+                                     "-A:c:C:D:g:G:i:m:M:n:O:Ppqrs:S:t:u:U:v",
+                                     long_opts, NULL)) >= 0) {
                 xtime = NULL;
                 xsign = NULL;
                 if (neg_opt)
@@ -568,13 +633,8 @@ static int lfs_find(int argc, char **argv)
                 }
                 if (!isoption && pathstart == -1)
                         pathstart = optind - 1;
-                if (isoption && pathstart != -1 && pathend == -1) {
+                if (isoption && pathstart != -1 && pathend == -1)
                         pathend = optind - 2;
-                        if ((c == 1 && strcmp(optarg, "!") == 0) ||
-                            c == 'P' || c == 'p' || c == 'O' ||
-                            c == 'q' || c == 'r' || c == 'v')
-                                pathend = optind - 1;
-                }
                 switch (c) {
                 case 0:
                         /* Long options. */
@@ -590,19 +650,20 @@ static int lfs_find(int argc, char **argv)
                         xtime = &param.atime;
                         xsign = &param.asign;
                         param.exclude_atime = !!neg_opt;
+                        /* no break, this falls through to 'C' for ctime */
                 case 'C':
                         if (c == 'C') {
                                 xtime = &param.ctime;
                                 xsign = &param.csign;
                                 param.exclude_ctime = !!neg_opt;
                         }
+                        /* no break, this falls through to 'M' for mtime */
                 case 'M':
                         if (c == 'M') {
                                 xtime = &param.mtime;
                                 xsign = &param.msign;
                                 param.exclude_mtime = !!neg_opt;
                         }
-                        new_fashion = 1;
                         ret = set_time(&t, xtime, optarg);
                         if (ret == INT_MAX) {
                                 ret = -1;
@@ -611,13 +672,30 @@ static int lfs_find(int argc, char **argv)
                         if (ret)
                                 *xsign = ret;
                         break;
+                case 'c':
+                        if (optarg[0] == '+') {
+                                param.stripecount_sign = -1;
+                                optarg++;
+                        } else if (optarg[0] == '-') {
+                                param.stripecount_sign =  1;
+                                optarg++;
+                        }
+
+                        param.stripecount = strtoul(optarg, &endptr, 0);
+                        if (*endptr != '\0') {
+                                fprintf(stderr,"error: bad stripe_count '%s'\n",
+                                        optarg);
+                                ret = -1;
+                                goto err;
+                        }
+                        param.check_stripecount = 1;
+                        param.exclude_stripecount = !!neg_opt;
+                        break;
                 case 'D':
-                        new_fashion = 1;
                         param.maxdepth = strtol(optarg, 0, 0);
                         break;
                 case 'g':
                 case 'G':
-                        new_fashion = 1;
                         ret = name2id(&param.gid, optarg, GROUP);
                         if (ret) {
                                 param.gid = strtoul(optarg, &endptr, 10);
@@ -633,7 +711,6 @@ static int lfs_find(int argc, char **argv)
                         break;
                 case 'u':
                 case 'U':
-                        new_fashion = 1;
                         ret = name2id(&param.uid, optarg, USER);
                         if (ret) {
                                 param.uid = strtoul(optarg, &endptr, 10);
@@ -648,7 +725,6 @@ static int lfs_find(int argc, char **argv)
                         param.check_uid = 1;
                         break;
                 case FIND_POOL_OPT:
-                        new_fashion = 1;
                         if (strlen(optarg) > LOV_MAXPOOLNAME) {
                                 fprintf(stderr,
                                         "Pool name %s is too long"
@@ -665,11 +741,11 @@ static int lfs_find(int argc, char **argv)
                         param.check_pool = 1;
                         break;
                 case 'n':
-                        new_fashion = 1;
                         param.pattern = (char *)optarg;
                         param.exclude_pattern = !!neg_opt;
                         break;
                 case 'm':
+                case 'i':
                 case 'O': {
                         char *buf, *token, *next, *p;
                         int len = 1;
@@ -691,16 +767,7 @@ static int lfs_find(int argc, char **argv)
                                         token++;
                                 }
                         }
-                        if (c == 'O') {
-                                param.exclude_obd = !!neg_opt;
-                                param.num_alloc_obds += len;
-                                tmp = realloc(param.obduuid,
-                                              param.num_alloc_obds *
-                                              sizeof(*param.obduuid));
-                                if (tmp == NULL)
-                                        GOTO(err_free, ret = -ENOMEM);
-                                param.obduuid = tmp;
-                        } else {
+                        if (c == 'm') {
                                 param.exclude_mdt = !!neg_opt;
                                 param.num_alloc_mdts += len;
                                 tmp = realloc(param.mdtuuid,
@@ -709,15 +776,24 @@ static int lfs_find(int argc, char **argv)
                                 if (tmp == NULL)
                                         GOTO(err_free, ret = -ENOMEM);
                                 param.mdtuuid = tmp;
+                        } else {
+                                param.exclude_obd = !!neg_opt;
+                                param.num_alloc_obds += len;
+                                tmp = realloc(param.obduuid,
+                                              param.num_alloc_obds *
+                                              sizeof(*param.obduuid));
+                                if (tmp == NULL)
+                                        GOTO(err_free, ret = -ENOMEM);
+                                param.obduuid = tmp;
                         }
                         for (token = buf; token && *token; token = next) {
                                 char *uuid;
-                                if (c == 'O')
+                                if (c == 'm')
                                         uuid =
-                                          param.obduuid[param.num_obds++].uuid;
+                                          param.mdtuuid[param.num_mdts++].uuid;
                                 else
                                         uuid =
-                                          param.mdtuuid[param.num_mdts++].uuid;
+                                          param.obduuid[param.num_obds++].uuid;
                                 p = strchr(token, ',');
                                 next = 0;
                                 if (p) {
@@ -732,19 +808,47 @@ err_free:
                         break;
                 }
                 case 'p':
-                        new_fashion = 1;
                         param.zeroend = 1;
                         break;
                 case 'P':
                         break;
-                case 'q':
-                        new_fashion = 0;
-                        param.quiet++;
-                        param.verbose = 0;
+                case 's':
+                        if (optarg[0] == '+') {
+                                param.size_sign = -1;
+                                optarg++;
+                        } else if (optarg[0] == '-') {
+                                param.size_sign =  1;
+                                optarg++;
+                        }
+
+                        ret = parse_size(optarg, &param.size,
+                                         &param.size_units, 0);
+                        if (ret) {
+                                fprintf(stderr, "error: bad file size '%s'\n",
+                                        optarg);
+                                goto err;
+                        }
+                        param.check_size = 1;
+                        param.exclude_size = !!neg_opt;
                         break;
-                case 'r':
-                        new_fashion = 0;
-                        param.recursive = 1;
+                case 'S':
+                        if (optarg[0] == '+') {
+                                param.stripesize_sign = -1;
+                                optarg++;
+                        } else if (optarg[0] == '-') {
+                                param.stripesize_sign =  1;
+                                optarg++;
+                        }
+
+                        ret = parse_size(optarg, &param.stripesize,
+                                         &param.stripesize_units, 0);
+                        if (ret) {
+                                fprintf(stderr, "error: bad stripe_size '%s'\n",
+                                        optarg);
+                                goto err;
+                        }
+                        param.check_stripesize = 1;
+                        param.exclude_stripesize = !!neg_opt;
                         break;
                 case 't':
                         param.exclude_type = !!neg_opt;
@@ -765,35 +869,7 @@ err_free:
                                  goto err;
                         };
                         break;
-                case 's':
-                        if (optarg[0] == '+')
-                                param.size_sign = -1;
-                        else if (optarg[0] == '-')
-                                param.size_sign = +1;
-
-                        if (param.size_sign)
-                                optarg++;
-                        ret = parse_size(optarg, &param.size,
-                                         &param.size_units, 0);
-                        if (ret) {
-                                fprintf(stderr,"error: bad size '%s'\n",
-                                        optarg);
-                                goto err;
-                        }
-                        param.check_size = 1;
-                        param.exclude_size = !!neg_opt;
-                        break;
-                case 'v':
-                        new_fashion = 0;
-                        param.verbose++;
-                        param.quiet = 0;
-                        break;
-                case '?':
-                        ret = CMD_HELP;
-                        goto err;
                 default:
-                        fprintf(stderr, "error: %s: option '%s' unrecognized\n",
-                                argv[0], argv[optind - 1]);
                         ret = CMD_HELP;
                         goto err;
                 };
@@ -809,24 +885,8 @@ err_free:
                 pathend = argc;
         }
 
-        if (new_fashion) {
-                param.quiet = 1;
-        } else {
-                static int deprecated_warning;
-                if (!deprecated_warning) {
-                        fprintf(stderr, "lfs find: -q, -r, -v options "
-                                "deprecated.  Use 'lfs getstripe' instead.\n");
-                        deprecated_warning = 1;
-                }
-                if (!param.recursive && param.maxdepth == -1)
-                        param.maxdepth = 1;
-        }
-
         do {
-                if (new_fashion)
-                        ret = llapi_find(argv[pathstart], &param);
-                else
-                        ret = llapi_getstripe(argv[pathstart], &param);
+                ret = llapi_find(argv[pathstart], &param);
         } while (++pathstart < pathend && !ret);
 
         if (ret)
@@ -845,19 +905,55 @@ err:
 static int lfs_getstripe(int argc, char **argv)
 {
         struct option long_opts[] = {
-                {"count", 0, 0, 'c'},
-                {"directory", 0, 0, 'd'},
-                {"generation", 0, 0, 'g'},
-                {"index", 0, 0, 'i'},
-                {"mdt", 0, 0, 'M'},
-                {"offset", 0, 0, 'o'},
-                {"obd", 1, 0, 'O'},
-                {"pool", 0, 0, 'p'},
-                {"quiet", 0, 0, 'q'},
-                {"recursive", 0, 0, 'r'},
-                {"raw", 0, 0, 'R'},
-                {"size", 0, 0, 's'},
-                {"verbose", 0, 0, 'v'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --count option"
+#else
+                /* This formerly implied "stripe-count", but was explicitly
+                 * made "stripe-count" for consistency with other options,
+                 * and to separate it from "mdt-count" when DNE arrives. */
+                {"count",        no_argument,       0, 'c'},
+#endif
+                {"stripe-count", no_argument,       0, 'c'},
+                {"stripe_count", no_argument,       0, 'c'},
+                {"directory",    no_argument,       0, 'd'},
+                {"generation",   no_argument,       0, 'g'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --index option"
+#else
+                /* This formerly implied "stripe-index", but was explicitly
+                 * made "stripe-index" for consistency with other options,
+                 * and to separate it from "mdt-index" when DNE arrives. */
+                {"index",        no_argument,       0, 'i'},
+#endif
+                {"stripe-index", no_argument,       0, 'i'},
+                {"stripe_index", no_argument,       0, 'i'},
+                {"mdt-index",    no_argument,       0, 'M'},
+                {"mdt_index",    no_argument,       0, 'M'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --offset option"
+#else
+                /* This formerly implied "stripe-index", but was confusing
+                 * with "file offset" (which will eventually be needed for
+                 * with different layouts by offset), so deprecate it. */
+                {"offset",       no_argument,       0, 'o'},
+#endif
+                {"obd",          required_argument, 0, 'O'},
+                {"ost",          required_argument, 0, 'O'},
+                {"pool",         no_argument,       0, 'p'},
+                {"quiet",        no_argument,       0, 'q'},
+                {"recursive",    no_argument,       0, 'r'},
+                {"raw",          no_argument,       0, 'R'},
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --size option"
+#else
+                /* This formerly implied "--stripe-size", but was confusing
+                 * with "lfs find --size|-s", which means "file size", so use
+                 * the consistent "--stripe-size|-S" for all commands. */
+                {"size",         no_argument,       0, 's'},
+#endif
+                {"stripe-size",  no_argument,       0, 'S'},
+                {"stripe_size",  no_argument,       0, 'S'},
+                {"verbose",      no_argument,       0, 'v'},
                 {0, 0, 0, 0}
         };
         int c, rc;
@@ -865,7 +961,7 @@ static int lfs_getstripe(int argc, char **argv)
 
         param.maxdepth = 1;
         optind = 0;
-        while ((c = getopt_long(argc, argv, "cdghiMoO:pqrRsv",
+        while ((c = getopt_long(argc, argv, "cdghiMoO:pqrRsSv",
                                 long_opts, NULL)) != -1) {
                 switch (c) {
                 case 'O':
@@ -890,19 +986,49 @@ static int lfs_getstripe(int argc, char **argv)
                         param.verbose = VERBOSE_ALL | VERBOSE_DETAIL;
                         break;
                 case 'c':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --count option"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        if (strcmp(argv[optind - 1], "--count") == 0)
+                                fprintf(stderr, "warning: '--count' deprecated,"
+                                        " use '--stripe-count' instead\n");
+#endif
                         if (!(param.verbose & VERBOSE_DETAIL)) {
                                 param.verbose |= VERBOSE_COUNT;
                                 param.maxdepth = 0;
                         }
                         break;
                 case 's':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --size option"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        fprintf(stderr, "warning: '--size|-s' deprecated, "
+                                "use '--stripe-size|-S' instead\n");
+#endif
+                case 'S':
                         if (!(param.verbose & VERBOSE_DETAIL)) {
                                 param.verbose |= VERBOSE_SIZE;
                                 param.maxdepth = 0;
                         }
                         break;
-                case 'i':
                 case 'o':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,4,50,0)
+                        fprintf(stderr, "warning: '--offset|-o' deprecated, "
+                                "use '--stripe-index|-i' instead\n");
+#else
+                        if (strcmp(argv[optind - 1], "--offset") == 0)
+                                /* need --stripe-index established first */
+                                fprintf(stderr, "warning: '--offset' deprecated"
+                                        ", use '--index' instead\n");
+#endif
+                case 'i':
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,9,50,0)
+#warning "remove deprecated --offset and --index options"
+#elif LUSTRE_VERSION >= OBD_OCD_VERSION(2,6,50,0)
+                        if (strcmp(argv[optind - 1], "--index") == 0)
+                                fprintf(stderr, "warning: '--index' deprecated"
+                                        ", use '--stripe-index' instead\n");
+#endif
                         if (!(param.verbose & VERBOSE_DETAIL)) {
                                 param.verbose |= VERBOSE_OFFSET;
                                 param.maxdepth = 0;
@@ -923,16 +1049,12 @@ static int lfs_getstripe(int argc, char **argv)
                 case 'M':
                         if (!(param.verbose & VERBOSE_DETAIL))
                                 param.maxdepth = 0;
-                        param.get_mdt_index = 1;
+                        param.verbose |= VERBOSE_MDTINDEX;
                         break;
                 case 'R':
                         param.raw = 1;
                         break;
-                case '?':
-                        return CMD_HELP;
                 default:
-                        fprintf(stderr, "error: %s: option '%s' unrecognized\n",
-                                argv[0], argv[optind - 1]);
                         return CMD_HELP;
                 }
         }