[PATCH] engine/io_uring: add write stream support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Keith Busch <kbusch@xxxxxxxxxx>

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@xxxxxxxxxx>
---
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@xxxxxxxx/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






[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux