aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.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/blk-throttle.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/blk-throttle.c')
-rw-r--r--block/blk-throttle.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 00c7eff66ecf..6a0a17a83862 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -49,6 +49,9 @@ struct tg_stats_cpu {
49}; 49};
50 50
51struct throtl_grp { 51struct throtl_grp {
52 /* must be the first member */
53 struct blkg_policy_data pd;
54
52 /* active throtl group service_tree member */ 55 /* active throtl group service_tree member */
53 struct rb_node rb_node; 56 struct rb_node rb_node;
54 57
@@ -120,14 +123,19 @@ static LIST_HEAD(tg_stats_alloc_list);
120static void tg_stats_alloc_fn(struct work_struct *); 123static void tg_stats_alloc_fn(struct work_struct *);
121static DECLARE_DELAYED_WORK(tg_stats_alloc_work, tg_stats_alloc_fn); 124static DECLARE_DELAYED_WORK(tg_stats_alloc_work, tg_stats_alloc_fn);
122 125
126static inline struct throtl_grp *pd_to_tg(struct blkg_policy_data *pd)
127{
128 return pd ? container_of(pd, struct throtl_grp, pd) : NULL;
129}
130
123static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg) 131static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg)
124{ 132{
125 return blkg_to_pdata(blkg, &blkcg_policy_throtl); 133 return pd_to_tg(blkg_to_pd(blkg, &blkcg_policy_throtl));
126} 134}
127 135
128static inline struct blkcg_gq *tg_to_blkg(struct throtl_grp *tg) 136static inline struct blkcg_gq *tg_to_blkg(struct throtl_grp *tg)
129{ 137{
130 return pdata_to_blkg(tg); 138 return pd_to_blkg(&tg->pd);
131} 139}
132 140
133static inline struct throtl_grp *td_root_tg(struct throtl_data *td) 141static inline struct throtl_grp *td_root_tg(struct throtl_data *td)
@@ -931,9 +939,10 @@ throtl_schedule_delayed_work(struct throtl_data *td, unsigned long delay)
931 } 939 }
932} 940}
933 941
934static u64 tg_prfill_cpu_rwstat(struct seq_file *sf, void *pdata, int off) 942static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,
943 struct blkg_policy_data *pd, int off)
935{ 944{
936 struct throtl_grp *tg = pdata; 945 struct throtl_grp *tg = pd_to_tg(pd);
937 struct blkg_rwstat rwstat = { }, tmp; 946 struct blkg_rwstat rwstat = { }, tmp;
938 int i, cpu; 947 int i, cpu;
939 948
@@ -945,7 +954,7 @@ static u64 tg_prfill_cpu_rwstat(struct seq_file *sf, void *pdata, int off)
945 rwstat.cnt[i] += tmp.cnt[i]; 954 rwstat.cnt[i] += tmp.cnt[i];
946 } 955 }
947 956
948 return __blkg_prfill_rwstat(sf, pdata, &rwstat); 957 return __blkg_prfill_rwstat(sf, pd, &rwstat);
949} 958}
950 959
951static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, 960static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
@@ -958,22 +967,26 @@ static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
958 return 0; 967 return 0;
959} 968}
960 969
961static u64 tg_prfill_conf_u64(struct seq_file *sf, void *pdata, int off) 970static u64 tg_prfill_conf_u64(struct seq_file *sf, struct blkg_policy_data *pd,
971 int off)
962{ 972{
963 u64 v = *(u64 *)(pdata + off); 973 struct throtl_grp *tg = pd_to_tg(pd);
974 u64 v = *(u64 *)((void *)tg + off);
964 975
965 if (v == -1) 976 if (v == -1)
966 return 0; 977 return 0;
967 return __blkg_prfill_u64(sf, pdata, v); 978 return __blkg_prfill_u64(sf, pd, v);
968} 979}
969 980
970static u64 tg_prfill_conf_uint(struct seq_file *sf, void *pdata, int off) 981static u64 tg_prfill_conf_uint(struct seq_file *sf, struct blkg_policy_data *pd,
982 int off)
971{ 983{
972 unsigned int v = *(unsigned int *)(pdata + off); 984 struct throtl_grp *tg = pd_to_tg(pd);
985 unsigned int v = *(unsigned int *)((void *)tg + off);
973 986
974 if (v == -1) 987 if (v == -1)
975 return 0; 988 return 0;
976 return __blkg_prfill_u64(sf, pdata, v); 989 return __blkg_prfill_u64(sf, pd, v);
977} 990}
978 991
979static int tg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft, 992static int tg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft,
@@ -1092,7 +1105,7 @@ static struct blkcg_policy blkcg_policy_throtl = {
1092 .pd_exit_fn = throtl_pd_exit, 1105 .pd_exit_fn = throtl_pd_exit,
1093 .pd_reset_stats_fn = throtl_pd_reset_stats, 1106 .pd_reset_stats_fn = throtl_pd_reset_stats,
1094 }, 1107 },
1095 .pdata_size = sizeof(struct throtl_grp), 1108 .pd_size = sizeof(struct throtl_grp),
1096 .cftypes = throtl_files, 1109 .cftypes = throtl_files,
1097}; 1110};
1098 1111