Skip to content

Commit

Permalink
io_uring: fix the sequence comparison in io_sequence_defer
Browse files Browse the repository at this point in the history
sq->cached_sq_head and cq->cached_cq_tail are both unsigned int. If
cached_sq_head overflows before cached_cq_tail, then we may miss a
barrier req. As cached_cq_tail always follows cached_sq_head, the NQ
should be enough.

Cc: stable@vger.kernel.org
Fixes: de0617e ("io_uring: add support for marking commands as draining")
Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Zhengyuan Liu authored and Jens Axboe committed Jul 16, 2019
1 parent 9637d51 commit dbd0f6d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static inline bool io_sequence_defer(struct io_ring_ctx *ctx,
if ((req->flags & (REQ_F_IO_DRAIN|REQ_F_IO_DRAINED)) != REQ_F_IO_DRAIN)
return false;

return req->sequence > ctx->cached_cq_tail + ctx->sq_ring->dropped;
return req->sequence != ctx->cached_cq_tail + ctx->sq_ring->dropped;
}

static struct io_kiocb *io_get_deferred_req(struct io_ring_ctx *ctx)
Expand Down

0 comments on commit dbd0f6d

Please sign in to comment.