diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-03-29 10:43:56 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-03-29 14:04:28 -0600 |
commit | 3f1d52abf098c85b177b8c6f5b310e8347d1bc42 (patch) | |
tree | eb34c7a4b58acfa4b7c253114aa54a636cea3cba /fs/io_uring.c | |
parent | 9666d4206e9a14ff612e374b6b572b3efc797d46 (diff) | |
download | linux-3f1d52abf098c85b177b8c6f5b310e8347d1bc42.tar.gz linux-3f1d52abf098c85b177b8c6f5b310e8347d1bc42.tar.bz2 linux-3f1d52abf098c85b177b8c6f5b310e8347d1bc42.zip |
io_uring: defer msg-ring file validity check until command issue
In preparation for not using the file at prep time, defer checking if this
file refers to a valid io_uring instance until issue time.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 923410937dc7..3d0dbcd2f69c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4473,9 +4473,6 @@ static int io_msg_ring_prep(struct io_kiocb *req, sqe->splice_fd_in || sqe->buf_index || sqe->personality)) return -EINVAL; - if (req->file->f_op != &io_uring_fops) - return -EBADFD; - req->msg.user_data = READ_ONCE(sqe->off); req->msg.len = READ_ONCE(sqe->len); return 0; @@ -4485,9 +4482,14 @@ static int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags) { struct io_ring_ctx *target_ctx; struct io_msg *msg = &req->msg; - int ret = -EOVERFLOW; bool filled; + int ret; + ret = -EBADFD; + if (req->file->f_op != &io_uring_fops) + goto done; + + ret = -EOVERFLOW; target_ctx = req->file->private_data; spin_lock(&target_ctx->completion_lock); @@ -4500,6 +4502,7 @@ static int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags) ret = 0; } +done: if (ret < 0) req_set_fail(req); __io_req_complete(req, issue_flags, ret, 0); |