From 69de6d7a745a319413f38c6659c4f75ffe20537b Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Tue, 14 Nov 2023 15:06:52 -0500 Subject: [PATCH] Check for zero len in scoutfs_data_wait_check We consistently enter scoutfs_data_wait_check when len == 0 from scoutfs_aio_write() which directly passes the i_size_read() value, and for cases where we `echo >> $FILE` this is always reached. This can cause the wrapping check to fail since `0 + (0 - 1) < 0` which triggers the WARN_ON_ONCE wrap check that needs updating to allow certain operations on huge files. More importantly we can just omit all these checks if `len == 0` anyway, since they should always succeed and never should require taking all the locks. Signed-off-by: Auke Kok --- kmod/src/data.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kmod/src/data.c b/kmod/src/data.c index 990c9029..16639f95 100644 --- a/kmod/src/data.c +++ b/kmod/src/data.c @@ -1730,6 +1730,9 @@ int scoutfs_data_wait_check(struct inode *inode, loff_t pos, loff_t len, u64 off; int ret = 0; + if (len == 0) + goto out; + if (WARN_ON_ONCE(sef & SEF_UNKNOWN) || WARN_ON_ONCE(op & SCOUTFS_IOC_DWO_UNKNOWN) || WARN_ON_ONCE(dw && !RB_EMPTY_NODE(&dw->node)) ||