|
|
9ae3a8 |
From ceea60585e2975d7860725bb8c6c860b791a4b72 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 17 Mar 2014 13:29:26 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 2/6] block: Update image size in bdrv_invalidate_cache()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1395062967-16867-2-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58111
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 1/2] block: Update image size in bdrv_invalidate_cache()
|
|
|
9ae3a8 |
Bugzilla: 1048575
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
After migration has completed, we call bdrv_invalidate_cache() so that
|
|
|
9ae3a8 |
drivers which cache some data drop their stale copy of the data and
|
|
|
9ae3a8 |
reread it from the image file to get a new version of data that the
|
|
|
9ae3a8 |
source modified while the migration was running.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reloading metadata from the image file is useless, though, if the size
|
|
|
9ae3a8 |
of the image file stays stale (this is a value that is cached for all
|
|
|
9ae3a8 |
image formats in block.c). Reads from (meta)data after the old EOF
|
|
|
9ae3a8 |
return only zeroes, causing image corruption.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
We need to update bs->total_sectors in all layers that could potentially
|
|
|
9ae3a8 |
have changed their size (i.e. backing files are not a concern - if they
|
|
|
9ae3a8 |
are changed, we're in bigger trouble)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 3456a8d1852e970688b73d03fdc44dde851759e1)
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 10 +++++++++-
|
|
|
9ae3a8 |
block/qcow2.c | 2 ++
|
|
|
9ae3a8 |
block/qed.c | 3 +++
|
|
|
9ae3a8 |
3 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 10 +++++++++-
|
|
|
9ae3a8 |
block/qcow2.c | 2 ++
|
|
|
9ae3a8 |
block/qed.c | 3 +++
|
|
|
9ae3a8 |
3 files changed, 14 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index ec8dc90..ae55535 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -4713,9 +4713,17 @@ flush_parent:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void bdrv_invalidate_cache(BlockDriverState *bs)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- if (bs->drv && bs->drv->bdrv_invalidate_cache) {
|
|
|
9ae3a8 |
+ if (!bs->drv) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (bs->drv->bdrv_invalidate_cache) {
|
|
|
9ae3a8 |
bs->drv->bdrv_invalidate_cache(bs);
|
|
|
9ae3a8 |
+ } else if (bs->file) {
|
|
|
9ae3a8 |
+ bdrv_invalidate_cache(bs->file);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ refresh_total_sectors(bs, bs->total_sectors);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void bdrv_invalidate_cache_all(void)
|
|
|
9ae3a8 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
9ae3a8 |
index daad932..e9bd9c9 100644
|
|
|
9ae3a8 |
--- a/block/qcow2.c
|
|
|
9ae3a8 |
+++ b/block/qcow2.c
|
|
|
9ae3a8 |
@@ -1176,6 +1176,8 @@ static void qcow2_invalidate_cache(BlockDriverState *bs)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qcow2_close(bs);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ bdrv_invalidate_cache(bs->file);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
options = qdict_new();
|
|
|
9ae3a8 |
qdict_put(options, QCOW2_OPT_LAZY_REFCOUNTS,
|
|
|
9ae3a8 |
qbool_from_int(s->use_lazy_refcounts));
|
|
|
9ae3a8 |
diff --git a/block/qed.c b/block/qed.c
|
|
|
9ae3a8 |
index be5945b..619f2d0 100644
|
|
|
9ae3a8 |
--- a/block/qed.c
|
|
|
9ae3a8 |
+++ b/block/qed.c
|
|
|
9ae3a8 |
@@ -1561,6 +1561,9 @@ static void bdrv_qed_invalidate_cache(BlockDriverState *bs)
|
|
|
9ae3a8 |
BDRVQEDState *s = bs->opaque;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bdrv_qed_close(bs);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ bdrv_invalidate_cache(bs->file);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
memset(s, 0, sizeof(BDRVQEDState));
|
|
|
9ae3a8 |
bdrv_qed_open(bs, NULL, bs->open_flags, NULL);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|