/* Get default LMV EA */
if (lum.lum_magic == LMV_USER_MAGIC) {
+ struct lmv_user_md *lum;
+ struct ll_inode_info *lli;
+
if (lmmsize > sizeof(*ulmv))
GOTO(finish_req, rc = -EINVAL);
- if (root_request != NULL) {
- struct lmv_user_md *lum;
- struct ll_inode_info *lli;
+ lum = (struct lmv_user_md *)lmm;
+ if (lum->lum_max_inherit == LMV_INHERIT_NONE)
+ GOTO(finish_req, rc = -ENODATA);
- lum = (struct lmv_user_md *)lmm;
+ if (root_request != NULL) {
lli = ll_i2info(inode);
if (lum->lum_max_inherit !=
LMV_INHERIT_UNLIMITED) {
- if (lum->lum_max_inherit ==
- LMV_INHERIT_NONE ||
- lum->lum_max_inherit <
+ if (lum->lum_max_inherit <
LMV_INHERIT_END ||
lum->lum_max_inherit >
LMV_INHERIT_MAX ||
- lum->lum_max_inherit <
+ lum->lum_max_inherit <=
lli->lli_dir_depth)
GOTO(finish_req, rc = -ENODATA);
- if (lum->lum_max_inherit ==
- lli->lli_dir_depth) {
- lum->lum_max_inherit =
- LMV_INHERIT_NONE;
- lum->lum_max_inherit_rr =
- LMV_INHERIT_RR_NONE;
- goto out_copy;
- }
-
lum->lum_max_inherit -=
lli->lli_dir_depth;
}
goto out_copy;
}
- if (lum->lum_max_inherit_rr >
- lli->lli_dir_depth)
- lum->lum_max_inherit_rr -=
- lli->lli_dir_depth;
+ lum->lum_max_inherit_rr -=
+ lli->lli_dir_depth;
}
}
out_copy:
struct ll_inode_info *rlli = ll_i2info(root);
struct ll_inode_info *lli = ll_i2info(dir);
struct lmv_stripe_md *lsm;
+ unsigned short depth;
op_data->op_dir_depth = lli->lli_inherit_depth ?: lli->lli_dir_depth;
+ depth = lli->lli_dir_depth;
/* parent directory is striped */
if (unlikely(lli->lli_lsm_md))
if (lsm->lsm_md_master_mdt_index != LMV_OFFSET_DEFAULT)
goto unlock;
+ /**
+ * Check if the fs default is to be applied.
+ * depth == 0 means 'not inited' for not root dir.
+ */
if (lsm->lsm_md_max_inherit != LMV_INHERIT_NONE &&
(lsm->lsm_md_max_inherit == LMV_INHERIT_UNLIMITED ||
- lsm->lsm_md_max_inherit >= lli->lli_dir_depth)) {
+ (depth && lsm->lsm_md_max_inherit > depth))) {
op_data->op_flags |= MF_QOS_MKDIR;
if (lsm->lsm_md_max_inherit_rr != LMV_INHERIT_RR_NONE &&
(lsm->lsm_md_max_inherit_rr == LMV_INHERIT_RR_UNLIMITED ||
- lsm->lsm_md_max_inherit_rr >= lli->lli_dir_depth))
+ (depth && lsm->lsm_md_max_inherit_rr > depth)))
op_data->op_flags |= MF_RR_MKDIR;
CDEBUG(D_INODE, DFID" requests qos mkdir %#x\n",
PFID(&lli->lli_fid), op_data->op_flags);
local inherit
local inherit_rr
- for i in 1 2 3; do
+ for i in 1 2; do
mkdir $testdir || error "mkdir $testdir failed"
count=$($LFS getdirstripe -D -c $testdir)
(( count == 1 )) ||
}
run_test 413h "don't stick to parent for round-robin dirs"
+test_413i() {
+ [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
+ (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "Need server version at least 2.14.55"
+
+ getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
+ error "dump $DIR default LMV failed"
+ stack_trap "setfattr --restore=$TMP/dmv.ea"
+
+ local testdir=$DIR/$tdir
+ local def_max_rr=1
+ local def_max=3
+ local count
+
+ $LFS setdirstripe -D -i-1 -c1 --max-inherit=$def_max \
+ --max-inherit-rr=$def_max_rr $DIR ||
+ error "set $DIR default LMV failed"
+
+ for i in $(seq 2 3); do
+ def_max=$((def_max - 1))
+ (( def_max_rr == 0 )) || def_max_rr=$((def_max_rr - 1))
+
+ mkdir $testdir
+ # RR is decremented and keeps zeroed once exhausted
+ count=$($LFS getdirstripe -D --max-inherit-rr $testdir)
+ (( count == def_max_rr )) ||
+ error_noexit "$testdir: max-inherit-rr $count != $def_max_rr"
+
+ # max-inherit is decremented
+ count=$($LFS getdirstripe -D --max-inherit $testdir)
+ (( count == def_max )) ||
+ error_noexit "$testdir: max-inherit $count != $def_max"
+
+ testdir=$testdir/d$i
+ done
+
+ # d3 is the last inherited from ROOT, no inheritance anymore
+ # i.e. no the default layout anymore
+ mkdir -p $testdir/d4/d5
+ count=$($LFS getdirstripe -D --max-inherit $testdir)
+ (( count == -1 )) ||
+ error_noexit "$testdir: max-inherit $count != -1"
+
+ local p_count=$($LFS getdirstripe -i $testdir)
+
+ for i in $(seq 4 5); do
+ testdir=$testdir/d$i
+
+ # the root default layout is not applied once exhausted
+ count=$($LFS getdirstripe -i $testdir)
+ (( count == p_count )) ||
+ error_noexit "$testdir: stripe-offset $count != parent offset $p_count"
+ done
+
+ $LFS setdirstripe -i 0 $DIR/d2
+ count=$($LFS getdirstripe -D --max-inherit $DIR/d2)
+ (( count == -1 )) ||
+ error_noexit "$DIR/d2: max-inherit non-striped default $count != -1"
+}
+run_test 413i "check default layout inheritance"
+
test_413z() {
local pids=""
local subdir
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) {
- if (lsa.lsa_stripe_count == 0 || lsa.lsa_stripe_count == 1)
+ if (lsa.lsa_stripe_count == 0 || lsa.lsa_stripe_count == 1 ||
+ lsa.lsa_stripe_count == LLAPI_LAYOUT_DEFAULT)
max_inherit = LMV_INHERIT_DEFAULT_PLAIN;
else
max_inherit = LMV_INHERIT_DEFAULT_STRIPED;
}
if ((verbose & VERBOSE_INHERIT_RR) &&
- lum->lum_magic == LMV_USER_MAGIC &&
- lum->lum_stripe_offset == LMV_OFFSET_DEFAULT) {
+ lum->lum_magic == LMV_USER_MAGIC) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
if (verbose & ~VERBOSE_INHERIT_RR)
llapi_printf(LLAPI_MSG_NORMAL, "lmv_max_inherit_rr: ");