]> www.infradead.org Git - users/hch/block.git/commitdiff
block: mark blk_put_queue as potentially blocking block-queue-kobj
authorChristoph Hellwig <hch@lst.de>
Sat, 5 Nov 2022 08:07:36 +0000 (09:07 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 10 Nov 2022 11:02:47 +0000 (12:02 +0100)
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>
block/blk-core.c

index d14317bfdf654a5413d72514e5aa9d273abbc2bd..8ab21dd01cd1c1951db119e67c6d4fffb9143e0e 100644 (file)
@@ -260,8 +260,6 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)
 
 static void blk_free_queue(struct request_queue *q)
 {
-       might_sleep();
-
        percpu_ref_exit(&q->q_usage_counter);
 
        if (q->poll_stat)
@@ -285,11 +283,11 @@ static void blk_free_queue(struct request_queue *q)
  * Decrements the refcount of the request_queue and free it when the refcount
  * reaches 0.
  *
- * Context: Any context, but the last reference must not be dropped from
- *          atomic context.
+ * Context: Can sleep.
  */
 void blk_put_queue(struct request_queue *q)
 {
+       might_sleep();
        if (refcount_dec_and_test(&q->refs))
                blk_free_queue(q);
 }