io_uring: improve rsrc quiesce refs checks
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 30 Nov 2022 15:21:57 +0000 (15:21 +0000)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Nov 2022 17:29:07 +0000 (10:29 -0700)
Do a little bit of refactoring of io_rsrc_ref_quiesce(), flatten the
data refs checks and so get rid of a conditional weird unlock-else-break
construct.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d21283e9f88a77612c746ed526d86fe3bfb58a70.1669821213.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rsrc.c

index 1336082..b36d325 100644 (file)
@@ -330,17 +330,14 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
                ret = wait_for_completion_interruptible(&data->done);
                if (!ret) {
                        mutex_lock(&ctx->uring_lock);
-                       if (atomic_read(&data->refs) > 0) {
-                               /*
-                                * it has been revived by another thread while
-                                * we were unlocked
-                                */
-                               mutex_unlock(&ctx->uring_lock);
-                       } else {
+                       if (atomic_read(&data->refs) <= 0)
                                break;
-                       }
+                       /*
+                        * it has been revived by another thread while
+                        * we were unlocked
+                        */
+                       mutex_unlock(&ctx->uring_lock);
                }
-
 reinit:
                atomic_inc(&data->refs);
                /* wait for all works potentially completing data->done */