}
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;
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;
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);
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);
}
/*
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;
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;