io_uring: poll update test patch poll-multiple
authorJens Axboe <axboe@kernel.dk>
Tue, 6 Apr 2021 15:49:31 +0000 (09:49 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 Apr 2021 15:49:31 +0000 (09:49 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index f94b32b434292d1dfc970c705624dac387163ea0..c210c9cc3feed2c09a32af2b3b0200a5ef326708 100644 (file)
@@ -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;
 }