@@ -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 );
308307out_free_iostat :
309308 free_percpu (blkg -> iostat_cpu );
310309out_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
588587const 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 /*
0 commit comments