aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2011-05-19 15:38:25 -0400
committerJens Axboe <jaxboe@fusionio.com>2011-05-20 14:34:52 -0400
commit269f541555d8f5da322d592fb3e13e23ed62d80c (patch)
tree8aaf602bc8d284f9c43720801b799f631dc47419 /block
parent29b125892f3317ada86b662e0b6ebc0f79be9037 (diff)
blk-throttle: Introduce a helper function to fill in device details
A helper function for the code which is used at 2-3 places. Makes reading code little easier. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-throttle.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 68f2ac3f3b07..97ea7f82477d 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -188,16 +188,34 @@ throtl_add_group_to_td_list(struct throtl_data *td, struct throtl_grp *tg)
188 td->nr_undestroyed_grps++; 188 td->nr_undestroyed_grps++;
189} 189}
190 190
191static void throtl_init_add_tg_lists(struct throtl_data *td, 191static void
192 struct throtl_grp *tg, struct blkio_cgroup *blkcg) 192__throtl_tg_fill_dev_details(struct throtl_data *td, struct throtl_grp *tg)
193{ 193{
194 struct backing_dev_info *bdi = &td->queue->backing_dev_info; 194 struct backing_dev_info *bdi = &td->queue->backing_dev_info;
195 unsigned int major, minor; 195 unsigned int major, minor;
196 196
197 if (!tg || tg->blkg.dev)
198 return;
199
200 /*
201 * Fill in device details for a group which might not have been
202 * filled at group creation time as queue was being instantiated
203 * and driver had not attached a device yet
204 */
205 if (bdi->dev && dev_name(bdi->dev)) {
206 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
207 tg->blkg.dev = MKDEV(major, minor);
208 }
209}
210
211static void throtl_init_add_tg_lists(struct throtl_data *td,
212 struct throtl_grp *tg, struct blkio_cgroup *blkcg)
213{
214 __throtl_tg_fill_dev_details(td, tg);
215
197 /* Add group onto cgroup list */ 216 /* Add group onto cgroup list */
198 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
199 blkiocg_add_blkio_group(blkcg, &tg->blkg, (void *)td, 217 blkiocg_add_blkio_group(blkcg, &tg->blkg, (void *)td,
200 MKDEV(major, minor), BLKIO_POLICY_THROTL); 218 tg->blkg.dev, BLKIO_POLICY_THROTL);
201 219
202 tg->bps[READ] = blkcg_get_read_bps(blkcg, tg->blkg.dev); 220 tg->bps[READ] = blkcg_get_read_bps(blkcg, tg->blkg.dev);
203 tg->bps[WRITE] = blkcg_get_write_bps(blkcg, tg->blkg.dev); 221 tg->bps[WRITE] = blkcg_get_write_bps(blkcg, tg->blkg.dev);
@@ -225,8 +243,6 @@ throtl_grp *throtl_find_tg(struct throtl_data *td, struct blkio_cgroup *blkcg)
225{ 243{
226 struct throtl_grp *tg = NULL; 244 struct throtl_grp *tg = NULL;
227 void *key = td; 245 void *key = td;
228 struct backing_dev_info *bdi = &td->queue->backing_dev_info;
229 unsigned int major, minor;
230 246
231 /* 247 /*
232 * This is the common case when there are no blkio cgroups. 248 * This is the common case when there are no blkio cgroups.
@@ -237,12 +253,7 @@ throtl_grp *throtl_find_tg(struct throtl_data *td, struct blkio_cgroup *blkcg)
237 else 253 else
238 tg = tg_of_blkg(blkiocg_lookup_group(blkcg, key)); 254 tg = tg_of_blkg(blkiocg_lookup_group(blkcg, key));
239 255
240 /* Fill in device details for root group */ 256 __throtl_tg_fill_dev_details(td, tg);
241 if (tg && !tg->blkg.dev && bdi->dev && dev_name(bdi->dev)) {
242 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
243 tg->blkg.dev = MKDEV(major, minor);
244 }
245
246 return tg; 257 return tg;
247} 258}
248 259