Commit 0ced756f authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: improve rsrc quiesce refs checks

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: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d21283e9f88a77612c746ed526d86fe3bfb58a70.1669821213.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 618d653a
...@@ -330,17 +330,14 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data, ...@@ -330,17 +330,14 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
ret = wait_for_completion_interruptible(&data->done); ret = wait_for_completion_interruptible(&data->done);
if (!ret) { if (!ret) {
mutex_lock(&ctx->uring_lock); mutex_lock(&ctx->uring_lock);
if (atomic_read(&data->refs) > 0) { if (atomic_read(&data->refs) <= 0)
/*
* it has been revived by another thread while
* we were unlocked
*/
mutex_unlock(&ctx->uring_lock);
} else {
break; break;
} /*
* it has been revived by another thread while
* we were unlocked
*/
mutex_unlock(&ctx->uring_lock);
} }
reinit: reinit:
atomic_inc(&data->refs); atomic_inc(&data->refs);
/* wait for all works potentially completing data->done */ /* wait for all works potentially completing data->done */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment