From: Lai Siyao Date: Mon, 30 Sep 2019 17:14:51 +0000 (-0700) Subject: LU-11739 lod: subdir under ROOT should honor default layout X-Git-Tag: 2.12.90~81 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=693fb63ac777eab426f1b618316a5649534759ad LU-11739 lod: subdir under ROOT should honor default layout Though sub directories under ROOT don't inherit ROOT default layout, they should hornor ROOT default layout in creation. Add sub test in sanity.sh 65n to verify this. Fixes: 0a988cae95 ("LU-11739 lod: don't inherit default layout from root directory") Signed-off-by: Lai Siyao Change-Id: I1edf91da7944a8871652df7bca2104d00f66163a Reviewed-on: https://review.whamcloud.com/35204 Reviewed-by: Jian Yu Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index db457a4..f26198d 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -5244,12 +5244,15 @@ static void lod_ah_init(const struct lu_env *env, * If parent object is not root directory, * then get default striping from parent object. */ - if (likely(lp != NULL) && !fid_is_root(lod_object_fid(lp))) + if (likely(lp != NULL)) { lod_get_default_striping(env, lp, lds); - /* set child default striping info, default value is NULL */ - if (lds->lds_def_striping_set || lds->lds_dir_def_striping_set) - lc->ldo_def_striping = lds; + /* inherit default striping except ROOT */ + if ((lds->lds_def_striping_set || + lds->lds_dir_def_striping_set) && + !fid_is_root(lod_object_fid(lp))) + lc->ldo_def_striping = lds; + } /* It should always honour the specified stripes */ /* Note: old client (< 2.7)might also do lfs mkdir, whose EA diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 644563f..c409edb 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7841,6 +7841,29 @@ test_65n() { local dir5_layout=$(get_layout_param $dir5) [[ "$dir4_layout" = "$dir5_layout" ]] || error "$dir5 should inherit the default layout from $dir4" + + # though subdir under ROOT doesn't inherit default layout, but + # its sub dir/file should be created with default layout. + [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs" + [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] || + skip "Need MDS version at least 2.12.59" + + local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT) + local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT) + local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT) + + if [ $default_lmv_hash == "none" ]; then + stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT + else + stack_trap "$LFS setdirstripe -D -i $default_lmv_index \ + -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT + fi + + $LFS setdirstripe -D -c 2 $MOUNT || + error "setdirstripe -D -c 2 failed" + mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed" + local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6) + [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count" } run_test 65n "don't inherit default layout from root for new subdirectories"