aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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