Skip to content

Commit 08823e8

Browse files
Ming Leiaxboe
authored andcommitted
block: Remove elevator_lock usage from blkg_conf frozen operations
Remove the acquisition and release of q->elevator_lock in the blkg_conf_open_bdev_frozen() and blkg_conf_exit_frozen() functions. The elevator lock is no longer needed in these code paths since commit 78c2713 ("block: move wbt_enable_default() out of queue freezing from sched ->exit()") which introduces `disk->rqos_state_mutex` for protecting wbt state change, and not necessary to abuse elevator_lock for this purpose. This change helps to solve the lockdep warning reported from Yu Kuai[1]. Pass blktests/throtl with lockdep enabled. Links: https://lore.kernel.org/linux-block/e5e7ac3f-2063-473a-aafb-4d8d43e5576e@yukuai.org.cn/ [1] Fixes: commit 78c2713 ("block: move wbt_enable_default() out of queue freezing from sched ->exit()") Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dc96cef commit 08823e8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

block/blk-cgroup.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,7 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
812812
}
813813
/*
814814
* Similar to blkg_conf_open_bdev, but additionally freezes the queue,
815-
* acquires q->elevator_lock, and ensures the correct locking order
816-
* between q->elevator_lock and q->rq_qos_mutex.
815+
* ensures the correct locking order between freeze queue and q->rq_qos_mutex.
817816
*
818817
* This function returns negative error on failure. On success it returns
819818
* memflags which must be saved and later passed to blkg_conf_exit_frozen
@@ -834,13 +833,11 @@ unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
834833
* At this point, we haven’t started protecting anything related to QoS,
835834
* so we release q->rq_qos_mutex here, which was first acquired in blkg_
836835
* conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
837-
* the queue and acquiring q->elevator_lock to maintain the correct
838-
* locking order.
836+
* the queue to maintain the correct locking order.
839837
*/
840838
mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
841839

842840
memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
843-
mutex_lock(&ctx->bdev->bd_queue->elevator_lock);
844841
mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
845842

846843
return memflags;
@@ -995,17 +992,15 @@ void blkg_conf_exit(struct blkg_conf_ctx *ctx)
995992
EXPORT_SYMBOL_GPL(blkg_conf_exit);
996993

997994
/*
998-
* Similar to blkg_conf_exit, but also unfreezes the queue and releases
999-
* q->elevator_lock. Should be used when blkg_conf_open_bdev_frozen
1000-
* is used to open the bdev.
995+
* Similar to blkg_conf_exit, but also unfreezes the queue. Should be used
996+
* when blkg_conf_open_bdev_frozen is used to open the bdev.
1001997
*/
1002998
void blkg_conf_exit_frozen(struct blkg_conf_ctx *ctx, unsigned long memflags)
1003999
{
10041000
if (ctx->bdev) {
10051001
struct request_queue *q = ctx->bdev->bd_queue;
10061002

10071003
blkg_conf_exit(ctx);
1008-
mutex_unlock(&q->elevator_lock);
10091004
blk_mq_unfreeze_queue(q, memflags);
10101005
}
10111006
}

0 commit comments

Comments
 (0)