]> www.infradead.org Git - users/hch/block.git/commitdiff
blk-cgroup: store a gendisk in struct blkcg_gq
authorChristoph Hellwig <hch@lst.de>
Fri, 9 Sep 2022 09:21:39 +0000 (11:21 +0200)
committerChristoph Hellwig <hch@lst.de>
Sun, 11 Sep 2022 06:07:34 +0000 (08:07 +0200)
Store a gendisk instead of the request_queue in struct blkcg_gq in
preparation of switching all blk-cgroup interface to be gendisk
based.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/bfq-cgroup.c
block/blk-cgroup-rwstat.c
block/blk-cgroup.c
block/blk-cgroup.h
block/blk-iocost.c
block/blk-iolatency.c
block/blk-throttle.c

index 144bca006463dbbf83e6b51f7c719e3fb3b6f3e8..514fdb2348eb5a5205e960477d75d3fdafcf918b 100644 (file)
@@ -407,7 +407,7 @@ static void bfqg_stats_xfer_dead(struct bfq_group *bfqg)
 
        parent = bfqg_parent(bfqg);
 
-       lockdep_assert_held(&bfqg_to_blkg(bfqg)->q->queue_lock);
+       lockdep_assert_held(&bfqg_to_blkg(bfqg)->disk->queue->queue_lock);
 
        if (unlikely(!parent))
                return;
