[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/13] block: preserve errno from fdatasync failures
From: |
Daniel P . Berrangé |
Subject: |
[PULL 08/13] block: preserve errno from fdatasync failures |
Date: |
Mon, 14 Jun 2021 15:15:44 +0100 |
When fdatasync() fails on a file backend we set a flag that
short-circuits any future attempts to call fdatasync(). The
first failure returns the true errno, but the later short-
circuited calls return a generic EIO. The latter is unhelpful
because fdatasync() can return a variety of errnos, including
EACCESS.
Reviewed-by: Connor Kuehl <ckuehl@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
block/file-posix.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index f37dfc10b3..5ff78ecb34 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -160,7 +160,7 @@ typedef struct BDRVRawState {
bool discard_zeroes:1;
bool use_linux_aio:1;
bool use_linux_io_uring:1;
- bool page_cache_inconsistent:1;
+ int page_cache_inconsistent; /* errno from fdatasync failure */
bool has_fallocate;
bool needs_alignment;
bool drop_cache;
@@ -1333,7 +1333,7 @@ static int handle_aiocb_flush(void *opaque)
int ret;
if (s->page_cache_inconsistent) {
- return -EIO;
+ return -s->page_cache_inconsistent;
}
ret = qemu_fdatasync(aiocb->aio_fildes);
@@ -1352,7 +1352,7 @@ static int handle_aiocb_flush(void *opaque)
* Obviously, this doesn't affect O_DIRECT, which bypasses the page
* cache. */
if ((s->open_flags & O_DIRECT) == 0) {
- s->page_cache_inconsistent = true;
+ s->page_cache_inconsistent = errno;
}
return -errno;
}
--
2.31.1
- [PULL 00/13] Misc fixes patches, Daniel P . Berrangé, 2021/06/14
- [PULL 01/13] docs: add table of contents to QAPI references, Daniel P . Berrangé, 2021/06/14
- [PULL 02/13] docs: document how to pass secret data to QEMU, Daniel P . Berrangé, 2021/06/14
- [PULL 03/13] docs: document usage of the authorization framework, Daniel P . Berrangé, 2021/06/14
- [PULL 04/13] docs: recommend SCRAM-SHA-256 SASL mech instead of SHA-1 variant, Daniel P . Berrangé, 2021/06/14
- [PULL 05/13] sasl: remove comment about obsolete kerberos versions, Daniel P . Berrangé, 2021/06/14
- [PULL 06/13] migration: add trace point when vm_stop_force_state fails, Daniel P . Berrangé, 2021/06/14
- [PULL 07/13] softmmu: add trace point when bdrv_flush_all fails, Daniel P . Berrangé, 2021/06/14
- [PULL 08/13] block: preserve errno from fdatasync failures,
Daniel P . Berrangé <=
- [PULL 10/13] block: remove duplicate trace.h include, Daniel P . Berrangé, 2021/06/14
- [PULL 11/13] migration: use GDateTime for formatting timestamp in snapshot names, Daniel P . Berrangé, 2021/06/14
- [PULL 09/13] block: add trace point when fdatasync fails, Daniel P . Berrangé, 2021/06/14
- [PULL 12/13] block: use GDateTime for formatting timestamp when dumping snapshot info, Daniel P . Berrangé, 2021/06/14
- [PULL 13/13] usb/dev-mtp: use GDateTime for formatting timestamp for objects, Daniel P . Berrangé, 2021/06/14
- Re: [PULL 00/13] Misc fixes patches, Peter Maydell, 2021/06/14