From: Denis V. Lunev <[email protected]>
ploop_allocator() tests prealloc_size and only then sets itself
TASK_INTERRUPTIBLE before schedule(). A request that lands between the
two finds the thread still running, so wake_up_process() does nothing,
and the thread goes to sleep with the request pending. A pio whose
cluster is past the end of the top delta then waits in
ploop_allocate_cluster() for good: ploop_req_prealloc() does not wake
the thread for a size already requested, so later requests do not end
the stall either. The dispatcher waits for every runner to go idle
before it hands out more work, so the whole device stalls.
The thread tests kthread_should_stop() before setting the task state
too, so a kthread_stop() is lost the same way and the removal of the
device hangs.
Set the task state before testing prealloc_size and
kthread_should_stop().
Fixes: cf489cf22cd5 ("dm-ploop: make filespace preallocations async")
Reported-by: Konstantin Khorenko <[email protected]>
https://virtuozzo.atlassian.net/browse/VSTOR-152984
Feature: dm-ploop: ploop target driver
Reviewed-by: Andrey Zhadchenko <[email protected]>
Reviewed-by: Konstantin Khorenko <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
---
drivers/md/dm-ploop-map.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index f0832fcefeb8..e64fd8965d46 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -2325,6 +2325,7 @@ int ploop_allocator(void *data)
struct file *file;
for (;;) {
+ set_current_state(TASK_INTERRUPTIBLE);
/* we do not care about exact number here - risk one extra
schedule wrt taking the lock */
if (ploop->prealloc_size) {
__set_current_state(TASK_RUNNING);
@@ -2348,7 +2349,6 @@ int ploop_allocator(void *data)
__set_current_state(TASK_RUNNING);
break;
}
- set_current_state(TASK_INTERRUPTIBLE);
schedule();
}
--
2.53.0
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel