From: Jens Axboe Date: Tue, 6 Apr 2021 15:49:31 +0000 (-0600) Subject: io_uring: poll update test patch X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=refs%2Fheads%2Fpoll-multiple;p=linux-2.6-block.git io_uring: poll update test patch Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index f94b32b43429..c210c9cc3fee 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5413,6 +5413,7 @@ static int io_poll_update(struct io_kiocb *req) { struct io_ring_ctx *ctx = req->ctx; struct io_kiocb *preq; + bool completing; int ret; spin_lock_irq(&ctx->completion_lock); @@ -5425,7 +5426,8 @@ static int io_poll_update(struct io_kiocb *req) ret = -EACCES; goto err; } - if (!__io_poll_remove_one(preq, &preq->poll, false)) { + completing = !__io_poll_remove_one(preq, &preq->poll, false); + if (completing) { if (preq->poll.events & EPOLLONESHOT) { ret = -EALREADY; goto err; @@ -5452,10 +5454,12 @@ err: /* complete update request, we're done with it */ io_req_complete(req, ret); - ret = __io_poll_add(preq); - if (ret < 0) { - req_set_fail_links(preq); - io_req_complete(preq, ret); + if (!completing) { + ret = __io_poll_add(preq); + if (ret < 0) { + req_set_fail_links(preq); + io_req_complete(preq, ret); + } } return 0; }