From nobody Mon May 6 02:00:06 2024 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=1564504497; cv=none; d=zoho.com; s=zohoarc; b=bUf5N8IFq1Ti+IKlwCBvsCOZQlSmC7LX+y4fMdXY7mvbmbJFOUoiNyv5/O71yjm4U7oz8Qp2Q7XinTUbmgJ0WteuZfNkB+j0XYOFn1cIkZBAf4OQeT/lRmN6Y4vKLb8rtnHaY5KntUZzgOH1sYcniJ8VMk/EqOf5fpLXj6htycQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564504497; 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=lSVR9DDFJD7n3UbCcNDlmZP40BgRA6vrpnVuFeMhaDA=; b=H/ZX4gI4SgVX579TmXeex+P9uTkFm5jv2GFtMQxXpwIrY2lKC1R0sHOM68X5iwfz2wUCyRVbpavZIFBomXn857MKRZYDOk6SPiqGxtVeLDE5T2ckRymRp1uoqLqLIWSWbOYEZWmfpJN2MTmL7UNf5hL2WTJmt/wm1Byi19KUQZs= 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 1564504497406700.6725213382122; Tue, 30 Jul 2019 09:34:57 -0700 (PDT) Received: from localhost ([::1]:34558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV5U-0004pq-Cz for importer@patchew.org; Tue, 30 Jul 2019 12:34:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53255) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV3c-0001oI-DR for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsV3b-0002X1-E0 for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:33:00 -0400 Received: from relay.sw.ru ([185.231.240.75]:54214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsV3Z-0002Uo-1i; Tue, 30 Jul 2019 12:32:57 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hsV3V-0001Yw-Bq; Tue, 30 Jul 2019 19:32:53 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Tue, 30 Jul 2019 19:32:49 +0300 Message-Id: <20190730163251.755248-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190730163251.755248-1-vsementsov@virtuozzo.com> References: <20190730163251.755248-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 1/3] block/backup: deal with zero detection 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: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@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" We have detect_zeroes option, so at least for blockdev-backup user should define it if zero-detection is needed. For drive-backup leave detection enabled by default but do it through existing option instead of open-coding. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/backup.c | 15 ++++++--------- blockdev.c | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/block/backup.c b/block/backup.c index 715e1d3be8..f4aaf08df3 100644 --- a/block/backup.c +++ b/block/backup.c @@ -110,7 +110,10 @@ 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_SERIALISIN= G : 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)); hbitmap_reset(job->copy_bitmap, start, job->cluster_size); @@ -128,14 +131,8 @@ static int coroutine_fn backup_cow_with_bounce_buffer(= BackupBlockJob *job, goto fail; } =20 - if (buffer_is_zero(*bounce_buffer, nbytes)) { - ret =3D blk_co_pwrite_zeroes(job->target, start, - nbytes, write_flags | BDRV_REQ_MAY_UNMA= P); - } else { - ret =3D blk_co_pwrite(job->target, start, - nbytes, *bounce_buffer, write_flags | - (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0= )); - } + ret =3D blk_co_pwrite(job->target, start, nbytes, *bounce_buffer, + write_flags); if (ret < 0) { trace_backup_do_cow_write_fail(job, start, ret); if (error_is_read) { diff --git a/blockdev.c b/blockdev.c index 4d141e9a1f..a94d754504 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3434,7 +3434,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= JobTxn *txn, BlockJob *job =3D NULL; BdrvDirtyBitmap *bmap =3D NULL; AioContext *aio_context; - QDict *options =3D NULL; + QDict *options; Error *local_err =3D NULL; int flags, job_flags =3D JOB_DEFAULT; int64_t size; @@ -3529,10 +3529,10 @@ static BlockJob *do_drive_backup(DriveBackup *backu= p, JobTxn *txn, goto out; } =20 + options =3D qdict_new(); + qdict_put_str(options, "discard", "unmap"); + qdict_put_str(options, "detect-zeroes", "unmap"); if (backup->format) { - if (!options) { - options =3D qdict_new(); - } qdict_put_str(options, "driver", backup->format); } =20 --=20 2.18.0 From nobody Mon May 6 02:00:06 2024 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=1564504428; cv=none; d=zoho.com; s=zohoarc; b=Dye4Lpj8ovrzYshsuJAES/lAJ1R4a0A2amhlubltNbHWz7vw5zt/U+kJeOd5hXbOshMF+EBgm2fB5MyjUOqQZ89mtxp8NHr0B8Pu0t1/2P1HY+idcIw8tCO01/w8w5KWHKMsjO7Z3AbECAJ6iTj03St/uq1n7H6xX4ZOye/xTOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564504428; 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=8X8wkyqwQPfyJlx4e2qb98qG0WyZRzgY1yxGZMBZNyE=; b=TPFElQohhNxkHb5egbnYbbPHpntz6zHz9JpbTD/bYClashh10ekF/e5YUA7WMq5iRqRUxnZNZCZKU3FLKGtZYEjLARl3LUnpG8SKxrEzm3QThj/IcAQjciWJ9JjS7dRSPUT7WCG4VNDqUL3W74jRzQ89GbvuPmCDMr69rjD5tgU= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564504428084902.7612217004294; Tue, 30 Jul 2019 09:33:48 -0700 (PDT) Received: from localhost ([::1]:34541 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV4D-0002ve-DK for importer@patchew.org; Tue, 30 Jul 2019 12:33:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53240) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV3b-0001nA-Tr for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:33:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsV3a-0002Wm-TB for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:32:59 -0400 Received: from relay.sw.ru ([185.231.240.75]:54208) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsV3Y-0002Up-Qe; Tue, 30 Jul 2019 12:32:56 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hsV3V-0001Yw-Lm; Tue, 30 Jul 2019 19:32:53 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Tue, 30 Jul 2019 19:32:50 +0300 Message-Id: <20190730163251.755248-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190730163251.755248-1-vsementsov@virtuozzo.com> References: <20190730163251.755248-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 2/3] block/backup: disable copy_range for compressed backup 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: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@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" Enabled by default copy_range ignores compress option. It's definitely unexpected for user. It's broken since introduction of copy_range usage in backup in 9ded4a011496. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow Reviewed-by: Max Reitz --- block/backup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/backup.c b/block/backup.c index f4aaf08df3..c5f941101a 100644 --- a/block/backup.c +++ b/block/backup.c @@ -645,7 +645,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, job->cluster_size =3D cluster_size; job->copy_bitmap =3D copy_bitmap; copy_bitmap =3D NULL; - job->use_copy_range =3D true; + job->use_copy_range =3D !compress; /* compression isn't supported for = it */ job->copy_range_size =3D MIN_NON_ZERO(blk_get_max_transfer(job->common= .blk), blk_get_max_transfer(job->target)); job->copy_range_size =3D MAX(job->cluster_size, --=20 2.18.0 From nobody Mon May 6 02:00:06 2024 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=1564504493; cv=none; d=zoho.com; s=zohoarc; b=RURrqwKmHdksFO69m9JS47Wt1ySzLSao+an5G5oPfsysNi/yfiCXlS8bCUrHjILop2Z/N5MyiwGoh7aK8aG67xZHTYCQeQQ0CZCMrO8eZITVpsDtbQe13uojiZ6qQhKEckw6VgPUYTrwvZOF/qHiCaTTgIrz+DX1ho+BNalafT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564504493; 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=7d2OP2tWMJfVAD9F8V6m3V5O36SeZAI8JN5Te28aFas=; b=XETRAYBedVIyYz8qQCSzVS2L69gC5wJuQaB+Cw5klLHl8Fn6vAK42oIMeO1au8v3ut5MV474K4Zku6oj6/QMZ3T8as3+365ZJoUZJSvQ0+dc8r/v2opfQv7D9M0t4szvvkVQyYCJy20xPjVQJ69r2cerZQtijOVD4uz8ssuO2/c= 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 1564504493548479.89918210197345; Tue, 30 Jul 2019 09:34:53 -0700 (PDT) Received: from localhost ([::1]:34556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV5Q-0004gf-KU for importer@patchew.org; Tue, 30 Jul 2019 12:34:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53261) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsV3c-0001p5-PJ for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsV3b-0002XD-Ml for qemu-devel@nongnu.org; Tue, 30 Jul 2019 12:33:00 -0400 Received: from relay.sw.ru ([185.231.240.75]:54206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsV3Z-0002Uq-3E; Tue, 30 Jul 2019 12:32:57 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hsV3V-0001Yw-RV; Tue, 30 Jul 2019 19:32:53 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Tue, 30 Jul 2019 19:32:51 +0300 Message-Id: <20190730163251.755248-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190730163251.755248-1-vsementsov@virtuozzo.com> References: <20190730163251.755248-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 3/3] 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: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@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 c5f941101a..4651649e9d 100644 --- a/block/backup.c +++ b/block/backup.c @@ -47,7 +47,6 @@ 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 @@ -55,7 +54,7 @@ typedef struct BackupBlockJob { bool use_copy_range; int64_t copy_range_size; =20 - bool serialize_target_writes; + BdrvRequestFlags write_flags; } BackupBlockJob; =20 static const BlockJobDriver backup_job_driver; @@ -110,10 +109,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)); hbitmap_reset(job->copy_bitmap, start, job->cluster_size); @@ -132,7 +127,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) { @@ -160,7 +155,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)); @@ -168,7 +162,7 @@ static int coroutine_fn backup_cow_with_offload(BackupB= lockJob *job, nr_clusters =3D DIV_ROUND_UP(nbytes, job->cluster_size); hbitmap_reset(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); hbitmap_set(job->copy_bitmap, start, job->cluster_size * nr_cluste= rs); @@ -638,10 +632,16 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, job->sync_mode =3D sync_mode; job->sync_bitmap =3D sync_mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL ? sync_bitmap : NULL; - 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