[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/7] qcow2: Make perform_cow() call do_perform_c
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 3/7] qcow2: Make perform_cow() call do_perform_cow() twice |
Date: |
Fri, 26 May 2017 10:11:29 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 23.05.2017 um 13:22 hat Alberto Garcia geschrieben:
> Instead of calling perform_cow() twice with a different COW region
> each time, call it just once and make perform_cow() handle both
> regions.
>
> This patch simply moves code around. The next one will do the actual
> reordering of the COW operations.
>
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
> block/qcow2-cluster.c | 38 +++++++++++++++++++++++---------------
> 1 file changed, 23 insertions(+), 15 deletions(-)
>
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index 6757875ec9..59a0ffba1a 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -414,6 +414,10 @@ static int coroutine_fn do_perform_cow(BlockDriverState
> *bs,
> struct iovec iov;
> int ret;
>
> + if (bytes == 0) {
> + return 0;
> + }
> +
> iov.iov_len = bytes;
> iov.iov_base = qemu_try_blockalign(bs, iov.iov_len);
> if (iov.iov_base == NULL) {
> @@ -751,31 +755,40 @@ uint64_t
> qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
> return cluster_offset;
> }
>
> -static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion
> *r)
> +static int perform_cow(BlockDriverState *bs, QCowL2Meta *m)
> {
> BDRVQcow2State *s = bs->opaque;
> + Qcow2COWRegion *start = &m->cow_start;
> + Qcow2COWRegion *end = &m->cow_end;
> int ret;
>
> - if (r->nb_bytes == 0) {
> + if (start->nb_bytes == 0 && end->nb_bytes == 0) {
> return 0;
> }
With this change, it can now happen that we call do_perform_cow() with
bytes == 0. Maybe it would be better for do_perform_cow() to check bytes
first so that it doesn't bdrv_co_preadv/pwritev() for 0 bytes?
Kevin
Re: [Qemu-devel] [PATCH 7/7] qcow2: Merge the writing of the COW regions with the guest data, Alberto Garcia, 2017/05/26
[Qemu-devel] [PATCH 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion, Alberto Garcia, 2017/05/23
[Qemu-devel] [PATCH 1/7] qcow2: Remove unused Error in do_perform_cow(), Alberto Garcia, 2017/05/23