[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/12] qemu-img map: Don't limit block status request size
From: |
Kevin Wolf |
Subject: |
[PULL 01/12] qemu-img map: Don't limit block status request size |
Date: |
Tue, 7 Jul 2020 18:34:53 +0200 |
Limiting each loop iteration of qemu-img map to 1 GB was arbitrary from
the beginning, though it only cut the maximum in half then because the
interface was a signed 32 bit byte count. These days, bdrv_block_status
supports a 64 bit byte count, so the arbitrary limit is even worse.
On file-posix, bdrv_block_status() eventually maps to SEEK_HOLE and
SEEK_DATA, which don't support a limit, but always do all of the work
necessary to find the start of the next hole/data. Much of this work may
be repeated if we don't use this information fully, but query with an
only slightly larger offset in the next loop iteration. Therefore, if
bdrv_block_status() is called in a loop, it should always pass the
full number of bytes that the whole loop is interested in.
This removes the arbitrary limit and speeds up 'qemu-img map'
significantly on heavily fragmented images.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200707144629.51235-1-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index bdb9f6aa46..74946f81ca 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3217,12 +3217,9 @@ static int img_map(int argc, char **argv)
curr.start = start_offset;
while (curr.start + curr.length < length) {
int64_t offset = curr.start + curr.length;
- int64_t n;
+ int64_t n = length - offset;
- /* Probe up to 1 GiB at a time. */
- n = MIN(1 * GiB, length - offset);
ret = get_block_status(bs, offset, n, &next);
-
if (ret < 0) {
error_report("Could not read file metadata: %s", strerror(-ret));
goto out;
--
2.25.4
- [PULL 00/12] Block layer patches, Kevin Wolf, 2020/07/07
- [PULL 01/12] qemu-img map: Don't limit block status request size,
Kevin Wolf <=
- [PULL 02/12] file-posix: Mitigate file fragmentation with extent size hints, Kevin Wolf, 2020/07/07
- [PULL 04/12] block: Finish deprecation of 'qemu-img convert -n -o', Kevin Wolf, 2020/07/07
- [PULL 05/12] sheepdog: Add trivial backing_fmt support, Kevin Wolf, 2020/07/07
- [PULL 06/12] vmdk: Add trivial backing_fmt support, Kevin Wolf, 2020/07/07
- [PULL 07/12] qcow: Tolerate backing_fmt=, Kevin Wolf, 2020/07/07
- [PULL 08/12] block: Error if backing file fails during creation without -u, Kevin Wolf, 2020/07/07
- [PULL 03/12] qemu-img: Flush stdout before before potential stderr messages, Kevin Wolf, 2020/07/07
- [PULL 10/12] iotests: Specify explicit backing format where sensible, Kevin Wolf, 2020/07/07
- [PULL 09/12] qcow2: Deprecate use of qemu-img amend to change backing file, Kevin Wolf, 2020/07/07
- [PULL 12/12] qemu-img: Deprecate use of -b without -F, Kevin Wolf, 2020/07/07