Skip to content

Commit 29c1ac2

Browse files
isilenceaxboe
authored andcommitted
io_uring: keep sendrecv flags in ioprio
We waste a u64 SQE field for flags even though we don't need as many bits and it can be used for something more useful later. Store io_uring specific send/recv flags in sqe->ioprio instead of ->addr2. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Fixes: 0455d4c ("io_uring: add POLL_FIRST support for send/sendmsg and recv/recvmsg") [axboe: change comment in io_uring.h as well] Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 386e4fb commit 29c1ac2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

fs/io_uring.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@ static const struct io_op_def io_op_defs[] = {
11831183
.unbound_nonreg_file = 1,
11841184
.pollout = 1,
11851185
.needs_async_setup = 1,
1186+
.ioprio = 1,
11861187
.async_size = sizeof(struct io_async_msghdr),
11871188
},
11881189
[IORING_OP_RECVMSG] = {
@@ -1191,6 +1192,7 @@ static const struct io_op_def io_op_defs[] = {
11911192
.pollin = 1,
11921193
.buffer_select = 1,
11931194
.needs_async_setup = 1,
1195+
.ioprio = 1,
11941196
.async_size = sizeof(struct io_async_msghdr),
11951197
},
11961198
[IORING_OP_TIMEOUT] = {
@@ -1266,13 +1268,15 @@ static const struct io_op_def io_op_defs[] = {
12661268
.unbound_nonreg_file = 1,
12671269
.pollout = 1,
12681270
.audit_skip = 1,
1271+
.ioprio = 1,
12691272
},
12701273
[IORING_OP_RECV] = {
12711274
.needs_file = 1,
12721275
.unbound_nonreg_file = 1,
12731276
.pollin = 1,
12741277
.buffer_select = 1,
12751278
.audit_skip = 1,
1279+
.ioprio = 1,
12761280
},
12771281
[IORING_OP_OPENAT2] = {
12781282
},
@@ -6075,12 +6079,12 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
60756079
{
60766080
struct io_sr_msg *sr = &req->sr_msg;
60776081

6078-
if (unlikely(sqe->file_index))
6082+
if (unlikely(sqe->file_index || sqe->addr2))
60796083
return -EINVAL;
60806084

60816085
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
60826086
sr->len = READ_ONCE(sqe->len);
6083-
sr->flags = READ_ONCE(sqe->addr2);
6087+
sr->flags = READ_ONCE(sqe->ioprio);
60846088
if (sr->flags & ~IORING_RECVSEND_POLL_FIRST)
60856089
return -EINVAL;
60866090
sr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;
@@ -6311,12 +6315,12 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
63116315
{
63126316
struct io_sr_msg *sr = &req->sr_msg;
63136317

6314-
if (unlikely(sqe->file_index))
6318+
if (unlikely(sqe->file_index || sqe->addr2))
63156319
return -EINVAL;
63166320

63176321
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
63186322
sr->len = READ_ONCE(sqe->len);
6319-
sr->flags = READ_ONCE(sqe->addr2);
6323+
sr->flags = READ_ONCE(sqe->ioprio);
63206324
if (sr->flags & ~IORING_RECVSEND_POLL_FIRST)
63216325
return -EINVAL;
63226326
sr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;

include/uapi/linux/io_uring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ enum io_uring_op {
244244
#define IORING_ASYNC_CANCEL_ANY (1U << 2)
245245

246246
/*
247-
* send/sendmsg and recv/recvmsg flags (sqe->addr2)
247+
* send/sendmsg and recv/recvmsg flags (sqe->ioprio)
248248
*
249249
* IORING_RECVSEND_POLL_FIRST If set, instead of first attempting to send
250250
* or receive and arm poll if that yields an

0 commit comments

Comments
 (0)