Whamcloud - gitweb
LU-11753 obdclass: lu_dirent record length missing '0' 65/33865/3
authorLai Siyao <lai.siyao@intel.com>
Sun, 9 Dec 2018 12:21:27 +0000 (20:21 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 17 Dec 2018 19:35:24 +0000 (19:35 +0000)
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 <lai.siyao@whamcloud.com>
Change-Id: Iab4947dea8e26ea798d5f64e218268200a5fabe8
Reviewed-on: https://review.whamcloud.com/33865
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/tests/sanity.sh

index 1e18f32..069fe56 100644 (file)
@@ -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
index d27f127..8b1bc51 100755 (executable)
@@ -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