From 3e1f8d30cb0209b35410e85e502e2cae40f1b58c Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Wed, 19 May 2021 14:08:57 -0400 Subject: [PATCH] LU-14687 llite: Return errors for aio The aio code incorrectly discards errors from ll_direct_rw_pages. Fix this and add a test for this. Signed-off-by: Patrick Farrell Change-Id: I49dadd0b3692820687fa6a1339e00516edf7a5d5 Reviewed-on: https://review.whamcloud.com/43722 Tested-by: jenkins Reviewed-by: Arshad Hussain Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/llite/rw26.c | 3 ++- lustre/obdclass/cl_page.c | 3 +++ lustre/tests/sanity.sh | 33 +++++++++++++++++++++++++++------ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index d24d3f1..87d8abd 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -596,6 +596,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415 #define OBD_FAIL_LLITE_CREATE_FILE_PAUSE2 0x1416 #define OBD_FAIL_LLITE_RACE_MOUNT 0x1417 +#define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418 #define OBD_FAIL_FID_INDIR 0x1501 #define OBD_FAIL_FID_INLMA 0x1502 diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 9a59996..6fdeba9 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -542,7 +542,8 @@ out: vio->u.readwrite.vui_written += tot_bytes; else vio->u.readwrite.vui_read += tot_bytes; - result = -EIOCBQUEUED; + if (result == 0) + result = -EIOCBQUEUED; } return result; diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index 1d1c375..e345958 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -215,6 +215,9 @@ static struct cl_page *__cl_page_alloc(struct cl_object *o) struct cl_page *cl_page = NULL; unsigned short bufsize = cl_object_header(o)->coh_page_bufsize; + if (OBD_FAIL_CHECK(OBD_FAIL_LLITE_PAGE_ALLOC)) + return NULL; + check: /* the number of entries in cl_page_kmem_array is expected to * only be 2-3 entries, so the lookup overhead should be low. diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 4e9d58f..157b568 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -23211,7 +23211,7 @@ test_398b() { # LU-4198 --filename=$DIR/$tfile || true wait $bg_pid - rm -rf $DIR/$tfile + rm -f $DIR/$tfile } run_test 398b "DIO and buffer IO race" @@ -23271,27 +23271,28 @@ test_398c() { # LU-4198 --filename=$DIR/$tfile [ $? -eq 0 ] || error "fio large block size failed" - rm -rf $DIR/$tfile + rm -f $DIR/$tfile $LCTL set_param debug="$saved_debug" } run_test 398c "run fio to test AIO" test_398d() { # LU-13846 - test -f aiocp || skip_env "no aiocp installed" - local aio_file=$DIR/aio_file + which aiocp || skip_env "no aiocp installed" + local aio_file=$DIR/$tfile.aio $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file + stack_trap "rm -f $DIR/$tfile $aio_file" - diff $DIR/$tfile $aio_file || "file diff after aiocp" + diff $DIR/$tfile $aio_file || error "file diff after aiocp" # make sure we don't crash and fail properly aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file && error "aio not aligned with PAGE SIZE should fail" - rm -rf $DIR/$tfile $aio_file + rm -f $DIR/$tfile $aio_file } run_test 398d "run aiocp to verify block size > stripe size" @@ -23302,6 +23303,26 @@ test_398e() { } run_test 398e "O_Direct open cleared by fcntl doesn't cause hang" +test_398f() { # LU-14687 + which aiocp || skip_env "no aiocp installed" + local aio_file=$DIR/$tfile.aio + + $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file + + dd if=/dev/zero of=$DIR/$tfile bs=1M count=64 + stack_trap "rm -f $DIR/$tfile $aio_file" + + #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418 + $LCTL set_param fail_loc=0x1418 + # make sure we don't crash and fail properly + aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file && + error "aio with page allocation failure succeeded" + $LCTL set_param fail_loc=0 + diff $DIR/$tfile $aio_file + [[ $? != 0 ]] || error "no diff after failed aiocp" +} +run_test 398f "verify aio handles ll_direct_rw_pages errors correctly" + test_fake_rw() { local read_write=$1 if [ "$read_write" = "write" ]; then -- 1.8.3.1