All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: khorenko@virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 2/3] dm-ploop: fix pios stuck in md->wait_llist after a failed BAT update
Date: Mon,  9 Nov 2026 20:06:03 +0100	[thread overview]
Message-ID: <20261109190604.1850504-3-den@openvz.org> (raw)
In-Reply-To: <20261109190604.1850504-1-den@openvz.org>

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

ploop_locate_new_cluster_and_attach_pio() and
ploop_process_one_discard_pio() set MD_UPDATING on the BAT page while
they prepare its update. A pio that needs the page meanwhile is parked
in md->wait_llist by ploop_delay_if_md_busy(), and only
ploop_advance_local_after_bat_wb(), at the end of a writeback of the
page, gives the parked pios back.

When the update fails, the error path breaks it, clears MD_DIRTY and
MD_UPDATING and leaves the parked pios where they are. No writeback of
the page is queued, so they are never resubmitted: the writers hang in
D state, and after a buffered write every later sync on the host hangs
behind them until a reboot. An allocation fails this way when
ploop_prepare_bat_update() runs out of memory, when no free cluster is
left, or when the punch, zero or preallocation of the new cluster in
the top delta fails, e.g. on a write to a read-only device that needs
a new cluster.

Take the parked pios together with clearing MD_UPDATING, under
bat_lock, which every caller of ploop_delay_if_md_busy() holds, and
resubmit them with ploop_dispatch_md_waiters(), as the writeback
completion does. The error paths of ploop_prepare_reloc_index_wb() and
ploop_grow_relocate_cluster() clear MD_UPDATING without a drain too,
but they run with pio submission stopped, so nothing is parked there.

https://virtuozzo.atlassian.net/browse/VSTOR-154096

Fixes: ddf38fa44df4 ("dm-ploop: fix and rework md updates")
Reported-by: Denis Genov <denis.genov@virtuozzo.com>
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 drivers/md/dm-ploop-map.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index f0569263622c..b49281691a01 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1750,6 +1750,7 @@ static bool ploop_locate_new_cluster_and_attach_pio(struct ploop *ploop,
 						    struct pio *pio)
 {
 	bool bat_update_prepared = false;
+	struct llist_node *waiters;
 	struct ploop_index_wb *piwb;
 	bool attached = false;
 	u32 page_id;
@@ -1818,7 +1819,9 @@ static bool ploop_locate_new_cluster_and_attach_pio(struct ploop *ploop,
 	if (add_to_wblist)
 		clear_bit(MD_DIRTY, &md->status);
 	clear_bit(MD_UPDATING, &md->status);
+	waiters = llist_del_all(&md->wait_llist);
 	spin_unlock_irqrestore(&ploop->bat_lock, flags);
+	ploop_dispatch_md_waiters(ploop, waiters);
 	return false;
 }
 
@@ -2026,6 +2029,7 @@ static void ploop_process_one_discard_pio(struct ploop *ploop, struct pio *pio)
 {
 	bool bat_update_prepared = false;
 	u32 page_id, clu = pio->clu;
+	struct llist_node *waiters;
 	struct ploop_index_wb *piwb;
 	struct md_page *md;
 	map_index_t *to;
@@ -2092,7 +2096,9 @@ static void ploop_process_one_discard_pio(struct ploop *ploop, struct pio *pio)
 	if (add_to_wblist)
 		clear_bit(MD_DIRTY, &md->status);
 	clear_bit(MD_UPDATING, &md->status);
+	waiters = llist_del_all(&md->wait_llist);
 	spin_unlock_irqrestore(&ploop->bat_lock, flags);
+	ploop_dispatch_md_waiters(ploop, waiters);
 }
 
 static inline int ploop_runners_have_pending(struct ploop *ploop)
-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-09 19:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 19:06 [Devel] [PATCH hci-8.1 0/3] dm-ploop: fix writes to a read-only device hanging the host Denis V. Lunev
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 1/3] dm-ploop: factor out ploop_dispatch_md_waiters() Denis V. Lunev
2026-11-09 19:15   ` no-reply
2026-11-09 19:06 ` Denis V. Lunev [this message]
2026-11-09 19:18   ` [Devel] [PATCH hci-8.1 2/3] dm-ploop: fix pios stuck in md->wait_llist after a failed BAT update no-reply
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 3/3] dm-ploop: fail writes to a read-only device Denis V. Lunev
2026-11-09 19:19   ` no-reply

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=20261109190604.1850504-3-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.