From c633a42f11aa0277f2cabae085d2ee095eab68ce Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 1 Apr 2024 11:28:28 -0400 Subject: [PATCH] LU-13802 llite: add fail loc to force bio-dio switch This adds a fail loc to force switching from BIO to DIO. Test-Parameters: trivial Test-Parameters:testlist=sanity env=ONLY=119j,ONLY_REPEAT=50 Signed-off-by: Patrick Farrell Change-Id: Icba303c32a86170af08a78c6b306db08e8ed6047 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52593 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/llite/file.c | 6 ++++-- lustre/tests/sanity.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index e94e8b3..ce97791 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -636,6 +636,7 @@ extern bool obd_enable_health_write; #define OBD_FAIL_LOV_COMP_MAGIC 0x1426 #define OBD_FAIL_LOV_COMP_PATTERN 0x1427 #define OBD_FAIL_LOV_INVALID_OSTIDX 0x1428 +#define OBD_FAIL_LLITE_FORCE_BIO_AS_DIO 0x1429 #define OBD_FAIL_LLITE_DELAY_TRUNCATE 0x1430 #define OBD_FAIL_LLITE_READ_PAUSE 0x1431 #define OBD_FAIL_LLITE_FAULT_PAUSE 0x1432 diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 668b870d..660a966 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2235,7 +2235,8 @@ static ssize_t ll_file_read_iter(struct kiocb *iocb, struct iov_iter *to) args->u.normal.via_iocb = iocb; if (ll_hybrid_bio_dio_switch_check(file, iocb, CIT_READ, - iov_iter_count(to))) { + iov_iter_count(to)) || + CFS_FAIL_CHECK(OBD_FAIL_LLITE_FORCE_BIO_AS_DIO)) { #ifdef IOCB_DIRECT iocb->ki_flags |= IOCB_DIRECT; CDEBUG(D_VFSTRACE, "switching to DIO\n"); @@ -2384,7 +2385,8 @@ static ssize_t ll_file_write_iter(struct kiocb *iocb, struct iov_iter *from) GOTO(out, rc_normal = result); if (ll_hybrid_bio_dio_switch_check(file, iocb, CIT_WRITE, - iov_iter_count(from))) { + iov_iter_count(from)) || + CFS_FAIL_CHECK(OBD_FAIL_LLITE_FORCE_BIO_AS_DIO)) { #ifdef IOCB_DIRECT iocb->ki_flags |= IOCB_DIRECT; CDEBUG(D_VFSTRACE, "switching to DIO\n"); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index c035a66..ae3b3c4 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14071,6 +14071,56 @@ test_119i() } run_test 119i "test unaligned aio at varying sizes" +test_119j() +{ + (( $LINUX_VERSION_CODE > $(version_code 4.5.0) )) || + skip "needs kernel > 4.5.0 for ki_flags support" + + local rpcs + dd if=/dev/urandom of=$DIR/$tfile bs=8 count=1 || error "(0) dd failed" + sync + $LCTL set_param -n osc.*.rpc_stats=0 + # Read from page cache, does not generate an rpc + dd if=$DIR/$tfile of=/dev/null bs=8 count=1 || error "(1) dd failed" + $LCTL get_param osc.*.rpc_stats + rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' | + sed -n '/pages per rpc/,/^$/p' | + awk '/'$pages':/ { reads += $2; writes += $6 }; \ + END { print reads,writes }')) + [[ ${rpcs[0]} == 0 ]] || + error "(3) ${rpcs[0]} != 0 read RPCs" + + # Test hybrid IO read + # Force next BIO as DIO + # This forces an RPC to the server + #define OBD_FAIL_LLITE_FORCE_BIO_AS_DIO 0x1429 + $LCTL set_param fail_loc=0x1429 + dd if=$DIR/$tfile of=/dev/null bs=8 count=1 || error "(4) dd failed" + $LCTL get_param osc.*.rpc_stats + rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' | + sed -n '/pages per rpc/,/^$/p' | + awk '/'$pages':/ { reads += $2; writes += $6 }; \ + END { print reads,writes }')) + [[ ${rpcs[0]} == 1 ]] || + error "(5) ${rpcs[0]} != 1 read RPCs" + + # Test hybrid IO write + #define OBD_FAIL_LLITE_FORCE_BIO_AS_DIO 0x1429 + $LCTL set_param fail_loc=0x1429 + #NB: We do not check for 0 write RPCs in the BIO case because that + # would make the test racey vs cache flushing + # but the DIO case is guaranteed to generate 1 write RPC + dd if=/dev/zero of=$DIR/$tfile bs=8 count=1 || error "(6) dd failed" + $LCTL get_param osc.*.rpc_stats + rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' | + sed -n '/pages per rpc/,/^$/p' | + awk '/'$pages':/ { reads += $2; writes += $6 }; \ + END { print reads,writes }')) + [[ ${rpcs[1]} == 1 ]] || + error "(7) ${rpcs[0]} != 1 read RPCs" +} +run_test 119j "basic tests of hybrid IO switching" + test_120a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" remote_mds_nodsh && skip "remote MDS with nodsh" -- 1.8.3.1