From nobody Tue Feb 10 02:27:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 1767960652417722.2106977922062; Fri, 9 Jan 2026 04:10:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1veBJk-0006DA-Ft; Fri, 09 Jan 2026 07:10:12 -0500 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 1veBIY-0005ap-2u; Fri, 09 Jan 2026 07:09:00 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1veBIW-00018J-GB; Fri, 09 Jan 2026 07:08:57 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 523AA48FB3; Fri, 09 Jan 2026 13:08:43 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, fam@euphon.net, stefanha@redhat.com Subject: [PATCH 6/6] block/io: keep zero flag for head/tail parts of misaligned zero write when possible Date: Fri, 9 Jan 2026 13:08:33 +0100 Message-ID: <20260109120837.2772961-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260109120837.2772961-1-f.ebner@proxmox.com> References: <20260109120837.2772961-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1767960482599 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 (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=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZM-MESSAGEID: 1767960654485158500 Content-Type: text/plain; charset="utf-8" This fixes io-test 179 with qcow2. Otherwise, there would be more 'data' sectors. Signed-off-by: Fiona Ebner --- Not sure if we should even attempt this without considering detect-zeroes. While it does keep 179 working, it is a change in behavior, since it could turn previously data sectors (with zeroes) into zero sectors when they are part of the head or tail of a zero write. Would it even be tolerable from a performance perspective? Remaining test failures after this patch are: 154 177 204 271 177 and 204 use opt-write-zero=3D15M with blkdebug, making an is_power_of_2(align) assertion fail. Changes in the output of 154 and 271 might be expected, but I didn't look into it in detail yet, as I wanted to discuss everything first. block/io.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index d92b30bce5..34b523c951 100644 --- a/block/io.c +++ b/block/io.c @@ -2179,10 +2179,14 @@ bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t o= ffset, int64_t bytes, int64_t write_bytes =3D pad.merge_reads ? pad.buf_len : align; =20 if (total_length >=3D aligned_offset + write_bytes) { + BdrvRequestFlags head_flags =3D + buffer_is_zero(pad.buf, write_bytes) ? + flags : flags & ~BDRV_REQ_ZERO_WRITE; + qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes); ret =3D bdrv_aligned_pwritev(child, req, aligned_offset, write_bytes, align, &local_qiov= , 0, - flags & ~BDRV_REQ_ZERO_WRITE); + head_flags); } else { write_bytes =3D total_length - aligned_offset; qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes); @@ -2220,10 +2224,13 @@ bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t o= ffset, int64_t bytes, if (total_length >=3D offset + align) { assert(align =3D=3D pad.tail + bytes); =20 + BdrvRequestFlags tail_flags =3D + buffer_is_zero(pad.tail_buf + bytes, pad.tail) ? + flags : flags & ~BDRV_REQ_ZERO_WRITE; + qemu_iovec_init_buf(&local_qiov, pad.tail_buf, align); ret =3D bdrv_aligned_pwritev(child, req, offset, align, align, - &local_qiov, 0, - flags & ~BDRV_REQ_ZERO_WRITE); + &local_qiov, 0, tail_flags); } else { int64_t write_bytes =3D total_length - offset; qemu_iovec_init_buf(&local_qiov, pad.tail_buf, write_bytes); --=20 2.47.3