|
|
383d26 |
From 25829686076eac2d3d6216145377ecca8f92d6bd Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Date: Tue, 19 Feb 2019 17:00:20 +0100
|
|
|
383d26 |
Subject: [PATCH 19/23] qcow2: Resize the cache upon image resizing
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Message-id: <20190219170023.27826-11-kwolf@redhat.com>
|
|
|
383d26 |
Patchwork-id: 84553
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 10/13] qcow2: Resize the cache upon image resizing
|
|
|
383d26 |
Bugzilla: 1656913
|
|
|
383d26 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Leonid Bloch <lbloch@janustech.com>
|
|
|
383d26 |
|
|
|
383d26 |
The caches are now recalculated upon image resizing. This is done
|
|
|
383d26 |
because the new default behavior of assigning L2 cache relatively to
|
|
|
383d26 |
the image size, implies that the cache will be adapted accordingly
|
|
|
383d26 |
after an image resize.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
|
|
|
383d26 |
Reviewed-by: Alberto Garcia <berto@igalia.com>
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 45b4949c7bcdcd998cb42f5c517e80a2657cfd33)
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
block/qcow2.c | 11 +++++++++++
|
|
|
383d26 |
1 file changed, 11 insertions(+)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
383d26 |
index fc6bddd..72f1ea8 100644
|
|
|
383d26 |
--- a/block/qcow2.c
|
|
|
383d26 |
+++ b/block/qcow2.c
|
|
|
383d26 |
@@ -3462,6 +3462,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
|
|
383d26 |
uint64_t old_length;
|
|
|
383d26 |
int64_t new_l1_size;
|
|
|
383d26 |
int ret;
|
|
|
383d26 |
+ QDict *options;
|
|
|
383d26 |
|
|
|
383d26 |
if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA &&
|
|
|
383d26 |
prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL)
|
|
|
383d26 |
@@ -3686,6 +3687,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+ bs->total_sectors = offset / BDRV_SECTOR_SIZE;
|
|
|
383d26 |
+
|
|
|
383d26 |
/* write updated header.size */
|
|
|
383d26 |
offset = cpu_to_be64(offset);
|
|
|
383d26 |
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
|
|
|
383d26 |
@@ -3696,6 +3699,14 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
s->l1_vm_state_index = new_l1_size;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ /* Update cache sizes */
|
|
|
383d26 |
+ options = qdict_clone_shallow(bs->options);
|
|
|
383d26 |
+ ret = qcow2_update_options(bs, options, s->flags, errp);
|
|
|
383d26 |
+ qobject_unref(options);
|
|
|
383d26 |
+ if (ret < 0) {
|
|
|
383d26 |
+ goto fail;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
ret = 0;
|
|
|
383d26 |
fail:
|
|
|
383d26 |
qemu_co_mutex_unlock(&s->lock);
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|