From: Lei Feng Date: Fri, 17 Dec 2021 03:15:01 +0000 (+0800) Subject: LU-15314 utils: set default max-inherit to 3 X-Git-Tag: 2.14.57~43 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=956b4b1e0d9f18c6fe62d84e1c20268363b8159b LU-15314 utils: set default max-inherit to 3 Change LMV_INHERIT_DEFAULT from 0 to 3. So that the default stripe policy of dir will not be inherited unlimited and reduce performance unexpectly. Signed-off-by: Lei Feng Test-Parameters: trivial Change-Id: I67ef540046867ccec7ccc3aab035edbff95874c3 Reviewed-on: https://review.whamcloud.com/45874 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 49f0b4c..aefead0 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -1135,23 +1135,25 @@ enum lmv_type { */ enum { /* for historical reason, 0 means unlimited inheritance */ - LMV_INHERIT_UNLIMITED = 0, - /* unlimited lum_max_inherit by default */ - LMV_INHERIT_DEFAULT = 0, + LMV_INHERIT_UNLIMITED = 0, + /* unlimited lum_max_inherit by default for plain stripe (0 or 1) */ + LMV_INHERIT_DEFAULT_PLAIN = LMV_INHERIT_UNLIMITED, /* not inherit any more */ - LMV_INHERIT_END = 1, + LMV_INHERIT_END = 1, + /* for multiple stripes, the default lum_max_inherit is 3 */ + LMV_INHERIT_DEFAULT_STRIPED = 3, /* max inherit depth */ - LMV_INHERIT_MAX = 250, + LMV_INHERIT_MAX = 250, /* [251, 254] are reserved */ /* not set, or when inherit depth goes beyond end, */ - LMV_INHERIT_NONE = 255, + LMV_INHERIT_NONE = 255, }; enum { /* not set, or when inherit_rr depth goes beyond end, */ LMV_INHERIT_RR_NONE = 0, /* disable lum_max_inherit_rr by default */ - LMV_INHERIT_RR_DEFAULT = 0, + LMV_INHERIT_RR_DEFAULT = LMV_INHERIT_RR_NONE, /* not inherit any more */ LMV_INHERIT_RR_END = 1, /* default inherit_rr of ROOT */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7dbdf2e..958ab7d 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -25601,6 +25601,54 @@ test_413d() { } run_test 413d "inherit ROOT default LMV" +test_413e() { + (( MDSCOUNT >= 2 )) || + skip "We need at least 2 MDTs for this test" + (( MDS1_VERSION >= $(version_code 2.14.55) )) || + skip "Need server version at least 2.14.55" + + local testdir=$DIR/$tdir + local tmpfile=$TMP/temp.setdirstripe.stderr.$$ + local max_inherit + local sub_max_inherit + + mkdir -p $testdir || error "failed to create $testdir" + + # set default max-inherit to -1 if stripe count is 0 or 1 + $LFS setdirstripe -D -c 1 $testdir || + error "failed to set default LMV" + max_inherit=$($LFS getdirstripe -D --max-inherit $testdir) + (( max_inherit == -1 )) || + error "wrong max_inherit value $max_inherit" + + # set default max_inherit to a fixed value if stripe count is not 0 or 1 + $LFS setdirstripe -D -c -1 $testdir || + error "failed to set default LMV" + max_inherit=$($LFS getdirstripe -D --max-inherit $testdir) + (( max_inherit > 0 )) || + error "wrong max_inherit value $max_inherit" + + # and the subdir will decrease the max_inherit by 1 + mkdir -p $testdir/subdir-1 || error "failed to make subdir" + sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1) + (( sub_max_inherit == max_inherit - 1)) || + error "wrong max-inherit of subdir $sub_max_inherit" + + # check specified --max-inherit and warning message + stack_trap "rm -f $tmpfile" + $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile || + error "failed to set default LMV" + max_inherit=$($LFS getdirstripe -D --max-inherit $testdir) + (( max_inherit == -1 )) || + error "wrong max_inherit value $max_inherit" + + # check the warning messages + if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then + error "failed to detect warning string" + fi +} +run_test 413e "check default max-inherit value" + test_413z() { local pids="" local subdir diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 095baf4..42d8d28 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -6891,6 +6891,21 @@ static int lfs_setdirstripe(int argc, char **argv) previous_mode = umask(0); } + /* check max-inherit and warn user in some cases */ + if (default_stripe && + (lsa.lsa_stripe_count < 0 || lsa.lsa_stripe_count > 1)) { + if (max_inherit == LMV_INHERIT_UNLIMITED) + fprintf(stderr, + "%s %s: unrecommended max-inherit=-1 when default stripe-count=%lld\n", + progname, argv[0], lsa.lsa_stripe_count); + else if (max_inherit > LMV_INHERIT_DEFAULT_STRIPED + 2 && + max_inherit != LMV_INHERIT_NONE) + fprintf(stderr, + "%s %s: unrecommended max-inherit=%d when default stripe-count=%lld\n", + progname, argv[0], max_inherit, + lsa.lsa_stripe_count); + } + if (max_inherit_rr != LAYOUT_INHERIT_UNSET && lsa.lsa_stripe_off != LLAPI_LAYOUT_DEFAULT && lsa.lsa_stripe_off != LMV_OFFSET_DEFAULT) { @@ -6950,10 +6965,15 @@ static int lfs_setdirstripe(int argc, char **argv) param->lsp_stripe_pattern = LMV_HASH_TYPE_UNKNOWN; param->lsp_pool = lsa.lsa_pool_name; param->lsp_is_specific = false; - if (max_inherit == LAYOUT_INHERIT_UNSET) - max_inherit = LMV_INHERIT_DEFAULT; + if (max_inherit == LAYOUT_INHERIT_UNSET) { + if (lsa.lsa_stripe_count == 0 || lsa.lsa_stripe_count == 1) + max_inherit = LMV_INHERIT_DEFAULT_PLAIN; + else + max_inherit = LMV_INHERIT_DEFAULT_STRIPED; + } param->lsp_max_inherit = max_inherit; if (default_stripe) { + if (max_inherit_rr == LAYOUT_INHERIT_UNSET) max_inherit_rr = LMV_INHERIT_RR_DEFAULT; param->lsp_max_inherit_rr = max_inherit_rr;