From nobody Wed Nov 12 04:58:39 2025 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=1565364898; cv=none; d=zoho.com; s=zohoarc; b=kfL6K+VgpBIkX5yp5wxUeFC2IYk280c4/SWwVNv0yE2/yCwGmW8KNACBgasqwb2aD3zBrbJFBNWhWzLZL8qM1CT4w5K2QzA+yhXZAQiACCL+V1wZJyxiirD2vgWcgzY9PFNbyMaPEsXJLW+hLrbbW0vmbWSyQbKjyleylHmSbx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565364898; 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=QAaryPl8e8bIbw3mXjYvTW8yGF1MvzneuZ3at1VqCQQ=; b=eXrWIERl1Rn+OjwDr/yoOyjS4Pp7bTr4WhHuyPnhh9PKImqOFADvxuHgWphYlA8KJ0IAIgOT/aY+m8V0CTDNtqKZbUgKKbWU0puk28fX5Ce8zWv/dAyku3ZOjjuV9okDd9u6BoX0fdw6uu7XuXSv37+JMa9MAvFexWZKCI41GFE= 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 1565364898787601.0644221389405; Fri, 9 Aug 2019 08:34:58 -0700 (PDT) Received: from localhost ([::1]:60164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw6uv-0007ut-SG for importer@patchew.org; Fri, 09 Aug 2019 11:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49086) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw6sN-00041h-IE for qemu-devel@nongnu.org; Fri, 09 Aug 2019 11:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hw6sL-0002pQ-5k for qemu-devel@nongnu.org; Fri, 09 Aug 2019 11:32:19 -0400 Received: from relay.sw.ru ([185.231.240.75]:57596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hw6sI-0002io-1r; Fri, 09 Aug 2019 11:32:14 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hw6sC-0004Cp-FL; Fri, 09 Aug 2019 18:32:08 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Fri, 9 Aug 2019 18:32:02 +0300 Message-Id: <20190809153207.49288-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190809153207.49288-1-vsementsov@virtuozzo.com> References: <20190809153207.49288-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 v2 2/7] block/backup: refactor write_flags 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" write flags are constant, let's store it in BackupBlockJob instead of recalculating. It also makes two boolean fields to be unused, so, drop them. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow Reviewed-by: Max Reitz --- block/backup.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/block/backup.c b/block/backup.c index d815436455..c6a3b2b7bb 100644 --- a/block/backup.c +++ b/block/backup.c @@ -50,14 +50,13 @@ typedef struct BackupBlockJob { uint64_t len; uint64_t bytes_read; int64_t cluster_size; - bool compress; NotifierWithReturn before_write; QLIST_HEAD(, CowRequest) inflight_reqs; =20 bool use_copy_range; int64_t copy_range_size; =20 - bool serialize_target_writes; + BdrvRequestFlags write_flags; bool initializing_bitmap; } BackupBlockJob; =20 @@ -113,10 +112,6 @@ static int coroutine_fn backup_cow_with_bounce_buffer(= BackupBlockJob *job, BlockBackend *blk =3D job->common.blk; int nbytes; int read_flags =3D is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0; - int write_flags =3D - (job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0) | - (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0); - =20 assert(QEMU_IS_ALIGNED(start, job->cluster_size)); bdrv_reset_dirty_bitmap(job->copy_bitmap, start, job->cluster_size); @@ -135,7 +130,7 @@ static int coroutine_fn backup_cow_with_bounce_buffer(B= ackupBlockJob *job, } =20 ret =3D blk_co_pwrite(job->target, start, nbytes, *bounce_buffer, - write_flags); + job->write_flags); if (ret < 0) { trace_backup_do_cow_write_fail(job, start, ret); if (error_is_read) { @@ -163,7 +158,6 @@ static int coroutine_fn backup_cow_with_offload(BackupB= lockJob *job, BlockBackend *blk =3D job->common.blk; int nbytes; int read_flags =3D is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0; - int write_flags =3D job->serialize_target_writes ? BDRV_REQ_SERIALISIN= G : 0; =20 assert(QEMU_IS_ALIGNED(job->copy_range_size, job->cluster_size)); assert(QEMU_IS_ALIGNED(start, job->cluster_size)); @@ -172,7 +166,7 @@ static int coroutine_fn backup_cow_with_offload(BackupB= lockJob *job, bdrv_reset_dirty_bitmap(job->copy_bitmap, start, job->cluster_size * nr_clusters); ret =3D blk_co_copy_range(blk, start, job->target, start, nbytes, - read_flags, write_flags); + read_flags, job->write_flags); if (ret < 0) { trace_backup_do_cow_copy_range_fail(job, start, ret); bdrv_set_dirty_bitmap(job->copy_bitmap, start, @@ -748,10 +742,16 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, job->sync_mode =3D sync_mode; job->sync_bitmap =3D sync_bitmap; job->bitmap_mode =3D bitmap_mode; - job->compress =3D compress; =20 - /* Detect image-fleecing (and similar) schemes */ - job->serialize_target_writes =3D bdrv_chain_contains(target, bs); + /* + * Set write flags: + * 1. Detect image-fleecing (and similar) schemes + * 2. Handle compression + */ + job->write_flags =3D + (bdrv_chain_contains(target, bs) ? BDRV_REQ_SERIALISING : 0) | + (compress ? BDRV_REQ_WRITE_COMPRESSED : 0); + job->cluster_size =3D cluster_size; job->copy_bitmap =3D copy_bitmap; copy_bitmap =3D NULL; --=20 2.18.0