aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-05-29 03:32:08 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-07-03 07:21:12 -0400
commit9a11b4ed0e7c44bca7c939aa544c3c47aae40c12 (patch)
tree438312dda8a63e0704c2ddbdea958f0d729c6c7e /block/cfq-iosched.c
parentc461a973118346d5c103aaaddd62e53939fd7c67 (diff)
cfq-iosched: properly protect ioc_gone and ioc count
If we have multiple tasks freeing cfq_io_contexts when cfq-iosched is being unloaded, we could complete() ioc_gone twice. Fix that by protecting ioc_gone complete() and clearing with a spinlock for just that purpose. Doesn't matter from a performance perspective, since it'll only enter that path when ioc_gone != NULL (when cfq-iosched is being rmmod'ed). Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d01b411c72f0..32aa3674f8a3 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -48,6 +48,7 @@ static struct kmem_cache *cfq_ioc_pool;
48 48
49static DEFINE_PER_CPU(unsigned long, ioc_count); 49static DEFINE_PER_CPU(unsigned long, ioc_count);
50static struct completion *ioc_gone; 50static struct completion *ioc_gone;
51static DEFINE_SPINLOCK(ioc_gone_lock);
51 52
52#define CFQ_PRIO_LISTS IOPRIO_BE_NR 53#define CFQ_PRIO_LISTS IOPRIO_BE_NR
53#define cfq_class_idle(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE) 54#define cfq_class_idle(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE)
@@ -1177,8 +1178,19 @@ static void cfq_cic_free_rcu(struct rcu_head *head)
1177 kmem_cache_free(cfq_ioc_pool, cic); 1178 kmem_cache_free(cfq_ioc_pool, cic);
1178 elv_ioc_count_dec(ioc_count); 1179 elv_ioc_count_dec(ioc_count);
1179 1180
1180 if (ioc_gone && !elv_ioc_count_read(ioc_count)) 1181 if (ioc_gone) {
1181 complete(ioc_gone); 1182 /*
1183 * CFQ scheduler is exiting, grab exit lock and check
1184 * the pending io context count. If it hits zero,
1185 * complete ioc_gone and set it back to NULL
1186 */
1187 spin_lock(&ioc_gone_lock);
1188 if (ioc_gone && !elv_ioc_count_read(ioc_count)) {
1189 complete(ioc_gone);
1190 ioc_gone = NULL;
1191 }
1192 spin_unlock(&ioc_gone_lock);
1193 }
1182} 1194}
1183 1195
1184static void cfq_cic_free(struct cfq_io_context *cic) 1196static void cfq_cic_free(struct cfq_io_context *cic)
@@ -2317,7 +2329,7 @@ static void __exit cfq_exit(void)
2317 * pending RCU callbacks 2329 * pending RCU callbacks
2318 */ 2330 */
2319 if (elv_ioc_count_read(ioc_count)) 2331 if (elv_ioc_count_read(ioc_count))
2320 wait_for_completion(ioc_gone); 2332 wait_for_completion(&all_gone);
2321 cfq_slab_kill(); 2333 cfq_slab_kill();
2322} 2334}
2323 2335