From nobody Sat Apr 26 14:15:12 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570708620; cv=none; d=zoho.com; s=zohoarc; b=H7pVzZlqbr+LxUhv/MjyzSa/zU7rgJRnk0AiqRk5JM4yqrgc+0e+tz5vqy5SpvonsYfnMqK7WGaJg96zrqbI86ovZD8dNSDgr6uqtDUGc8k8jKK9ym4qHMGCVN3kN8MVHahew0c0kHhYzHxYQ9i2GXMUiF0W+IDRQ6PaUfkOyPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570708620; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TikPFlOGby/dysBtZx+0p/PbFUoDL6VQlIYYd+0EnYI=; b=JZJQ4M8vDmAB4A7ZaswtTw+pCNEqaADvDuTO5JrpU0EQK7DCJsFoy30No/nYPd+YapT3EMVcEYVeFpBHBa47HvNyZ9tNfq4VXFhMQGQqpb92n2kJb7Dv4ED0GBM9RWVU4iuPF5MRKAgB9aUOlgQx75h0wzN957rRaRBIyoHJkIQ= 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=<mreitz@redhat.com> (p=none dis=none) header.from=<mreitz@redhat.com> Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15707086209374.149973551286621; Thu, 10 Oct 2019 04:57:00 -0700 (PDT) Received: from localhost ([::1]:36808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1iIX3o-0004tM-A6 for importer@patchew.org; Thu, 10 Oct 2019 07:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51672) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <mreitz@redhat.com>) id 1iIWqm-0006Mc-H2 for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <mreitz@redhat.com>) id 1iIWql-00086b-H6 for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <mreitz@redhat.com>) id 1iIWqi-00085T-T8; Thu, 10 Oct 2019 07:43:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22EF689810E; Thu, 10 Oct 2019 11:43:16 +0000 (UTC) Received: from localhost (unknown [10.36.118.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAFE45C241; Thu, 10 Oct 2019 11:43:15 +0000 (UTC) From: Max Reitz <mreitz@redhat.com> To: qemu-block@nongnu.org Subject: [PULL 06/36] block/backup: fix max_transfer handling for copy_range Date: Thu, 10 Oct 2019 13:42:30 +0200 Message-Id: <20191010114300.7746-7-mreitz@redhat.com> In-Reply-To: <20191010114300.7746-1-mreitz@redhat.com> References: <20191010114300.7746-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Thu, 10 Oct 2019 11:43:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: Kevin Wolf <kwolf@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Of course, QEMU_ALIGN_UP is a typo, it should be QEMU_ALIGN_DOWN, as we are trying to find aligned size which satisfy both source and target. Also, don't ignore too small max_transfer. In this case seems safer to disable copy_range. Fixes: 9ded4a0114968e Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-id: 20190920142056.12778-2-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com> --- block/backup.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index 763f0d7ff6..db20249063 100644 --- a/block/backup.c +++ b/block/backup.c @@ -741,12 +741,19 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, job->cluster_size =3D cluster_size; job->copy_bitmap =3D copy_bitmap; copy_bitmap =3D NULL; - 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, - QEMU_ALIGN_UP(job->copy_range_size, - job->cluster_size)); + job->copy_range_size =3D QEMU_ALIGN_DOWN(job->copy_range_size, + job->cluster_size); + /* + * Set use_copy_range, consider the following: + * 1. Compression is not supported for copy_range. + * 2. copy_range does not respect max_transfer (it's a TODO), so we fa= ctor + * that in here. If max_transfer is smaller than the job->cluster_s= ize, + * we do not use copy_range (in that case it's zero after aligning = down + * above). + */ + job->use_copy_range =3D !compress && job->copy_range_size > 0; =20 /* Required permissions are already taken with target's blk_new() */ block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, --=20 2.21.0