@@ -235,8 +235,13 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
235
235
blkg -> online = true;
236
236
spin_unlock (& blkcg -> lock );
237
237
238
- if (!ret )
238
+ if (!ret ) {
239
+ if (blkcg == & blkcg_root ) {
240
+ q -> root_blkg = blkg ;
241
+ q -> root_rl .blkg = blkg ;
242
+ }
239
243
return blkg ;
244
+ }
240
245
241
246
/* @blkg failed fully initialized, use the usual release path */
242
247
blkg_put (blkg );
@@ -334,6 +339,15 @@ static void blkg_destroy(struct blkcg_gq *blkg)
334
339
if (rcu_dereference_raw (blkcg -> blkg_hint ) == blkg )
335
340
rcu_assign_pointer (blkcg -> blkg_hint , NULL );
336
341
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
+
337
351
/*
338
352
* Put the reference taken at the time of creation so that when all
339
353
* queues are gone, group can be destroyed.
@@ -360,13 +374,6 @@ static void blkg_destroy_all(struct request_queue *q)
360
374
blkg_destroy (blkg );
361
375
spin_unlock (& blkcg -> lock );
362
376
}
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 ;
370
377
}
371
378
372
379
/*
@@ -973,8 +980,6 @@ int blkcg_activate_policy(struct request_queue *q,
973
980
ret = PTR_ERR (blkg );
974
981
goto out_unlock ;
975
982
}
976
- q -> root_blkg = blkg ;
977
- q -> root_rl .blkg = blkg ;
978
983
979
984
list_for_each_entry (blkg , & q -> blkg_list , q_node )
980
985
cnt ++ ;
0 commit comments