Commit 479664ce authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-cgroup: pass a gendisk to blkg_lookup

Pass a gendisk to blkg_lookup and use that to find the match as part
of phasing out usage of the request_queue in the blk-cgroup code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAndreas Herrmann <aherrmann@suse.de>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20230203150400.3199230-19-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0a0b4f79
...@@ -337,7 +337,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk, ...@@ -337,7 +337,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk,
/* link parent */ /* link parent */
if (blkcg_parent(blkcg)) { if (blkcg_parent(blkcg)) {
blkg->parent = blkg_lookup(blkcg_parent(blkcg), disk->queue); blkg->parent = blkg_lookup(blkcg_parent(blkcg), disk);
if (WARN_ON_ONCE(!blkg->parent)) { if (WARN_ON_ONCE(!blkg->parent)) {
ret = -ENODEV; ret = -ENODEV;
goto err_put_css; goto err_put_css;
...@@ -409,12 +409,12 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, ...@@ -409,12 +409,12 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
WARN_ON_ONCE(!rcu_read_lock_held()); WARN_ON_ONCE(!rcu_read_lock_held());
blkg = blkg_lookup(blkcg, q); blkg = blkg_lookup(blkcg, disk);
if (blkg) if (blkg)
return blkg; return blkg;
spin_lock_irqsave(&q->queue_lock, flags); spin_lock_irqsave(&q->queue_lock, flags);
blkg = blkg_lookup(blkcg, q); blkg = blkg_lookup(blkcg, disk);
if (blkg) { if (blkg) {
if (blkcg != &blkcg_root && if (blkcg != &blkcg_root &&
blkg != rcu_dereference(blkcg->blkg_hint)) blkg != rcu_dereference(blkcg->blkg_hint))
...@@ -433,7 +433,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, ...@@ -433,7 +433,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
struct blkcg_gq *ret_blkg = q->root_blkg; struct blkcg_gq *ret_blkg = q->root_blkg;
while (parent) { while (parent) {
blkg = blkg_lookup(parent, q); blkg = blkg_lookup(parent, disk);
if (blkg) { if (blkg) {
/* remember closest blkg */ /* remember closest blkg */
ret_blkg = blkg; ret_blkg = blkg;
...@@ -719,7 +719,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, ...@@ -719,7 +719,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
goto fail_unlock; goto fail_unlock;
} }
blkg = blkg_lookup(blkcg, q); blkg = blkg_lookup(blkcg, disk);
if (blkg) if (blkg)
goto success; goto success;
...@@ -733,7 +733,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, ...@@ -733,7 +733,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
struct blkcg_gq *new_blkg; struct blkcg_gq *new_blkg;
parent = blkcg_parent(blkcg); parent = blkcg_parent(blkcg);
while (parent && !blkg_lookup(parent, q)) { while (parent && !blkg_lookup(parent, disk)) {
pos = parent; pos = parent;
parent = blkcg_parent(parent); parent = blkcg_parent(parent);
} }
...@@ -763,7 +763,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, ...@@ -763,7 +763,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
goto fail_preloaded; goto fail_preloaded;
} }
blkg = blkg_lookup(pos, q); blkg = blkg_lookup(pos, disk);
if (blkg) { if (blkg) {
blkg_free(new_blkg); blkg_free(new_blkg);
} else { } else {
...@@ -1838,7 +1838,7 @@ void blkcg_maybe_throttle_current(void) ...@@ -1838,7 +1838,7 @@ void blkcg_maybe_throttle_current(void)
blkcg = css_to_blkcg(blkcg_css()); blkcg = css_to_blkcg(blkcg_css());
if (!blkcg) if (!blkcg)
goto out; goto out;
blkg = blkg_lookup(blkcg, disk->queue); blkg = blkg_lookup(blkcg, disk);
if (!blkg) if (!blkg)
goto out; goto out;
if (!blkg_tryget(blkg)) if (!blkg_tryget(blkg))
......
...@@ -234,30 +234,30 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio) ...@@ -234,30 +234,30 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio)
} }
/** /**
* blkg_lookup - lookup blkg for the specified blkcg - q pair * blkg_lookup - lookup blkg for the specified blkcg - disk pair
* @blkcg: blkcg of interest * @blkcg: blkcg of interest
* @q: request_queue of interest * @disk: gendisk of interest
* *
* Lookup blkg for the @blkcg - @q pair. * Lookup blkg for the @blkcg - @disk pair.
* Must be called in a RCU critical section. * Must be called in a RCU critical section.
*/ */
static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,
struct request_queue *q) struct gendisk *disk)
{ {
struct blkcg_gq *blkg; struct blkcg_gq *blkg;
WARN_ON_ONCE(!rcu_read_lock_held()); WARN_ON_ONCE(!rcu_read_lock_held());
if (blkcg == &blkcg_root) if (blkcg == &blkcg_root)
return q->root_blkg; return disk->queue->root_blkg;
blkg = rcu_dereference(blkcg->blkg_hint); blkg = rcu_dereference(blkcg->blkg_hint);
if (blkg && blkg->disk->queue == q) if (blkg && blkg->disk == disk)
return blkg; return blkg;
blkg = radix_tree_lookup(&blkcg->blkg_tree, q->id); blkg = radix_tree_lookup(&blkcg->blkg_tree, disk->queue->id);
if (blkg && blkg->disk->queue != q) if (blkg && blkg->disk != disk)
blkg = NULL; blkg = NULL;
return blkg; return blkg;
} }
...@@ -357,7 +357,7 @@ static inline void blkg_put(struct blkcg_gq *blkg) ...@@ -357,7 +357,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg) \ #define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg) \
css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \
if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \
(p_blkg)->disk->queue))) (p_blkg)->disk)))
/** /**
* blkg_for_each_descendant_post - post-order walk of a blkg's descendants * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
...@@ -372,7 +372,7 @@ static inline void blkg_put(struct blkcg_gq *blkg) ...@@ -372,7 +372,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg) \ #define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg) \
css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \
if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \
(p_blkg)->disk->queue))) (p_blkg)->disk)))
bool __blkcg_punt_bio_submit(struct bio *bio); bool __blkcg_punt_bio_submit(struct bio *bio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment