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 | static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) | 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 | const struct cred *creds = NULL; | 8305 | const struct cred *creds = NULL; |
| 8305 | int ret; | 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 | if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred())) | 8311 | if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred())) |
| 8311 | creds = override_creds(req->creds); | 8312 | creds = override_creds(req->creds); |
| 8312 | 8313 | ||
| 8313 | if (!io_op_defs[req->opcode].audit_skip) | 8314 | if (!def->audit_skip) |
| 8314 | audit_uring_entry(req->opcode); | 8315 | audit_uring_entry(req->opcode); |
| 8315 | 8316 | ||
| 8316 | switch (req->opcode) { | 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 | break; | 8450 | break; |
| 8450 | } | 8451 | } |
| 8451 | 8452 | ||
| 8452 | if (!io_op_defs[req->opcode].audit_skip) | 8453 | if (!def->audit_skip) |
| 8453 | audit_uring_exit(!ret, ret); | 8454 | audit_uring_exit(!ret, ret); |
| 8454 | 8455 | ||
| 8455 | if (creds) | 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 | const struct io_uring_sqe *sqe) | 8802 | const struct io_uring_sqe *sqe) |
| 8802 | __must_hold(&ctx->uring_lock) | 8803 | __must_hold(&ctx->uring_lock) |
| 8803 | { | 8804 | { |
| 8805 | const struct io_op_def *def; | ||
| 8804 | unsigned int sqe_flags; | 8806 | unsigned int sqe_flags; |
| 8805 | int personality; | 8807 | int personality; |
| 8806 | u8 opcode; | 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 | req->opcode = 0; | 8820 | req->opcode = 0; |
| 8819 | return -EINVAL; | 8821 | return -EINVAL; |
| 8820 | } | 8822 | } |
| 8823 | def = &io_op_defs[opcode]; | ||
| 8821 | if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) { | 8824 | if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) { |
| 8822 | /* enforce forwards compatibility on users */ | 8825 | /* enforce forwards compatibility on users */ |
| 8823 | if (sqe_flags & ~SQE_VALID_FLAGS) | 8826 | if (sqe_flags & ~SQE_VALID_FLAGS) |
| 8824 | return -EINVAL; | 8827 | return -EINVAL; |
| 8825 | if (sqe_flags & IOSQE_BUFFER_SELECT) { | 8828 | if (sqe_flags & IOSQE_BUFFER_SELECT) { |
| 8826 | if (!io_op_defs[opcode].buffer_select) | 8829 | if (!def->buffer_select) |
| 8827 | return -EOPNOTSUPP; | 8830 | return -EOPNOTSUPP; |
| 8828 | req->buf_index = READ_ONCE(sqe->buf_group); | 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 | return -EINVAL; | 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 | return -EINVAL; | 8858 | return -EINVAL; |
| 8856 | 8859 | ||
| 8857 | if (io_op_defs[opcode].needs_file) { | 8860 | if (def->needs_file) { |
| 8858 | struct io_submit_state *state = &ctx->submit_state; | 8861 | struct io_submit_state *state = &ctx->submit_state; |
| 8859 | 8862 | ||
| 8860 | req->cqe.fd = READ_ONCE(sqe->fd); | 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 | * Plug now if we have more than 2 IO left after this, and the | 8866 | * Plug now if we have more than 2 IO left after this, and the |
| 8864 | * target is potentially a read/write to block based storage. | 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 | state->plug_started = true; | 8870 | state->plug_started = true; |
| 8868 | state->need_plug = false; | 8871 | state->need_plug = false; |
| 8869 | blk_start_plug_nr_ios(&state->plug, state->submit_nr); | 8872 | blk_start_plug_nr_ios(&state->plug, state->submit_nr); |