aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
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