From 77f01308c5095030ee84f83339c085bcbcf04155 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Sun, 9 Dec 2018 20:21:27 +0800 Subject: [PATCH] LU-11753 obdclass: lu_dirent record length missing '0' In lu_dirent packing, a '0' is appended after name, but it's not counted in size calcuation, which may cause crash. Add sanity test_230l. Signed-off-by: Lai Siyao Change-Id: Iab4947dea8e26ea798d5f64e218268200a5fabe8 Reviewed-on: https://review.whamcloud.com/33865 Reviewed-by: Stephan Thiell Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/uapi/linux/lustre/lustre_idl.h | 13 ++++++++----- lustre/tests/sanity.sh | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 1e18f32..069fe56 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -534,12 +534,15 @@ static inline size_t lu_dirent_calc_size(size_t namelen, __u16 attr) if (attr & LUDA_TYPE) { const size_t align = sizeof(struct luda_type) - 1; - size = (sizeof(struct lu_dirent) + namelen + align) & ~align; - size += sizeof(struct luda_type); - } else - size = sizeof(struct lu_dirent) + namelen; - return (size + 7) & ~7; + size = (sizeof(struct lu_dirent) + namelen + 1 + align) & + ~align; + size += sizeof(struct luda_type); + } else { + size = sizeof(struct lu_dirent) + namelen + 1; + } + + return (size + 7) & ~7; } #define MDS_DIR_END_OFF 0xfffffffffffffffeULL diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d27f127..8b1bc51 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -15518,6 +15518,18 @@ test_230k() { } run_test 230k "file data not changed after dir migration" +test_230l() { + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] && + skip "Need MDS version at least 2.11.56" + + $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed" + createmany -o $DIR/$tdir/f___________________________________ 1000 || + error "create files under remote dir failed $i" + $LFS migrate -m 1 $DIR/$tdir || error "migrate failed" +} +run_test 230l "readdir between MDTs won't crash" + test_231a() { # For simplicity this test assumes that max_pages_per_rpc -- 1.8.3.1