[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 6/8] qcow2: Resize the cache upon image resizing
From: |
Leonid Bloch |
Subject: |
[Qemu-devel] [PATCH v6 6/8] qcow2: Resize the cache upon image resizing |
Date: |
Fri, 10 Aug 2018 00:53:05 +0300 |
The caches are now recalculated upon image resizing. This is done
because the new default behavior of assigning L2 cache relatively to
the image size, implies that the cache will be adapted accordingly
after an image resize.
Signed-off-by: Leonid Bloch <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block/qcow2.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 434fb89076..ba4dfae735 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3418,6 +3418,7 @@ static int coroutine_fn
qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
uint64_t old_length;
int64_t new_l1_size;
int ret;
+ QDict *options;
if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA &&
prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL)
@@ -3642,6 +3643,8 @@ static int coroutine_fn
qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
}
}
+ bs->total_sectors = offset / BDRV_SECTOR_SIZE;
+
/* write updated header.size */
offset = cpu_to_be64(offset);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
@@ -3652,6 +3655,13 @@ static int coroutine_fn
qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
}
s->l1_vm_state_index = new_l1_size;
+
+ /* Update cache sizes */
+ options = qdict_clone_shallow(bs->options);
+ ret = qcow2_update_options(bs, options, s->flags, errp);
+ if (ret < 0) {
+ goto fail;
+ }
ret = 0;
fail:
qemu_co_mutex_unlock(&s->lock);
--
2.17.1
- [Qemu-devel] [PATCH v6 0/8] qcow2: Take the image size into account when allocating the L2 cache, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 1/8] qcow2: Options' documentation fixes, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 2/8] qcow2: Cosmetic changes, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 3/8] qcow2: Avoid duplication in setting the refcount cache size, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 4/8] qcow2: Assign the L2 cache relatively to the image size, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 6/8] qcow2: Resize the cache upon image resizing,
Leonid Bloch <=
- [Qemu-devel] [PATCH v6 5/8] qcow2: Increase the default upper limit on the L2 cache size, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 7/8] qcow2: Set the default cache-clean-interval to 10 minutes, Leonid Bloch, 2018/08/09
- [Qemu-devel] [PATCH v6 8/8] qcow2: Explicit number replaced by a constant, Leonid Bloch, 2018/08/09