Whamcloud - gitweb
LU-13417 utils: lfs setdirstripe -D -i -1 should work 60/38160/4
authorAndreas Dilger <adilger@whamcloud.com>
Tue, 7 Apr 2020 20:25:33 +0000 (14:25 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 1 May 2020 04:26:16 +0000 (04:26 +0000)
Allow "lfs setdirstripe -D -i -1" to work as expected to create remote
directories balanced across MDTs.  Otherwise, this sets a default
stripe count of 0, which results in only local directories created.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I8fb92e352d278b0c2985976df69751309fce7057
Reviewed-on: https://review.whamcloud.com/38160
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Jian Yu <yujian@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 8d48380..8e5ff62 100644 (file)
@@ -5,10 +5,12 @@ lfs setdirstripe, mkdir \- set striping pattern of a directory.
 .B lfs setdirstripe [\fR-cdDHioTx\fR] \fIDIR\fR...
 .br
 .SH DESCRIPTION
 .B lfs setdirstripe [\fR-cdDHioTx\fR] \fIDIR\fR...
 .br
 .SH DESCRIPTION
-Create a striped directory with specified striping pattern. This lfs utility
-is similar to
-.BR lfs setstripe
-, but is used to create striped directory.
+Create a striped directory with specified striping pattern. This
+.B lfs
+sub-command is similar to
+.BR "lfs setstripe" ,
+but is used to create a striped directory or set the default layout for
+subdirectories.
 Can also be used to create directory with a foreign (free format) striping pattern (see
 .BR --foreign
 and
 Can also be used to create directory with a foreign (free format) striping pattern (see
 .BR --foreign
 and
@@ -68,10 +70,12 @@ but existing sub-directories will not be affected.  The newly
 created sub-directories will also inherit the specified default
 striping pattern. Only default stripe count is supported for now.
 
 created sub-directories will also inherit the specified default
 striping pattern. Only default stripe count is supported for now.
 
-Note that striping all directories across all MDTs by default is not
+Note that striping all directories across all MDTs by default is
+.B not
 recommended at this time, as the clients will have to do more RPCs to
 create and access each directory, hurting performance rather than
 recommended at this time, as the clients will have to do more RPCs to
 create and access each directory, hurting performance rather than
-improving it.  Default striped directories are preferred for cases
+improving it.  Default striped directories are preferred for parent
+directories
 where large subdirectories will be created (e.g. file-per-process
 job output directories).
 .TP
 where large subdirectories will be created (e.g. file-per-process
 job output directories).
 .TP
@@ -90,13 +94,12 @@ Create a directory with a foreign (non-Lustre/free format, see
 option) striping. Where
 .BR type
 specifies a known foreign type (like
 option) striping. Where
 .BR type
 specifies a known foreign type (like
-.BR none
-,
-.BR daos
-, ...) or a 32-bit numeric type.
+.BR none ,
+.BR daos )
+or a 32-bit numeric type.
 .TP
 .BR \-\-flags =\fI<hex>\fR
 .TP
 .BR \-\-flags =\fI<hex>\fR
-Specify a bitmask of flags.
+Specify a numeric bitmask of type-specific layout flags for the foreign layout.
 .TP
 .BR \-x ", " \-\-xattr =\fISTRING\fR
 Specify a string to be used as a foreign (free format) striping.
 .TP
 .BR \-x ", " \-\-xattr =\fISTRING\fR
 Specify a string to be used as a foreign (free format) striping.
@@ -104,20 +107,26 @@ Specify a string to be used as a foreign (free format) striping.
 .PP
 The
 .B lfs setdirstripe
 .PP
 The
 .B lfs setdirstripe
-command is only executable by root unless
+command is only usable by root unless the
 .B "mdt.*.enable_remote_dir_gid"
 is set on the MDS via
 .B lctl set_param
 .B "mdt.*.enable_remote_dir_gid"
 is set on the MDS via
 .B lctl set_param
-to be either a non-zero GID to limit it to a single group
-(e.g. "operator" or "admin"), or "-1" to allow any group
-to create remote directories.
+to be either a non-zero numeric GID to limit it to a single group (e.g. the
+.BR "operator " or " admin"
+GID), or
+.B "-1"
+to allow any user/group to create remote directories.  By default, it is
+.B "0"
+to limit remote/striped directories to only the root user.
 
 
-The root of the file system is on MDT0000, and directories and files inherit the
-MDT of their parent directory unless a different MDT is specified with this
-command.
+The root directory of the file system is on MDT0000, and directories and
+files inherit the MDT of their parent directory unless a different MDT is
+specified with this command.
 
 By default, only directories on MDT0000 can contain directories that are not on
 
 By default, only directories on MDT0000 can contain directories that are not on
-the same MDT.  However, if "mdt.*.enable_remote_dir" is set non-zero on an MDT
+the same MDT.  However, if
+.B "mdt.*.enable_remote_dir"
+is set non-zero on an MDT (the default)
 then it will allow creating remote directories that have parents other than
 MDT0000. This is restricted to avoid creating directory trees that have
 intermediate path components on a series different MDTs and become unavailable
 then it will allow creating remote directories that have parents other than
 MDT0000. This is restricted to avoid creating directory trees that have
 intermediate path components on a series different MDTs and become unavailable
index 6151625..bcad3e6 100644 (file)
@@ -429,8 +429,8 @@ command_t cmdlist[] = {
         "                  [!] --mirror-id=[+-]<id>]\n"
         "                 <directory|filename> ..."},
        {"setdirstripe", lfs_setdirstripe, 0,
         "                  [!] --mirror-id=[+-]<id>]\n"
         "                 <directory|filename> ..."},
        {"setdirstripe", lfs_setdirstripe, 0,
-        "To create a striped directory on a specified MDT. This can only\n"
-        "be done on MDT0 with the right of administrator.\n"
+        "Create striped directory on specified MDT, same as mkdir.\n"
+        "May be restricted to root or group users, depending on settings.\n"
         "usage: setdirstripe [OPTION] <directory>\n"
         SETDIRSTRIPE_USAGE},
        {"getdirstripe", lfs_getdirstripe, 0,
         "usage: setdirstripe [OPTION] <directory>\n"
         SETDIRSTRIPE_USAGE},
        {"getdirstripe", lfs_getdirstripe, 0,
@@ -441,8 +441,7 @@ command_t cmdlist[] = {
         "                    [--recursive|-r] [--yaml|-y]\n"
         "                    [--verbose|-v] [--default|-D] <dir> ..."},
        {"mkdir", lfs_setdirstripe, 0,
         "                    [--recursive|-r] [--yaml|-y]\n"
         "                    [--verbose|-v] [--default|-D] <dir> ..."},
        {"mkdir", lfs_setdirstripe, 0,
-        "To create a striped directory on a specified MDT. This can only\n"
-        "be done on MDT0 with the right of administrator.\n"
+        "Create striped directory on specified MDT, same as setdirstripe.\n"
         "usage: mkdir [OPTION] <directory>\n"
         SETDIRSTRIPE_USAGE},
        {"rm_entry", lfs_rmentry, 0,
         "usage: mkdir [OPTION] <directory>\n"
         SETDIRSTRIPE_USAGE},
        {"rm_entry", lfs_rmentry, 0,
@@ -6049,6 +6048,11 @@ static int lfs_setdirstripe(int argc, char **argv)
                return CMD_HELP;
        }
 
                return CMD_HELP;
        }
 
+       /* if "lfs setdirstripe -D -i -1" is used, assume 1-stripe directory */
+       if (default_stripe && lsa.lsa_stripe_off == -1 &&
+           (lsa.lsa_stripe_count == LLAPI_LAYOUT_DEFAULT ||
+            lsa.lsa_stripe_count == 0))
+               lsa.lsa_stripe_count = 1;
        if (lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT)
                param->lsp_stripe_count = lsa.lsa_stripe_count;
        if (lsa.lsa_stripe_off == LLAPI_LAYOUT_DEFAULT)
        if (lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT)
                param->lsp_stripe_count = lsa.lsa_stripe_count;
        if (lsa.lsa_stripe_off == LLAPI_LAYOUT_DEFAULT)