aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/block.c b/block.c
index b1a462956f..86910b046c 100644
--- a/block.c
+++ b/block.c
@@ -2791,12 +2791,11 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{
int ret;
- if (bs->open_flags & BDRV_O_NO_FLUSH) {
- return 0;
- } else if (!bs->drv) {
+ if (!bs->drv) {
return 0;
}
+ /* Write back cached data to the OS even with cache=unsafe */
if (bs->drv->bdrv_co_flush_to_os) {
ret = bs->drv->bdrv_co_flush_to_os(bs);
if (ret < 0) {
@@ -2804,6 +2803,11 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
}
}
+ /* But don't actually force it to the disk with cache=unsafe */
+ if (bs->open_flags & BDRV_O_NO_FLUSH) {
+ return 0;
+ }
+
if (bs->drv->bdrv_co_flush_to_disk) {
return bs->drv->bdrv_co_flush_to_disk(bs);
} else if (bs->drv->bdrv_aio_flush) {