summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-06-29 19:18:42 +0300
committerJens Axboe <axboe@kernel.dk>2020-06-30 08:39:59 -0600
commitdebb85f496c9cc70663eac31d3ad9153839c844c (patch)
tree139cc22b293fa8d4e8ccce72b97c0921350c2752 /fs/io_uring.c
parentedcdfcc149a8d0c11d4dd2b23b5338af22e31a5f (diff)
downloadlwn-debb85f496c9cc70663eac31d3ad9153839c844c.tar.gz
lwn-debb85f496c9cc70663eac31d3ad9153839c844c.zip
io_uring: factor out grab_env() from defer_prep()
Remove io_req_work_grab_env() call from io_req_defer_prep(), just call it when neccessary. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3b2f6fd8f58f..caf908382cdb 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5240,7 +5240,7 @@ static int io_files_update(struct io_kiocb *req, bool force_nonblock,
}
static int io_req_defer_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe, bool for_async)
+ const struct io_uring_sqe *sqe)
{
ssize_t ret = 0;
@@ -5254,9 +5254,6 @@ static int io_req_defer_prep(struct io_kiocb *req,
return ret;
}
- if (for_async || (req->flags & REQ_F_WORK_INITIALIZED))
- io_req_work_grab_env(req);
-
switch (req->opcode) {
case IORING_OP_NOP:
break;
@@ -5369,9 +5366,10 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (!req->io) {
if (io_alloc_async_ctx(req))
return -EAGAIN;
- ret = io_req_defer_prep(req, sqe, true);
+ ret = io_req_defer_prep(req, sqe);
if (ret < 0)
return ret;
+ io_req_work_grab_env(req);
}
spin_lock_irq(&ctx->completion_lock);
@@ -5983,9 +5981,10 @@ fail_req:
ret = -EAGAIN;
if (io_alloc_async_ctx(req))
goto fail_req;
- ret = io_req_defer_prep(req, sqe, true);
+ ret = io_req_defer_prep(req, sqe);
if (unlikely(ret < 0))
goto fail_req;
+ io_req_work_grab_env(req);
}
/*
@@ -6039,7 +6038,7 @@ static int io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (io_alloc_async_ctx(req))
return -EAGAIN;
- ret = io_req_defer_prep(req, sqe, false);
+ ret = io_req_defer_prep(req, sqe);
if (ret) {
/* fail even hard links since we don't submit */
head->flags |= REQ_F_FAIL_LINK;
@@ -6066,7 +6065,7 @@ static int io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (io_alloc_async_ctx(req))
return -EAGAIN;
- ret = io_req_defer_prep(req, sqe, false);
+ ret = io_req_defer_prep(req, sqe);
if (ret)
req->flags |= REQ_F_FAIL_LINK;
*link = req;