memcg: add mem_cgroup_zone_nr_pages()
[linux-2.6-block.git] / block / cfq-iosched.c
index ee8a90c7c46cab5a48f1eb8d0620dbf8ff030499..e8525fa72823a0c88adfd386e84e7b3e5db33af7 100644 (file)
@@ -1314,7 +1314,15 @@ static void cfq_exit_single_io_context(struct io_context *ioc,
                unsigned long flags;
 
                spin_lock_irqsave(q->queue_lock, flags);
-               __cfq_exit_single_io_context(cfqd, cic);
+
+               /*
+                * Ensure we get a fresh copy of the ->key to prevent
+                * race between exiting task and queue
+                */
+               smp_read_barrier_depends();
+               if (cic->key)
+                       __cfq_exit_single_io_context(cfqd, cic);
+
                spin_unlock_irqrestore(q->queue_lock, flags);
        }
 }