From nobody Mon Feb 9 12:10:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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=1565165379; cv=none; d=zoho.com; s=zohoarc; b=PQLr66hMO1OzWucVFS3toHh3wx1LKSnLz0KPO/Vy6EDFPj1CFpNtTmEERf3Ca9IbOjhxgo4BO1k5xv2A5I1/Q9cRLBdkJ7qm/UA3DUUXqQlB2qRRJGtkBZw/BBTL3JJTQIchw3bUHvrlnn6aCpNwzEZ707tBAHAD2RSeCwSbHs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565165379; 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=oQ4Ifk+NDD8escA3zyNpEmBQXJVDsg/jMPOLcoOCq58=; b=cLvJdNCD4AdsqHKuYZgfdFrQRLRYOotIz6E3YW5I9vyKfkHVfRIuo5JaFn4F37RoQGzRPtRaOxfVTNweb01BtZnB0ZHmDLIEu1dNm78a2pejY1VTUj6WTn69lEnFndjtwoGtGhFaVhD90S0ZVBwmry3Jb40RxqxKuxqX7xZsovE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 1565165379283440.8948311023356; Wed, 7 Aug 2019 01:09:39 -0700 (PDT) Received: from localhost ([::1]:38108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvH0q-0004Ag-8a for importer@patchew.org; Wed, 07 Aug 2019 04:09:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40460) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvGzG-0008Cr-G5 for qemu-devel@nongnu.org; Wed, 07 Aug 2019 04:07:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvGzF-0006sj-C4 for qemu-devel@nongnu.org; Wed, 07 Aug 2019 04:07:58 -0400 Received: from relay.sw.ru ([185.231.240.75]:53658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvGzC-0006oS-61; Wed, 07 Aug 2019 04:07:54 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hvGz8-000300-Sj; Wed, 07 Aug 2019 11:07:50 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Wed, 7 Aug 2019 11:07:46 +0300 Message-Id: <20190807080750.15950-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190807080750.15950-1-vsementsov@virtuozzo.com> References: <20190807080750.15950-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 4/8] block/backup: improve unallocated clusters skipping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, jsnow@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" Limit block_status querying to request bounds on write notifier to avoid extra seeking. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/backup.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/block/backup.c b/block/backup.c index 11e27c844d..a4d37d2d62 100644 --- a/block/backup.c +++ b/block/backup.c @@ -180,14 +180,14 @@ static int coroutine_fn backup_cow_with_offload(Backu= pBlockJob *job, * return via pnum the number of contiguous clusters sharing this allocati= on. */ static int backup_is_cluster_allocated(BackupBlockJob *s, int64_t offset, - int64_t *pnum) + int64_t bytes, int64_t *pnum) { BlockDriverState *bs =3D blk_bs(s->common.blk); int64_t count, total_count =3D 0; - int64_t bytes =3D s->len - offset; int ret; =20 assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); + bytes =3D MIN(s->len - offset, bytes); =20 while (true) { ret =3D bdrv_is_allocated(bs, offset, bytes, &count); @@ -224,12 +224,13 @@ static int backup_is_cluster_allocated(BackupBlockJob= *s, int64_t offset, * 1 otherwise, and -ret on error. */ static int64_t backup_bitmap_reset_unallocated(BackupBlockJob *s, - int64_t offset, int64_t *co= unt) + int64_t offset, int64_t byt= es, + int64_t *pnum) { int ret; - int64_t clusters, bytes, estimate; + int64_t clusters, estimate; =20 - ret =3D backup_is_cluster_allocated(s, offset, &clusters); + ret =3D backup_is_cluster_allocated(s, offset, bytes, &clusters); if (ret < 0) { return ret; } @@ -242,7 +243,7 @@ static int64_t backup_bitmap_reset_unallocated(BackupBl= ockJob *s, job_progress_set_remaining(&s->common.job, estimate); } =20 - *count =3D bytes; + *pnum =3D bytes; return ret; } =20 @@ -255,7 +256,6 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *j= ob, int ret =3D 0; int64_t start, end; /* bytes */ void *bounce_buffer =3D NULL; - int64_t skip_bytes; =20 qemu_co_rwlock_rdlock(&job->flush_rwlock); =20 @@ -267,6 +267,18 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *= job, wait_for_overlapping_requests(job, start, end); cow_request_begin(&cow_request, job, start, end); =20 + if (job->initializing_bitmap) { + int64_t off, chunk; + + for (off =3D offset; offset < end; offset +=3D chunk) { + ret =3D backup_bitmap_reset_unallocated(job, off, end - off, &= chunk); + if (ret < 0) { + chunk =3D job->cluster_size; + } + } + } + ret =3D 0; + while (start < end) { int64_t dirty_end; =20 @@ -276,15 +288,6 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *= job, continue; /* already copied */ } =20 - if (job->initializing_bitmap) { - ret =3D backup_bitmap_reset_unallocated(job, start, &skip_byte= s); - if (ret =3D=3D 0) { - trace_backup_do_cow_skip_range(job, start, skip_bytes); - start +=3D skip_bytes; - continue; - } - } - dirty_end =3D bdrv_dirty_bitmap_next_zero(job->copy_bitmap, start, end - start); if (dirty_end < 0) { @@ -546,7 +549,8 @@ static int coroutine_fn backup_run(Job *job, Error **er= rp) goto out; } =20 - ret =3D backup_bitmap_reset_unallocated(s, offset, &count); + ret =3D backup_bitmap_reset_unallocated(s, offset, s->len - of= fset, + &count); if (ret < 0) { goto out; } --=20 2.18.0