From nobody Mon Feb 9 07:05:22 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1556529683; cv=none; d=zoho.com; s=zohoarc; b=jQbggdwTSg9Y7hyOn+dCsRGvd/SBpwlrJ/frtunqRDCkOKJMaIHh/nACiXrodkSZ/ydbdC+bMj6GDXc4qeKNOXc11UpjPiWaBxIqkZTks8QMqRO9h2Ewd8rwjdMuTajy+7suCWmuYhYzOcz2CI2Em9OWNk6rPJvWhGM2ZP+B9ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556529683; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EepKlEJR7oNDZnD4aF85OcSNhJq+ZFi1dnHcZyHJN08=; b=VC8P76A/SDgdxPzdQoDx8ise9Wxwczq1+QBHKviOnG7bFdLyNFDFitYi3kUXY0ONqW5JzoXVFY6mfWLj21bEYSjALgH95cNL7HUg08/8G+rmNT/kTj9y8I+Wkp2IOKMM7JNyll1V+Zog0FR3vW/e9R1FUgGtrm7tLTQUpRstF6c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556529683038387.5645520573861; Mon, 29 Apr 2019 02:21:23 -0700 (PDT) Received: from localhost ([127.0.0.1]:54566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL2TF-0003fc-N0 for importer@patchew.org; Mon, 29 Apr 2019 05:21:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL2HL-0002RI-Hp for qemu-devel@nongnu.org; Mon, 29 Apr 2019 05:08:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hL2HJ-0003v8-FW for qemu-devel@nongnu.org; Mon, 29 Apr 2019 05:08:51 -0400 Received: from relay.sw.ru ([185.231.240.75]:32878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hL2HH-0003sQ-H9; Mon, 29 Apr 2019 05:08:49 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hL2HE-0002jV-4c; Mon, 29 Apr 2019 12:08:44 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 29 Apr 2019 12:08:41 +0300 Message-Id: <20190429090842.57910-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190429090842.57910-1-vsementsov@virtuozzo.com> References: <20190429090842.57910-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v7 4/5] block/backup: unify different modes code path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Do full, top and incremental mode copying all in one place. This unifies the code path and helps further improvements. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/backup.c | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/block/backup.c b/block/backup.c index 298e85f1a9..b54386b699 100644 --- a/block/backup.c +++ b/block/backup.c @@ -393,15 +393,23 @@ static bool bdrv_is_unallocated_range(BlockDriverStat= e *bs, return offset >=3D end; } =20 -static int coroutine_fn backup_run_incremental(BackupBlockJob *job) +static int coroutine_fn backup_loop(BackupBlockJob *job) { int ret; bool error_is_read; int64_t offset; HBitmapIter hbi; + BlockDriverState *bs =3D blk_bs(job->common.blk); =20 hbitmap_iter_init(&hbi, job->copy_bitmap, 0); while ((offset =3D hbitmap_iter_next(&hbi)) !=3D -1) { + if (job->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP && + bdrv_is_unallocated_range(bs, offset, job->cluster_size)) + { + hbitmap_reset(job->copy_bitmap, offset, job->cluster_size); + continue; + } + do { if (yield_and_check(job)) { return 0; @@ -446,7 +454,6 @@ static int coroutine_fn backup_run(Job *job, Error **er= rp) { BackupBlockJob *s =3D container_of(job, BackupBlockJob, common.job); BlockDriverState *bs =3D blk_bs(s->common.blk); - int64_t offset; int ret =3D 0; =20 QLIST_INIT(&s->inflight_reqs); @@ -471,38 +478,8 @@ static int coroutine_fn backup_run(Job *job, Error **e= rrp) * notify callback service CoW requests. */ job_yield(job); } - } else if (s->sync_mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { - ret =3D backup_run_incremental(s); } else { - /* Both FULL and TOP SYNC_MODE's require copying.. */ - for (offset =3D 0; offset < s->len; - offset +=3D s->cluster_size) { - bool error_is_read; - - if (yield_and_check(s)) { - break; - } - - if (s->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP && - bdrv_is_unallocated_range(bs, offset, s->cluster_size)) - { - continue; - } - - ret =3D backup_do_cow(s, offset, s->cluster_size, - &error_is_read, false); - if (ret < 0) { - /* Depending on error action, fail now or retry cluster */ - BlockErrorAction action =3D - backup_error_action(s, error_is_read, -ret); - if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { - break; - } else { - offset -=3D s->cluster_size; - continue; - } - } - } + ret =3D backup_loop(s); } =20 notifier_with_return_remove(&s->before_write); --=20 2.18.0