qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 08/21] backup: skip unallocated clusters for ful


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [PATCH 08/21] backup: skip unallocated clusters for full mode
Date: Tue, 31 Jan 2017 14:33:12 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

On Fri, Dec 23, 2016 at 05:28:51PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> In case of full backup we can skip unallocated clusters if the target
> disk is already zero-initialized.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
>  block/backup.c         | 8 ++++++--
>  tests/qemu-iotests/055 | 2 ++
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/block/backup.c b/block/backup.c
> index 2afd1b6..4ef8daf 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -562,9 +562,13 @@ static void coroutine_fn backup_run(void *opaque)
>          if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
>              backup_incremental_init_copy_bitmap(job);
>          } else {
> +            /* top or full mode */
> +            bool is_top = job->sync_mode == MIRROR_SYNC_MODE_TOP;
> +            BlockDriverState *base =
> +                    is_top ? backing_bs(blk_bs(job->common.blk)) : NULL;
>              hbitmap_set(job->copy_bitmap, 0, end);
> -            if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
> -                backup_skip_loop(job, backing_bs(blk_bs(job->common.blk)));
> +            if (is_top || bdrv_has_zero_init(blk_bs(job->target))) {
> +                backup_skip_loop(job, base);
>              }

An alternative that I find easier to read:

hbitmap_set(job->copy_bitmap, 0, end);
if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
    backup_skip_loop(job, backing_bs(blk_bs(job->common.blk)));
} else if (bdrv_has_zero_init(blk_bs(job->target))) {
    backup_skip_loop(job, NULL);
}

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]