summaryrefslogtreecommitdiff
path: root/block/file-posix.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2021-05-27 19:20:20 +0200
committerKevin Wolf <kwolf@redhat.com>2021-06-02 14:23:20 +0200
commitfa95e9fbab2c19fc07ba82988b1690f8a6ff171b (patch)
treeb05b5ef713fd08f51bcb62700f0d000119f0a406 /block/file-posix.c
parent73ebf29729d1a40feaa9f8ab8951b6ee6dbfbede (diff)
downloadqemu-fa95e9fbab2c19fc07ba82988b1690f8a6ff171b.zip
block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE
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>
Diffstat (limited to 'block/file-posix.c')
-rw-r--r--block/file-posix.c18
1 files 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