Whamcloud - gitweb
LU-16227 utils: Add warning for lfs setdirstripe -D -i x,y,z 20/49420/6
authorTimothy Day <timday@amazon.com>
Thu, 15 Dec 2022 19:47:57 +0000 (19:47 +0000)
committerOleg Drokin <green@whamcloud.com>
Fri, 13 Jan 2023 07:17:09 +0000 (07:17 +0000)
Adjust setdirstripe to be more user friendly. The
use of "-D -i x,y,z" now returns a clear error
that this is creating a default striped directory
layout and that this is a bad idea, if it is not
accompanied by "-c N" that matches the number of
index values given.

Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Ic9f91853d4016bf0edfb3845ac9f1edafdf73d55
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49420
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs-setdirstripe.1
lustre/tests/sanity.sh
lustre/utils/lfs.c

index c1be84f..be8c653 100644 (file)
@@ -42,6 +42,19 @@ across all MDTs if their free space is within
 percent of each other, otherwise the client will prefer to select
 .B COUNT
 MDT(s) proportional to the free space and inodes on each.
+
+Providing mutiple
+.I MDT_INDEX
+values while trying to set the default striping pattern of subdirectories using
+.B -D
+will not load balance subdirectory creation amongst the MDTs. Instead, this
+will cause all new subdirectories to be striped across all of the specified
+MDTs. This is discouraged and can lead to filesystem problems if too many
+striped directories are created. To do this anyway,
+.B -c N
+must also be specified, where
+.B N
+matches the number of MDT indices given.
 .TP
 .BR \-H ", " \-\-mdt-hash =\fIHASH_TYPE\fR
 Use
index 0f41d98..900de19 100755 (executable)
@@ -4420,6 +4420,25 @@ test_33i()
 }
 run_test 33i "striped directory can be accessed when one MDT is down"
 
+test_33j() {
+       (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
+
+       mkdir -p $DIR/$tdir/
+
+       $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
+               error "setdirstripe -D -i0,1 incorrectly succeeded"
+
+       $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
+               error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
+
+       $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
+               error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
+
+       $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
+               error "-D was not specified, but still failed"
+}
+run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
+
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
        rm -f $DIR/f34
index 58890c8..ed90a6f 100644 (file)
@@ -6641,6 +6641,7 @@ static int lfs_setdirstripe(int argc, char **argv)
        bool default_stripe = false;
        bool delete = false;
        bool foreign_mode = false;
+       bool mdt_count_set = false;
        mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
        mode_t previous_mode = 0;
        char *xattr = NULL;
@@ -6703,6 +6704,7 @@ static int lfs_setdirstripe(int argc, char **argv)
                                        progname, optarg);
                                return CMD_HELP;
                        }
+                       mdt_count_set = true;
                        break;
                case 'd':
                        delete = true;
@@ -6929,6 +6931,15 @@ static int lfs_setdirstripe(int argc, char **argv)
                                lsa.lsa_stripe_count);
        }
 
+       if (default_stripe && lsa.lsa_nr_tgts > 1 && !mdt_count_set) {
+               fprintf(stderr,
+                       "%s %s: trying to create unrecommended default striped directory layout,\n"
+                       "       '-D -i x,y,z' will stripe every new directory across all MDTs,\n"
+                       "       add -c with the number of MDTs to do this anyway\n",
+                       progname, argv[0]);
+               return CMD_HELP;
+       }
+
        if (max_inherit_rr != LAYOUT_INHERIT_UNSET &&
            lsa.lsa_stripe_off != LLAPI_LAYOUT_DEFAULT &&
            lsa.lsa_stripe_off != LMV_OFFSET_DEFAULT) {