Commit ba5290cc authored by Jackie Liu's avatar Jackie Liu Committed by Jens Axboe

io_uring: replace s->needs_lock with s->in_async

There is no function change, just to clean up the code, use s->in_async
to make the code know where it is.
Signed-off-by: default avatarJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 33a107f0
...@@ -271,7 +271,7 @@ struct sqe_submit { ...@@ -271,7 +271,7 @@ struct sqe_submit {
unsigned short index; unsigned short index;
u32 sequence; u32 sequence;
bool has_user; bool has_user;
bool needs_lock; bool in_async;
bool needs_fixed_file; bool needs_fixed_file;
}; };
...@@ -1474,13 +1474,9 @@ static int io_read(struct io_kiocb *req, const struct sqe_submit *s, ...@@ -1474,13 +1474,9 @@ static int io_read(struct io_kiocb *req, const struct sqe_submit *s,
ret2 = -EAGAIN; ret2 = -EAGAIN;
/* Catch -EAGAIN return for forced non-blocking submission */ /* Catch -EAGAIN return for forced non-blocking submission */
if (!force_nonblock || ret2 != -EAGAIN) { if (!force_nonblock || ret2 != -EAGAIN) {
kiocb_done(kiocb, ret2, nxt, s->needs_lock); kiocb_done(kiocb, ret2, nxt, s->in_async);
} else { } else {
/* if (!s->in_async)
* If ->needs_lock is true, we're already in async
* context.
*/
if (!s->needs_lock)
io_async_list_note(READ, req, iov_count); io_async_list_note(READ, req, iov_count);
ret = -EAGAIN; ret = -EAGAIN;
} }
...@@ -1518,8 +1514,7 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s, ...@@ -1518,8 +1514,7 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s,
ret = -EAGAIN; ret = -EAGAIN;
if (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT)) { if (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT)) {
/* If ->needs_lock is true, we're already in async context. */ if (!s->in_async)
if (!s->needs_lock)
io_async_list_note(WRITE, req, iov_count); io_async_list_note(WRITE, req, iov_count);
goto out_free; goto out_free;
} }
...@@ -1548,13 +1543,9 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s, ...@@ -1548,13 +1543,9 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s,
else else
ret2 = loop_rw_iter(WRITE, file, kiocb, &iter); ret2 = loop_rw_iter(WRITE, file, kiocb, &iter);
if (!force_nonblock || ret2 != -EAGAIN) { if (!force_nonblock || ret2 != -EAGAIN) {
kiocb_done(kiocb, ret2, nxt, s->needs_lock); kiocb_done(kiocb, ret2, nxt, s->in_async);
} else { } else {
/* if (!s->in_async)
* If ->needs_lock is true, we're already in async
* context.
*/
if (!s->needs_lock)
io_async_list_note(WRITE, req, iov_count); io_async_list_note(WRITE, req, iov_count);
ret = -EAGAIN; ret = -EAGAIN;
} }
...@@ -2152,10 +2143,10 @@ static int __io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -2152,10 +2143,10 @@ static int __io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
return -EAGAIN; return -EAGAIN;
/* workqueue context doesn't hold uring_lock, grab it now */ /* workqueue context doesn't hold uring_lock, grab it now */
if (s->needs_lock) if (s->in_async)
mutex_lock(&ctx->uring_lock); mutex_lock(&ctx->uring_lock);
io_iopoll_req_issued(req); io_iopoll_req_issued(req);
if (s->needs_lock) if (s->in_async)
mutex_unlock(&ctx->uring_lock); mutex_unlock(&ctx->uring_lock);
} }
...@@ -2220,7 +2211,7 @@ static void io_sq_wq_submit_work(struct work_struct *work) ...@@ -2220,7 +2211,7 @@ static void io_sq_wq_submit_work(struct work_struct *work)
if (!ret) { if (!ret) {
s->has_user = cur_mm != NULL; s->has_user = cur_mm != NULL;
s->needs_lock = true; s->in_async = true;
do { do {
ret = __io_submit_sqe(ctx, req, s, &nxt, false); ret = __io_submit_sqe(ctx, req, s, &nxt, false);
/* /*
...@@ -2696,7 +2687,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr, ...@@ -2696,7 +2687,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
-EFAULT); -EFAULT);
} else { } else {
s.has_user = has_user; s.has_user = has_user;
s.needs_lock = true; s.in_async = true;
s.needs_fixed_file = true; s.needs_fixed_file = true;
io_submit_sqe(ctx, &s, statep, &link); io_submit_sqe(ctx, &s, statep, &link);
submitted++; submitted++;
...@@ -2883,7 +2874,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit) ...@@ -2883,7 +2874,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
out: out:
s.has_user = true; s.has_user = true;
s.needs_lock = false; s.in_async = false;
s.needs_fixed_file = false; s.needs_fixed_file = false;
submit++; submit++;
io_submit_sqe(ctx, &s, statep, &link); io_submit_sqe(ctx, &s, statep, &link);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment