aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-04-16 16:57:26 -0400
committerJens Axboe <axboe@kernel.dk>2012-04-20 04:06:17 -0400
commitf95a04afa80c0f4ddd645ef6a84ed118b5d1ad46 (patch)
tree2428dacf9bab1eb643628c872aed3092704f7fb2 /block/cfq-iosched.c
parent3c798398e393e5f9502dbab2b51e6c25e2e8f2ac (diff)
blkcg: embed struct blkg_policy_data in policy specific data
Currently blkg_policy_data carries policy specific data as char flex array instead of being embedded in policy specific data. This was forced by oddities around blkg allocation which are all gone now. This patch makes blkg_policy_data embedded in policy specific data - throtl_grp and cfq_group so that it's more conventional and consistent with how io_cq is handled. * blkcg_policy->pdata_size is renamed to ->pd_size. * Functions which used to take void *pdata now takes struct blkg_policy_data *pd. * blkg_to_pdata/pdata_to_blkg() updated to blkg_to_pd/pd_to_blkg(). * Dummy struct blkg_policy_data definition added. Dummy pdata_to_blkg() definition was unused and inconsistent with the non-dummy version - correct dummy pd_to_blkg() added. * throtl and cfq updated accordingly. * As dummy blkg_to_pd/pd_to_blkg() are provided, blkg_to_cfqg/cfqg_to_blkg() don't need to be ifdef'd. Moved outside ifdef block. This patch doesn't introduce any functional change. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 792218281d91..7865cc38ea77 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -217,6 +217,9 @@ struct cfqg_stats {
217 217
218/* This is per cgroup per device grouping structure */ 218/* This is per cgroup per device grouping structure */
219struct cfq_group { 219struct cfq_group {
220 /* must be the first member */
221 struct blkg_policy_data pd;
222
220 /* group service_tree member */ 223 /* group service_tree member */
221 struct rb_node rb_node; 224 struct rb_node rb_node;
222 225
@@ -409,6 +412,21 @@ CFQ_CFQQ_FNS(deep);
409CFQ_CFQQ_FNS(wait_busy); 412CFQ_CFQQ_FNS(wait_busy);
410#undef CFQ_CFQQ_FNS 413#undef CFQ_CFQQ_FNS
411 414
415static inline struct cfq_group *pd_to_cfqg(struct blkg_policy_data *pd)
416{
417 return pd ? container_of(pd, struct cfq_group, pd) : NULL;
418}
419
420static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg)
421{
422 return pd_to_cfqg(blkg_to_pd(blkg, &blkcg_policy_cfq));
423}
424
425static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg)
426{
427 return pd_to_blkg(&cfqg->pd);
428}
429
412#if defined(CONFIG_CFQ_GROUP_IOSCHED) && defined(CONFIG_DEBUG_BLK_CGROUP) 430#if defined(CONFIG_CFQ_GROUP_IOSCHED) && defined(CONFIG_DEBUG_BLK_CGROUP)
413 431
414/* cfqg stats flags */ 432/* cfqg stats flags */
@@ -553,16 +571,6 @@ static inline void cfqg_stats_update_avg_queue_size(struct cfq_group *cfqg) { }
553 571
554#ifdef CONFIG_CFQ_GROUP_IOSCHED 572#ifdef CONFIG_CFQ_GROUP_IOSCHED
555 573
556static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg)
557{
558 return blkg_to_pdata(blkg, &blkcg_policy_cfq);
559}
560
561static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg)
562{
563 return pdata_to_blkg(cfqg);
564}
565
566static inline void cfqg_get(struct cfq_group *cfqg) 574static inline void cfqg_get(struct cfq_group *cfqg)
567{ 575{
568 return blkg_get(cfqg_to_blkg(cfqg)); 576 return blkg_get(cfqg_to_blkg(cfqg));
@@ -662,8 +670,6 @@ static void cfq_pd_reset_stats(struct blkcg_gq *blkg)
662 670
663#else /* CONFIG_CFQ_GROUP_IOSCHED */ 671#else /* CONFIG_CFQ_GROUP_IOSCHED */
664 672
665static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg) { return NULL; }
666static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg) { return NULL; }
667static inline void cfqg_get(struct cfq_group *cfqg) { } 673static inline void cfqg_get(struct cfq_group *cfqg) { }
668static inline void cfqg_put(struct cfq_group *cfqg) { } 674static inline void cfqg_put(struct cfq_group *cfqg) { }
669 675
@@ -1374,13 +1380,14 @@ static void cfq_link_cfqq_cfqg(struct cfq_queue *cfqq, struct cfq_group *cfqg)
1374 cfqg_get(cfqg); 1380 cfqg_get(cfqg);
1375} 1381}
1376 1382
1377static u64 cfqg_prfill_weight_device(struct seq_file *sf, void *pdata, int off) 1383static u64 cfqg_prfill_weight_device(struct seq_file *sf,
1384 struct blkg_policy_data *pd, int off)
1378{ 1385{
1379 struct cfq_group *cfqg = pdata; 1386 struct cfq_group *cfqg = pd_to_cfqg(pd);
1380 1387
1381 if (!cfqg->dev_weight) 1388 if (!cfqg->dev_weight)
1382 return 0; 1389 return 0;
1383 return __blkg_prfill_u64(sf, pdata, cfqg->dev_weight); 1390 return __blkg_prfill_u64(sf, pd, cfqg->dev_weight);
1384} 1391}
1385 1392
1386static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft, 1393static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft,
@@ -1467,9 +1474,10 @@ static int cfqg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
1467} 1474}
1468 1475
1469#ifdef CONFIG_DEBUG_BLK_CGROUP 1476#ifdef CONFIG_DEBUG_BLK_CGROUP
1470static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, void *pdata, int off) 1477static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,
1478 struct blkg_policy_data *pd, int off)
1471{ 1479{
1472 struct cfq_group *cfqg = pdata; 1480 struct cfq_group *cfqg = pd_to_cfqg(pd);
1473 u64 samples = blkg_stat_read(&cfqg->stats.avg_queue_size_samples); 1481 u64 samples = blkg_stat_read(&cfqg->stats.avg_queue_size_samples);
1474 u64 v = 0; 1482 u64 v = 0;
1475 1483
@@ -1477,7 +1485,7 @@ static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, void *pdata, int off)
1477 v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum); 1485 v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum);
1478 do_div(v, samples); 1486 do_div(v, samples);
1479 } 1487 }
1480 __blkg_prfill_u64(sf, pdata, v); 1488 __blkg_prfill_u64(sf, pd, v);
1481 return 0; 1489 return 0;
1482} 1490}
1483 1491
@@ -4161,7 +4169,7 @@ static struct blkcg_policy blkcg_policy_cfq = {
4161 .pd_init_fn = cfq_pd_init, 4169 .pd_init_fn = cfq_pd_init,
4162 .pd_reset_stats_fn = cfq_pd_reset_stats, 4170 .pd_reset_stats_fn = cfq_pd_reset_stats,
4163 }, 4171 },
4164 .pdata_size = sizeof(struct cfq_group), 4172 .pd_size = sizeof(struct cfq_group),
4165 .cftypes = cfq_blkcg_files, 4173 .cftypes = cfq_blkcg_files,
4166}; 4174};
4167#endif 4175#endif