diff options
Diffstat (limited to 'block/blk-throttle.c')
-rw-r--r-- | block/blk-throttle.c | 37 |
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 | ||
51 | struct throtl_grp { | 51 | struct 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); | |||
120 | static void tg_stats_alloc_fn(struct work_struct *); | 123 | static void tg_stats_alloc_fn(struct work_struct *); |
121 | static DECLARE_DELAYED_WORK(tg_stats_alloc_work, tg_stats_alloc_fn); | 124 | static DECLARE_DELAYED_WORK(tg_stats_alloc_work, tg_stats_alloc_fn); |
122 | 125 | ||
126 | static 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 | |||
123 | static inline struct throtl_grp *blkg_to_tg(struct blkcg_gq *blkg) | 131 | static 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 | ||
128 | static inline struct blkcg_gq *tg_to_blkg(struct throtl_grp *tg) | 136 | static 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 | ||
133 | static inline struct throtl_grp *td_root_tg(struct throtl_data *td) | 141 | static 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 | ||
934 | static u64 tg_prfill_cpu_rwstat(struct seq_file *sf, void *pdata, int off) | 942 | static 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 | ||
951 | static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, | 960 | static 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 | ||
961 | static u64 tg_prfill_conf_u64(struct seq_file *sf, void *pdata, int off) | 970 | static 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 | ||
970 | static u64 tg_prfill_conf_uint(struct seq_file *sf, void *pdata, int off) | 981 | static 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 | ||
979 | static int tg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft, | 992 | static 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 | ||