[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] block: preserve errno from fdatasync failures
From: |
Daniel P . Berrangé |
Subject: |
[PATCH 3/5] block: preserve errno from fdatasync failures |
Date: |
Thu, 15 Apr 2021 14:58:49 +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.
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 20e14f8e96..99cf452f84 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;
@@ -1357,7 +1357,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);
@@ -1376,7 +1376,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.30.2
- [PATCH 0/5] block, migration: improve debugging of migration bdrv_flush failure, Daniel P . Berrangé, 2021/04/15
- [PATCH 1/5] migration: add trace point when vm_stop_force_state fails, Daniel P . Berrangé, 2021/04/15
- [PATCH 2/5] softmmu: add trace point when bdrv_flush_all fails, Daniel P . Berrangé, 2021/04/15
- [PATCH 3/5] block: preserve errno from fdatasync failures,
Daniel P . Berrangé <=
- [PATCH 4/5] block: add trace point when fdatasync fails, Daniel P . Berrangé, 2021/04/15
- [PATCH 5/5] block: remove duplicate trace.h include, Daniel P . Berrangé, 2021/04/15
- Re: [PATCH 0/5] block, migration: improve debugging of migration bdrv_flush failure, Connor Kuehl, 2021/04/15