From de4d0db15f8de47ff2fe52b43cda96df55a7b91e Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Mon, 5 Sep 2022 10:41:37 +0300 Subject: [PATCH] LU-16135 lod: prohibit DoM pattern in plain layout DoM pattern can be set as default directory plain layout by older LFS version. It misses DoM component sanity checks if plain layout is used. Such layout is not allowed and causes later crashed when file is created under that directory. While LFS can prevent this but not in all Lustre versions, so LOD should do the check as well Lustre-change: https://review.whamcloud.com/48433 Lustre-commit: a8272168e3888ec4ced18035182159a8ee56a51a Signed-off-by: Mikhail Pershin Change-Id: Ic58fdda2ab3e63083128cb6cf949fcb43ccd2c02 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/48514 Tested-by: jenkins Tested-by: Maloo --- lustre/lod/lod_lov.c | 6 ++++++ lustre/tests/sanity.sh | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 6d4b08d..329688e 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -2103,6 +2103,12 @@ int lod_verify_striping(const struct lu_env *env, struct lod_device *d, case LOV_USER_MAGIC_V1: case LOV_USER_MAGIC_V3: case LOV_USER_MAGIC_SPECIFIC: + if (lov_pattern(le32_to_cpu(lum->lmm_pattern)) == + LOV_PATTERN_MDT) { + /* DoM must use composite layout */ + CDEBUG(D_LAYOUT, "DoM without composite layout\n"); + RETURN(-EINVAL); + } RETURN(lod_verify_v1v3(d, buf, is_from_disk)); case LOV_USER_MAGIC_COMP_V1: case LOV_USER_MAGIC_SEL: diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 54880c6..f58b630 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -22041,12 +22041,20 @@ test_270h() { run_test 270h "DoM: DoM stripe removal when disabled on server" test_270i() { - (( $MDS1_VERSION >= $(version_code 2.14.54) )) || - skip "Need MDS version at least 2.14.54" + (( $MDS1_VERSION >= $(version_code 2.14.0.62) )) || + skip "Need MDS version at least 2.14.0.62" mkdir $DIR/$tdir + # DoM with plain layout $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir && - error "setstripe should fail" || true + error "default plain layout with DoM must fail" + $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile && + error "setstripe plain file layout with DoM must fail" + $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir && + error "default DoM layout with bad striping must fail" + $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile && + error "setstripe to DoM layout with bad striping must fail" + return 0 } run_test 270i "DoM: setting invalid DoM striping should fail" -- 1.8.3.1