summaryrefslogtreecommitdiffstats
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorJackie Liu <liuyun01@kylinos.cn>2019-09-09 08:50:39 -0400
committerJens Axboe <axboe@kernel.dk>2019-09-09 18:14:47 -0400
commit8776f3fa15a5cd213c4dfab7ddaf557983374ea6 (patch)
treea3844c46ef13328be32e5894046b45fe04a6c2b5 /fs/io_uring.c
parentac90f249e15cd2a850daa9e36e15f81ce1ff6550 (diff)
io_uring: fix wrong sequence setting logic
Sqo_thread will get sqring in batches, which will cause ctx->cached_sq_head to be added in batches. if one of these sqes is set with the DRAIN flag, then he will never get a chance to process, and finally sqo_thread will not exit. Fixes: de0617e4671 ("io_uring: add support for marking commands as draining") Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index be24596e90d7..cf6d807fa414 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -264,6 +264,7 @@ struct io_ring_ctx {
264struct sqe_submit { 264struct sqe_submit {
265 const struct io_uring_sqe *sqe; 265 const struct io_uring_sqe *sqe;
266 unsigned short index; 266 unsigned short index;
267 u32 sequence;
267 bool has_user; 268 bool has_user;
268 bool needs_lock; 269 bool needs_lock;
269 bool needs_fixed_file; 270 bool needs_fixed_file;
@@ -2016,7 +2017,7 @@ static int io_req_set_file(struct io_ring_ctx *ctx, const struct sqe_submit *s,
2016 2017
2017 if (flags & IOSQE_IO_DRAIN) { 2018 if (flags & IOSQE_IO_DRAIN) {
2018 req->flags |= REQ_F_IO_DRAIN; 2019 req->flags |= REQ_F_IO_DRAIN;
2019 req->sequence = ctx->cached_sq_head - 1; 2020 req->sequence = s->sequence;
2020 } 2021 }
2021 2022
2022 if (!io_op_needs_file(s->sqe)) 2023 if (!io_op_needs_file(s->sqe))
@@ -2224,6 +2225,7 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)
2224 if (head < ctx->sq_entries) { 2225 if (head < ctx->sq_entries) {
2225 s->index = head; 2226 s->index = head;
2226 s->sqe = &ctx->sq_sqes[head]; 2227 s->sqe = &ctx->sq_sqes[head];
2228 s->sequence = ctx->cached_sq_head;
2227 ctx->cached_sq_head++; 2229 ctx->cached_sq_head++;
2228 return true; 2230 return true;
2229 } 2231 }