@@ -2908,9 +2908,7 @@ static void coroutine_fn bdrv_flush_co_entry(void *opaque)
int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{
- if (bs->open_flags & BDRV_O_NO_FLUSH) {
- return 0;
- } else if (!bs->drv) {
+ if (!bs->drv) {
return 0;
} else if (bs->drv->bdrv_co_flush) {
return bs->drv->bdrv_co_flush(bs);
@@ -380,6 +380,10 @@ static int raw_co_flush(BlockDriverState *bs)
.coroutine = qemu_coroutine_self(),
};
+ if (bs->open_flags & BDRV_O_NO_FLUSH) {
+ return 0;
+ }
+
ret = fd_open(bs);
if (ret < 0) {
return ret;
@@ -156,6 +156,10 @@ static int raw_flush(BlockDriverState *bs)
BDRVRawState *s = bs->opaque;
int ret;
+ if (bs->open_flags & BDRV_O_NO_FLUSH) {
+ return 0;
+ }
+
ret = FlushFileBuffers(s->hfile);
if (ret == 0) {
return -EIO;
The expected meaning of cache=unsafe with qcow2 is that on a flush the metadata caches are written out, but no fsync is performed. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block.c | 4 +--- block/raw-posix.c | 4 ++++ block/raw-win32.c | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-)