aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:03 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:22 -0500
commitca32aefc7f2539ed88d42763330d54ee3e61769a (patch)
tree791d2ac1c11b738ce34629653090b6e971fc11b5 /block/cfq-iosched.c
parent0a5a7d0e32be6643b881f0e7cd9d0d06fadde27a (diff)
blkcg: use q and plid instead of opaque void * for blkio_group association
blkgio_group is association between a block cgroup and a queue for a given policy. Using opaque void * for association makes things confusing and hinders factoring of common code. Use request_queue * and, if necessary, policy id instead. This will help block cgroup API cleanup. 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/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 0f7a81fc7c73..37e2da9cbb09 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1020,7 +1020,8 @@ static inline struct cfq_group *cfqg_of_blkg(struct blkio_group *blkg)
1020 return NULL; 1020 return NULL;
1021} 1021}
1022 1022
1023static void cfq_update_blkio_group_weight(void *key, struct blkio_group *blkg, 1023static void cfq_update_blkio_group_weight(struct request_queue *q,
1024 struct blkio_group *blkg,
1024 unsigned int weight) 1025 unsigned int weight)
1025{ 1026{
1026 struct cfq_group *cfqg = cfqg_of_blkg(blkg); 1027 struct cfq_group *cfqg = cfqg_of_blkg(blkg);
@@ -1043,10 +1044,10 @@ static void cfq_init_add_cfqg_lists(struct cfq_data *cfqd,
1043 if (bdi->dev) { 1044 if (bdi->dev) {
1044 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor); 1045 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
1045 cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg, 1046 cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg,
1046 (void *)cfqd, MKDEV(major, minor)); 1047 cfqd->queue, MKDEV(major, minor));
1047 } else 1048 } else
1048 cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg, 1049 cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg,
1049 (void *)cfqd, 0); 1050 cfqd->queue, 0);
1050 1051
1051 cfqd->nr_blkcg_linked_grps++; 1052 cfqd->nr_blkcg_linked_grps++;
1052 cfqg->weight = blkcg_get_weight(blkcg, cfqg->blkg.dev); 1053 cfqg->weight = blkcg_get_weight(blkcg, cfqg->blkg.dev);
@@ -1097,7 +1098,6 @@ static struct cfq_group *
1097cfq_find_cfqg(struct cfq_data *cfqd, struct blkio_cgroup *blkcg) 1098cfq_find_cfqg(struct cfq_data *cfqd, struct blkio_cgroup *blkcg)
1098{ 1099{
1099 struct cfq_group *cfqg = NULL; 1100 struct cfq_group *cfqg = NULL;
1100 void *key = cfqd;
1101 struct backing_dev_info *bdi = &cfqd->queue->backing_dev_info; 1101 struct backing_dev_info *bdi = &cfqd->queue->backing_dev_info;
1102 unsigned int major, minor; 1102 unsigned int major, minor;
1103 1103
@@ -1108,7 +1108,8 @@ cfq_find_cfqg(struct cfq_data *cfqd, struct blkio_cgroup *blkcg)
1108 if (blkcg == &blkio_root_cgroup) 1108 if (blkcg == &blkio_root_cgroup)
1109 cfqg = &cfqd->root_group; 1109 cfqg = &cfqd->root_group;
1110 else 1110 else
1111 cfqg = cfqg_of_blkg(blkiocg_lookup_group(blkcg, key)); 1111 cfqg = cfqg_of_blkg(blkiocg_lookup_group(blkcg, cfqd->queue,
1112 BLKIO_POLICY_PROP));
1112 1113
1113 if (cfqg && !cfqg->blkg.dev && bdi->dev && dev_name(bdi->dev)) { 1114 if (cfqg && !cfqg->blkg.dev && bdi->dev && dev_name(bdi->dev)) {
1114 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor); 1115 sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
@@ -1247,21 +1248,22 @@ static bool cfq_release_cfq_groups(struct cfq_data *cfqd)
1247 * any pending IO in the group is finished. 1248 * any pending IO in the group is finished.
1248 * 1249 *
1249 * This function is called under rcu_read_lock(). key is the rcu protected 1250 * This function is called under rcu_read_lock(). key is the rcu protected
1250 * pointer. That means "key" is a valid cfq_data pointer as long as we are rcu 1251 * pointer. That means @q is a valid request_queue pointer as long as we
1251 * read lock. 1252 * are rcu read lock.
1252 * 1253 *
1253 * "key" was fetched from blkio_group under blkio_cgroup->lock. That means 1254 * @q was fetched from blkio_group under blkio_cgroup->lock. That means
1254 * it should not be NULL as even if elevator was exiting, cgroup deltion 1255 * it should not be NULL as even if elevator was exiting, cgroup deltion
1255 * path got to it first. 1256 * path got to it first.
1256 */ 1257 */
1257static void cfq_unlink_blkio_group(void *key, struct blkio_group *blkg) 1258static void cfq_unlink_blkio_group(struct request_queue *q,
1259 struct blkio_group *blkg)
1258{ 1260{
1259 unsigned long flags; 1261 struct cfq_data *cfqd = q->elevator->elevator_data;
1260 struct cfq_data *cfqd = key; 1262 unsigned long flags;
1261 1263
1262 spin_lock_irqsave(cfqd->queue->queue_lock, flags); 1264 spin_lock_irqsave(q->queue_lock, flags);
1263 cfq_destroy_cfqg(cfqd, cfqg_of_blkg(blkg)); 1265 cfq_destroy_cfqg(cfqd, cfqg_of_blkg(blkg));
1264 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags); 1266 spin_unlock_irqrestore(q->queue_lock, flags);
1265} 1267}
1266 1268
1267static struct elevator_type iosched_cfq; 1269static struct elevator_type iosched_cfq;
@@ -3718,7 +3720,7 @@ static int cfq_init_queue(struct request_queue *q)
3718 rcu_read_lock(); 3720 rcu_read_lock();
3719 3721
3720 cfq_blkiocg_add_blkio_group(&blkio_root_cgroup, &cfqg->blkg, 3722 cfq_blkiocg_add_blkio_group(&blkio_root_cgroup, &cfqg->blkg,
3721 (void *)cfqd, 0); 3723 cfqd->queue, 0);
3722 rcu_read_unlock(); 3724 rcu_read_unlock();
3723 cfqd->nr_blkcg_linked_grps++; 3725 cfqd->nr_blkcg_linked_grps++;
3724 3726