All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: qemu-devel@nongnu.org
Cc: Damien Le Moal <dlemoal@kernel.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
	qemu-block@nongnu.org, Sam Li <faithilikerun@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
	Jeuk Kim <jeuk20.kim@samsung.com>,
	Daejun Park <daejun7.park@samsung.com>,
	Niklas Cassel <cassel@kernel.org>
Subject: [PATCH v19 01/11] block: write zeroes to a host managed device through the write path
Date: Fri, 27 Nov 2026 18:10:58 +0100	[thread overview]
Message-ID: <20261127171108.3256778-2-cassel@kernel.org> (raw)
In-Reply-To: <20261127171108.3256778-1-cassel@kernel.org>

On a host managed zoned device, a write zeroes request moves the write
pointer, like a write. For a write zeroes request, however, file-posix
does not update the copy of the write pointer that it keeps for zone
appends, so the next zone append, also after a zero write that
detect-zeroes converts, fails with EIO.

Write the zeroes through the write path of the driver instead, which
updates the write pointer, and extend the zoned test.

Fixes: 4751d09adcc3 ("block: introduce zone append write for zoned devices")
Reported-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 block/io.c                         | 10 +++++++---
 tests/qemu-iotests/tests/zoned     |  9 +++++++++
 tests/qemu-iotests/tests/zoned.out | 12 ++++++++++++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/block/io.c b/block/io.c
index 0f81b7e6bb..7ee5598d43 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1918,15 +1918,19 @@ bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
         }
 
         ret = -ENOTSUP;
-        /* First try the efficient write zeroes operation */
-        if (drv->bdrv_co_pwrite_zeroes) {
+        /*
+         * First try the efficient write zeroes operation, except on a host
+         * managed zoned device, where only the write path checks and moves
+         * the write pointer: there, the zeroes are written as data below.
+         */
+        if (drv->bdrv_co_pwrite_zeroes && bs->bl.zoned != BLK_Z_HM) {
             ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
                                              flags & bs->supported_zero_flags);
             if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
                 !(bs->supported_zero_flags & BDRV_REQ_FUA)) {
                 need_flush = true;
             }
-        } else {
+        } else if (!drv->bdrv_co_pwrite_zeroes) {
             assert(!bs->supported_zero_flags);
         }
 
diff --git a/tests/qemu-iotests/tests/zoned b/tests/qemu-iotests/tests/zoned
index 3d23ce9cc1..c52e1f7fb4 100755
--- a/tests/qemu-iotests/tests/zoned
+++ b/tests/qemu-iotests/tests/zoned
@@ -99,6 +99,15 @@ $QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000"
 echo "After appending the second zone secondly:"
 $QEMU_IO $IMG -c "zrp 268435456 1"
 
+echo
+echo "(7) append write after a zero write"
+$QEMU_IO $IMG -c "write -z 536870912 0x1000" -c "zap -p 536870912 0x1000" \
+    -c "zrp 536870912 1" | _filter_qemu_io
+echo
+echo "(8) append write after a zero write with detect-zeroes"
+$QEMU_IO $IMG,detect-zeroes=on -c "write -P 0 805306368 0x1000" \
+    -c "zap -p 805306368 0x1000" -c "zrp 805306368 1" | _filter_qemu_io
+
 # success, all done
 echo "*** done"
 rm -f $seq.full
diff --git a/tests/qemu-iotests/tests/zoned.out b/tests/qemu-iotests/tests/zoned.out
index fe53ba4744..8a64676e38 100644
--- a/tests/qemu-iotests/tests/zoned.out
+++ b/tests/qemu-iotests/tests/zoned.out
@@ -66,4 +66,16 @@ start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80018, zcond:2, [type: 2]
 After zap done, the append sector is 0x80018
 After appending the second zone secondly:
 start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80030, zcond:2, [type: 2]
+
+(7) append write after a zero write
+wrote 4096/4096 bytes at offset 536870912
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+After zap done, the append sector is 0x100008
+start: 0x100000, len 0x80000, cap 0x80000, wptr 0x100010, zcond:2, [type: 2]
+
+(8) append write after a zero write with detect-zeroes
+wrote 4096/4096 bytes at offset 805306368
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+After zap done, the append sector is 0x180008
+start: 0x180000, len 0x80000, cap 0x80000, wptr 0x180010, zcond:2, [type: 2]
 *** done
-- 
2.56.1



  reply	other threads:[~2026-11-27 17:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 17:10 [PATCH v19 00/11] Add full zoned storage emulation to the qcow2 driver Niklas Cassel
2026-11-27 17:10 ` Niklas Cassel [this message]
2026-11-27 17:10 ` [PATCH v19 02/11] docs/qcow2: add the zoned format feature Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 03/11] qcow2: add configurations for zoned format extension Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 04/11] block: define errnos for zone protocol errors Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 05/11] qcow2: do not flush when a cache dependency is already set Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 06/11] qcow2: add zoned emulation capability Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 07/11] iotests: test the zoned format feature for qcow2 file Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 08/11] qcow2: validate the write pointer table when opening an image Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 09/11] virtio-blk: report zone errors with their zone status codes Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 10/11] block: add accessors for the zone model, capacity and open zone limit Niklas Cassel
2026-11-27 17:11 ` [PATCH v19 11/11] scsi: add the sense codes of zoned block devices Niklas Cassel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127171108.3256778-2-cassel@kernel.org \
    --to=cassel@kernel.org \
    --cc=armbru@redhat.com \
    --cc=daejun7.park@samsung.com \
    --cc=dlemoal@kernel.org \
    --cc=eblake@redhat.com \
    --cc=faithilikerun@gmail.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.