OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 2/4] dm-ploop: fix a lost wakeup of the ploop_allocator() thread
Date: Wed,  4 Nov 2026 19:55:17 +0100	[thread overview]
Message-ID: <20261104185519.1870488-3-den@openvz.org> (raw)
In-Reply-To: <20261104185519.1870488-1-den@openvz.org>

From: Denis V. Lunev <den@openvz.org>

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 <khorenko@virtuozzo.com>
https://virtuozzo.atlassian.net/browse/VSTOR-152984
Feature: dm-ploop: ploop target driver
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-04 18:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 18:55 [Devel] [PATCH hci-8.1 v2 0/4] dm-ploop: fix the pio submission stop around cmds Denis V. Lunev
2026-11-04 18:55 ` [Devel] [PATCH hci-8.1 v2 1/4] dm-ploop: fix pio submission racing with the suspend and resume of a cmd Denis V. Lunev
2026-11-04 18:59   ` no-reply
2026-11-04 18:55 ` Denis V. Lunev [this message]
2026-11-04 18:59   ` [Devel] [PATCH hci-8.1 v2 2/4] dm-ploop: fix a lost wakeup of the ploop_allocator() thread no-reply
2026-11-04 18:55 ` [Devel] [PATCH hci-8.1 v2 3/4] dm-ploop: wait for the ploop_allocator() thread before changing deltas[] Denis V. Lunev
2026-11-04 19:02   ` no-reply
2026-11-04 18:55 ` [Devel] [PATCH hci-8.1 v2 4/4] dm-ploop: fix a failed cluster copy on grow leaving the BAT page busy Denis V. Lunev
2026-11-04 19:03   ` no-reply
2026-11-04 19:09 ` [Devel] [PATCH hci-8.1 v2 0/4] dm-ploop: fix the pio submission stop around cmds Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261104185519.1870488-3-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox