Make the callers of blkg_create() and blkg_lookup_create() pass the request queue pointer as an additional argument. All callers already have that pointer since they hold q->queue_lock while calling these functions. Use q instead of disk->queue in blkg_create(), remove the local variable q from blkg_lookup_create() since it is now passed as an argument, and update the stale kernel-doc comment on blkg_lookup_create(). This change prepares for annotating blkg_create() and blkg_lookup_create() with __must_hold(&q->queue_lock). Clang's context analysis cannot determine that e.g. bio->bi_bdev->bd_queue->queue_lock and bio->bi_bdev->bd_disk->queue->queue_lock in blkg_tryget_closest() refer to the same spinlock. No functional change is intended since the request queue pointer passed by all callers equals disk->queue. Signed-off-by: Bart Van Assche --- block/blk-cgroup.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 5b7a32293dc6..453c03d78caa 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -391,15 +391,16 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk, * necessary using %GFP_NOWAIT. @new_blkg is always consumed on return. */ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk, + struct request_queue *q, struct blkcg_gq *new_blkg) { struct blkcg_gq *blkg; int i, ret; - lockdep_assert_held(&disk->queue->queue_lock); + lockdep_assert_held(&q->queue_lock); /* request_queue is dying, do not create/recreate a blkg */ - if (blk_queue_dying(disk->queue)) { + if (blk_queue_dying(q)) { ret = -ENODEV; goto err_free_blkg; } @@ -416,7 +417,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk, /* link parent */ if (blkcg_parent(blkcg)) { - blkg->parent = blkg_lookup(blkcg_parent(blkcg), disk->queue); + blkg->parent = blkg_lookup(blkcg_parent(blkcg), q); if (WARN_ON_ONCE(!blkg->parent)) { ret = -ENODEV; goto err_free_blkg; @@ -434,10 +435,10 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk, /* insert */ spin_lock(&blkcg->lock); - ret = radix_tree_insert(&blkcg->blkg_tree, disk->queue->id, blkg); + ret = radix_tree_insert(&blkcg->blkg_tree, q->id, blkg); if (likely(!ret)) { hlist_add_head_rcu(&blkg->blkcg_node, &blkcg->blkg_list); - list_add(&blkg->q_node, &disk->queue->blkg_list); + list_add(&blkg->q_node, &q->blkg_list); for (i = 0; i < BLKCG_MAX_POLS; i++) { struct blkcg_policy *pol = blkcg_policy[i]; @@ -469,19 +470,19 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk, * blkg_lookup_create - lookup blkg, try to create one if not there * @blkcg: blkcg of interest * @disk: gendisk of interest + * @q: request queue associated with @disk * * Lookup blkg for the @blkcg - @disk pair. If it doesn't exist, try to * create one. blkg creation is performed recursively from blkcg_root such * that all non-root blkg's have access to the parent blkg. This function - * should be called under RCU read lock and takes @disk->queue->queue_lock. + * must be called with @q->queue_lock held. * * Returns the blkg or the closest blkg if blkg_create() fails as it walks * down from root. */ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, - struct gendisk *disk) + struct gendisk *disk, struct request_queue *q) { - struct request_queue *q = disk->queue; struct blkcg_gq *blkg; rcu_read_lock(); @@ -516,7 +517,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, parent = blkcg_parent(parent); } - blkg = blkg_create(pos, disk, NULL); + blkg = blkg_create(pos, disk, q, NULL); if (IS_ERR(blkg)) { blkg = ret_blkg; break; @@ -915,7 +916,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, if (blkg) { blkg_free(new_blkg); } else { - blkg = blkg_create(pos, disk, new_blkg); + blkg = blkg_create(pos, disk, q, new_blkg); if (IS_ERR(blkg)) { ret = PTR_ERR(blkg); goto fail_preloaded; @@ -1512,7 +1513,7 @@ int blkcg_init_disk(struct gendisk *disk) /* Make sure the root blkg exists. */ /* spin_lock_irq can serve as RCU read-side critical section. */ spin_lock_irq(&q->queue_lock); - blkg = blkg_create(&blkcg_root, disk, new_blkg); + blkg = blkg_create(&blkcg_root, disk, q, new_blkg); if (IS_ERR(blkg)) goto err_unlock; q->root_blkg = blkg; @@ -2130,7 +2131,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, * time, hold lock to create new blkg. */ spin_lock_irqsave(&q->queue_lock, flags); - blkg = blkg_lookup_create(blkcg, bio->bi_bdev->bd_disk); + blkg = blkg_lookup_create(blkcg, bio->bi_bdev->bd_disk, q); if (blkg) blkg = blkg_lookup_tryget(blkg); spin_unlock_irqrestore(&q->queue_lock, flags);