Skip to content

Commit 03d8e11

Browse files
htejunaxboe
authored andcommitted
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>
1 parent b82d4b1 commit 03d8e11

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎block/blk-throttle.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct throtl_data
9797
/* service tree for active throtl groups */
9898
struct throtl_rb_root tg_service_tree;
9999

100-
struct throtl_grp *root_tg;
101100
struct request_queue *queue;
102101

103102
/* Total Number of queued bios on READ and WRITE lists */
@@ -131,6 +130,11 @@ static inline struct blkio_group *tg_to_blkg(struct throtl_grp *tg)
131130
return pdata_to_blkg(tg);
132131
}
133132

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+
134138
enum tg_state_flags {
135139
THROTL_TG_FLAG_on_rr = 0, /* on round-robin busy list */
136140
};
@@ -261,7 +265,7 @@ throtl_grp *throtl_lookup_tg(struct throtl_data *td, struct blkio_cgroup *blkcg)
261265
* Avoid lookup in this case
262266
*/
263267
if (blkcg == &blkio_root_cgroup)
264-
return td->root_tg;
268+
return td_root_tg(td);
265269

266270
return blkg_to_tg(blkg_lookup(blkcg, td->queue));
267271
}
@@ -277,7 +281,7 @@ static struct throtl_grp *throtl_lookup_create_tg(struct throtl_data *td,
277281
* Avoid lookup in this case
278282
*/
279283
if (blkcg == &blkio_root_cgroup) {
280-
tg = td->root_tg;
284+
tg = td_root_tg(td);
281285
} else {
282286
struct blkio_group *blkg;
283287

@@ -287,7 +291,7 @@ static struct throtl_grp *throtl_lookup_create_tg(struct throtl_data *td,
287291
if (!IS_ERR(blkg))
288292
tg = blkg_to_tg(blkg);
289293
else if (!blk_queue_dead(q))
290-
tg = td->root_tg;
294+
tg = td_root_tg(td);
291295
}
292296

293297
return tg;
@@ -1245,12 +1249,12 @@ int blk_throtl_init(struct request_queue *q)
12451249

12461250
blkg = blkg_lookup_create(&blkio_root_cgroup, q, true);
12471251
if (!IS_ERR(blkg))
1248-
td->root_tg = blkg_to_tg(blkg);
1252+
q->root_blkg = blkg;
12491253

12501254
spin_unlock_irq(q->queue_lock);
12511255
rcu_read_unlock();
12521256

1253-
if (!td->root_tg) {
1257+
if (!q->root_blkg) {
12541258
kfree(td);
12551259
return -ENOMEM;
12561260
}

‎block/cfq-iosched.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3964,8 +3964,10 @@ static int cfq_init_queue(struct request_queue *q)
39643964
spin_lock_irq(q->queue_lock);
39653965

39663966
blkg = blkg_lookup_create(&blkio_root_cgroup, q, true);
3967-
if (!IS_ERR(blkg))
3967+
if (!IS_ERR(blkg)) {
3968+
q->root_blkg = blkg;
39683969
cfqd->root_group = blkg_to_cfqg(blkg);
3970+
}
39693971

39703972
spin_unlock_irq(q->queue_lock);
39713973
rcu_read_unlock();

‎include/linux/blkdev.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct blk_trace;
3131
struct request;
3232
struct sg_io_hdr;
3333
struct bsg_job;
34+
struct blkio_group;
3435

3536
#define BLKDEV_MIN_RQ 4
3637
#define BLKDEV_MAX_RQ 128 /* Default maximum */
@@ -369,6 +370,7 @@ struct request_queue {
369370

370371
struct list_head icq_list;
371372
#ifdef CONFIG_BLK_CGROUP
373+
struct blkio_group *root_blkg;
372374
struct list_head blkg_list;
373375
#endif
374376

0 commit comments

Comments
 (0)