file-posix: allow -EBUSY -EINVAL errors during write zeros on block
PATCH v3 1/1 file-posix: allow -EBUSY -EINVAL errors during write zeros on block
Since Linux 5.10, write zeros to a multipath device using ioctl(fd, BLKZEROOUT, range) with cache none or directsync return -EBUSY permanently.
Similar to handle_aiocb_write_zeroes_unmap, handle_aiocb_write_zeroes_block allow -EBUSY and -EINVAL errors during ioctl(fd, BLKZEROOUT, range).
Reference commit in Linux 5.10:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02
Although it will be fixed in 5.12, I think it's good to avoid similar problem in the future.
https://lore.kernel.org/linux-block/[email protected]/
--- block/file-posix.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
block/file-posix.c +7 -2
@@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) } while (errno == EINTR); ret =translate_err (-errno); -if (ret == -ENOTSUP ) { - s->has_write_zeroes = false; +switch (ret) { +case -ENOTSUP : + s->has_write_zeroes = false;/* fall through */ +case -EINVAL : +case -EBUSY : +return -ENOTSUP ; +break ; } }#endif
--
2.27.0
Quoted 4 lines · ChangLimin
Since Linux 5.10, write zeros to a multipath device using
ioctl(fd, BLKZEROOUT, range)with cache none or directsync return-EBUSYpermanently.
When do we get -EINVAL? Both of the commits referenced below don't specifically mention it, so I am not sure in which circumstances that might arise.
Quoted 9 lines
Similar to
handle_aiocb_write_zeroes_unmap,handle_aiocb_write_zeroes_blockallow-EBUSYand-EINVALerrors duringioctl(fd, BLKZEROOUT, range).Reference commit in Linux 5.10:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02 <https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02>Although it will be fixed in 5.12, I think it's good to avoid similar problem in the future.
https://lore.kernel.org/linux-block/[email protected]/ <https://lore.kernel.org/linux-block/[email protected]/>
Wait, if they're fixing the function to actually apply a different fallback path, shouldn't we *not* allow EBUSY?
Quoted 13 lines
Signed-off-by ChangLimin <[email protected]>--- block/file-posix.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)block/file-posix.c +0
-0@@ -1629,8 +1629,13 @@ static ssize_thandle_aiocb_write_zeroes_block (RawPosixAIOData *aiocb) } while (errno == EINTR);
block/file-posix.c static ssize_t · line 1639
Quoted 10 lines
block/file-posix.c +7
-2ret = translate_err(-errno); - if (ret == -ENOTSUP) { - s->has_write_zeroes = false; + switch (ret) { + case -ENOTSUP: + s->has_write_zeroes = false; /* fall through */ + case -EINVAL: + case -EBUSY: + return -ENOTSUP; + break;
oh, we're not "allowing" them, we're treating the failure *more seriously* so that we avoid attempting to call this function ever again for this FD.
Can you please add a brief comment here, something like:
/* Linux 5.10/5.11 may return these for multipath devices */
Quoted 6 lines
block/file-posix.c +0
-0} }#endif
--
2.27.0
Quoted 32 lines · John Snow
Quoted 4 lines · ChangLimin
Since Linux 5.10, write zeros to a multipath device using
ioctl(fd, BLKZEROOUT, range)with cache none or directsync return-EBUSYpermanently.When do we get
-EINVAL? Both of the commits referenced below don't specifically mention it, so I am not sure in which circumstances that might arise.Quoted 9 lines
Similar to
handle_aiocb_write_zeroes_unmap,handle_aiocb_write_zeroes_blockallow-EBUSYand-EINVALerrors duringioctl(fd, BLKZEROOUT, range).Reference commit in Linux 5.10:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02 <https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=384d87ef2c954fc58e6c5fd8253e4a1984f5fe02>Although it will be fixed in 5.12, I think it's good to avoid similar problem in the future.
https://lore.kernel.org/linux-block/[email protected]/ <https://lore.kernel.org/linux-block/[email protected]/>Wait, if they're fixing the function to actually apply a different fallback path, shouldn't we *not* allow EBUSY?
Quoted 12 lines
Signed-off-by ChangLimin <[email protected]>---
block/file-posix.c | 9 +++++++--1 file changed, 7 insertions(+), 2 deletions(-)block/file-posix.c +0
-0@@ -1629,8 +1629,13 @@ static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) } while (errno == EINTR);
Quoted 12 lines
block/file-posix.c static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) · line 1638
Quoted 10 lines
block/file-posix.c +7
-2ret = translate_err(-errno); - if (ret == -ENOTSUP) { - s->has_write_zeroes = false; + switch (ret) { + case -ENOTSUP: + s->has_write_zeroes = false; /* fall through */ + case -EINVAL: + case -EBUSY: + return -ENOTSUP; + break;oh, we're not "allowing" them, we're treating the failure *more seriously* so that we avoid attempting to call this function ever again for this FD.
No. s->has_write_zeroes is set to false only for ENOTSUP came from translate_err, this behavior is not changed.
The only thing the patch does is _returning_ ENOTSUP instead of EINVAL and EBUSY. And I don't understand why. I think that at least for EINVAL it's just wrong.
Quoted 13 lines
Can you please add a brief comment here, something like:
/* Linux 5.10/5.11 may return these for multipath devices */
Quoted 6 lines
block/file-posix.c +0
-0} } #endifSignature · 1 line
2.27.0
Signature · 2 lines
Best regards, Vladimir