Whamcloud - gitweb
LU-14265 utils: allow 'lfs mkdir' without arguments 54/41054/2
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 18 Dec 2020 22:47:09 +0000 (15:47 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 5 Jan 2021 08:27:15 +0000 (08:27 +0000)
If no arguments are given to "lfs mkdir <newdir>" assume that
"-i -1 -c 1" were given, to create the specified <newdir> on
an MDT with above-average free space/inodes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I319f68240832a905a86833a70a4631cde5ce7057
Reviewed-on: https://review.whamcloud.com/41054
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs-setdirstripe.1
lustre/utils/lfs.c

index 8e5ff62..6f0906a 100644 (file)
@@ -105,6 +105,16 @@ Specify a numeric bitmask of type-specific layout flags for the foreign layout.
 Specify a string to be used as a foreign (free format) striping.
 .SH NOTE
 .PP
 Specify a string to be used as a foreign (free format) striping.
 .SH NOTE
 .PP
+If neither
+.B -c
+or
+.B -i
+are specified,
+.B lfs mkdir
+will default to
+.B -c 1 -i -1
+and create the directory on an MDT that is less full than the others.
+.PP
 The
 .B lfs setdirstripe
 command is only usable by root unless the
 The
 .B lfs setdirstripe
 command is only usable by root unless the
index a50c958..98c3eb0 100644 (file)
@@ -6209,10 +6209,9 @@ static int lfs_setdirstripe(int argc, char **argv)
 
        if (!delete && lsa.lsa_stripe_off == LLAPI_LAYOUT_DEFAULT &&
            lsa.lsa_stripe_count == LLAPI_LAYOUT_DEFAULT && !foreign_mode) {
 
        if (!delete && lsa.lsa_stripe_off == LLAPI_LAYOUT_DEFAULT &&
            lsa.lsa_stripe_count == LLAPI_LAYOUT_DEFAULT && !foreign_mode) {
-               fprintf(stderr,
-                       "%s %s: stripe offset and count must be specified\n",
-                       progname, argv[0]);
-               return CMD_HELP;
+               /* if no parameters set, create directory on least-used MDTs */
+               lsa.lsa_stripe_off = -1;
+               lsa.lsa_stripe_count = 1;
        }
 
        if (delete &&
        }
 
        if (delete &&