block: fix concurrent elevator change failure#950
Conversation
|
Upstream branch: 9716c08 |
c3a084b to
5f78e5d
Compare
|
Upstream branch: 2a2974b |
7319d84 to
e311169
Compare
5f78e5d to
e48f9db
Compare
|
Upstream branch: 062871f |
e311169 to
3c67290
Compare
199644a to
e6d9eb8
Compare
|
Upstream branch: 66affa3 |
3c67290 to
7be7953
Compare
e6d9eb8 to
7d8604f
Compare
|
Upstream branch: bade58e |
7be7953 to
937b8ef
Compare
7d8604f to
4cc45a3
Compare
|
Upstream branch: 4edcdef |
937b8ef to
3deda6a
Compare
4cc45a3 to
90ffd56
Compare
When elevator_change() is called concurrently for the same queue, the elevator_change_done() function runs concurrently as well. This function adds or deletes kobjects for the debugfs entry of the queue. Then the concurrent calls cause memory corruption of the kobjects and result in a process hang. The core part of the elevator switch is protected by queue freeze and q->elevator_lock. However, since the commit 559dc11 ("block: move elv_register[unregister]_queue out of elevator_lock"), the elevator_change_done() is not serialized. Hence the memory corruption and the hang. The failures are observed when udev-worker writes to a sysfs queue/scheduler attribute file while the blktests test case block/005 writes to the same attribute file. The failure also can be recreated by running two processes that write to the same queue/scheduler file concurrently. The failure is observed since another commit 370ac28 ("block: avoid cpu_hotplug_lock depedency on freeze_lock"). This commit changed the behavior of queue freeze and it unveiled the failure. Fix the failure by adding a new per-queue lock 'elevator_queue_lock', which serializes the whole elevator switch steps for the same queue including the elevator_change_done() call. Fixes: 559dc11 ("block: move elv_register[unregister]_queue out of elevator_lock") Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
|
Upstream branch: dc59e4f |
3deda6a to
4a6efa0
Compare
Pull request for series with
subject: block: fix concurrent elevator change failure
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1109814