@@ -235,8 +235,13 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
235235 blkg -> online = true;
236236 spin_unlock (& blkcg -> lock );
237237
238- if (!ret )
238+ if (!ret ) {
239+ if (blkcg == & blkcg_root ) {
240+ q -> root_blkg = blkg ;
241+ q -> root_rl .blkg = blkg ;
242+ }
239243 return blkg ;
244+ }
240245
241246 /* @blkg failed fully initialized, use the usual release path */
242247 blkg_put (blkg );
@@ -334,6 +339,15 @@ static void blkg_destroy(struct blkcg_gq *blkg)
334339 if (rcu_dereference_raw (blkcg -> blkg_hint ) == blkg )
335340 rcu_assign_pointer (blkcg -> blkg_hint , NULL );
336341
342+ /*
343+ * If root blkg is destroyed. Just clear the pointer since root_rl
344+ * does not take reference on root blkg.
345+ */
346+ if (blkcg == & blkcg_root ) {
347+ blkg -> q -> root_blkg = NULL ;
348+ blkg -> q -> root_rl .blkg = NULL ;
349+ }
350+
337351 /*
338352 * Put the reference taken at the time of creation so that when all
339353 * queues are gone, group can be destroyed.
@@ -360,13 +374,6 @@ static void blkg_destroy_all(struct request_queue *q)
360374 blkg_destroy (blkg );
361375 spin_unlock (& blkcg -> lock );
362376 }
363-
364- /*
365- * root blkg is destroyed. Just clear the pointer since
366- * root_rl does not take reference on root blkg.
367- */
368- q -> root_blkg = NULL ;
369- q -> root_rl .blkg = NULL ;
370377}
371378
372379/*
@@ -973,8 +980,6 @@ int blkcg_activate_policy(struct request_queue *q,
973980 ret = PTR_ERR (blkg );
974981 goto out_unlock ;
975982 }
976- q -> root_blkg = blkg ;
977- q -> root_rl .blkg = blkg ;
978983
979984 list_for_each_entry (blkg , & q -> blkg_list , q_node )
980985 cnt ++ ;
0 commit comments