diff options
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r-- | block/blk-cgroup.h | 87 |
1 files changed, 82 insertions, 5 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 2b866ec1dcea..ea4861bdd549 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -15,6 +15,14 @@ | |||
15 | 15 | ||
16 | #include <linux/cgroup.h> | 16 | #include <linux/cgroup.h> |
17 | 17 | ||
18 | enum blkio_policy_id { | ||
19 | BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */ | ||
20 | BLKIO_POLICY_THROTL, /* Throttling */ | ||
21 | }; | ||
22 | |||
23 | /* Max limits for throttle policy */ | ||
24 | #define THROTL_IOPS_MAX UINT_MAX | ||
25 | |||
18 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) | 26 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) |
19 | 27 | ||
20 | #ifndef CONFIG_BLK_CGROUP | 28 | #ifndef CONFIG_BLK_CGROUP |
@@ -65,6 +73,35 @@ enum blkg_state_flags { | |||
65 | BLKG_empty, | 73 | BLKG_empty, |
66 | }; | 74 | }; |
67 | 75 | ||
76 | /* cgroup files owned by proportional weight policy */ | ||
77 | enum blkcg_file_name_prop { | ||
78 | BLKIO_PROP_weight = 1, | ||
79 | BLKIO_PROP_weight_device, | ||
80 | BLKIO_PROP_io_service_bytes, | ||
81 | BLKIO_PROP_io_serviced, | ||
82 | BLKIO_PROP_time, | ||
83 | BLKIO_PROP_sectors, | ||
84 | BLKIO_PROP_io_service_time, | ||
85 | BLKIO_PROP_io_wait_time, | ||
86 | BLKIO_PROP_io_merged, | ||
87 | BLKIO_PROP_io_queued, | ||
88 | BLKIO_PROP_avg_queue_size, | ||
89 | BLKIO_PROP_group_wait_time, | ||
90 | BLKIO_PROP_idle_time, | ||
91 | BLKIO_PROP_empty_time, | ||
92 | BLKIO_PROP_dequeue, | ||
93 | }; | ||
94 | |||
95 | /* cgroup files owned by throttle policy */ | ||
96 | enum blkcg_file_name_throtl { | ||
97 | BLKIO_THROTL_read_bps_device, | ||
98 | BLKIO_THROTL_write_bps_device, | ||
99 | BLKIO_THROTL_read_iops_device, | ||
100 | BLKIO_THROTL_write_iops_device, | ||
101 | BLKIO_THROTL_io_service_bytes, | ||
102 | BLKIO_THROTL_io_serviced, | ||
103 | }; | ||
104 | |||
68 | struct blkio_cgroup { | 105 | struct blkio_cgroup { |
69 | struct cgroup_subsys_state css; | 106 | struct cgroup_subsys_state css; |
70 | unsigned int weight; | 107 | unsigned int weight; |
@@ -112,6 +149,8 @@ struct blkio_group { | |||
112 | char path[128]; | 149 | char path[128]; |
113 | /* The device MKDEV(major, minor), this group has been created for */ | 150 | /* The device MKDEV(major, minor), this group has been created for */ |
114 | dev_t dev; | 151 | dev_t dev; |
152 | /* policy which owns this blk group */ | ||
153 | enum blkio_policy_id plid; | ||
115 | 154 | ||
116 | /* Need to serialize the stats in the case of reset/update */ | 155 | /* Need to serialize the stats in the case of reset/update */ |
117 | spinlock_t stats_lock; | 156 | spinlock_t stats_lock; |
@@ -121,24 +160,60 @@ struct blkio_group { | |||
121 | struct blkio_policy_node { | 160 | struct blkio_policy_node { |
122 | struct list_head node; | 161 | struct list_head node; |
123 | dev_t dev; | 162 | dev_t dev; |
124 | unsigned int weight; | 163 | /* This node belongs to max bw policy or porportional weight policy */ |
164 | enum blkio_policy_id plid; | ||
165 | /* cgroup file to which this rule belongs to */ | ||
166 | int fileid; | ||
167 | |||
168 | union { | ||
169 | unsigned int weight; | ||
170 | /* | ||
171 | * Rate read/write in terms of byptes per second | ||
172 | * Whether this rate represents read or write is determined | ||
173 | * by file type "fileid". | ||
174 | */ | ||
175 | u64 bps; | ||
176 | unsigned int iops; | ||
177 | } val; | ||
125 | }; | 178 | }; |
126 | 179 | ||
127 | extern unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg, | 180 | extern unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg, |
128 | dev_t dev); | 181 | dev_t dev); |
182 | extern uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, | ||
183 | dev_t dev); | ||
184 | extern uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, | ||
185 | dev_t dev); | ||
186 | extern unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, | ||
187 | dev_t dev); | ||
188 | extern unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, | ||
189 | dev_t dev); | ||
129 | 190 | ||
130 | typedef void (blkio_unlink_group_fn) (void *key, struct blkio_group *blkg); | 191 | typedef void (blkio_unlink_group_fn) (void *key, struct blkio_group *blkg); |
131 | typedef void (blkio_update_group_weight_fn) (struct blkio_group *blkg, | 192 | |
132 | unsigned int weight); | 193 | typedef void (blkio_update_group_weight_fn) (void *key, |
194 | struct blkio_group *blkg, unsigned int weight); | ||
195 | typedef void (blkio_update_group_read_bps_fn) (void * key, | ||
196 | struct blkio_group *blkg, u64 read_bps); | ||
197 | typedef void (blkio_update_group_write_bps_fn) (void *key, | ||
198 | struct blkio_group *blkg, u64 write_bps); | ||
199 | typedef void (blkio_update_group_read_iops_fn) (void *key, | ||
200 | struct blkio_group *blkg, unsigned int read_iops); | ||
201 | typedef void (blkio_update_group_write_iops_fn) (void *key, | ||
202 | struct blkio_group *blkg, unsigned int write_iops); | ||
133 | 203 | ||
134 | struct blkio_policy_ops { | 204 | struct blkio_policy_ops { |
135 | blkio_unlink_group_fn *blkio_unlink_group_fn; | 205 | blkio_unlink_group_fn *blkio_unlink_group_fn; |
136 | blkio_update_group_weight_fn *blkio_update_group_weight_fn; | 206 | blkio_update_group_weight_fn *blkio_update_group_weight_fn; |
207 | blkio_update_group_read_bps_fn *blkio_update_group_read_bps_fn; | ||
208 | blkio_update_group_write_bps_fn *blkio_update_group_write_bps_fn; | ||
209 | blkio_update_group_read_iops_fn *blkio_update_group_read_iops_fn; | ||
210 | blkio_update_group_write_iops_fn *blkio_update_group_write_iops_fn; | ||
137 | }; | 211 | }; |
138 | 212 | ||
139 | struct blkio_policy_type { | 213 | struct blkio_policy_type { |
140 | struct list_head list; | 214 | struct list_head list; |
141 | struct blkio_policy_ops ops; | 215 | struct blkio_policy_ops ops; |
216 | enum blkio_policy_id plid; | ||
142 | }; | 217 | }; |
143 | 218 | ||
144 | /* Blkio controller policy registration */ | 219 | /* Blkio controller policy registration */ |
@@ -212,7 +287,8 @@ static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg) {} | |||
212 | extern struct blkio_cgroup blkio_root_cgroup; | 287 | extern struct blkio_cgroup blkio_root_cgroup; |
213 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); | 288 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); |
214 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | 289 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, |
215 | struct blkio_group *blkg, void *key, dev_t dev); | 290 | struct blkio_group *blkg, void *key, dev_t dev, |
291 | enum blkio_policy_id plid); | ||
216 | extern int blkiocg_del_blkio_group(struct blkio_group *blkg); | 292 | extern int blkiocg_del_blkio_group(struct blkio_group *blkg); |
217 | extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, | 293 | extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, |
218 | void *key); | 294 | void *key); |
@@ -234,7 +310,8 @@ static inline struct blkio_cgroup * | |||
234 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } | 310 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } |
235 | 311 | ||
236 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | 312 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, |
237 | struct blkio_group *blkg, void *key, dev_t dev) {} | 313 | struct blkio_group *blkg, void *key, dev_t dev, |
314 | enum blkio_policy_id plid) {} | ||
238 | 315 | ||
239 | static inline int | 316 | static inline int |
240 | blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } | 317 | blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } |