io_uring: enable per-io write streams
authorKeith Busch <kbusch@kernel.org>
Tue, 6 May 2025 12:17:27 +0000 (17:47 +0530)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 May 2025 13:46:43 +0000 (07:46 -0600)
Allow userspace to pass a per-I/O write stream in the SQE:

      __u8 write_stream;

The __u8 type matches the size the filesystems and block layer support.

Application can query the supported values from the block devices
max_write_streams sysfs attribute. Unsupported values are ignored by
file operations that do not support write streams or rejected with an
error by those that support them.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20250506121732.8211-7-joshi.k@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/io_uring.h
io_uring/io_uring.c
io_uring/rw.c

index 8f1fc12bac4620b9b40728cdd9baa2243e3cafd7..50e372ea97c549dc56cc29aecfa3a3f3ce94b97d 100644 (file)
@@ -93,6 +93,10 @@ struct io_uring_sqe {
                        __u16   addr_len;
                        __u16   __pad3[1];
                };
+               struct {
+                       __u8    write_stream;
+                       __u8    __pad4[3];
+               };
        };
        union {
                struct {
index c6209fe44cb175c02687d6b734542c4aacf74d16..479205df3485807002aca99bd195e5c819e55358 100644 (file)
@@ -3919,6 +3919,8 @@ static int __init io_uring_init(void)
        BUILD_BUG_SQE_ELEM(44, __s32,  splice_fd_in);
        BUILD_BUG_SQE_ELEM(44, __u32,  file_index);
        BUILD_BUG_SQE_ELEM(44, __u16,  addr_len);
+       BUILD_BUG_SQE_ELEM(44, __u8,   write_stream);
+       BUILD_BUG_SQE_ELEM(45, __u8,   __pad4[0]);
        BUILD_BUG_SQE_ELEM(46, __u16,  __pad3[0]);
        BUILD_BUG_SQE_ELEM(48, __u64,  addr3);
        BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd);
index 039e063f7091ebb8c3ac2e1412785747ceadf208..b8389674a747fc0b476c2ee378200cde928a95c8 100644 (file)
@@ -276,6 +276,7 @@ static int __io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
        }
        rw->kiocb.dio_complete = NULL;
        rw->kiocb.ki_flags = 0;
+       rw->kiocb.ki_write_stream = READ_ONCE(sqe->write_stream);
 
        if (req->ctx->flags & IORING_SETUP_IOPOLL)
                rw->kiocb.ki_complete = io_complete_rw_iopoll;