Skip to content

Commit eef81fc

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: refactor io_rsrc_ref_quiesce
Refactor io_rsrc_ref_quiesce() by moving the first mutex_unlock(), so we don't have to have a second mutex_unlock() further in the loop. It prepares us to the next patch. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/65bc876271fb16bf550a53a4c76c91aacd94e52e.1681395792.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent c732ea2 commit eef81fc

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

io_uring/rsrc.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
272272
return 0;
273273

274274
data->quiesce = true;
275-
mutex_unlock(&ctx->uring_lock);
276275
do {
276+
mutex_unlock(&ctx->uring_lock);
277277
ret = io_run_task_work_sig(ctx);
278278
if (ret < 0) {
279279
mutex_lock(&ctx->uring_lock);
@@ -285,18 +285,10 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
285285
}
286286
break;
287287
}
288-
ret = wait_for_completion_interruptible(&data->done);
289-
if (!ret) {
290-
mutex_lock(&ctx->uring_lock);
291-
if (!data->refs)
292-
break;
293-
/*
294-
* it has been revived by another thread while
295-
* we were unlocked
296-
*/
297-
mutex_unlock(&ctx->uring_lock);
298-
}
299-
} while (1);
288+
wait_for_completion_interruptible(&data->done);
289+
mutex_lock(&ctx->uring_lock);
290+
ret = 0;
291+
} while (data->refs);
300292
data->quiesce = false;
301293

302294
return ret;

0 commit comments

Comments
 (0)