rc = ll_dir_get_default_layout(inode, (void **)&lmm, &lmm_size,
&req, valid, 0);
if (rc == -ENODATA && !fid_is_root(ll_inode2fid(inode)) &&
- !(valid & (OBD_MD_MEA|OBD_MD_DEFAULT_MEA)) && root_request != NULL){
+ !(valid & OBD_MD_MEA) && root_request != NULL) {
int rc2 = ll_dir_get_default_layout(inode, (void **)&lmm,
&lmm_size, &root_req, valid,
GET_DEFAULT_LAYOUT_ROOT);
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;
+ lli = ll_i2info(inode);
+ if (lum->lum_max_inherit == LMV_INHERIT_NONE ||
+ (lum->lum_max_inherit > 0 &&
+ 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;
+ }
+ if (lum->lum_max_inherit > lli->lli_dir_depth &&
+ lum->lum_max_inherit <= LMV_INHERIT_MAX)
+ lum->lum_max_inherit -=
+ lli->lli_dir_depth;
+
+ if (lum->lum_max_inherit_rr >
+ lli->lli_dir_depth &&
+ lum->lum_max_inherit_rr <=
+ LMV_INHERIT_RR_MAX)
+ lum->lum_max_inherit_rr -=
+ lli->lli_dir_depth;
+ else if (lum->lum_max_inherit_rr ==
+ lli->lli_dir_depth)
+ lum->lum_max_inherit_rr =
+ LMV_INHERIT_RR_NONE;
+ }
+out_copy:
if (copy_to_user(ulmv, lmm, lmmsize))
GOTO(finish_req, rc = -EFAULT);
}
run_test 413e "check default max-inherit value"
+test_413f() {
+ (( 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"
+
+ getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
+ error "dump $DIR default LMV failed"
+ stack_trap "setfattr --restore=$TMP/dmv.ea"
+
+ $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
+ error "set $DIR default LMV failed"
+
+ local testdir=$DIR/$tdir
+
+ local count
+ local inherit
+ local inherit_rr
+
+ for i in $(seq 3); do
+ mkdir $testdir || error "mkdir $testdir failed"
+ count=$($LFS getdirstripe -D -c $testdir)
+ (( count == 1 )) ||
+ error "$testdir default LMV count mismatch $count != 1"
+ inherit=$($LFS getdirstripe -D -X $testdir)
+ (( inherit == 3 - i )) ||
+ error "$testdir default LMV max-inherit $inherit != $((3 - i))"
+ inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
+ (( inherit_rr == 3 - i )) ||
+ error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
+ testdir=$testdir/sub
+ done
+
+ mkdir $testdir || error "mkdir $testdir failed"
+ count=$($LFS getdirstripe -D -c $testdir)
+ (( count == 0 )) ||
+ error "$testdir default LMV count not zero: $count"
+}
+run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
+
test_413z() {
local pids=""
local subdir
return -ENOTDIR;
again:
param->fp_lmv_md->lum_stripe_count = param->fp_lmv_stripe_count;
- if (param->fp_get_default_lmv)
+ if (param->fp_get_default_lmv) {
+#ifdef HAVE_STATX
+ struct statx stx;
+
+ /* open() may not fetch LOOKUP lock, statx() to ensure dir depth
+ * is set.
+ */
+ statx(*d, "", AT_EMPTY_PATH, STATX_MODE, &stx);
+#else
+ struct stat st;
+
+ fstat(*d, &st);
+#endif
param->fp_lmv_md->lum_magic = LMV_USER_MAGIC;
- else
+ } else {
param->fp_lmv_md->lum_magic = LMV_MAGIC_V1;
+ }
ret = ioctl(*d, LL_IOC_LMV_GETSTRIPE, param->fp_lmv_md);