From 7023698133970372031a16beac276e5e3e64cfbe Mon Sep 17 00:00:00 2001 From: Li Xi Date: Fri, 6 Nov 2015 17:06:08 +0800 Subject: [PATCH] LU-7371 test: wrong read length over isize This patch adds tests to check read length is correct if reading a file of size 4095. Signed-off-by: Li Xi Change-Id: I0c0f6b378fa4af053ed54f2f5dea2418191a7b69 Reviewed-on: http://review.whamcloud.com/17060 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger --- lustre/include/obd_support.h | 1 + lustre/target/tgt_handler.c | 3 +++ lustre/tests/sanity.sh | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index b9d36ee..a537840 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -320,6 +320,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231 #define OBD_FAIL_OST_SET_INFO_NET 0x232 #define OBD_FAIL_OST_NODESTROY 0x233 +#define OBD_FAIL_OST_READ_SIZE 0x234 #define OBD_FAIL_LDLM 0x300 #define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index e65269f..21cecc2 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -1896,6 +1896,9 @@ int tgt_brw_read(struct tgt_session_info *tsi) break; } } + if (OBD_FAIL_CHECK(OBD_FAIL_OST_READ_SIZE) && + nob != cfs_fail_val) + rc = -E2BIG; if (body->oa.o_valid & OBD_MD_FLCKSUM) { cksum_type_t cksum_type = diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a73ace6..1ec7f46 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13410,6 +13410,19 @@ test_245() { } run_test 245 "check mdc connection flag/data: multiple modify RPCs" +test_246() { # LU-7371 + [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] && + skip "Need OST version >= 2.7.62" && return 0 + do_facet ost1 $LCTL set_param fail_val=4095 +#define OBD_FAIL_OST_READ_SIZE 0x234 + do_facet ost1 $LCTL set_param fail_loc=0x234 + $LFS setstripe $DIR/$tfile -i 0 -c 1 + dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1 + cancel_lru_locks $FSNAME-OST0000 + dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed" +} +run_test 246 "Read file of size 4095 should return right length" + test_250() { [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \ && skip "no 16TB file size limit on ZFS" && return -- 1.8.3.1