[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/20] block/file-posix: Try other fallbacks after invalid FALLOC_
From: |
Kevin Wolf |
Subject: |
[PULL 09/20] block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE |
Date: |
Wed, 2 Jun 2021 15:45:18 +0200 |
From: Thomas Huth <thuth@redhat.com>
If fallocate(... FALLOC_FL_ZERO_RANGE ...) returns EINVAL, it's likely
an indication that the file system is buggy and does not implement
unaligned accesses right. We still might be lucky with the other
fallback fallocate() calls later in this function, though, so we should
not return immediately and try the others first.
Since FALLOC_FL_ZERO_RANGE could also return EINVAL if the file descriptor
is not a regular file, we ignore this filesystem bug silently, without
printing an error message for the user.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210527172020.847617-3-thuth@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/file-posix.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 6e24083f3f..f37dfc10b3 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1625,17 +1625,17 @@ static int handle_aiocb_write_zeroes(void *opaque)
if (s->has_write_zeroes) {
int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE,
aiocb->aio_offset, aiocb->aio_nbytes);
- if (ret == -EINVAL) {
- /*
- * Allow falling back to pwrite for file systems that
- * do not support fallocate() for an unaligned byte range.
- */
- return -ENOTSUP;
- }
- if (ret == 0 || ret != -ENOTSUP) {
+ if (ret == -ENOTSUP) {
+ s->has_write_zeroes = false;
+ } else if (ret == 0 || ret != -EINVAL) {
return ret;
}
- s->has_write_zeroes = false;
+ /*
+ * Note: Some file systems do not like unaligned byte ranges, and
+ * return EINVAL in such a case, though they should not do it according
+ * to the man-page of fallocate(). Thus we simply ignore this return
+ * value and try the other fallbacks instead.
+ */
}
#endif
--
2.30.2
- [PULL 00/20] Block layer patches, Kevin Wolf, 2021/06/02
- [PULL 02/20] qemu-io-cmds: assert that we don't have .perm requested in no-blk case, Kevin Wolf, 2021/06/02
- [PULL 01/20] block/quorum: Provide .bdrv_co_flush instead of .bdrv_co_flush_to_disk, Kevin Wolf, 2021/06/02
- [PULL 03/20] block/vvfat: child_vvfat_qcow: add .get_parent_aio_context, fix crash, Kevin Wolf, 2021/06/02
- [PULL 04/20] block/vvfat: fix vvfat_child_perm crash, Kevin Wolf, 2021/06/02
- [PULL 05/20] block: consistently use bdrv_is_read_only(), Kevin Wolf, 2021/06/02
- [PULL 06/20] block: drop BlockDriverState::read_only, Kevin Wolf, 2021/06/02
- [PULL 08/20] block/file-posix: Fix problem with fallocate(PUNCH_HOLE) on GPFS, Kevin Wolf, 2021/06/02
- [PULL 07/20] block: drop BlockBackendRootState::read_only, Kevin Wolf, 2021/06/02
- [PULL 10/20] block: document child argument of bdrv_attach_child_common(), Kevin Wolf, 2021/06/02
- [PULL 09/20] block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE,
Kevin Wolf <=
- [PULL 11/20] block-backend: improve blk_root_get_parent_desc(), Kevin Wolf, 2021/06/02
- [PULL 12/20] block: improve bdrv_child_get_parent_desc(), Kevin Wolf, 2021/06/02
- [PULL 13/20] block/vvfat: inherit child_vvfat_qcow from child_of_bds, Kevin Wolf, 2021/06/02
- [PULL 14/20] block: simplify bdrv_child_user_desc(), Kevin Wolf, 2021/06/02
- [PULL 15/20] block: improve permission conflict error message, Kevin Wolf, 2021/06/02
- [PULL 17/20] nbd/server: Use drained block ops to quiesce the server, Kevin Wolf, 2021/06/02
- [PULL 16/20] block-backend: add drained_poll, Kevin Wolf, 2021/06/02
- [PULL 20/20] docs/secure-coding-practices: Describe how to use 'null-co' block driver, Kevin Wolf, 2021/06/02
- [PULL 18/20] block-copy: fix block_copy_task_entry() progress update, Kevin Wolf, 2021/06/02
- [PULL 19/20] block-copy: refactor copy_range handling, Kevin Wolf, 2021/06/02