From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <rth@twiddle.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Julia Suvorova" <jusual@redhat.com>,
"Aarushi Mehta" <mehta.aaru20@gmail.com>,
"Kevin Wolf" <kwolf@redhat.com>,
kvm@vger.kernel.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Hanna Reitz" <hreitz@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Fam Zheng" <fam@euphon.net>, "Sam Li" <faithilikerun@gmail.com>
Subject: [PULL v2 11/16] qemu-iotests: test zone append operation
Date: Mon, 15 May 2023 12:05:01 -0400 [thread overview]
Message-ID: <20230515160506.1776883-12-stefanha@redhat.com> (raw)
In-Reply-To: <20230515160506.1776883-1-stefanha@redhat.com>
From: Sam Li <faithilikerun@gmail.com>
The patch tests zone append writes by reporting the zone wp after
the completion of the call. "zap -p" option can print the sector
offset value after completion, which should be the start sector
where the append write begins.
Signed-off-by: Sam Li <faithilikerun@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20230508051510.177850-4-faithilikerun@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
qemu-io-cmds.c | 75 ++++++++++++++++++++++++++++++
tests/qemu-iotests/tests/zoned | 16 +++++++
tests/qemu-iotests/tests/zoned.out | 16 +++++++
3 files changed, 107 insertions(+)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index f35ea627d7..3f75d2f5a6 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1874,6 +1874,80 @@ static const cmdinfo_t zone_reset_cmd = {
.oneline = "reset a zone write pointer in zone block device",
};
+static int do_aio_zone_append(BlockBackend *blk, QEMUIOVector *qiov,
+ int64_t *offset, int flags, int *total)
+{
+ int async_ret = NOT_DONE;
+
+ blk_aio_zone_append(blk, offset, qiov, flags, aio_rw_done, &async_ret);
+ while (async_ret == NOT_DONE) {
+ main_loop_wait(false);
+ }
+
+ *total = qiov->size;
+ return async_ret < 0 ? async_ret : 1;
+}
+
+static int zone_append_f(BlockBackend *blk, int argc, char **argv)
+{
+ int ret;
+ bool pflag = false;
+ int flags = 0;
+ int total = 0;
+ int64_t offset;
+ char *buf;
+ int c, nr_iov;
+ int pattern = 0xcd;
+ QEMUIOVector qiov;
+
+ if (optind > argc - 3) {
+ return -EINVAL;
+ }
+
+ if ((c = getopt(argc, argv, "p")) != -1) {
+ pflag = true;
+ }
+
+ offset = cvtnum(argv[optind]);
+ if (offset < 0) {
+ print_cvtnum_err(offset, argv[optind]);
+ return offset;
+ }
+ optind++;
+ nr_iov = argc - optind;
+ buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern,
+ flags & BDRV_REQ_REGISTERED_BUF);
+ if (buf == NULL) {
+ return -EINVAL;
+ }
+ ret = do_aio_zone_append(blk, &qiov, &offset, flags, &total);
+ if (ret < 0) {
+ printf("zone append failed: %s\n", strerror(-ret));
+ goto out;
+ }
+
+ if (pflag) {
+ printf("After zap done, the append sector is 0x%" PRIx64 "\n",
+ tosector(offset));
+ }
+
+out:
+ qemu_io_free(blk, buf, qiov.size,
+ flags & BDRV_REQ_REGISTERED_BUF);
+ qemu_iovec_destroy(&qiov);
+ return ret;
+}
+
+static const cmdinfo_t zone_append_cmd = {
+ .name = "zone_append",
+ .altname = "zap",
+ .cfunc = zone_append_f,
+ .argmin = 3,
+ .argmax = 4,
+ .args = "offset len [len..]",
+ .oneline = "append write a number of bytes at a specified offset",
+};
+
static int truncate_f(BlockBackend *blk, int argc, char **argv);
static const cmdinfo_t truncate_cmd = {
.name = "truncate",
@@ -2672,6 +2746,7 @@ static void __attribute((constructor)) init_qemuio_commands(void)
qemuio_add_command(&zone_close_cmd);
qemuio_add_command(&zone_finish_cmd);
qemuio_add_command(&zone_reset_cmd);
+ qemuio_add_command(&zone_append_cmd);
qemuio_add_command(&truncate_cmd);
qemuio_add_command(&length_cmd);
qemuio_add_command(&info_cmd);
diff --git a/tests/qemu-iotests/tests/zoned b/tests/qemu-iotests/tests/zoned
index 56f60616b5..3d23ce9cc1 100755
--- a/tests/qemu-iotests/tests/zoned
+++ b/tests/qemu-iotests/tests/zoned
@@ -82,6 +82,22 @@ echo "(5) resetting the second zone"
$QEMU_IO $IMG -c "zrs 268435456 268435456"
echo "After resetting a zone:"
$QEMU_IO $IMG -c "zrp 268435456 1"
+echo
+echo
+echo "(6) append write" # the physical block size of the device is 4096
+$QEMU_IO $IMG -c "zrp 0 1"
+$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000"
+echo "After appending the first zone firstly:"
+$QEMU_IO $IMG -c "zrp 0 1"
+$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000"
+echo "After appending the first zone secondly:"
+$QEMU_IO $IMG -c "zrp 0 1"
+$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000"
+echo "After appending the second zone firstly:"
+$QEMU_IO $IMG -c "zrp 268435456 1"
+$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000"
+echo "After appending the second zone secondly:"
+$QEMU_IO $IMG -c "zrp 268435456 1"
# success, all done
echo "*** done"
diff --git a/tests/qemu-iotests/tests/zoned.out b/tests/qemu-iotests/tests/zoned.out
index b2d061da49..fe53ba4744 100644
--- a/tests/qemu-iotests/tests/zoned.out
+++ b/tests/qemu-iotests/tests/zoned.out
@@ -50,4 +50,20 @@ start: 0x80000, len 0x80000, cap 0x80000, wptr 0x100000, zcond:14, [type: 2]
(5) resetting the second zone
After resetting a zone:
start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80000, zcond:1, [type: 2]
+
+
+(6) append write
+start: 0x0, len 0x80000, cap 0x80000, wptr 0x0, zcond:1, [type: 2]
+After zap done, the append sector is 0x0
+After appending the first zone firstly:
+start: 0x0, len 0x80000, cap 0x80000, wptr 0x18, zcond:2, [type: 2]
+After zap done, the append sector is 0x18
+After appending the first zone secondly:
+start: 0x0, len 0x80000, cap 0x80000, wptr 0x30, zcond:2, [type: 2]
+After zap done, the append sector is 0x80000
+After appending the second zone firstly:
+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]
*** done
--
2.40.1
next prev parent reply other threads:[~2023-05-15 16:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 16:04 [PULL v2 00/16] Block patches Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 01/16] block/block-common: add zoned device structs Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 02/16] block/file-posix: introduce helper functions for sysfs attributes Stefan Hajnoczi
[not found] ` <8b0ced3c-2fb5-2479-fe78-f4956ac037a6@linux.ibm.com>
2023-06-02 18:18 ` Sam Li
2023-06-02 18:41 ` Matthew Rosato
2023-06-02 18:45 ` Sam Li
2023-05-15 16:04 ` [PULL v2 03/16] block/block-backend: add block layer APIs resembling Linux ZonedBlockDevice ioctls Stefan Hajnoczi
2024-05-03 12:33 ` Peter Maydell
2024-05-07 15:09 ` Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 04/16] block/raw-format: add zone operations to pass through requests Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 05/16] block: add zoned BlockDriver check to block layer Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 06/16] iotests: test new zone operations Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 07/16] block: add some trace events for new block layer APIs Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 08/16] docs/zoned-storage: add zoned device documentation Stefan Hajnoczi
2023-05-15 16:04 ` [PULL v2 09/16] file-posix: add tracking of the zone write pointers Stefan Hajnoczi
2023-05-15 16:05 ` [PULL v2 10/16] block: introduce zone append write for zoned devices Stefan Hajnoczi
2023-05-15 16:05 ` Stefan Hajnoczi [this message]
2023-05-15 16:05 ` [PULL v2 12/16] block: add some trace events for zone append Stefan Hajnoczi
2023-05-15 16:05 ` [PULL v2 13/16] virtio-blk: add zoned storage emulation for zoned devices Stefan Hajnoczi
2023-05-15 16:05 ` [PULL v2 14/16] block: add accounting for zone append operation Stefan Hajnoczi
2023-05-15 16:05 ` [PULL v2 15/16] virtio-blk: add some trace events for zoned emulation Stefan Hajnoczi
2023-05-15 16:05 ` [PULL v2 16/16] docs/zoned-storage:add zoned emulation use case Stefan Hajnoczi
2023-05-15 23:37 ` [PULL v2 00/16] Block patches Richard Henderson
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=20230515160506.1776883-12-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=cohuck@redhat.com \
--cc=eblake@redhat.com \
--cc=faithilikerun@gmail.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jusual@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mehta.aaru20@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=raphael.norwitz@nutanix.com \
--cc=rth@twiddle.net \
--cc=sgarzare@redhat.com \
--cc=thuth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).