From cbc3bdf074aeb6d056297f50f2b3d96b8a64b282 Mon Sep 17 00:00:00 2001 From: Kanchan Joshi Date: Fri, 8 Nov 2024 11:36:26 -0800 Subject: [PATCH] io_uring: enable passing a per-io write stream Allow userspace to pass a per-I/O write stream in the SQE: __u16 write_stream; Application can query the supported values from the statx max_write_streams field. Unsupported values are ignored by file operations that do not support write streams or rejected with an error by those that support them. Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Keith Busch [hch: s/write_hints/write_streams/g] Signed-off-by: Christoph Hellwig --- include/uapi/linux/io_uring.h | 4 ++++ io_uring/io_uring.c | 2 ++ io_uring/rw.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index aac9a4f8fa9a..7a6a1b3726d3 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -98,6 +98,10 @@ struct io_uring_sqe { __u64 addr3; __u64 __pad2[1]; }; + struct { + __u64 __pad4[1]; + __u16 write_stream; + }; __u64 optval; /* * If the ring is initialized with IORING_SETUP_SQE128, then diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index da8fd460977b..a54da2dd83a1 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3868,6 +3868,8 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); BUILD_BUG_SQE_ELEM(48, __u64, addr3); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); + BUILD_BUG_SQE_ELEM(48, __u64, __pad4); + BUILD_BUG_SQE_ELEM(56, __u16, write_stream); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); BUILD_BUG_ON(sizeof(struct io_uring_files_update) != diff --git a/io_uring/rw.c b/io_uring/rw.c index cce8bc2ecd3f..88a5b5f65a9b 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -279,7 +279,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, rw->kiocb.ki_ioprio = get_current_ioprio(); } rw->kiocb.dio_complete = NULL; - + rw->kiocb.ki_write_stream = READ_ONCE(sqe->write_stream); rw->addr = READ_ONCE(sqe->addr); rw->len = READ_ONCE(sqe->len); rw->flags = READ_ONCE(sqe->rw_flags); -- 2.50.1