diff --git a/fs/io_uring.c b/fs/io_uring.c index 76be27600631503769c53d9bd322b6afdba5edb0..0ffa8537c36a29b9324fc843f9362992aa313c06 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4827,8 +4827,11 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr, break; } - if (submitted != nr) - percpu_ref_put_many(&ctx->refs, nr - submitted); + if (unlikely(submitted != nr)) { + int ref_used = (submitted == -EAGAIN) ? 0 : submitted; + + percpu_ref_put_many(&ctx->refs, nr - ref_used); + } if (link) io_queue_link_head(link); if (statep)