Whamcloud - gitweb
LU-4929 lfs: Add lfs dirstripe to the manpage 43/10643/10
authorWang Di <di.wang@intel.com>
Sat, 7 Jun 2014 20:18:11 +0000 (13:18 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Jun 2014 03:19:31 +0000 (03:19 +0000)
Add lfs-setdirstripe.1, lfs-getdirstripe and
lfs-mkdir.1 to the manpage.

Add -m mode to "lfs mkdir" help, and also mention lfs
setdirstripe can only be done on MDT0 with adminitrator
right.

lfs getdirstripe should honor -O MDTUUID to list the
stripe information of subdirectories located on that MDT.

Remove unnecessary error message in cb_getstripe.

Fix the default getdirstripe behavior, which should list all of
its subdirectories stripe pattern, like lfs getstripe.

Fix format of LMV stripe information.

Change-Id: I7ee6ef3d6df5df50e35f5874a27e176884d79704
Signed-off-by: Wang Di <di.wang@intel.com>
Reviewed-on: http://review.whamcloud.com/10643
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/doc/Makefile.am
lustre/doc/lfs-getdirstripe.1 [new file with mode: 0644]
lustre/doc/lfs-mkdir.1 [new file with mode: 0644]
lustre/doc/lfs-setdirstripe.1 [new file with mode: 0644]
lustre/doc/lfs.1
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index 691d98c..b15c822 100644 (file)
@@ -43,7 +43,8 @@ MANFILES = lustre.7 lfs.1 mount.lustre.8 lctl.8 \
        llapi_file_create.3 llapi_file_get_stripe.3 lustreapi.7 \
        lustre_rsync.8 lfs_migrate.1 lhbadm.8 ldev.8 ldev.conf.5 nids.5 \
        lfs-hsm.1 llapi_hsm_state_get.3 llapi_hsm_state_set.3 \
-       lustre_routes_config.8 lustre_routes_conversion.8
+       lustre_routes_config.8 lustre_routes_conversion.8 \
+       lfs-setdirstripe.1 lfs-mkdir.1 lfs-getdirstripe.1
 SERVER_MANFILES = mkfs.lustre.8 tunefs.lustre.8
 
 if SERVER
diff --git a/lustre/doc/lfs-getdirstripe.1 b/lustre/doc/lfs-getdirstripe.1
new file mode 100644 (file)
index 0000000..b5bcaff
--- /dev/null
@@ -0,0 +1,52 @@
+.TH LFS-GETDIRSTRIPE 1 2014-06-08 "Lustre" "Lustre Utilities"
+.SH NAME
+lfs getdirstripe \- list the striping pattern of a given directory.
+.SH SYNOPSIS
+.B lfs getdirstripe
+[\fIOPTION\fR]... \fIDIR\fR...
+.SH DESCRIPTION
+Get the striping pattern information of directories. This lfs utility is
+similar to
+.B lfs getstripe
+, but is used to get directory striping pattern.
+.BP lfs
+.SH OPTIONS
+.TP
+.B \-c, \-\-stripe-count
+Only show the stripe count of the directory.
+.TP
+.B \-i, \-\-stripe-index
+Only show the stripe index of the directory.
+.TP
+.B \-R, \-\-raw
+The striping information is printed without substituting the
+filesystem's default values for unspecified fields. If the striping EA is not
+set, 0, and -1 will be printed for the stripe count, and offset respectively.
+.TP
+.B \-q, \-\-quiet
+Only show the details of the sub-striped directory FID information.
+.TP
+.B \-v, \-\-verbose
+Additional information will be shown with this option.
+.TP
+.B \-r, \-\-recursive
+The default behavior when a directory is specified is to list the striping
+information for all sub-directories within the specified directory. This
+can be expanded with --recursive, which will recurse into all subdirectories.
+.TP
+\fB\-O\fR, \fB\-\-obd\fR=\fIFSNAME-MDTnnnn_UUID\fR
+Limit the returned directories to those with objects on a specific MDT,
+whose uuid is
+.I FSNAME-MDTnnnn_UUID.
+.SH EXAMPLES
+.TP
+.B $ lfs getdirstripe -O lustre-MDT0001_UUID -r /mnt/lustre/dir1
+List the striping information of sub-directories, that are located on MDT1,
+under /mnt/lustre/dir1.
+.SH AVAILABILTY
+The lfs getdirstripe command is part of the Lustre filesystem.
+.SH SEE ALSO
+.BR lfs (1),
+.BR lfs-setdirstripe (1),
+.BR lfs-getstripe (1),
+.BR lustre (7)
diff --git a/lustre/doc/lfs-mkdir.1 b/lustre/doc/lfs-mkdir.1
new file mode 100644 (file)
index 0000000..c02a68e
--- /dev/null
@@ -0,0 +1 @@
+.so man1/lfs-setdirstripe.1
diff --git a/lustre/doc/lfs-setdirstripe.1 b/lustre/doc/lfs-setdirstripe.1
new file mode 100644 (file)
index 0000000..9720cb3
--- /dev/null
@@ -0,0 +1,87 @@
+.TH LFS-SETDIRSTRIPE 1 2014-06-08 "Lustre" "Lustre Utilities"
+.SH NAME
+lfs setdirstripe, mkdir \- set striping pattern of a directory.
+.SH SYNOPSIS
+.B lfs setdirstripe
+[\fIOPTION\fR]... \fIDIR\fR...
+.br
+.SH DESCRIPTION
+Create a striped directory with specified striping pattern. This lfs utility
+is similar to
+.B lfs setstripe
+, but is used to create striped directory.
+.B lfs mkdir
+is an alias for this command.
+.SH OPTIONS
+.TP
+\fB\-c\fR, \fB\-\-count\fR=\fICOUNT\fR
+Stripe over
+.I COUNT
+MDTs.
+.TP
+\fB\-i\fR, \fB\-\-index\fR=\fISTART_MDT_INDEX\fR
+Stripe from the MDT, whose index is
+.I START_MDT_INDEX.
+.TP
+\fB\-t\fR, \fB\-\-hash\-type\fR=\fIHASH_TYPE\fR
+the hash_type of the striped directory.
+.RS 1.2i
+.TP
+.B fnv_1a_64
+Fowler-Noll-Vo (FNV-1a) hash algorithm.  This provides
+reasonably uniform, but not cryptographically strong,
+hashing of the filename. (default)
+.TP
+.B all_char
+Sum of ASCII characters modulo number of MDTs. This
+provides weak hashing of the filename, and is suitable
+for only testing or when the input is known to have
+perfectly uniform distribution (e.g. sequential numbers).
+.RE
+.TP
+.B \-D, \-\-default_stripe
+Set the default striping pattern of the directory. Newly created
+sub-directories will use the new default striping pattern,
+but existing sub-directories will not be affected.  The newly
+created sub-directories will also inherit the current default
+striping pattern. Only default stripe count is supported for now.
+.TP
+\fB\-m\fR, \fB\-\-mode\fR=\fIMODE\fR
+Set the file access mode of the new directory to the specified
+numeric value (typically octal) as specified in
+.BR chmod (1),
+and is not affected by the current
+.BR umask (1p).
+.SH NOTE
+.PP
+The "lfs setdirstripe" command is only executable by root unless
+"mdt.*.enable_remote_dir_gid" is set via "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.
+
+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.
+
+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
+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
+if any of the intermediate MDTs are offline.
+.SH EXAMPLES
+.TP
+.B $ lfs setdirstripe -c 2 -i 1 -t all_char /mnt/lustre/dir1
+This creates a directory striped on two MDTs, whose first stripe is on
+.B MDT0001
+(MDT index 1), and whose hash type is
+.BR all_char .
+.SH BUGS
+Default stripe cannot be deleted once it is set.
+.SH AVAILABILITY
+The lfs setdirstripe command is part of the Lustre filesystem.
+.SH SEE ALSO
+.BR lfs (1),
+.BR lfs-getdirstripe (1),
+.BR lfs-setstripe (1),
+.BR lustre (7)
index 6537be1..1d5d9fb 100644 (file)
@@ -84,8 +84,6 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs data_version [-n] \fB<filename>\fR
 .br
-.B lfs mkdir <--index|-i mdt_index> <dir>
-.br
 .B lfs help
 .SH DESCRIPTION
 .B lfs
@@ -350,13 +348,14 @@ Set quotas of user `bob': 1GB block quota hardlimit and 2 GB block quota softlim
 .B $ lfs setquota -t -u --block-grace 1000 --inode-grace 1w4d /mnt/lustre
 Set grace times for user quotas: 1000 seconds for block quotas, 1 week and 4 days for inode quotas
 .TP
-.B $ lfs mkdir -i 1 new_directory
-Create directory 'new_directory' on the mdt with index 1.
 .SH BUGS
 The \fBlfs find\fR command isn't as comprehensive as \fBfind\fR(1).
 .SH AUTHOR
 The lfs command is part of the Lustre filesystem.
 .SH SEE ALSO
 .BR lfs-hsm (1),
+.BR lfs-setdirstripe (1),
+.BR lfs-getdirstripe (1),
+.BR lfs-mkdir (1),
 .BR lctl (8),
 .BR lustre (7)
index c34f9ba..5f125f2 100644 (file)
@@ -148,16 +148,18 @@ command_t cmdlist[] = {
         "                 [--layout|-L]\n"
         "                 <directory|filename> ..."},
        {"setdirstripe", lfs_setdirstripe, 0,
-        "To create a remote directory on a specified MDT.\n"
+        "To create a striped directory on a specified MDT. This can only\n"
+        "be done on MDT0 with the right of administrator.\n"
         "usage: setdirstripe <--count|-c stripe_count>\n"
-        "[--index|-i mdt_index] [--hash-type|-t hash_type]\n"
-        "[--default_stripe|-D ] <dir>\n"
+        "              [--index|-i mdt_index] [--hash-type|-t hash_type]\n"
+        "              [--default_stripe|-D ] [--mode|-m mode] <dir>\n"
         "\tstripe_count: stripe count of the striped directory\n"
         "\tmdt_index:  MDT index of first stripe\n"
         "\thash_type:  hash type of the striped directory. Hash types:\n"
-        "      -t fnv_1a_64 FNV-1a hash algorithm(default)\n"
-        "      -t all_char  sum of characters % MDT_COUNT. (not recommended)\n"
-        "\tdefault_stripe: set default dirstripe of the directory\n"},
+        "      fnv_1a_64 FNV-1a hash algorithm (default)\n"
+        "      all_char  sum of characters % MDT_COUNT (not recommended)\n"
+        "\tdefault_stripe: set default dirstripe of the directory\n"
+        "\tmode: the mode of the directory\n"},
        {"getdirstripe", lfs_getdirstripe, 0,
         "To list the striping info for a given directory\n"
         "or recursively for all directories in a directory tree.\n"
@@ -165,10 +167,18 @@ command_t cmdlist[] = {
         "               [--count|-c ] [--index|-i ] [--raw|-R]\n"
         "               [--recursive | -r] [ --default_stripe | -D ] <dir> "},
        {"mkdir", lfs_setdirstripe, 0,
-        "To create a remote directory on a specified MDT. And this can only\n"
-        "be done on MDT0 by administrator.\n"
-        "usage: mkdir <--index|-i mdt_index> <dir>\n"
-        "\tmdt_index:    MDT index of the remote directory.\n"},
+        "To create a striped directory on a specified MDT. This can only\n"
+        "be done on MDT0 with the right of administrator.\n"
+        "usage: mkdir <--count|-c stripe_count>\n"
+        "              [--index|-i mdt_index] [--hash-type|-t hash_type]\n"
+        "              [--default_stripe|-D ] [--mode|-m mode] <dir>\n"
+        "\tstripe_count: stripe count of the striped directory\n"
+        "\tmdt_index:  MDT index of first stripe\n"
+        "\thash_type:  hash type of the striped directory. Hash types:\n"
+        "      fnv_1a_64 FNV-1a hash algorithm (default)\n"
+        "      all_char  sum of characters % MDT_COUNT (not recommended)\n"
+        "\tdefault_stripe: set default dirstripe of the directory\n"
+        "\tmode: the mode of the directory\n"},
        {"rm_entry", lfs_rmentry, 0,
         "To remove the name entry of the remote directory. Note: This\n"
         "command will only delete the name entry, i.e. the remote directory\n"
index 5247d58..57a14eb 100644 (file)
@@ -1580,7 +1580,7 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent,
        if (sem_init && (ret = sem_init(path, parent ?: p, &d, data, de)))
                goto err;
 
-       if (!d || (param->get_lmv && !param->recursive))
+       if (d == NULL)
                goto out;
 
        while ((dent = readdir64(d)) != NULL) {
@@ -2393,18 +2393,27 @@ void lmv_dump_user_lmm(struct lmv_user_md *lum, char *pool_name,
        char *separator = "";
 
        if (obdindex != OBD_NOT_FOUND) {
-               for (i = 0; i < lum->lum_stripe_count; i++) {
-                       if (obdindex == objects[i].lum_mds) {
-                               llapi_printf(LLAPI_MSG_NORMAL, "%s%s\n", prefix,
-                                            path);
+               if (lum->lum_stripe_count == 0) {
+                       if (obdindex == lum->lum_stripe_offset)
                                obdstripe = 1;
-                               break;
+               } else {
+                       for (i = 0; i < lum->lum_stripe_count; i++) {
+                               if (obdindex == objects[i].lum_mds) {
+                                       llapi_printf(LLAPI_MSG_NORMAL,
+                                                    "%s%s\n", prefix,
+                                                    path);
+                                       obdstripe = 1;
+                                       break;
+                               }
                        }
                }
        } else {
                obdstripe = 1;
        }
 
+       if (!obdstripe)
+               return;
+
        /* show all information default */
        if (!verbose) {
                if (lum->lum_magic == LMV_USER_MAGIC)
@@ -2422,7 +2431,10 @@ void lmv_dump_user_lmm(struct lmv_user_md *lum, char *pool_name,
                        llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_count: ");
                llapi_printf(LLAPI_MSG_NORMAL, "%u",
                             (int)lum->lum_stripe_count);
-               separator = "\n";
+               if (verbose & VERBOSE_OFFSET)
+                       separator = " ";
+               else
+                       separator = "\n";
        }
 
        if (verbose & VERBOSE_OFFSET) {
@@ -3286,17 +3298,10 @@ static int cb_getstripe(char *path, DIR *parent, DIR **dirp, void *data,
                                     (void *)&param->lmd->lmd_lmm);
                }
 
-       } else if (parent) {
+       } else if (parent && !param->get_lmv && !param->get_default_lmv) {
                char *fname = strrchr(path, '/');
                fname = (fname == NULL ? path : fname + 1);
 
-               if (param->get_lmv) {
-                       llapi_printf(LLAPI_MSG_NORMAL,
-                                    "%s get dirstripe information for file\n",
-                                    path);
-                       goto out;
-               }
-
                strncpy((char *)&param->lmd->lmd_lmm, fname, param->lumlen);
 
                ret = ioctl(dirfd(parent), IOC_MDC_GETFILESTRIPE,