Skip to content

Commit a06377c

Browse files
Christoph Hellwigaxboe
authored andcommitted
Revert "blk-cgroup: pin the gendisk in struct blkcg_gq"
This reverts commit 84d7d46. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 9a9c261 commit a06377c

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

block/bfq-cgroup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static void bfqg_stats_xfer_dead(struct bfq_group *bfqg)
405405

406406
parent = bfqg_parent(bfqg);
407407

408-
lockdep_assert_held(&bfqg_to_blkg(bfqg)->disk->queue->queue_lock);
408+
lockdep_assert_held(&bfqg_to_blkg(bfqg)->q->queue_lock);
409409

410410
if (unlikely(!parent))
411411
return;
@@ -536,7 +536,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
536536
{
537537
struct blkcg_gq *blkg = pd_to_blkg(pd);
538538
struct bfq_group *bfqg = blkg_to_bfqg(blkg);
539-
struct bfq_data *bfqd = blkg->disk->queue->elevator->elevator_data;
539+
struct bfq_data *bfqd = blkg->q->elevator->elevator_data;
540540
struct bfq_entity *entity = &bfqg->entity;
541541
struct bfq_group_data *d = blkcg_to_bfqgd(blkg->blkcg);
542542

@@ -1199,7 +1199,7 @@ static u64 bfqg_prfill_stat_recursive(struct seq_file *sf,
11991199
struct cgroup_subsys_state *pos_css;
12001200
u64 sum = 0;
12011201

1202-
lockdep_assert_held(&blkg->disk->queue->queue_lock);
1202+
lockdep_assert_held(&blkg->q->queue_lock);
12031203

12041204
rcu_read_lock();
12051205
blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {

block/blk-cgroup-rwstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
107107
struct cgroup_subsys_state *pos_css;
108108
unsigned int i;
109109

110-
lockdep_assert_held(&blkg->disk->queue->queue_lock);
110+
lockdep_assert_held(&blkg->q->queue_lock);
111111

112112
memset(sum, 0, sizeof(*sum));
113113
rcu_read_lock();

block/blk-cgroup.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static void blkg_free_workfn(struct work_struct *work)
118118
{
119119
struct blkcg_gq *blkg = container_of(work, struct blkcg_gq,
120120
free_work);
121+
struct request_queue *q = blkg->q;
121122
int i;
122123

123124
/*
@@ -127,16 +128,16 @@ static void blkg_free_workfn(struct work_struct *work)
127128
* blkcg_mutex is used to synchronize blkg_free_workfn() and
128129
* blkcg_deactivate_policy().
129130
*/
130-
mutex_lock(&blkg->disk->queue->blkcg_mutex);
131+
mutex_lock(&q->blkcg_mutex);
131132
for (i = 0; i < BLKCG_MAX_POLS; i++)
132133
if (blkg->pd[i])
133134
blkcg_policy[i]->pd_free_fn(blkg->pd[i]);
134135
if (blkg->parent)
135136
blkg_put(blkg->parent);
136137
list_del_init(&blkg->q_node);
137-
mutex_unlock(&blkg->disk->queue->blkcg_mutex);
138+
mutex_unlock(&q->blkcg_mutex);
138139

139-
put_disk(blkg->disk);
140+
blk_put_queue(q);
140141
free_percpu(blkg->iostat_cpu);
141142
percpu_ref_exit(&blkg->refcnt);
142143
kfree(blkg);
@@ -263,12 +264,10 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
263264
blkg->iostat_cpu = alloc_percpu_gfp(struct blkg_iostat_set, gfp_mask);
264265
if (!blkg->iostat_cpu)
265266
goto out_exit_refcnt;
266-
267-
if (test_bit(GD_DEAD, &disk->state))
267+
if (!blk_get_queue(disk->queue))
268268
goto out_free_iostat;
269-
get_device(disk_to_dev(disk));
270-
blkg->disk = disk;
271269

270+
blkg->q = disk->queue;
272271
INIT_LIST_HEAD(&blkg->q_node);
273272
spin_lock_init(&blkg->async_bio_lock);
274273
bio_list_init(&blkg->async_bios);
@@ -304,7 +303,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
304303
while (--i >= 0)
305304
if (blkg->pd[i])
306305
blkcg_policy[i]->pd_free_fn(blkg->pd[i]);
307-
put_disk(blkg->disk);
306+
blk_put_queue(disk->queue);
308307
out_free_iostat:
309308
free_percpu(blkg->iostat_cpu);
310309
out_exit_refcnt:
@@ -476,7 +475,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
476475
struct blkcg *blkcg = blkg->blkcg;
477476
int i;
478477

479-
lockdep_assert_held(&blkg->disk->queue->queue_lock);
478+
lockdep_assert_held(&blkg->q->queue_lock);
480479
lockdep_assert_held(&blkcg->lock);
481480

482481
/*
@@ -500,7 +499,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
500499

501500
blkg->online = false;
502501

503-
radix_tree_delete(&blkcg->blkg_tree, blkg->disk->queue->id);
502+
radix_tree_delete(&blkcg->blkg_tree, blkg->q->id);
504503
hlist_del_init_rcu(&blkg->blkcg_node);
505504

506505
/*
@@ -587,7 +586,9 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,
587586

588587
const char *blkg_dev_name(struct blkcg_gq *blkg)
589588
{
590-
return bdi_dev_name(blkg->disk->bdi);
589+
if (!blkg->q->disk)
590+
return NULL;
591+
return bdi_dev_name(blkg->q->disk->bdi);
591592
}
592593

593594
/**
@@ -619,10 +620,10 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
619620

620621
rcu_read_lock();
621622
hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
622-
spin_lock_irq(&blkg->disk->queue->queue_lock);
623-
if (blkcg_policy_enabled(blkg->disk->queue, pol))
623+
spin_lock_irq(&blkg->q->queue_lock);
624+
if (blkcg_policy_enabled(blkg->q, pol))
624625
total += prfill(sf, blkg->pd[pol->plid], data);
625-
spin_unlock_irq(&blkg->disk->queue->queue_lock);
626+
spin_unlock_irq(&blkg->q->queue_lock);
626627
}
627628
rcu_read_unlock();
628629

@@ -1046,9 +1047,9 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
10461047

10471048
rcu_read_lock();
10481049
hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
1049-
spin_lock_irq(&blkg->disk->queue->queue_lock);
1050+
spin_lock_irq(&blkg->q->queue_lock);
10501051
blkcg_print_one_stat(blkg, sf);
1051-
spin_unlock_irq(&blkg->disk->queue->queue_lock);
1052+
spin_unlock_irq(&blkg->q->queue_lock);
10521053
}
10531054
rcu_read_unlock();
10541055
return 0;
@@ -1118,7 +1119,7 @@ static void blkcg_destroy_blkgs(struct blkcg *blkcg)
11181119
while (!hlist_empty(&blkcg->blkg_list)) {
11191120
struct blkcg_gq *blkg = hlist_entry(blkcg->blkg_list.first,
11201121
struct blkcg_gq, blkcg_node);
1121-
struct request_queue *q = blkg->disk->queue;
1122+
struct request_queue *q = blkg->q;
11221123

11231124
if (need_resched() || !spin_trylock(&q->queue_lock)) {
11241125
/*

block/blk-cgroup.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct blkg_iostat_set {
5353

5454
/* association between a blk cgroup and a request queue */
5555
struct blkcg_gq {
56-
struct gendisk *disk;
56+
/* Pointer to the associated request_queue */
57+
struct request_queue *q;
5758
struct list_head q_node;
5859
struct hlist_node blkcg_node;
5960
struct blkcg *blkcg;
@@ -253,11 +254,11 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,
253254
return q->root_blkg;
254255

255256
blkg = rcu_dereference(blkcg->blkg_hint);
256-
if (blkg && blkg->disk->queue == q)
257+
if (blkg && blkg->q == q)
257258
return blkg;
258259

259260
blkg = radix_tree_lookup(&blkcg->blkg_tree, q->id);
260-
if (blkg && blkg->disk->queue != q)
261+
if (blkg && blkg->q != q)
261262
blkg = NULL;
262263
return blkg;
263264
}
@@ -357,7 +358,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
357358
#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg) \
358359
css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \
359360
if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \
360-
(p_blkg)->disk->queue)))
361+
(p_blkg)->q)))
361362

