From a8272168e3888ec4ced18035182159a8ee56a51a 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 Signed-off-by: Mikhail Pershin Change-Id: Ic58fdda2ab3e63083128cb6cf949fcb43ccd2c02 Reviewed-on: https://review.whamcloud.com/48433 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 6 ++++++ lustre/tests/sanity.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index fe8c3d4..525c9d5 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -2012,6 +2012,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 5c361e1..e649462 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -22845,8 +22845,16 @@ test_270i() { skip "Need MDS version at least 2.14.54" 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