Commit 03d8e11142a893ad322285d3c8a08e88b570cda1

Authored by Tejun Heo
Committed by Jens Axboe
1 parent b82d4b197c

blkcg: add request_queue->root_blkg

With per-queue policy activation, root blkg creation will be moved to
blkcg core.  Add q->root_blkg in preparation.  For blk-throtl, this
replaces throtl_data->root_tg; however, cfq needs to keep
cfqd->root_group for !CONFIG_CFQ_GROUP_IOSCHED.

This is to prepare for per-queue policy activation and doesn't cause
any functional difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

Showing 3 changed files with 15 additions and 7 deletions Side-by-side Diff

block/blk-throttle.c
... ... @@ -97,7 +97,6 @@
97 97 /* service tree for active throtl groups */
98 98 struct throtl_rb_root tg_service_tree;
99 99  
100   - struct throtl_grp *root_tg;
101 100 struct request_queue *queue;
102 101  
103 102 /* Total Number of queued bios on READ and WRITE lists */
... ... @@ -131,6 +130,11 @@
131 130 return pdata_to_blkg(tg);
132 131 }
133 132  
  133 +static inline struct throtl_grp *td_root_tg(struct throtl_data *td)
  134 +{
  135 + return blkg_to_tg(td->queue->root_blkg);
  136 +}
  137 +
134 138 enum tg_state_flags {
135 139 THROTL_TG_FLAG_on_rr = 0, /* on round-robin busy list */
136 140 };
... ... @@ -261,7 +265,7 @@
261 265 * Avoid lookup in this case
262 266 */
263 267 if (blkcg == &blkio_root_cgroup)
264   - return td->root_tg;
  268 + return td_root_tg(td);
265 269  
266 270 return blkg_to_tg(blkg_lookup(blkcg, td->queue));
267 271 }
... ... @@ -277,7 +281,7 @@
277 281 * Avoid lookup in this case
278 282 */
279 283 if (blkcg == &blkio_root_cgroup) {
280   - tg = td->root_tg;
  284 + tg = td_root_tg(td);
281 285 } else {
282 286 struct blkio_group *blkg;
283 287  
... ... @@ -287,7 +291,7 @@
287 291 if (!IS_ERR(blkg))
288 292 tg = blkg_to_tg(blkg);
289 293 else if (!blk_queue_dead(q))
290   - tg = td->root_tg;
  294 + tg = td_root_tg(td);
291 295 }
292 296  
293 297 return tg;
294 298  
... ... @@ -1245,12 +1249,12 @@
1245 1249  
1246 1250 blkg = blkg_lookup_create(&blkio_root_cgroup, q, true);
1247 1251 if (!IS_ERR(blkg))
1248   - td->root_tg = blkg_to_tg(blkg);
  1252 + q->root_blkg = blkg;
1249 1253  
1250 1254 spin_unlock_irq(q->queue_lock);
1251 1255 rcu_read_unlock();
1252 1256  
1253   - if (!td->root_tg) {
  1257 + if (!q->root_blkg) {
1254 1258 kfree(td);
1255 1259 return -ENOMEM;
1256 1260 }
... ... @@ -3964,8 +3964,10 @@
3964 3964 spin_lock_irq(q->queue_lock);
3965 3965  
3966 3966 blkg = blkg_lookup_create(&blkio_root_cgroup, q, true);
3967   - if (!IS_ERR(blkg))
  3967 + if (!IS_ERR(blkg)) {
  3968 + q->root_blkg = blkg;
3968 3969 cfqd->root_group = blkg_to_cfqg(blkg);
  3970 + }
3969 3971  
3970 3972 spin_unlock_irq(q->queue_lock);
3971 3973 rcu_read_unlock();
include/linux/blkdev.h
... ... @@ -31,6 +31,7 @@
31 31 struct request;
32 32 struct sg_io_hdr;
33 33 struct bsg_job;
  34 +struct blkio_group;
34 35  
35 36 #define BLKDEV_MIN_RQ 4
36 37 #define BLKDEV_MAX_RQ 128 /* Default maximum */
... ... @@ -369,6 +370,7 @@
369 370  
370 371 struct list_head icq_list;
371 372 #ifdef CONFIG_BLK_CGROUP
  373 + struct blkio_group *root_blkg;
372 374 struct list_head blkg_list;
373 375 #endif
374 376