io_uring: fix ctx refcounting in io_submit_sqes()
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 5 Apr 2020 21:08:52 +0000 (00:08 +0300)
committerJens Axboe <axboe@kernel.dk>
Sun, 5 Apr 2020 22:23:48 +0000 (16:23 -0600)
If io_get_req() fails, it drops a ref. Then, awhile keeping @submitted
unmodified, io_submit_sqes() breaks the loop and puts @nr - @submitted
refs. For each submitted req a ref is dropped in io_put_req() and
friends. So, for @nr taken refs there will be
(@nr - @submitted + @submitted + 1) dropped.

Remove ctx refcounting from io_get_req(), that at the same time makes
it clearer.

Fixes: 2b85edfc0c90 ("io_uring: batch getting pcpu references")
Cc: stable@vger.kernel.org # v5.6
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 78ae8e8..79bd222 100644 (file)
@@ -1342,7 +1342,6 @@ fallback:
        req = io_get_fallback_req(ctx);
        if (req)
                goto got_it;
-       percpu_ref_put(&ctx->refs);
        return NULL;
 }