From nobody Tue Apr 7 21:27:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773257989; cv=none; d=zohomail.com; s=zohoarc; b=Q914FOOZb+v6UaynFOQULQScIkY8CD8jyydsRKUo7o7cYXsCjnsi8eSc5PptACCR3dTd7WOVtgIkbSUAZjXn1BbYPOvceWk1o1Bq30ic09mbS0n6cNwsDShfQU+dfUyuCHeqoiG7BfrR/G3o0g5/4m2a4mh2fVQYruzE7KqBWg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773257989; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UoGb0BKqTNLVbqMypWVdpjTUN53yHk/kila/Ec8DzfQ=; b=ed0gTBH8nxGP0nm3tV78LOv//gPqJqMzb9vNZ7SQDCwLNnd4EXbOu14u8FXdcRmLx49PbA22s30Ja+QmTPAwyfCIRO1JriyIFbxiq4D5BeUv3cO0z1eu2FDwBIqA++NUaC51XoNY59KvbLasTtkWDq8OoY2WaaujdOZ3Qemt7eo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773257989606833.4652874486736; Wed, 11 Mar 2026 12:39:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0PLA-0007WQ-5l; Wed, 11 Mar 2026 15:35:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0PKr-0007S0-Gq; Wed, 11 Mar 2026 15:35:15 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0PKp-0008W8-Bq; Wed, 11 Mar 2026 15:35:12 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0B7E61920EB; Wed, 11 Mar 2026 22:34:26 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 4EBD637C450; Wed, 11 Mar 2026 22:35:04 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1773257666; bh=29LT6J/dsLVkqfhdajZM0lyy+YR1nzRrR8wysJ6fTn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wd7JSqXOOYG1PYd9x53fp9gHIhpl/CRjk0S1HoARe5yK/E8a0vGZ8pNH7fix4W9ja HJSXua0S0okME+MeO9gS0VKKr9Z/F1Y45cg42+q7g3sVPTwQl8kxmGpi3P8Moaigg1 3H1QyLBhdT/mVtrTVtwxsW51t1O6CWWdFNGLsgjdjnSkenlJv86fDt2jf/ge7TQelY Z6VUr+f4aqloqwaIn6YUWIyVzEmGi9UYO/YQ3vmOB7rMboTV2aZfEiFKjjzv5C8FmT 9zi6GU6/MChn+kELhUz1C/i1TP9PJI2fHXq569nHLTlrdAwXIIh12pRJbnIrL4qY7W NnBifzkHSAcKQ== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Fiona Ebner , Vladimir Sementsov-Ogievskiy , Michael Tokarev Subject: [Stable-10.2.2 03/53] block/mirror: check range when setting zero bitmap for sync write Date: Wed, 11 Mar 2026 22:33:56 +0300 Message-ID: <20260311193449.1096110-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1773257991579154100 Content-Type: text/plain; charset="utf-8" From: Fiona Ebner Some Proxmox users reported an occasional assertion failure [0][1] in busy VMs when using drive mirror with active mode. In particular, the failure may occur for zero writes shorter than the job granularity: > #0 0x00007b421154b507 in abort () > #1 0x00007b421154b420 in ?? () > #2 0x0000641c582e061f in bitmap_set (map=3D0x7b4204014e00, start=3D14, n= r=3D-1) > #3 0x0000641c58062824 in do_sync_target_write (job=3D0x641c7e73d1e0, > method=3DMIRROR_METHOD_ZERO, offset=3D852480, bytes=3D4096, qiov=3D= 0x0, flags=3D0) > #4 0x0000641c58062250 in bdrv_mirror_top_do_write (bs=3D0x641c7e62e1f0, method=3DMIRROR_METHOD_ZERO, copy_to_target=3Dtrue, offset=3D852480, bytes=3D4096, qiov=3D0x0, flags=3D0) > #5 0x0000641c58061f31 in bdrv_mirror_top_pwrite_zeroes (bs=3D0x641c7e62e= 1f0, offset=3D852480, bytes=3D4096, flags=3D0) The range for the dirty bitmap described by dirty_bitmap_offset and dirty_bitmap_end is narrower than the original range and in fact, dirty_bitmap_end might be smaller than dirty_bitmap_offset. There already is a check for 'dirty_bitmap_offset < dirty_bitmap_end' before resetting the dirty bitmap. Add such a check for setting the zero bitmap too, which uses the same narrower range. [0]: https://forum.proxmox.com/threads/177981/ [1]: https://bugzilla.proxmox.com/show_bug.cgi?id=3D7222 Cc: qemu-stable@nongnu.org Fixes: 7e277545b9 ("mirror: Skip writing zeroes when target is already zero= ") Signed-off-by: Fiona Ebner Message-ID: <20260112152544.261923-1-f.ebner@proxmox.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit 4a7b1bd18d2e1a6b3796e177ae5df9b198264a0b) Signed-off-by: Michael Tokarev diff --git a/block/mirror.c b/block/mirror.c index b344182c74..bc982cb99a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1514,9 +1514,12 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMeth= od method, assert(!qiov); ret =3D blk_co_pwrite_zeroes(job->target, offset, bytes, flags); if (job->zero_bitmap && ret >=3D 0) { - bitmap_set(job->zero_bitmap, dirty_bitmap_offset / job->granul= arity, - (dirty_bitmap_end - dirty_bitmap_offset) / - job->granularity); + if (dirty_bitmap_offset < dirty_bitmap_end) { + bitmap_set(job->zero_bitmap, + dirty_bitmap_offset / job->granularity, + (dirty_bitmap_end - dirty_bitmap_offset) / + job->granularity); + } } break; =20 --=20 2.47.3