From a53869aa31ceee700215520e5267b155a0f59d46 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Fri, 4 Oct 2019 22:42:56 -0700 Subject: [PATCH] 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") Lustre-change: https://review.whamcloud.com/35204 Lustre-commit: 693fb63ac777eab426f1b618316a5649534759ad Signed-off-by: Lai Siyao Change-Id: I1edf91da7944a8871652df7bca2104d00f66163a Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/36370 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_object.c | 11 +++++++---- lustre/tests/sanity.sh | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index bb61bbc..238c5c5 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -4808,12 +4808,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 8118bec..a388f32 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6908,6 +6908,31 @@ 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) ]] || + [[ $MDS1_VERSION -ge $(version_code 2.12.3) && + $MDS1_VERSION -lt $(version_code 2.12.50) ]] || + skip "Need MDS version at least 2.12.3 or 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" -- 1.8.3.1