Skip to contentSkip to conversation

engine/io_uring: add write stream support

PATCH In review Keith Busch 4 participants 4 messages Dec 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 engine/io_uring: add write stream support

From: Keith Busch <[email protected]>

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.

---
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/[email protected]/T/#u

 engines/io_uring.c  | 18 ++++++++++++++++--
 os/linux/io_uring.h |  4 ++++
 2 files changed, 20 insertions(+), 2 deletions(-)
engines/io_uring.c +16 -2
index facc967f..edb6af37 100644
@@ -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)
os/linux/io_uring.h +4 -0
index b3876381..8fa3d080 100644
@@ -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 {
Signature · 1 line
2.43.5
#2 lore raw
In reply to Keith Busch
Quoted 6 lines · Keith Busch

From: Keith Busch <[email protected]>

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.

Quoted 6 lines

---
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/[email protected]/T/#u

Looks fine to me, but let's hold off on the fio side until the kernel changes are at least staged for a kernel.

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Keith Busch
Quoted 6 lines · Keith Busch

From: Keith Busch <[email protected]>

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.

Quoted 6 lines

---
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/[email protected]/T/#u

[sending this again because I forgot to reply all]

Please add documentation for tihs option. Note that the stream_id option already exists for the sg ioengine. Consider using this pre-existing name to limit the growth of fio's already voluminous documentation.

Vincent