362363
/**
363364
* blkg_for_each_descendant_post - post-order walk of a blkg's descendants
@@ -372,7 +373,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
372373
#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg) \
373374
css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \
374375
if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \
375-
(p_blkg)->disk->queue)))
376+
(p_blkg)->q)))
376377

377378
bool __blkcg_punt_bio_submit(struct bio *bio);
378379

block/blk-iocost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
29472947
{
29482948
struct ioc_gq *iocg = pd_to_iocg(pd);
29492949
struct blkcg_gq *blkg = pd_to_blkg(&iocg->pd);
2950-
struct ioc *ioc = q_to_ioc(blkg->disk->queue);
2950+
struct ioc *ioc = q_to_ioc(blkg->q);
29512951
struct ioc_now now;
29522952
struct blkcg_gq *tblkg;
29532953
unsigned long flags;

block/blk-iolatency.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,12 +967,12 @@ static void iolatency_pd_init(struct blkg_policy_data *pd)
967967
{
968968
struct iolatency_grp *iolat = pd_to_lat(pd);
969969
struct blkcg_gq *blkg = lat_to_blkg(iolat);
970-
struct rq_qos *rqos = blkcg_rq_qos(blkg->disk->queue);
970+
struct rq_qos *rqos = blkcg_rq_qos(blkg->q);
971971
struct blk_iolatency *blkiolat = BLKIOLATENCY(rqos);
972972
u64 now = ktime_to_ns(ktime_get());
973973
int cpu;
974974

975-
if (blk_queue_nonrot(blkg->disk->queue))
975+
if (blk_queue_nonrot(blkg->q))
976976
iolat->ssd = true;
977977
else
978978
iolat->ssd = false;

block/blk-throttle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static void throtl_pd_init(struct blkg_policy_data *pd)
387387
{
388388
struct throtl_grp *tg = pd_to_tg(pd);
389389
struct blkcg_gq *blkg = tg_to_blkg(tg);
390-
struct throtl_data *td = blkg->disk->queue->td;
390+
struct throtl_data *td = blkg->q->td;
391391
struct throtl_service_queue *sq = &tg->service_queue;
392392

393393
/*
@@ -1174,7 +1174,7 @@ static void throtl_pending_timer_fn(struct timer_list *t)
11741174

11751175
/* throtl_data may be gone, so figure out request queue by blkg */
11761176
if (tg)
1177-
q = tg->pd.blkg->disk->queue;
1177+
q = tg->pd.blkg->q;
11781178
else
11791179
q = td->queue;
11801180

0 commit comments

Comments
 (0)