diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-05-21 10:45:16 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-05-21 10:47:32 -0600 |
commit | 829f6a9a93f99231cf1cda088816cce013ec393c (patch) | |
tree | 279ca85d251172bbe64c7189ab4f47a0014dd0e3 /src | |
parent | ffe3e090cd41d0977ca74fafcb452838f76ceea1 (diff) |
io_uring_submit: fix head/tail wrap issue
Use proper unsigned math to figure out how many entries we have. If
we have head and tail on either side of UINT_MAX, then we currently
don't submit anything as:
while (head < tail) {
is never true.
Reported-by: Weiping Zhang <zhangweiping@didiglobal.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src')
-rw-r--r-- | src/queue.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/queue.c b/src/queue.c index 4b4fea9..5bbb279 100644 --- a/src/queue.c +++ b/src/queue.c @@ -71,7 +71,7 @@ int io_uring_submit(struct io_uring *ring) { struct io_uring_sq *sq = &ring->sq; const unsigned mask = *sq->kring_mask; - unsigned ktail, ktail_next, submitted; + unsigned ktail, ktail_next, submitted, to_submit; int ret; /* @@ -93,7 +93,8 @@ int io_uring_submit(struct io_uring *ring) */ submitted = 0; ktail = ktail_next = *sq->ktail; - while (sq->sqe_head < sq->sqe_tail) { + to_submit = sq->sqe_tail - sq->sqe_head; + while (to_submit--) { ktail_next++; read_barrier(); |