aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/block.c b/block.c
index f1ef4b0109..7b306fb62f 100644
--- a/block.c
+++ b/block.c
@@ -4776,9 +4776,17 @@ flush_parent:
void bdrv_invalidate_cache(BlockDriverState *bs)
{
- if (bs->drv && bs->drv->bdrv_invalidate_cache) {
+ if (!bs->drv) {
+ return;
+ }
+
+ if (bs->drv->bdrv_invalidate_cache) {
bs->drv->bdrv_invalidate_cache(bs);
+ } else if (bs->file) {
+ bdrv_invalidate_cache(bs->file);
}
+
+ refresh_total_sectors(bs, bs->total_sectors);
}
void bdrv_invalidate_cache_all(void)