aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:01 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:22 -0500
commit2a7f124414b35645049e9c1b125a6f0b470aa5ae (patch)
tree298d9bc310dc46baed69baf88f083c6db35f0964 /block/cfq-iosched.c
parent72e06c255181537d0b3e1f657a9ed81655d745b1 (diff)
blkcg: move rcu_read_lock() outside of blkio_group get functions
rcu_read_lock() in throtl_get_tb() and cfq_get_cfqg() holds onto @blkcg while looking up blkg. For API cleanup, the next patch will make the caller responsible for determining @blkcg to look blkg from and let them specify it as a parameter. Move rcu read locking out to the callers to prepare for the change. -v2: Originally this patch was described as a fix for RCU read locking bug around @blkg, which Vivek pointed out to be incorrect. It was from misunderstanding the role of rcu locking as protecting @blkg not @blkcg. Patch description updated. 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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 61693d3404d0..6063c4482b86 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1128,13 +1128,10 @@ static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd)
1128 struct cfq_group *cfqg = NULL, *__cfqg = NULL; 1128 struct cfq_group *cfqg = NULL, *__cfqg = NULL;
1129 struct request_queue *q = cfqd->queue; 1129 struct request_queue *q = cfqd->queue;
1130 1130
1131 rcu_read_lock();
1132 blkcg = task_blkio_cgroup(current); 1131 blkcg = task_blkio_cgroup(current);
1133 cfqg = cfq_find_cfqg(cfqd, blkcg); 1132 cfqg = cfq_find_cfqg(cfqd, blkcg);
1134 if (cfqg) { 1133 if (cfqg)
1135 rcu_read_unlock();
1136 return cfqg; 1134 return cfqg;
1137 }
1138 1135
1139 /* 1136 /*
1140 * Need to allocate a group. Allocation of group also needs allocation 1137 * Need to allocate a group. Allocation of group also needs allocation
@@ -1164,7 +1161,6 @@ static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd)
1164 1161
1165 if (__cfqg) { 1162 if (__cfqg) {
1166 kfree(cfqg); 1163 kfree(cfqg);
1167 rcu_read_unlock();
1168 return __cfqg; 1164 return __cfqg;
1169 } 1165 }
1170 1166
@@ -1172,7 +1168,6 @@ static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd)
1172 cfqg = &cfqd->root_group; 1168 cfqg = &cfqd->root_group;
1173 1169
1174 cfq_init_add_cfqg_lists(cfqd, cfqg, blkcg); 1170 cfq_init_add_cfqg_lists(cfqd, cfqg, blkcg);
1175 rcu_read_unlock();
1176 return cfqg; 1171 return cfqg;
1177} 1172}
1178 1173
@@ -2870,6 +2865,8 @@ cfq_find_alloc_queue(struct cfq_data *cfqd, bool is_sync,
2870 struct cfq_group *cfqg; 2865 struct cfq_group *cfqg;
2871 2866
2872retry: 2867retry:
2868 rcu_read_lock();
2869
2873 cfqg = cfq_get_cfqg(cfqd); 2870 cfqg = cfq_get_cfqg(cfqd);
2874 cic = cfq_cic_lookup(cfqd, ioc); 2871 cic = cfq_cic_lookup(cfqd, ioc);
2875 /* cic always exists here */ 2872 /* cic always exists here */
@@ -2885,6 +2882,7 @@ retry:
2885 cfqq = new_cfqq; 2882 cfqq = new_cfqq;
2886 new_cfqq = NULL; 2883 new_cfqq = NULL;
2887 } else if (gfp_mask & __GFP_WAIT) { 2884 } else if (gfp_mask & __GFP_WAIT) {
2885 rcu_read_unlock();
2888 spin_unlock_irq(cfqd->queue->queue_lock); 2886 spin_unlock_irq(cfqd->queue->queue_lock);
2889 new_cfqq = kmem_cache_alloc_node(cfq_pool, 2887 new_cfqq = kmem_cache_alloc_node(cfq_pool,
2890 gfp_mask | __GFP_ZERO, 2888 gfp_mask | __GFP_ZERO,
@@ -2910,6 +2908,7 @@ retry:
2910 if (new_cfqq) 2908 if (new_cfqq)
2911 kmem_cache_free(cfq_pool, new_cfqq); 2909 kmem_cache_free(cfq_pool, new_cfqq);
2912 2910
2911 rcu_read_unlock();
2913 return cfqq; 2912 return cfqq;
2914} 2913}
2915 2914