elevator: Fix a race in elevator switching and md device initialization
[linux-3.10.git] / block / elevator.c
index 668394d..02d4390 100644 (file)
@@ -186,6 +186,12 @@ int elevator_init(struct request_queue *q, char *name)
        struct elevator_type *e = NULL;
        int err;
 
+       /*
+        * q->sysfs_lock must be held to provide mutual exclusion between
+        * elevator_switch() and here.
+        */
+       lockdep_assert_held(&q->sysfs_lock);
+
        if (unlikely(q->elevator))
                return 0;