*/
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 */
}
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
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) {
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;