On the one hand, nest q_usage_counter under rq_qos_mutex is wrong; On the other hand, policy activation is now all under queue frozen: - for bfq queue is frozen from elevator_change(); - for blk-throttle, iocost, iolatency, queue is frozen from blkg_conf_open_bdev_frozen(&ctx); Signed-off-by: Yu Kuai --- block/blk-cgroup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 3cffb68ba5d8..31ac518b347c 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1580,12 +1580,13 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) struct request_queue *q = disk->queue; struct blkg_policy_data *pd_prealloc = NULL; struct blkcg_gq *blkg, *pinned_blkg = NULL; - unsigned int memflags; int ret; if (blkcg_policy_enabled(q, pol)) return 0; + WARN_ON_ONCE(q->mq_freeze_depth == 0); + /* * Policy is allowed to be registered without pd_alloc_fn/pd_free_fn, * for example, ioprio. Such policy will work on blkcg level, not disk @@ -1594,8 +1595,6 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) if (WARN_ON_ONCE(!pol->pd_alloc_fn || !pol->pd_free_fn)) return -EINVAL; - if (queue_is_mq(q)) - memflags = blk_mq_freeze_queue(q); retry: spin_lock_irq(&q->queue_lock); @@ -1658,8 +1657,6 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) spin_unlock_irq(&q->queue_lock); out: - if (queue_is_mq(q)) - blk_mq_unfreeze_queue(q, memflags); if (pinned_blkg) blkg_put(pinned_blkg); if (pd_prealloc) -- 2.51.0