History

io_uring: add io_op_defs 'def' pointer in req init and issue

Define and set it when appropriate, and use it consistently in the function rather than using io_op_defs[opcode].

Jens Axboe committed 4 years ago

Commit fcde59f1 parent 54739cc1 file · +10 −7Browse files

Unified · Split

fs/io_uring.c+10−7
@@ -8301,6 +8301,7 @@ static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags) · 8300 unmodified lines
83018301
83028302 static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
83038303 {
8304+ const struct io_op_def *def = &io_op_defs[req->opcode];
83048305 const struct cred *creds = NULL;
83058306 int ret;
83068307
@@ -8310,7 +8311,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) · 3 unmodified lines
83108311 if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred()))
83118312 creds = override_creds(req->creds);
83128313
8313− if (!io_op_defs[req->opcode].audit_skip)
8314+ if (!def->audit_skip)
83148315 audit_uring_entry(req->opcode);
83158316
83168317 switch (req->opcode) {
@@ -8449,7 +8450,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) · 132 unmodified lines
84498450 break;
84508451 }
84518452
8452− if (!io_op_defs[req->opcode].audit_skip)
8453+ if (!def->audit_skip)
84538454 audit_uring_exit(!ret, ret);
84548455
84558456 if (creds)
@@ -8801,6 +8802,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 345 unmodified lines
88018802 const struct io_uring_sqe *sqe)
88028803 __must_hold(&ctx->uring_lock)
88038804 {
8805+ const struct io_op_def *def;
88048806 unsigned int sqe_flags;
88058807 int personality;
88068808 u8 opcode;
@@ -8818,12 +8820,13 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 11 unmodified lines
88188820 req->opcode = 0;
88198821 return -EINVAL;
88208822 }
8823+ def = &io_op_defs[opcode];
88218824 if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) {
88228825 /* enforce forwards compatibility on users */
88238826 if (sqe_flags & ~SQE_VALID_FLAGS)
88248827 return -EINVAL;
88258828 if (sqe_flags & IOSQE_BUFFER_SELECT) {
8826− if (!io_op_defs[opcode].buffer_select)
8829+ if (!def->buffer_select)
88278830 return -EOPNOTSUPP;
88288831 req->buf_index = READ_ONCE(sqe->buf_group);
88298832 }
@@ -8849,12 +8852,12 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 19 unmodified lines
88498852 }
88508853 }
88518854
8852− if (!io_op_defs[opcode].ioprio && sqe->ioprio)
8855+ if (!def->ioprio && sqe->ioprio)
88538856 return -EINVAL;
8854− if (!io_op_defs[opcode].iopoll && (ctx->flags & IORING_SETUP_IOPOLL))
8857+ if (!def->iopoll && (ctx->flags & IORING_SETUP_IOPOLL))
88558858 return -EINVAL;
88568859
8857− if (io_op_defs[opcode].needs_file) {
8860+ if (def->needs_file) {
88588861 struct io_submit_state *state = &ctx->submit_state;
88598862
88608863 req->cqe.fd = READ_ONCE(sqe->fd);
@@ -8863,7 +8866,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 2 unmodified lines
88638866 * Plug now if we have more than 2 IO left after this, and the
88648867 * target is potentially a read/write to block based storage.
88658868 */
8866− if (state->need_plug && io_op_defs[opcode].plug) {
8869+ if (state->need_plug && def->plug) {
88678870 state->plug_started = true;
88688871 state->need_plug = false;
88698872 blk_start_plug_nr_ios(&state->plug, state->submit_nr);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t