public inbox for fio@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@meta.com>
To: <fio@vger.kernel.org>, <vincent.fu@samsung.com>, <axboe@kernel.dk>
Cc: Keith Busch <kbusch@kernel.org>
Subject: [PATCH] engine/io_uring: add write stream support
Date: Wed, 11 Dec 2024 10:44:38 -0800	[thread overview]
Message-ID: <20241211184438.106449-1-kbusch@meta.com> (raw)

From: Keith Busch <kbusch@kernel.org>

Let a user specify a write stream specific to each job. You can check
the block device's max_write_streams sysfs queue attribute for the valid
range of stream values.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
This depends on the kernel side supporting this feature. The latest is
here, which I *think* appears to have stablized on the API.

  https://lore.kernel.org/io-uring/20241210194722.1905732-1-kbusch@meta.com/T/#u

 engines/io_uring.c  | 18 ++++++++++++++++--
 os/linux/io_uring.h |  4 ++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/engines/io_uring.c b/engines/io_uring.c
index facc967f..edb6af37 100644
--- a/engines/io_uring.c
+++ b/engines/io_uring.c
@@ -104,6 +104,7 @@ struct ioring_options {
 	unsigned int hipri;
 	unsigned int readfua;
 	unsigned int writefua;
+	unsigned int write_stream;
 	unsigned int deac;
 	unsigned int write_mode;
 	unsigned int verify_mode;
@@ -174,6 +175,16 @@ static struct fio_option options[] = {
 		.category = FIO_OPT_C_ENGINE,
 		.group	= FIO_OPT_G_IOURING,
 	},
+	{
+		.name	= "write_stream",
+		.lname	= "Tag write commands with this write stream index",
+		.type	= FIO_OPT_INT,
+		.off1	= offsetof(struct ioring_options, write_stream),
+		.def	= "0",
+		.help	= "Tag this job's write commands with the requested write stream (Default: 0)",
+		.category = FIO_OPT_C_ENGINE,
+		.group	= FIO_OPT_G_IOURING,
+	},
 	{
 		.name	= "write_mode",
 		.lname	= "Additional Write commands support (Write Uncorrectable, Write Zeores)",
@@ -434,8 +445,11 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
 		sqe->rw_flags = 0;
 		if (o->nowait)
 			sqe->rw_flags |= RWF_NOWAIT;
-		if (td->o.oatomic && io_u->ddir == DDIR_WRITE)
-			sqe->rw_flags |= RWF_ATOMIC;
+		if (io_u->ddir == DDIR_WRITE) {
+			if (td->o.oatomic)
+				sqe->rw_flags |= RWF_ATOMIC;
+			sqe->write_stream = o->write_stream;
+		}
 
 		/*
 		 * Since io_uring can have a submission context (sqthread_poll)
diff --git a/os/linux/io_uring.h b/os/linux/io_uring.h
index b3876381..8fa3d080 100644
--- a/os/linux/io_uring.h
+++ b/os/linux/io_uring.h
@@ -64,6 +64,10 @@ struct io_uring_sqe {
 	union {
 		__s32	splice_fd_in;
 		__u32	file_index;
+		struct {
+			__u8   write_stream;
+			__u8   __pad4[3];
+		};
 	};
 	union {
 		struct {
-- 
2.43.5


             reply	other threads:[~2024-12-11 18:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-11 18:44 Keith Busch [this message]
2024-12-11 19:10 ` [PATCH] engine/io_uring: add write stream support fiotestbot
2024-12-11 19:11 ` Jens Axboe
2024-12-11 19:43 ` Vincent Fu

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=20241211184438.106449-1-kbusch@meta.com \
    --to=kbusch@meta.com \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=kbusch@kernel.org \
    --cc=vincent.fu@samsung.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