@@ -116,7 +116,6 @@ static bool blkcg_policy_enabled(struct request_queue *q,
116116
117117static void blkg_free (struct blkcg_gq * blkg )
118118{
119- struct request_queue * q = blkg -> q ;
120119 int i ;
121120
122121 /*
@@ -126,16 +125,16 @@ static void blkg_free(struct blkcg_gq *blkg)
126125 * blkcg_mutex is used to synchronize blkg_free_workfn() and
127126 * blkcg_deactivate_policy().
128127 */
129- mutex_lock (& q -> blkcg_mutex );
128+ mutex_lock (& blkg -> disk -> queue -> blkcg_mutex );
130129 for (i = 0 ; i < BLKCG_MAX_POLS ; i ++ )
131130 if (blkg -> pd [i ])
132131 blkcg_policy [i ]-> pd_free_fn (blkg -> pd [i ]);
133132 if (blkg -> parent )
134133 blkg_put (blkg -> parent );
135134 list_del_init (& blkg -> q_node );
136- mutex_unlock (& q -> blkcg_mutex );
135+ mutex_unlock (& blkg -> disk -> queue -> blkcg_mutex );
137136
138- blk_put_queue ( q );
137+ put_disk ( blkg -> disk );
139138 free_percpu (blkg -> iostat_cpu );
140139 percpu_ref_exit (& blkg -> refcnt );
141140 kfree (blkg );
@@ -251,10 +250,12 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
251250 blkg -> iostat_cpu = alloc_percpu_gfp (struct blkg_iostat_set , gfp_mask );
252251 if (!blkg -> iostat_cpu )
253252 goto out_exit_refcnt ;
254- if (!blk_get_queue (disk -> queue ))
253+
254+ if (test_bit (GD_DEAD , & disk -> state ))
255255 goto out_free_iostat ;
256+ get_device (disk_to_dev (disk ));
257+ blkg -> disk = disk ;
256258
257- blkg -> q = disk -> queue ;
258259 INIT_LIST_HEAD (& blkg -> q_node );
259260 spin_lock_init (& blkg -> async_bio_lock );
260261 bio_list_init (& blkg -> async_bios );
@@ -290,7 +291,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
290291 while (-- i >= 0 )
291292 if (blkg -> pd [i ])
292293 blkcg_policy [i ]-> pd_free_fn (blkg -> pd [i ]);
293- blk_put_queue ( disk -> queue );
294+ put_disk ( blkg -> disk );
294295out_free_iostat :
295296 free_percpu (blkg -> iostat_cpu );
296297out_exit_refcnt :
@@ -461,7 +462,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
461462 struct blkcg * blkcg = blkg -> blkcg ;
462463 int i ;
463464
464- lockdep_assert_held (& blkg -> q -> queue_lock );
465+ lockdep_assert_held (& blkg -> disk -> queue -> queue_lock );
465466 lockdep_assert_held (& blkcg -> lock );
466467
467468 /*
@@ -485,7 +486,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)
485486
486487 blkg -> online = false;
487488
488- radix_tree_delete (& blkcg -> blkg_tree , blkg -> q -> id );
489+ radix_tree_delete (& blkcg -> blkg_tree , blkg -> disk -> queue -> id );
489490 hlist_del_init_rcu (& blkg -> blkcg_node );
490491
491492 /*
@@ -572,9 +573,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,
572573
573574const char * blkg_dev_name (struct blkcg_gq * blkg )
574575{
575- if (!blkg -> q -> disk )
576- return NULL ;
577- return bdi_dev_name (blkg -> q -> disk -> bdi );
576+ return bdi_dev_name (blkg -> disk -> bdi );
578577}
579578
580579/**
@@ -606,10 +605,10 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
606605
607606 rcu_read_lock ();
608607 hlist_for_each_entry_rcu (blkg , & blkcg -> blkg_list , blkcg_node ) {
609- spin_lock_irq (& blkg -> q -> queue_lock );
610- if (blkcg_policy_enabled (blkg -> q , pol ))
608+ spin_lock_irq (& blkg -> disk -> queue -> queue_lock );
609+ if (blkcg_policy_enabled (blkg -> disk -> queue , pol ))
611610 total += prfill (sf , blkg -> pd [pol -> plid ], data );
612- spin_unlock_irq (& blkg -> q -> queue_lock );
611+ spin_unlock_irq (& blkg -> disk -> queue -> queue_lock );
613612 }
614613 rcu_read_unlock ();
615614
@@ -1033,9 +1032,9 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
10331032
10341033 rcu_read_lock ();
10351034 hlist_for_each_entry_rcu (blkg , & blkcg -> blkg_list , blkcg_node ) {
1036- spin_lock_irq (& blkg -> q -> queue_lock );
1035+ spin_lock_irq (& blkg -> disk -> queue -> queue_lock );
10371036 blkcg_print_one_stat (blkg , sf );
1038- spin_unlock_irq (& blkg -> q -> queue_lock );
1037+ spin_unlock_irq (& blkg -> disk -> queue -> queue_lock );
10391038 }
10401039 rcu_read_unlock ();
10411040 return 0 ;
@@ -1105,7 +1104,7 @@ static void blkcg_destroy_blkgs(struct blkcg *blkcg)
11051104 while (!hlist_empty (& blkcg -> blkg_list )) {
11061105 struct blkcg_gq * blkg = hlist_entry (blkcg -> blkg_list .first ,
11071106 struct blkcg_gq , blkcg_node );
1108- struct request_queue * q = blkg -> q ;
1107+ struct request_queue * q = blkg -> disk -> queue ;
11091108
11101109 if (need_resched () || !spin_trylock (& q -> queue_lock )) {
11111110 /*
0 commit comments