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=1565364872; cv=none; d=zoho.com; s=zohoarc; b=IY1wQ0X2cfQTyYo8uOT4t9pJr08bJF6ojrfRUQkV8OcTHgzsWDWLwpLo7fBrQQ40acquITM0HWQO7wgfkvR9dEdIIhse81yLrKVZtpIF+beeK1yEw1icz6jr5i9vyv73b8hA26QB2saZi72iBDNHvKjTaTZglzPH4paw4EGGziI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565364872; 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=fQ+1h/7MeQt4hH/J3dDO5eXC4uSqVFaXxERylLizMMM=; b=MNsd3MILD/yXWeXY2WqClUAwP/jYLOofbSd4+WFfJ+D6WMc9ABDUUgBION7FxU7xWeltBFdv+XLzLmlmcCUUimnAl0aTNUHijdJZyHBXT3QWrPkdjVbk1Qpg1WWUDjmVIOWHgwXqMMrwsW89EFRD/5XN6Zapz19sEUhm/jqRJA0= 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 1565364872862205.43277413415262; Fri, 9 Aug 2019 08:34:32 -0700 (PDT) Received: from localhost ([::1]:60154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw6uV-0006fk-UD for importer@patchew.org; Fri, 09 Aug 2019 11:34:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49087) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw6sN-00041j-IJ 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 1hw6sK-0002p3-Rv for qemu-devel@nongnu.org; Fri, 09 Aug 2019 11:32:19 -0400 Received: from relay.sw.ru ([185.231.240.75]:57586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hw6sI-0002ij-1i; 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-7N; Fri, 09 Aug 2019 18:32:08 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Fri, 9 Aug 2019 18:32:01 +0300 Message-Id: <20190809153207.49288-2-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 1/7] 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: 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" 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 adc4d44244..d815436455 100644 --- a/block/backup.c +++ b/block/backup.c @@ -113,7 +113,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)); bdrv_reset_dirty_bitmap(job->copy_bitmap, start, job->cluster_size); @@ -131,14 +134,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 29c6c6044a..2d7e7be538 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3613,7 +3613,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= JobTxn *txn, BlockDriverState *source =3D NULL; BlockJob *job =3D NULL; AioContext *aio_context; - QDict *options =3D NULL; + QDict *options; Error *local_err =3D NULL; int flags; int64_t size; @@ -3686,10 +3686,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