@@ -538,7 +538,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
 {
        struct blkcg_gq *blkg = pd_to_blkg(pd);
        struct bfq_group *bfqg = blkg_to_bfqg(blkg);
-       struct bfq_data *bfqd = blkg->q->elevator->elevator_data;
+       struct bfq_data *bfqd = blkg->disk->queue->elevator->elevator_data;
        struct bfq_entity *entity = &bfqg->entity;
        struct bfq_group_data *d = blkcg_to_bfqgd(blkg->blkcg);
 
@@ -1184,7 +1184,7 @@ static u64 bfqg_prfill_stat_recursive(struct seq_file *sf,
        struct cgroup_subsys_state *pos_css;
        u64 sum = 0;
 
-       lockdep_assert_held(&blkg->q->queue_lock);
+       lockdep_assert_held(&blkg->disk->queue->queue_lock);
 
        rcu_read_lock();
        blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
index 3304e841df7ce924a1a64c69b5ab9102294d6801..b8b8c82e667a3b537ce6db888c101601a025532a 100644 (file)
@@ -107,7 +107,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
        struct cgroup_subsys_state *pos_css;
        unsigned int i;
 
-       lockdep_assert_held(&blkg->q->queue_lock);
+       lockdep_assert_held(&blkg->disk->queue->queue_lock);
 
        memset(sum, 0, sizeof(*sum));
        rcu_read_lock();
index 94af5f3f3620bba81468983fe2613788d46b704c..03d24363081336aa7615a5cfc337fa26169c7dde 100644 (file)
@@ -92,8 +92,8 @@ static void blkg_free_workfn(struct work_struct *work)
                if (blkg->pd[i])
                        blkcg_policy[i]->pd_free_fn(blkg->pd[i]);
 
-       if (blkg->q)
-               blk_put_queue(blkg->q);
+       if (blkg->disk->queue)
+               blk_put_queue(blkg->disk->queue);
        free_percpu(blkg->iostat_cpu);
        percpu_ref_exit(&blkg->refcnt);
        kfree(blkg);
@@ -228,7 +228,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
        if (!blk_get_queue(disk->queue))
                goto err_free;
 
-       blkg->q = disk->queue;
+       blkg->disk = disk;
        INIT_LIST_HEAD(&blkg->q_node);
        spin_lock_init(&blkg->async_bio_lock);
        bio_list_init(&blkg->async_bios);
@@ -265,7 +265,7 @@ err_free:
 
 static void blkg_update_hint(struct blkcg *blkcg, struct blkcg_gq *blkg)
 {
-       lockdep_assert_held(&blkg->q->queue_lock);
+       lockdep_assert_held(&blkg->disk->queue->queue_lock);
 
        if (blkcg != &blkcg_root && blkg != rcu_dereference(blkcg->blkg_hint))
                rcu_assign_pointer(blkcg->blkg_hint, blkg);
@@ -427,7 +427,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
        struct blkcg *blkcg = blkg->blkcg;
        int i;
 
-       lockdep_assert_held(&blkg->q->queue_lock);
+       lockdep_assert_held(&blkg->disk->queue->queue_lock);
        lockdep_assert_held(&blkcg->lock);
 
        /* Something wrong if we are trying to remove same group twice */
@@ -443,7 +443,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
 
        blkg->online = false;
 
-       radix_tree_delete(&blkcg->blkg_tree, blkg->q->id);
+       radix_tree_delete(&blkcg->blkg_tree, blkg->disk->queue->id);
        list_del_init(&blkg->q_node);
        hlist_del_init_rcu(&blkg->blkcg_node);
 
@@ -531,9 +531,9 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,
 
 const char *blkg_dev_name(struct blkcg_gq *blkg)
 {
-       if (!blkg->q->disk || !blkg->q->disk->bdi->dev)
+       if (!blkg->disk->bdi->dev)
                return NULL;
-       return bdi_dev_name(blkg->q->disk->bdi);
+       return bdi_dev_name(blkg->disk->bdi);
 }
 
 /**
@@ -565,10 +565,10 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
-               spin_lock_irq(&blkg->q->queue_lock);
-               if (blkcg_policy_enabled(blkg->q, pol))
+               spin_lock_irq(&blkg->disk->queue->queue_lock);
+               if (blkcg_policy_enabled(blkg->disk->queue, pol))
                        total += prfill(sf, blkg->pd[pol->plid], data);
-               spin_unlock_irq(&blkg->q->queue_lock);
+               spin_unlock_irq(&blkg->disk->queue->queue_lock);
        }
        rcu_read_unlock();
 
@@ -982,9 +982,9 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
-               spin_lock_irq(&blkg->q->queue_lock);
+               spin_lock_irq(&blkg->disk->queue->queue_lock);
                blkcg_print_one_stat(blkg, sf);
-               spin_unlock_irq(&blkg->q->queue_lock);
+               spin_unlock_irq(&blkg->disk->queue->queue_lock);
        }
        rcu_read_unlock();
        return 0;
@@ -1054,7 +1054,7 @@ static void blkcg_destroy_blkgs(struct blkcg *blkcg)
        while (!hlist_empty(&blkcg->blkg_list)) {
                struct blkcg_gq *blkg = hlist_entry(blkcg->blkg_list.first,
                                                struct blkcg_gq, blkcg_node);
-               struct request_queue *q = blkg->q;
+               struct request_queue *q = blkg->disk->queue;
 
                if (need_resched() || !spin_trylock(&q->queue_lock)) {
                        /*
index aa2b286bc825fbdcb3bc404dc106f158a6e750dd..7cd96e54d4126885f3aa16efb03a393d1b4e24d0 100644 (file)
@@ -47,10 +47,9 @@ struct blkg_iostat_set {
        struct blkg_iostat              last;
 };
 
-/* association between a blk cgroup and a request queue */
+/* association between a blk cgroup and a gendisk */
 struct blkcg_gq {
-       /* Pointer to the associated request_queue */
-       struct request_queue            *q;
+       struct gendisk                  *disk;
        struct list_head                q_node;
        struct hlist_node               blkcg_node;
        struct blkcg                    *blkcg;
@@ -112,8 +111,8 @@ static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
 
 /*
  * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
- * request_queue (q).  This is used by blkcg policies which need to track
- * information per blkcg - q pair.
+ * gendisk.  This is used by blkcg policies which need to track
+ * information per blkcg - gendisk pair.
  *
  * There can be multiple active blkcg policies and each blkg:policy pair is
  * represented by a blkg_policy_data which is allocated and freed by each
@@ -129,7 +128,7 @@ struct blkg_policy_data {
 
 /*
  * Policies that need to keep per-blkcg data which is independent from any
- * request_queue associated to it should implement cpd_alloc/free_fn()
+ * gendisk associated to it should implement cpd_alloc/free_fn()
  * methods.  A policy can allocate private data area by allocating larger
  * data structure which embeds blkcg_policy_data at the beginning.
  * cpd_init() is invoked to let each policy handle per-blkcg data.
@@ -244,11 +243,11 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,
                return q->root_blkg;
 
        blkg = rcu_dereference(blkcg->blkg_hint);
-       if (blkg && blkg->q == q)
+       if (blkg && blkg->disk->queue == q)
                return blkg;
 
        blkg = radix_tree_lookup(&blkcg->blkg_tree, q->id);
-       if (blkg && blkg->q != q)
+       if (blkg && blkg->disk->queue != q)
                blkg = NULL;
        return blkg;
 }
@@ -348,7 +347,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
 #define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg)          \
        css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css)   \
                if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css),      \
-                                           (p_blkg)->q)))
+                                           (p_blkg)->disk->queue)))
 
 /**
  * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
@@ -363,7 +362,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
 #define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg)         \
        css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css)  \
                if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css),      \
-                                           (p_blkg)->q)))
+                                           (p_blkg)->disk->queue)))
 
 bool __blkcg_punt_bio_submit(struct bio *bio);
 
index af953603a5a0f0f9d490a532759a7b5041734337..2898cdd2552b660d285002ae22dd51dba62dccdb 100644 (file)
@@ -2933,7 +2933,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
 {
        struct ioc_gq *iocg = pd_to_iocg(pd);
        struct blkcg_gq *blkg = pd_to_blkg(&iocg->pd);
-       struct ioc *ioc = q_to_ioc(blkg->q);
+       struct ioc *ioc = q_to_ioc(blkg->disk->queue);
        struct ioc_now now;
        struct blkcg_gq *tblkg;
        unsigned long flags;
index 1e822d89da39a84cdf0fa6360a5a577230ff876e..26967adc50b12d38656ea44bccccc23f631c2f21 100644 (file)
@@ -969,12 +969,12 @@ static void iolatency_pd_init(struct blkg_policy_data *pd)
 {
        struct iolatency_grp *iolat = pd_to_lat(pd);
        struct blkcg_gq *blkg = lat_to_blkg(iolat);
-       struct rq_qos *rqos = blkcg_rq_qos(blkg->q);
+       struct rq_qos *rqos = blkcg_rq_qos(blkg->disk->queue);
        struct blk_iolatency *blkiolat = BLKIOLATENCY(rqos);
        u64 now = ktime_to_ns(ktime_get());
        int cpu;
 
-       if (blk_queue_nonrot(blkg->q))
+       if (blk_queue_nonrot(blkg->disk->queue))
                iolat->ssd = true;
        else
                iolat->ssd = false;
@@ -988,7 +988,7 @@ static void iolatency_pd_init(struct blkg_policy_data *pd)
        latency_stat_init(iolat, &iolat->cur_stat);
        rq_wait_init(&iolat->rq_wait);
        spin_lock_init(&iolat->child_lat.lock);
-       iolat->rq_depth.queue_depth = blkg->q->nr_requests;
+       iolat->rq_depth.queue_depth = blkg->disk->queue->nr_requests;
        iolat->rq_depth.max_depth = UINT_MAX;
        iolat->rq_depth.default_depth = iolat->rq_depth.queue_depth;
        iolat->blkiolat = blkiolat;
index fc8f64beeb78ca5fb99cb73fb153aa96a2ae936d..94eefed6836fcf2478b5401fd72257c0ef30c392 100644 (file)
@@ -388,7 +388,7 @@ static void throtl_pd_init(struct blkg_policy_data *pd)
 {
        struct throtl_grp *tg = pd_to_tg(pd);
        struct blkcg_gq *blkg = tg_to_blkg(tg);
-       struct throtl_data *td = blkg->q->td;
+       struct throtl_data *td = blkg->disk->queue->td;
        struct throtl_service_queue *sq = &tg->service_queue;
 
        /*
@@ -1145,7 +1145,7 @@ static void throtl_pending_timer_fn(struct timer_list *t)
 
        /* throtl_data may be gone, so figure out request queue by blkg */
        if (tg)
-               q = tg->pd.blkg->q;
+               q = tg->pd.blkg->disk->queue;
        else
                q = td->queue;