[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 09/27] qcow2: Avoid COW during metadata preallocation
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 09/27] qcow2: Avoid COW during metadata preallocation |
Date: |
Tue, 30 Apr 2019 17:42:26 +0200 |
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>
---
block/qcow2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 3ace3b2209..dfac74c264 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2734,7 +2734,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.20.1
- [Qemu-block] [PULL 00/27] Block layer patches, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 03/27] vpc: unlock Coroutine lock to make IO submit Concurrently, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 02/27] block: Fix AioContext switch for bs->drv == NULL, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 04/27] vmdk: Set vmdk parent backing_format to vmdk, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 05/27] block/vhdx: Remove redundant IEC binary prefixes definition, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 06/27] block/vhdx: Use IEC binary prefixes for size constants, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 01/27] tests/qemu-iotests: Fix output of qemu-io related tests, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 07/27] cutils: Fix size_to_str() on 32-bit platforms, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 09/27] qcow2: Avoid COW during metadata preallocation,
Kevin Wolf <=
- [Qemu-block] [PULL 11/27] qcow2: Fix full preallocation with external data file, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 10/27] qcow2: Add errp to preallocate_co(), Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 08/27] qemu-img: Saner printing of large file sizes, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 12/27] iotests: Perform the correct test in 082, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 14/27] qcow2: Fix qcow2_make_empty() with external data file, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 15/27] qcow2: Fix error handling in the compression code, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 16/27] block: introduce byte-based io helpers, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 13/27] qemu-img: Make create hint at protocol options, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 20/27] block/parallels: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 23/27] block/stream: use buffer-based io, Kevin Wolf, 2019/04/30