qemu-img: rebase: Reduce reads on in-chain rebase
commit863cc78f1b38e926a1ac71348aaba0f6777660ff
authorSam Eiderman <shmuel.eiderman@oracle.com>
Thu, 23 May 2019 16:33:36 +0000 (23 19:33 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 28 May 2019 18:30:55 +0000 (28 20:30 +0200)
tree07ebe09ef0b91561d0b3ee8fc0cadc05d29ca56e
parent4ebe0617269113ec52a74d3dbb574a62ef6a0c83
qemu-img: rebase: Reduce reads on in-chain rebase

In the following case:

(base) A <- B <- C (tip)

when running:

    qemu-img rebase -b A C

QEMU would read all sectors not allocated in the file being rebased (C)
and compare them to the new base image (A), regardless of whether they
were changed or even allocated anywhere along the chain between the new
base and the top image (B). This causes many unneeded reads when
rebasing an image which represents a small diff of a large disk, as it
would read most of the disk's sectors.

Instead, use bdrv_is_allocated_above() to reduce the number of
unnecessary reads.

Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com>
Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Message-id: 20190523163337.4497-3-shmuel.eiderman@oracle.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c