Define and set it when appropriate, and use it consistently in the function rather than using io_op_defs[opcode].
Unified · Split
| @@ -8301,6 +8301,7 @@ static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags) · 8300 unmodified lines | ||
| 8301 | 8301 | |
| 8302 | 8302 | static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) |
| 8303 | 8303 | { |
| 8304 | + const struct io_op_def *def = &io_op_defs[req->opcode]; | |
| 8304 | 8305 | const struct cred *creds = NULL; |
| 8305 | 8306 | int ret; |
| 8306 | 8307 | |
| @@ -8310,7 +8311,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) · 3 unmodified lines | ||
| 8310 | 8311 | if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred())) |
| 8311 | 8312 | creds = override_creds(req->creds); |
| 8312 | 8313 | |
| 8313 | − if (!io_op_defs[req->opcode].audit_skip) | |
| 8314 | + if (!def->audit_skip) | |
| 8314 | 8315 | audit_uring_entry(req->opcode); |
| 8315 | 8316 | |
| 8316 | 8317 | switch (req->opcode) { |
| @@ -8449,7 +8450,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) · 132 unmodified lines | ||
| 8449 | 8450 | break; |
| 8450 | 8451 | } |
| 8451 | 8452 | |
| 8452 | − if (!io_op_defs[req->opcode].audit_skip) | |
| 8453 | + if (!def->audit_skip) | |
| 8453 | 8454 | audit_uring_exit(!ret, ret); |
| 8454 | 8455 | |
| 8455 | 8456 | if (creds) |
| @@ -8801,6 +8802,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 345 unmodified lines | ||
| 8801 | 8802 | const struct io_uring_sqe *sqe) |
| 8802 | 8803 | __must_hold(&ctx->uring_lock) |
| 8803 | 8804 | { |
| 8805 | + const struct io_op_def *def; | |
| 8804 | 8806 | unsigned int sqe_flags; |
| 8805 | 8807 | int personality; |
| 8806 | 8808 | u8 opcode; |
| @@ -8818,12 +8820,13 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 11 unmodified lines | ||
| 8818 | 8820 | req->opcode = 0; |
| 8819 | 8821 | return -EINVAL; |
| 8820 | 8822 | } |
| 8823 | + def = &io_op_defs[opcode]; | |
| 8821 | 8824 | if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) { |
| 8822 | 8825 | /* enforce forwards compatibility on users */ |
| 8823 | 8826 | if (sqe_flags & ~SQE_VALID_FLAGS) |
| 8824 | 8827 | return -EINVAL; |
| 8825 | 8828 | if (sqe_flags & IOSQE_BUFFER_SELECT) { |
| 8826 | − if (!io_op_defs[opcode].buffer_select) | |
| 8829 | + if (!def->buffer_select) | |
| 8827 | 8830 | return -EOPNOTSUPP; |
| 8828 | 8831 | req->buf_index = READ_ONCE(sqe->buf_group); |
| 8829 | 8832 | } |
| @@ -8849,12 +8852,12 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 19 unmodified lines | ||
| 8849 | 8852 | } |
| 8850 | 8853 | } |
| 8851 | 8854 | |
| 8852 | − if (!io_op_defs[opcode].ioprio && sqe->ioprio) | |
| 8855 | + if (!def->ioprio && sqe->ioprio) | |
| 8853 | 8856 | return -EINVAL; |
| 8854 | − if (!io_op_defs[opcode].iopoll && (ctx->flags & IORING_SETUP_IOPOLL)) | |
| 8857 | + if (!def->iopoll && (ctx->flags & IORING_SETUP_IOPOLL)) | |
| 8855 | 8858 | return -EINVAL; |
| 8856 | 8859 | |
| 8857 | − if (io_op_defs[opcode].needs_file) { | |
| 8860 | + if (def->needs_file) { | |
| 8858 | 8861 | struct io_submit_state *state = &ctx->submit_state; |
| 8859 | 8862 | |
| 8860 | 8863 | 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 | ||
| 8863 | 8866 | * Plug now if we have more than 2 IO left after this, and the |
| 8864 | 8867 | * target is potentially a read/write to block based storage. |
| 8865 | 8868 | */ |
| 8866 | − if (state->need_plug && io_op_defs[opcode].plug) { | |
| 8869 | + if (state->need_plug && def->plug) { | |
| 8867 | 8870 | state->plug_started = true; |
| 8868 | 8871 | state->need_plug = false; |
| 8869 | 8872 | blk_start_plug_nr_ios(&state->plug, state->submit_nr); |