[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 27/36] qcow2: Avoid COW during metadata preallocatio
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 27/36] qcow2: Avoid COW during metadata preallocation |
Date: |
Tue, 23 Jul 2019 12:00:55 -0500 |
From: Kevin Wolf <address@hidden>
Limiting the allocation to INT_MAX bytes isn't particularly clever
because it means that the final cluster will be a partial cluster which
will be completed through a COW operation. This results in unnecessary
data read and write requests which lead to an unwanted non-sparse
filesystem block for metadata preallocation.
Align the maximum allocation size down to the cluster size to avoid this
situation.
Cc: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
(cherry picked from commit f29fbf7c6b1c9a84f6931c1c222716fbe073e6e4)
*modified to avoid functional dependency on 93e32b3e
Signed-off-by: Michael Roth <address@hidden>
---
block/qcow2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 991d6ac91b..6ddaf9a1f8 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2590,6 +2590,7 @@ static int qcow2_set_up_encryption(BlockDriverState *bs,
static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
uint64_t new_length)
{
+ BDRVQcow2State *s = bs->opaque;
uint64_t bytes;
uint64_t host_offset = 0;
unsigned int cur_bytes;
@@ -2600,7 +2601,7 @@ static int coroutine_fn preallocate_co(BlockDriverState
*bs, uint64_t offset,
bytes = new_length - offset;
while (bytes) {
- cur_bytes = MIN(bytes, INT_MAX);
+ cur_bytes = MIN(bytes, QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size));
ret = qcow2_alloc_cluster_offset(bs, offset, &cur_bytes,
&host_offset, &meta);
if (ret < 0) {
--
2.17.1
- [Qemu-devel] [PATCH 11/36] tpm: Make sure the locality received from backend is valid, (continued)
- [Qemu-devel] [PATCH 11/36] tpm: Make sure the locality received from backend is valid, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 13/36] hw/rdma: another clang compilation fix, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 10/36] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 17/36] i386: remove the new CPUID 'PCONFIG' from Icelake-Server CPU model, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 18/36] i386: remove the 'INTEL_PT' CPUID bit from named CPU models, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 15/36] tpm_tis: fix loop that cancels any seizure by a lower locality, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 16/36] vfio-ap: flag as compatible with balloon, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 20/36] qga-win: include glib when building VSS DLL, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 19/36] json: Fix % handling when not interpolating, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 21/36] configure: improve usbfs check, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 27/36] qcow2: Avoid COW during metadata preallocation,
Michael Roth <=
- [Qemu-devel] [PATCH 25/36] usb-mtp: use O_NOFOLLOW and O_CLOEXEC., Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 28/36] cutils: Fix size_to_str() on 32-bit platforms, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 29/36] block: Fix AioContext switch for bs->drv == NULL, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 24/36] qga: update docs with systemd suspend support info, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 14/36] slirp: check sscanf result when emulating ident, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 26/36] qemu-img: fix error reporting for -object, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 30/36] do not call vhost_net_cleanup() on running net from char user event, Michael Roth, 2019/07/23
- [Qemu-devel] [PATCH 01/36] i2c: Move typedef of bitbang_i2c_interface to i2c.h, Michael Roth, 2019/07/23