From 73d5ee7033d0bd7dc6f928cc62766234a607a7c9 Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Mon, 24 Jan 2022 20:13:59 +0300 Subject: [PATCH] LU-15459 llite: clear async errors on write commit sync Async errors should be cleared after vvp_io_commit_sync(). Otherwise, that will be done in ll_flush() called from linux/fs/open.c:filp_close() and close(2) will fail. ll_flush() replaces any error code with EIO which is confusing. Test to illustrate the issue is added. 'P' mode is added to multiop. It is like 'w' but does only 1 write call regardless to how many bytes were written. HPE-bug-id: LUS-7529 Signed-off-by: Vladimir Saveliev Change-Id: I6b7a1465268999b48a50f3584f3821f4b088303d Reviewed-on: https://review.whamcloud.com/46178 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexander Boyko Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- lustre/llite/vvp_io.c | 5 +++++ lustre/tests/multiop.c | 4 ++++ lustre/tests/sanity.sh | 14 ++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 87ad197..baf28af 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1177,6 +1177,8 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io) /* out of quota, try sync write */ if (rc == -EDQUOT && !cl_io_is_mkwrite(io)) { + struct ll_inode_info *lli = ll_i2info(inode); + rc = vvp_io_commit_sync(env, io, queue, vio->u.readwrite.vui_from, vio->u.readwrite.vui_to); @@ -1184,6 +1186,9 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io) vio->u.readwrite.vui_written += rc; rc = 0; } + if (lli->lli_clob != NULL) + lov_read_and_clear_async_rc(lli->lli_clob); + lli->lli_async_rc = 0; } /* update inode size */ diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index 100d014..e206785 100644 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -103,6 +103,7 @@ char usage[] = " v verbose\n" " V open a volatile file\n" " w[num] write optional length\n" +" P[num] like w, but only one write call\n" " x get file data version\n" " W write entire mmap-ed region\n" " y fsync\n" @@ -685,6 +686,7 @@ int main(int argc, char **argv) rc = fd; break; case 'w': + case 'P': len = atoi(commands + 1); if (len <= 0) len = 1; @@ -715,6 +717,8 @@ int main(int argc, char **argv) fprintf(stderr, "short write: %lld/%u\n", rc, len); + if (commands[0] == 'P') + break; len -= rc; } break; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index aaf7c99..d37c6b5e 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3414,6 +3414,20 @@ test_27S() { } run_test 27S "don't deactivate OSP on network issue" +test_27T() { + [ $(facet_host client) == $(facet_host ost1) ] && + skip "need ost1 and client on different nodes" + +#define OBD_FAIL_OSC_NO_GRANT 0x411 + $LCTL set_param fail_loc=0x20000411 fail_val=1 +#define OBD_FAIL_OST_ENOSPC 0x215 + do_facet ost1 "$LCTL set_param fail_loc=0x80000215" + $LFS setstripe -i 0 -c 1 $DIR/$tfile + $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c || + error "multiop failed" +} +run_test 27T "no eio on close on partial write due to enosp" + # createtest also checks that device nodes are created and # then visible correctly (#2091) test_28() { # bug 2091 -- 1.8.3.1