Skip to content

Commit 63f93fd

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: mark blk_put_queue as potentially blocking
We can't just say that the last reference release may block, as any reference dropped could be the last one. So move the might_sleep() from blk_free_queue to blk_put_queue and update the documentation. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20221114042637.1009333-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2bd8522 commit 63f93fd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

block/blk-core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)
260260

261261
static void blk_free_queue(struct request_queue *q)
262262
{
263-
might_sleep();
264-
265263
percpu_ref_exit(&q->q_usage_counter);
266264

267265
if (q->poll_stat)
@@ -285,11 +283,11 @@ static void blk_free_queue(struct request_queue *q)
285283
* Decrements the refcount of the request_queue and free it when the refcount
286284
* reaches 0.
287285
*
288-
* Context: Any context, but the last reference must not be dropped from
289-
* atomic context.
286+
* Context: Can sleep.
290287
*/
291288
void blk_put_queue(struct request_queue *q)
292289
{
290+
might_sleep();
293291
if (refcount_dec_and_test(&q->refs))
294292
blk_free_queue(q);
295293
}

0 commit comments

Comments
 (0)