mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 22:50:41 +00:00
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>
This commit is contained in:
parent
edcdfcc149
commit
debb85f496
@ -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,
|
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;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
@ -5254,9 +5254,6 @@ static int io_req_defer_prep(struct io_kiocb *req,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (for_async || (req->flags & REQ_F_WORK_INITIALIZED))
|
|
||||||
io_req_work_grab_env(req);
|
|
||||||
|
|
||||||
switch (req->opcode) {
|
switch (req->opcode) {
|
||||||
case IORING_OP_NOP:
|
case IORING_OP_NOP:
|
||||||
break;
|
break;
|
||||||
@ -5369,9 +5366,10 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
|||||||
if (!req->io) {
|
if (!req->io) {
|
||||||
if (io_alloc_async_ctx(req))
|
if (io_alloc_async_ctx(req))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
ret = io_req_defer_prep(req, sqe, true);
|
ret = io_req_defer_prep(req, sqe);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
io_req_work_grab_env(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irq(&ctx->completion_lock);
|
spin_lock_irq(&ctx->completion_lock);
|
||||||
@ -5983,9 +5981,10 @@ fail_req:
|
|||||||
ret = -EAGAIN;
|
ret = -EAGAIN;
|
||||||
if (io_alloc_async_ctx(req))
|
if (io_alloc_async_ctx(req))
|
||||||
goto fail_req;
|
goto fail_req;
|
||||||
ret = io_req_defer_prep(req, sqe, true);
|
ret = io_req_defer_prep(req, sqe);
|
||||||
if (unlikely(ret < 0))
|
if (unlikely(ret < 0))
|
||||||
goto fail_req;
|
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))
|
if (io_alloc_async_ctx(req))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
ret = io_req_defer_prep(req, sqe, false);
|
ret = io_req_defer_prep(req, sqe);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* fail even hard links since we don't submit */
|
/* fail even hard links since we don't submit */
|
||||||
head->flags |= REQ_F_FAIL_LINK;
|
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))
|
if (io_alloc_async_ctx(req))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
ret = io_req_defer_prep(req, sqe, false);
|
ret = io_req_defer_prep(req, sqe);
|
||||||
if (ret)
|
if (ret)
|
||||||
req->flags |= REQ_F_FAIL_LINK;
|
req->flags |= REQ_F_FAIL_LINK;
|
||||||
*link = req;
|
*link = req;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user