Skip to content

Commit 0a35d16

Browse files
committed
Merge tag 'io_uring-5.19-2022-07-01' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: "Two minor tweaks: - While we still can, adjust the send/recv based flags to be in ->ioprio rather than in ->addr2. This is consistent with eg accept, and also doesn't waste a full 64-bit field for flags (Pavel) - 5.18-stable fix for re-importing provided buffers. Not much real world relevance here as it'll only impact non-pollable files gone async, which is more of a practical test case rather than something that is used in the wild (Dylan)" * tag 'io_uring-5.19-2022-07-01' of git://git.kernel.dk/linux-block: io_uring: fix provided buffer import io_uring: keep sendrecv flags in ioprio
2 parents d516e22 + 09007af commit 0a35d16

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

fs/io_uring.c

Lines changed: 12 additions & 7 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
},
@@ -4314,18 +4318,19 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
43144318
if (unlikely(ret < 0))
43154319
return ret;
43164320
} else {
4321+
rw = req->async_data;
4322+
s = &rw->s;
4323+
43174324
/*
43184325
* Safe and required to re-import if we're using provided
43194326
* buffers, as we dropped the selected one before retry.
43204327
*/
4321-
if (req->flags & REQ_F_BUFFER_SELECT) {
4328+
if (io_do_buffer_select(req)) {
43224329
ret = io_import_iovec(READ, req, &iovec, s, issue_flags);
43234330
if (unlikely(ret < 0))
43244331
return ret;
43254332
}
43264333

4327-
rw = req->async_data;
4328-
s = &rw->s;
43294334
/*
43304335
* We come here from an earlier attempt, restore our state to
43314336
* match in case it doesn't. It's cheap enough that we don't
@@ -6075,12 +6080,12 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
60756080
{
60766081
struct io_sr_msg *sr = &req->sr_msg;
60776082

6078-
if (unlikely(sqe->file_index))
6083+
if (unlikely(sqe->file_index || sqe->addr2))
60796084
return -EINVAL;
60806085

60816086
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
60826087
sr->len = READ_ONCE(sqe->len);
6083-
sr->flags = READ_ONCE(sqe->addr2);
6088+
sr->flags = READ_ONCE(sqe->ioprio);
60846089
if (sr->flags & ~IORING_RECVSEND_POLL_FIRST)
60856090
return -EINVAL;
60866091
sr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;
@@ -6311,12 +6316,12 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
63116316
{
63126317
struct io_sr_msg *sr = &req->sr_msg;
63136318

6314-
if (unlikely(sqe->file_index))
6319+
if (unlikely(sqe->file_index || sqe->addr2))
63156320
return -EINVAL;
63166321

63176322
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
63186323
sr->len = READ_ONCE(sqe->len);
6319-
sr->flags = READ_ONCE(sqe->addr2);
6324+
sr->flags = READ_ONCE(sqe->ioprio);
63206325
if (sr->flags & ~IORING_RECVSEND_POLL_FIRST)
63216326
return -EINVAL;
63226327
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)