From nobody Wed Nov 12 03:43:51 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=1568301381; cv=none; d=zoho.com; s=zohoarc; b=muOYH1kEdm8CG0elWuHO5ONfvcMsFoIdRr84B1ZIZkaA76mgQVNjogFELANB9HZPNCxRVqmGMQaGPORckMPZiYMJfbhFQ+UPhSZ5nOL4X5P89l9+L19UcCBdkbaBzlqWEszUcMiI2PrSejLChEyPY2jqX2W5nPZTqzifwxHI4zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568301381; 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:ARC-Authentication-Results; bh=NMWd1Li7Qi0BCDysj5W4ekNtpuV1fq5DAzJ8Q0C2s50=; b=U4WLnSQX3pAjzMLoP3EhRjL7fUjwd2+NXTUl0eaIj9sA3eFS70eRB5WzbGxYESH9sMUUS9Sr+SRtIcnbxi+N/ViH3mG7RLiYXBjAI6padsXtxoqEpWLIe7S7w8oy19XtRIH1SqoFRZAWROWpmf4S6XlDhcs6OUGXi4/4gwhtr9E= 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 1568301380919854.8783594097368; Thu, 12 Sep 2019 08:16:20 -0700 (PDT) Received: from localhost ([::1]:35754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8QpN-0003dN-QM for importer@patchew.org; Thu, 12 Sep 2019 11:16:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38368) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Qn5-000251-86 for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8Qn3-00036I-7v for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:47 -0400 Received: from relay.sw.ru ([185.231.240.75]:57854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8Qmz-000348-Sa; Thu, 12 Sep 2019 11:13:42 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i8Qmw-0000kk-Ow; Thu, 12 Sep 2019 18:13:38 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Thu, 12 Sep 2019 18:13:35 +0300 Message-Id: <20190912151338.21225-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912151338.21225-1-vsementsov@virtuozzo.com> References: <20190912151338.21225-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 1/4] block/mirror: simplify do_sync_target_write 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, 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-Type: text/plain; charset="utf-8" do_sync_target_write is called from bdrv_mirror_top_do_write after write/discard operation, all inside active_write/active_write_settle protecting us from mirror iteration. So the whole area is dirty for sure, no reason to examine dirty bitmap. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/mirror.c | 95 +++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 67 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 853e2c7510..d176bf5920 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1203,84 +1203,45 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMet= hod method, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - QEMUIOVector target_qiov; - uint64_t dirty_offset =3D offset; - uint64_t dirty_bytes; - - if (qiov) { - qemu_iovec_init(&target_qiov, qiov->niov); - } - - while (true) { - bool valid_area; - int ret; - - bdrv_dirty_bitmap_lock(job->dirty_bitmap); - dirty_bytes =3D MIN(offset + bytes - dirty_offset, INT_MAX); - valid_area =3D bdrv_dirty_bitmap_next_dirty_area(job->dirty_bitmap, - &dirty_offset, - &dirty_bytes); - if (!valid_area) { - bdrv_dirty_bitmap_unlock(job->dirty_bitmap); - break; - } + int ret; =20 - bdrv_reset_dirty_bitmap_locked(job->dirty_bitmap, - dirty_offset, dirty_bytes); - bdrv_dirty_bitmap_unlock(job->dirty_bitmap); + bdrv_reset_dirty_bitmap(job->dirty_bitmap, offset, bytes); =20 - job_progress_increase_remaining(&job->common.job, dirty_bytes); + job_progress_increase_remaining(&job->common.job, bytes); =20 - assert(dirty_offset - offset <=3D SIZE_MAX); - if (qiov) { - qemu_iovec_reset(&target_qiov); - qemu_iovec_concat(&target_qiov, qiov, - dirty_offset - offset, dirty_bytes); - } - - switch (method) { - case MIRROR_METHOD_COPY: - ret =3D blk_co_pwritev(job->target, dirty_offset, dirty_bytes, - qiov ? &target_qiov : NULL, flags); - break; + switch (method) { + case MIRROR_METHOD_COPY: + ret =3D blk_co_pwritev(job->target, offset, bytes, qiov, flags); + break; =20 - case MIRROR_METHOD_ZERO: - assert(!qiov); - ret =3D blk_co_pwrite_zeroes(job->target, dirty_offset, dirty_= bytes, - flags); - break; + case MIRROR_METHOD_ZERO: + assert(!qiov); + ret =3D blk_co_pwrite_zeroes(job->target, offset, bytes, flags); + break; =20 - case MIRROR_METHOD_DISCARD: - assert(!qiov); - ret =3D blk_co_pdiscard(job->target, dirty_offset, dirty_bytes= ); - break; + case MIRROR_METHOD_DISCARD: + assert(!qiov); + ret =3D blk_co_pdiscard(job->target, offset, bytes); + break; =20 - default: - abort(); - } + default: + abort(); + } =20 - if (ret >=3D 0) { - job_progress_update(&job->common.job, dirty_bytes); - } else { - BlockErrorAction action; + if (ret >=3D 0) { + job_progress_update(&job->common.job, bytes); + } else { + BlockErrorAction action; =20 - bdrv_set_dirty_bitmap(job->dirty_bitmap, dirty_offset, dirty_b= ytes); - job->actively_synced =3D false; + bdrv_set_dirty_bitmap(job->dirty_bitmap, offset, bytes); + job->actively_synced =3D false; =20 - action =3D mirror_error_action(job, false, -ret); - if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { - if (!job->ret) { - job->ret =3D ret; - } - break; + action =3D mirror_error_action(job, false, -ret); + if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { + if (!job->ret) { + job->ret =3D ret; } } - - dirty_offset +=3D dirty_bytes; - } - - if (qiov) { - qemu_iovec_destroy(&target_qiov); } } =20 --=20 2.21.0 From nobody Wed Nov 12 03:43:51 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=1568301407; cv=none; d=zoho.com; s=zohoarc; b=SofFep7Q1l/aJPKOj7z18mwv8protZARdnOtZOqlQWSkhZzdH3sx5YnMw4NVDo7f8w2TjDo1Q0ayP2cOinLtN9+gKVY72lnkPXP+ISKpjMW/9mim5jjgGwgnbBmQM2Qoad7J9mHJ2ovALePLAfY79x7cBx7WY2oJOES/MwDX7GY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568301407; 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:ARC-Authentication-Results; bh=x5YxWMheaTJKfFgXnBwEKqjJ6EWPrJOl3+uz7B6salQ=; b=VlBsloXpQFnF+rO9sYepZqnbNcYR/IrbFOnb+JhqH0otT+orPSeRpNk1MVwy8eZPbP+EcaP/Dqg2rx6JNDGLU0Mp9Tv66zqvlEAoRi1Jm+42Uk4OTilFpxRZtsALsdmvhc0QZ65AuV1F/mH6Y38VcmB2WJf+6vSqHxPwzvUx3sc= 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 1568301407759544.655998086948; Thu, 12 Sep 2019 08:16:47 -0700 (PDT) Received: from localhost ([::1]:35756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Qpt-0003pw-Ph for importer@patchew.org; Thu, 12 Sep 2019 11:16:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38363) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Qn5-00024y-83 for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8Qn3-00036S-8B for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:47 -0400 Received: from relay.sw.ru ([185.231.240.75]:57858) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8Qmz-00034B-SZ; Thu, 12 Sep 2019 11:13:42 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i8Qmw-0000kk-Tj; Thu, 12 Sep 2019 18:13:39 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Thu, 12 Sep 2019 18:13:36 +0300 Message-Id: <20190912151338.21225-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912151338.21225-1-vsementsov@virtuozzo.com> References: <20190912151338.21225-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 2/4] block/block-backend: add blk_co_pwritev_part 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, 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-Type: text/plain; charset="utf-8" Add blk write function with qiov_offset parameter. It's needed for the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/sysemu/block-backend.h | 4 ++++ block/block-backend.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 368d53af77..73f2cef7fe 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -121,6 +121,10 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDev= Ops *ops, void *opaque); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, + unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offse= t, + BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); diff --git a/block/block-backend.c b/block/block-backend.c index 1c605d5444..b3d00478af 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1176,9 +1176,10 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, in= t64_t offset, return ret; } =20 -int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, - unsigned int bytes, QEMUIOVector *qiov, - BdrvRequestFlags flags) +int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, + unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offse= t, + BdrvRequestFlags flags) { int ret; BlockDriverState *bs; @@ -1205,11 +1206,19 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, = int64_t offset, flags |=3D BDRV_REQ_FUA; } =20 - ret =3D bdrv_co_pwritev(blk->root, offset, bytes, qiov, flags); + ret =3D bdrv_co_pwritev_part(blk->root, offset, bytes, qiov, qiov_offs= et, + flags); bdrv_dec_in_flight(bs); return ret; } =20 +int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, + unsigned int bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags) +{ + return blk_co_pwritev_part(blk, offset, bytes, qiov, 0, flags); +} + typedef struct BlkRwCo { BlockBackend *blk; int64_t offset; --=20 2.21.0 From nobody Wed Nov 12 03:43:51 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=1568301677; cv=none; d=zoho.com; s=zohoarc; b=nWA3tYAVG7uBzoRn89tckr8kfzjF2ynQ/v68v7HhsLLP3U/j5Nh0PFEhJY9EazWkFI91m6AelIbrjjHUXKnblkAS/QA4zibQy1leh0o0TVgQpHK9YoEuaGAGJRPhASbKS39NPcCExM9NaKckfNlusrB1tMYIXvJgRnWJ9v9AbCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568301677; 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:ARC-Authentication-Results; bh=kpZt6fDtGmTAn3UjHj/cLwi7UZjzGf9e49nmFq2M9Gc=; b=XWuVwhdZJ9tid96tFdJPyhYg9ex1emRE8LFbKlpUVVdhGNfFJ8LbjXLLu8/MjDfN9OK+4r6CzRjvT7b5YnQKLRnkYsjZwhUeUn5lk/Jw46rQn0DKK676S2Z68RmOMj2tpn0jQ1kdE2k1AzzFE9ssQGEssgk0otuNpAewE/yhaSk= 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 1568301677790178.74549799856845; Thu, 12 Sep 2019 08:21:17 -0700 (PDT) Received: from localhost ([::1]:35814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8QuI-0000DR-Nf for importer@patchew.org; Thu, 12 Sep 2019 11:21:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38364) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Qn5-00024x-7w for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8Qn3-00036W-93 for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:47 -0400 Received: from relay.sw.ru ([185.231.240.75]:57852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8Qmz-00034A-Ur; Thu, 12 Sep 2019 11:13:42 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i8Qmx-0000kk-2b; Thu, 12 Sep 2019 18:13:39 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Thu, 12 Sep 2019 18:13:37 +0300 Message-Id: <20190912151338.21225-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912151338.21225-1-vsementsov@virtuozzo.com> References: <20190912151338.21225-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 3/4] block/mirror: support unaligned write in active mirror 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, 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-Type: text/plain; charset="utf-8" Prior 9adc1cb49af8d do_sync_target_write had a bug: it reset aligned-up region in the dirty bitmap, which means that we may not copy some bytes and assume them copied, which actually leads to producing corrupted target. So 9adc1cb49af8d forced dirty bitmap granularity to be request_alignment for mirror-top filter, so we are not working with unaligned requests. However forcing large alignment obviously decreases performance of unaligned requests. This commit provides another solution for the problem: if unaligned padding is already dirty, we can safely ignore it, as 1. It's dirty, it will be copied by mirror_iteration anyway 2. It's dirty, so skipping it now we don't increase dirtiness of the bitmap and therefore don't damage "synchronicity" of the write-blocking mirror. If unaligned padding is not dirty, we just write it, no reason to touch dirty bitmap if we succeed (on failure we'll set the whole region ofcourse, but we loss "synchronicity" on failure anyway). Note: we need to disable dirty_bitmap, otherwise we will not be able to see in do_sync_target_write bitmap state before current operation. We may of course check dirty bitmap before the operation in bdrv_mirror_top_do_write and remember it, but we don't need active dirty bitmap for write-blocking mirror anyway. New code-path is unused until the following commit reverts 9adc1cb49af8d. Suggested-by: Denis V. Lunev Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index d176bf5920..d192f6a96b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1204,6 +1204,39 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMeth= od method, QEMUIOVector *qiov, int flags) { int ret; + size_t qiov_offset =3D 0; + + if (!QEMU_IS_ALIGNED(offset, job->granularity) && + bdrv_dirty_bitmap_get(job->dirty_bitmap, offset)) { + /* + * Dirty unaligned padding + * 1. It's already dirty, no damage to "actively_synced" if we= just + * skip unaligned part. + * 2. If we copy it, we can't reset corresponding bit in + * dirty_bitmap as there may be some "dirty" bytes still not + * copied. + * So, just ignore it. + */ + qiov_offset =3D QEMU_ALIGN_UP(offset, job->granularity) - offs= et; + if (bytes <=3D qiov_offset) { + /* nothing to do after shrink */ + return; + } + offset +=3D qiov_offset; + bytes -=3D qiov_offset; + } + + if (!QEMU_IS_ALIGNED(offset + bytes, job->granularity) && + bdrv_dirty_bitmap_get(job->dirty_bitmap, offset + bytes - 1)) + { + uint64_t tail =3D (offset + bytes) % job->granularity; + + if (bytes <=3D tail) { + /* nothing to do after shrink */ + return; + } + bytes -=3D tail; + } =20 bdrv_reset_dirty_bitmap(job->dirty_bitmap, offset, bytes); =20 @@ -1211,7 +1244,8 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMetho= d method, =20 switch (method) { case MIRROR_METHOD_COPY: - ret =3D blk_co_pwritev(job->target, offset, bytes, qiov, flags); + ret =3D blk_co_pwritev_part(job->target, offset, bytes, + qiov, qiov_offset, flags); break; =20 case MIRROR_METHOD_ZERO: @@ -1640,6 +1674,9 @@ static BlockJob *mirror_start_job( if (!s->dirty_bitmap) { goto fail; } + if (s->copy_mode =3D=3D MIRROR_COPY_MODE_WRITE_BLOCKING) { + bdrv_disable_dirty_bitmap(s->dirty_bitmap); + } =20 ret =3D block_job_add_bdrv(&s->common, "source", bs, 0, BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE | --=20 2.21.0 From nobody Wed Nov 12 03:43:51 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=1568301433; cv=none; d=zoho.com; s=zohoarc; b=fkswgEg76Strur/93rsLJuZsd25Shys5kb06YZCsEIPUAOwDx8gTFmHHo0fMKuXO2aCyOHeKOar4CjnR4mLD5gOgAMvOwpCxlJ00eQHumC0SZyqF+YuPrEqKHYGyHc7k/q70afpYTCC1UjJ8Ywdysc3vh439xGHgznmhUG1zbL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568301433; 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:ARC-Authentication-Results; bh=uerRlFstMtgtQX9ySVCl1YirblvzjJ5b4wXTm4je9Fc=; b=ZmdLjEVKmyplk8GcyMGZApXrZHfT9PsoqrdcfGpS72RKHVCl2UDbhljhagSI8nZEbfCOawsfbRIvm1G2xuCBcG3AVWKL6BjJVpHTPru9nAq27utPbWgDx4OdMbLuWaBo4ROYEcsWShWKiua2kP5QkoDFfuftQougJ133N5yO1uU= 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 1568301433477918.5062434346231; Thu, 12 Sep 2019 08:17:13 -0700 (PDT) Received: from localhost ([::1]:35758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8QqN-00043T-Hj for importer@patchew.org; Thu, 12 Sep 2019 11:17:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38366) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8Qn5-00024z-8R for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8Qn3-00036E-86 for qemu-devel@nongnu.org; Thu, 12 Sep 2019 11:13:47 -0400 Received: from relay.sw.ru ([185.231.240.75]:57850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8Qmz-00034C-SW; Thu, 12 Sep 2019 11:13:42 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i8Qmx-0000kk-4U; Thu, 12 Sep 2019 18:13:39 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Thu, 12 Sep 2019 18:13:38 +0300 Message-Id: <20190912151338.21225-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912151338.21225-1-vsementsov@virtuozzo.com> References: <20190912151338.21225-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 4/4] Revert "mirror: Only mirror granularity-aligned chunks" 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, 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-Type: text/plain; charset="utf-8" This reverts commit 9adc1cb49af8d4e54f57980b1eed5c0a4b2dafa6. "mirror: Only mirror granularity-aligned chunks" Since previous commit unaligned chunks are supported by do_sync_target_write. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/mirror.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index d192f6a96b..4626b91541 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1482,15 +1482,6 @@ static void bdrv_mirror_top_child_perm(BlockDriverSt= ate *bs, BdrvChild *c, *nshared =3D BLK_PERM_ALL; } =20 -static void bdrv_mirror_top_refresh_limits(BlockDriverState *bs, Error **e= rrp) -{ - MirrorBDSOpaque *s =3D bs->opaque; - - if (s && s->job && s->job->copy_mode =3D=3D MIRROR_COPY_MODE_WRITE_BLO= CKING) { - bs->bl.request_alignment =3D s->job->granularity; - } -} - /* Dummy node that provides consistent read to its users without requiring= it * from its backing file and that allows writes on the backing file chain.= */ static BlockDriver bdrv_mirror_top =3D { @@ -1503,7 +1494,6 @@ static BlockDriver bdrv_mirror_top =3D { .bdrv_co_block_status =3D bdrv_co_block_status_from_backing, .bdrv_refresh_filename =3D bdrv_mirror_top_refresh_filename, .bdrv_child_perm =3D bdrv_mirror_top_child_perm, - .bdrv_refresh_limits =3D bdrv_mirror_top_refresh_limits, }; =20 static BlockJob *mirror_start_job( @@ -1651,25 +1641,6 @@ static BlockJob *mirror_start_job( s->should_complete =3D true; } =20 - /* - * Must be called before we start tracking writes, but after - * - * ((MirrorBlockJob *) - * ((MirrorBDSOpaque *) - * mirror_top_bs->opaque - * )->job - * )->copy_mode - * - * has the correct value. - * (We start tracking writes as of the following - * bdrv_create_dirty_bitmap() call.) - */ - bdrv_refresh_limits(mirror_top_bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto fail; - } - s->dirty_bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, NULL, er= rp); if (!s->dirty_bitmap) { goto fail; --=20 2.21.0