On 06/07/2017 09:08 AM, Alberto Garcia wrote: > 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 <[email protected]> > --- > block/qcow2-cluster.c | 38 +++++++++++++++++++++++--------------- > 1 file changed, 23 insertions(+), 15 deletions(-)
> qemu_co_mutex_unlock(&s->lock);
> - ret = do_perform_cow(bs, m->offset, m->alloc_offset, r->offset,
> r->nb_bytes);
> + ret = do_perform_cow(bs, m->offset, m->alloc_offset,
> + start->offset, start->nb_bytes);
> + if (ret < 0) {
> + goto fail;
> + }
> +
> + ret = do_perform_cow(bs, m->offset, m->alloc_offset,
> + end->offset, end->nb_bytes);
> +
> +fail:
Since you reach this label even on success, it feels a bit awkward. I
probably would have avoided the goto and used fewer lines by refactoring
the logic as:
ret = do_perform_cow(..., start->...);
if (ret >= 0) {
ret = do_perform_cow(..., end->...);
}
But that doesn't affect correctness, so whether or not you redo the
logic in the shorter fashion:
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
