* [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check
@ 2026-11-10 18:55 Denis V. Lunev
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-10 18:55 UTC (permalink / raw)
To: khorenko; +Cc: devel
ploop_check_delta_before_flip() runs on every flip_upper_deltas, as
PLOOP_DEBUG is always defined in dm-ploop-cmd.c, and has three bugs
(VSTOR-153445):
- patch 1: when it finds a cluster both deltas map, it returns -EEXIST
with two md_locks held and interrupts disabled. The next pio on that
BAT page spins on the lock forever, and the host panics on a hard
lockup;
- patch 2: a flip after a grow of the device, with the lower delta left
at its old size, oopses in the walk, which runs past the BAT of the
lower delta. Refuse it: a flip that got past the walk would damage
the new top delta on the first BAT writeback after resume;
- patch 3: the walk stops one page early when entry nr_be - 1 of the
lower delta is the first one of its BAT page, and misses a cluster
both deltas map there.
The ploop library does not get there. Its reverse merge, the only sender
of the flip, grows the lower delta to the size of the top and, with the
device suspended, clears the clusters both deltas map before it flips,
so VSTOR-153445 has no RK for 8.0. This is the fix the v2 cover letter
of "dm-ploop: fix the pio submission stop around cmds" said would be
sent separately.
Tested on dev-cl04, stock 6.12.0-211.52.1.22.11.vz10, dm-ploop built
out of tree with the series on top of the applied dm-ploop v2:
- a chain whose top delta overwrote a cluster of the base, both deltas
reloaded read-write, and a direct flip_upper_deltas: the message fails
with EEXIST, the device keeps working and both images pass ploop
check;
- an online grow from 1G to 2G, both deltas reloaded read-write, a
direct flip_upper_deltas and then a write past the old size: with v1
the flip completes and the images no longer open after unmount, the
ploop target fails the table with EPROTO. With patch 2 alone and with
the series the flip fails with EBADSLT, and the data below and past
the old size survives a remount;
- an online grow, a write past the old size, ploop snapshot-delete of
the base snapshot (the reverse merge of the library) and another write
past the old size: the flip goes through, the merged image passes
ploop check and keeps all writes across a remount;
- the ploop pytest suite, ploop and qcow2 formats, passes.
Changes since v1:
- patch 1: drop the read-only and EACCES argument for the library from
the message, the library reloads the lower delta read-write before
the flip;
- new patch 2: refuse the flip when the lower delta has fewer BAT
entries than the device, outside PLOOP_DEBUG;
- patch 3 (was 2/2): say in the message where the old stop matched and
what it skipped, split the first paragraph, leave the loop with a
plain break;
- the grow test writes past the old size after the flip.
v1: http://lore.virtuozzo.com/kernel/20261104214635.2063009-1-den@openvz.org/
Denis V. Lunev (3):
dm-ploop: fix flip_upper_deltas returning with two md_locks held
dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the
device
dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry
drivers/md/dm-ploop-cmd.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
base-commit: 1f21db982845109040d1feb279e9ee34f8e6f065
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
@ 2026-11-10 18:55 ` Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device Denis V. Lunev
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-10 18:55 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Denis V. Lunev <den@openvz.org>
ploop_check_delta_before_flip() takes the md_lock of a live BAT page
and of the matching page of the lower delta before it compares them.
When it finds a cluster both deltas map, it jumps to unmap past both
unlocks: the cmd returns -EEXIST with the locks held and interrupts
disabled, after freeing the page of the lower delta with its lock still
taken. dmsetup comes back to userspace in atomic context, and the next
pio touching that BAT page spins on its md_lock for good, a hard
lockup.
A flip_upper_deltas message on a chain where the top delta overwrote a
cluster of the lower one gets there. The ploop library does not: its
reverse merge clears those entries in the lower delta with the device
suspended before it flips.
Leave the scan only after both locks are dropped.
Fixes: 0d4b4d0a20a9 ("dm-ploop: introduce per-md page locking")
https://virtuozzo.atlassian.net/browse/VSTOR-153445
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-cmd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 45fa4fe7a45a..d6abbdc3c7e3 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1146,11 +1146,13 @@ static int ploop_check_delta_before_flip(struct ploop *ploop, struct file *file)
d_bat_entries[i] != BAT_ENTRY_NONE) {
ret = -EEXIST;
stop = true;
- goto unmap;
+ break;
}
}
spin_unlock(&d_md->md_lock);
spin_unlock_irq(&md->md_lock);
+ if (stop)
+ break;
clu = ploop_page_clu_idx_to_bat_clu(md->id, i);
if (clu == nr_be - 1) {
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
@ 2026-11-10 18:55 ` Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry Denis V. Lunev
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-10 18:55 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Denis V. Lunev <den@openvz.org>
A flip_upper_deltas after a grow of the device, with the lower delta
left at its old size, makes a top delta whose header and BAT cover fewer
entries than the device. After resume the BAT writeback puts the grown
header into page 0 of that file and the BAT pages past its old size onto
its data clusters, and the image no longer opens.
Today ploop_check_delta_before_flip() oopses on such a flip before it
gets that far, as its walk runs past the end of the BAT of the lower
delta. Fixing the walk alone would let the flip through.
Read the header of the lower delta on every flip, not only under
PLOOP_DEBUG, and refuse with -EBADSLT when it has fewer BAT entries than
the device, as ploop_add_delta() refuses a lower delta bigger than the
upper one. Compare entries, not BAT pages: fewer entries in the same
number of pages still gives a stack that ploop_add_delta() refuses on
the next load. The reverse merge of the ploop library grows the lower
delta to the size of the device before it flips, so it never gets the
refusal.
Fixes: 6ddad5a4d226 ("dm-ploop: Add ploop target driver")
https://virtuozzo.atlassian.net/browse/VSTOR-153445
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
drivers/md/dm-ploop-cmd.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index d6abbdc3c7e3..5549ba448594 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1118,20 +1118,27 @@ static int ploop_set_noresume(struct ploop *ploop, char *mode)
static int ploop_check_delta_before_flip(struct ploop *ploop, struct file *file)
{
- int ret = 0;
-#ifdef PLOOP_DEBUG
- u32 i, end, *d_bat_entries, clu, nr_be;
struct rb_root md_root = RB_ROOT;
+ u32 nr_be;
+ int ret;
+#ifdef PLOOP_DEBUG
+ u32 i, end, *d_bat_entries, clu;
struct md_page *md, *d_md;
struct rb_node *node;
bool stop = false;
+#endif
ret = ploop_read_delta_metadata(ploop, file, &md_root, &nr_be);
if (ret) {
PL_ERR("Error reading metadata");
- goto out;
+ return ret;
}
+ ret = -EBADSLT;
+ if (nr_be < ploop->nr_bat_entries)
+ goto free;
+ ret = 0;
+#ifdef PLOOP_DEBUG
/* Points to hdr since md_page[0] also contains hdr. */
d_md = ploop_md_first_entry(&md_root);
@@ -1164,10 +1171,9 @@ static int ploop_check_delta_before_flip(struct ploop *ploop, struct file *file)
break;
d_md = ploop_md_next_entry(d_md);
}
-
- ploop_free_md_pages_tree(&md_root);
-out:
#endif
+free:
+ ploop_free_md_pages_tree(&md_root);
return ret;
}
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device Denis V. Lunev
@ 2026-11-10 18:55 ` Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:59 ` [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
2026-11-17 10:11 ` Andrey Zhadchenko
4 siblings, 1 reply; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-10 18:55 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Denis V. Lunev <den@openvz.org>
ploop_check_delta_before_flip() means to stop its walk after the BAT
page that holds entry nr_be - 1 of the lower delta. It takes the last
entry of the page from i after the scan, when i is already end + 1.
When entry nr_be - 1 is the first one of its page (nr_be = 1009, for
example), the test matches on the full page before it, and the walk
stops one page early: a cluster both deltas map at entry nr_be - 1 gets
past the check. Otherwise the test never matches and the walk ends
with the live BAT, which the previous patch keeps the same size as the
BAT of the lower delta.
Take the last entry of the page from end, and leave the loop with a
plain break.
Fixes: 6ddad5a4d226 ("dm-ploop: Add ploop target driver")
https://virtuozzo.atlassian.net/browse/VSTOR-153445
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
drivers/md/dm-ploop-cmd.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 5549ba448594..2d1fa449b052 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1161,13 +1161,8 @@ static int ploop_check_delta_before_flip(struct ploop *ploop, struct file *file)
if (stop)
break;
- clu = ploop_page_clu_idx_to_bat_clu(md->id, i);
- if (clu == nr_be - 1) {
- stop = true;
- goto unmap;
- }
-unmap:
- if (stop)
+ clu = ploop_page_clu_idx_to_bat_clu(md->id, end);
+ if (clu == nr_be - 1)
break;
d_md = ploop_md_next_entry(d_md);
}
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
@ 2026-11-10 18:58 ` no-reply
0 siblings, 0 replies; 11+ messages in thread
From: no-reply @ 2026-11-10 18:58 UTC (permalink / raw)
To: khorenko, Denis V. Lunev; +Cc: devel
> From: Denis V. Lunev <den@openvz.org>
>
> ploop_check_delta_before_flip() takes the md_lock of a live BAT page
> and of the matching page of the lower delta before it compares them.
> When it finds a cluster both deltas map, it jumps to unmap past both
> unlocks: the cmd returns -EEXIST with the locks held and interrupts
> disabled, after freeing the page of the lower delta with its lock still
> taken. dmsetup comes back to userspace in atomic context, and the next
> pio touching that BAT page spins on its md_lock for good, a hard
> lockup.
>
> A flip_upper_deltas message on a chain where the top delta overwrote a
> cluster of the lower one gets there. The ploop library does not: its
> reverse merge clears those entries in the lower delta with the device
> suspended before it flips.
>
> Leave the scan only after both locks are dropped.
>
> Fixes: 0d4b4d0a20a9 ("dm-ploop: introduce per-md page locking")
> https://virtuozzo.atlassian.net/browse/VSTOR-153445
> 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>
This patch is unchanged since "[Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held", which Sashiko reviewed and found no issues in. That review applies to this posting unaltered, so the patch has not been reviewed again.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261105145749.2643035-1-den@openvz.org?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry Denis V. Lunev
@ 2026-11-10 18:58 ` no-reply
0 siblings, 0 replies; 11+ messages in thread
From: no-reply @ 2026-11-10 18:58 UTC (permalink / raw)
To: khorenko, Denis V. Lunev; +Cc: devel
> From: Denis V. Lunev <den@openvz.org>
>
> ploop_check_delta_before_flip() means to stop its walk after the BAT
> page that holds entry nr_be - 1 of the lower delta. It takes the last
> entry of the page from i after the scan, when i is already end + 1.
>
> When entry nr_be - 1 is the first one of its page (nr_be = 1009, for
> example), the test matches on the full page before it, and the walk
> stops one page early: a cluster both deltas map at entry nr_be - 1 gets
> past the check. Otherwise the test never matches and the walk ends
> with the live BAT, which the previous patch keeps the same size as the
> BAT of the lower delta.
>
> Take the last entry of the page from end, and leave the loop with a
> plain break.
>
> Fixes: 6ddad5a4d226 ("dm-ploop: Add ploop target driver")
> https://virtuozzo.atlassian.net/browse/VSTOR-153445
> Feature: dm-ploop: ploop target driver
> Signed-off-by: Denis V. Lunev <den@openvz.org>
This patch is unchanged since "[Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry", which Sashiko reviewed and found no issues in. That review applies to this posting unaltered, so the patch has not been reviewed again.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261105145749.2643035-1-den@openvz.org?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device Denis V. Lunev
@ 2026-11-10 18:58 ` no-reply
0 siblings, 0 replies; 11+ messages in thread
From: no-reply @ 2026-11-10 18:58 UTC (permalink / raw)
To: khorenko, Denis V. Lunev; +Cc: devel
> From: Denis V. Lunev <den@openvz.org>
>
> A flip_upper_deltas after a grow of the device, with the lower delta
> left at its old size, makes a top delta whose header and BAT cover fewer
> entries than the device. After resume the BAT writeback puts the grown
> header into page 0 of that file and the BAT pages past its old size onto
> its data clusters, and the image no longer opens.
>
> Today ploop_check_delta_before_flip() oopses on such a flip before it
> gets that far, as its walk runs past the end of the BAT of the lower
> delta. Fixing the walk alone would let the flip through.
>
> Read the header of the lower delta on every flip, not only under
> PLOOP_DEBUG, and refuse with -EBADSLT when it has fewer BAT entries than
> the device, as ploop_add_delta() refuses a lower delta bigger than the
> upper one. Compare entries, not BAT pages: fewer entries in the same
> number of pages still gives a stack that ploop_add_delta() refuses on
> the next load. The reverse merge of the ploop library grows the lower
> delta to the size of the device before it flips, so it never gets the
> refusal.
>
> Fixes: 6ddad5a4d226 ("dm-ploop: Add ploop target driver")
> https://virtuozzo.atlassian.net/browse/VSTOR-153445
> Feature: dm-ploop: ploop target driver
> Signed-off-by: Denis V. Lunev <den@openvz.org>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261110185554.2970417-1-den@openvz.org?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
` (2 preceding siblings ...)
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry Denis V. Lunev
@ 2026-11-10 18:59 ` Denis V. Lunev
2026-11-17 10:11 ` Andrey Zhadchenko
4 siblings, 0 replies; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-10 18:59 UTC (permalink / raw)
To: Denis V. Lunev, khorenko; +Cc: devel
On 11/10/26 19:55, Denis V. Lunev wrote:
> This email originated from an IP that might not be authorized by the domain it was sent from.
> Do not click links or open attachments unless it is an email you expected to receive.
> ploop_check_delta_before_flip() runs on every flip_upper_deltas, as
> PLOOP_DEBUG is always defined in dm-ploop-cmd.c, and has three bugs
> (VSTOR-153445):
>
> - patch 1: when it finds a cluster both deltas map, it returns -EEXIST
> with two md_locks held and interrupts disabled. The next pio on that
> BAT page spins on the lock forever, and the host panics on a hard
> lockup;
>
> - patch 2: a flip after a grow of the device, with the lower delta left
> at its old size, oopses in the walk, which runs past the BAT of the
> lower delta. Refuse it: a flip that got past the walk would damage
> the new top delta on the first BAT writeback after resume;
>
> - patch 3: the walk stops one page early when entry nr_be - 1 of the
> lower delta is the first one of its BAT page, and misses a cluster
> both deltas map there.
>
> The ploop library does not get there. Its reverse merge, the only sender
> of the flip, grows the lower delta to the size of the top and, with the
> device suspended, clears the clusters both deltas map before it flips,
> so VSTOR-153445 has no RK for 8.0. This is the fix the v2 cover letter
> of "dm-ploop: fix the pio submission stop around cmds" said would be
> sent separately.
>
> Tested on dev-cl04, stock 6.12.0-211.52.1.22.11.vz10, dm-ploop built
> out of tree with the series on top of the applied dm-ploop v2:
> - a chain whose top delta overwrote a cluster of the base, both deltas
> reloaded read-write, and a direct flip_upper_deltas: the message fails
> with EEXIST, the device keeps working and both images pass ploop
> check;
> - an online grow from 1G to 2G, both deltas reloaded read-write, a
> direct flip_upper_deltas and then a write past the old size: with v1
> the flip completes and the images no longer open after unmount, the
> ploop target fails the table with EPROTO. With patch 2 alone and with
> the series the flip fails with EBADSLT, and the data below and past
> the old size survives a remount;
> - an online grow, a write past the old size, ploop snapshot-delete of
> the base snapshot (the reverse merge of the library) and another write
> past the old size: the flip goes through, the merged image passes
> ploop check and keeps all writes across a remount;
> - the ploop pytest suite, ploop and qcow2 formats, passes.
>
> Changes since v1:
> - patch 1: drop the read-only and EACCES argument for the library from
> the message, the library reloads the lower delta read-write before
> the flip;
> - new patch 2: refuse the flip when the lower delta has fewer BAT
> entries than the device, outside PLOOP_DEBUG;
> - patch 3 (was 2/2): say in the message where the old stop matched and
> what it skipped, split the first paragraph, leave the loop with a
> plain break;
> - the grow test writes past the old size after the flip.
>
> v1: http://lore.virtuozzo.com/kernel/20261104214635.2063009-1-den@openvz.org/
>
>
> Denis V. Lunev (3):
> dm-ploop: fix flip_upper_deltas returning with two md_locks held
> dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the
> device
> dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry
>
> drivers/md/dm-ploop-cmd.c | 33 ++++++++++++++++++---------------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
>
> base-commit: 1f21db982845109040d1feb279e9ee34f8e6f065
pls disregard
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
` (3 preceding siblings ...)
2026-11-10 18:59 ` [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
@ 2026-11-17 10:11 ` Andrey Zhadchenko
4 siblings, 0 replies; 11+ messages in thread
From: Andrey Zhadchenko @ 2026-11-17 10:11 UTC (permalink / raw)
To: Denis V. Lunev, khorenko; +Cc: devel
There is a new patch in v2, so again
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
On 11/10/26 19:55, Denis V. Lunev wrote:
> ploop_check_delta_before_flip() runs on every flip_upper_deltas, as
> PLOOP_DEBUG is always defined in dm-ploop-cmd.c, and has three bugs
> (VSTOR-153445):
>
> - patch 1: when it finds a cluster both deltas map, it returns -EEXIST
> with two md_locks held and interrupts disabled. The next pio on that
> BAT page spins on the lock forever, and the host panics on a hard
> lockup;
>
> - patch 2: a flip after a grow of the device, with the lower delta left
> at its old size, oopses in the walk, which runs past the BAT of the
> lower delta. Refuse it: a flip that got past the walk would damage
> the new top delta on the first BAT writeback after resume;
>
> - patch 3: the walk stops one page early when entry nr_be - 1 of the
> lower delta is the first one of its BAT page, and misses a cluster
> both deltas map there.
>
> The ploop library does not get there. Its reverse merge, the only sender
> of the flip, grows the lower delta to the size of the top and, with the
> device suspended, clears the clusters both deltas map before it flips,
> so VSTOR-153445 has no RK for 8.0. This is the fix the v2 cover letter
> of "dm-ploop: fix the pio submission stop around cmds" said would be
> sent separately.
>
> Tested on dev-cl04, stock 6.12.0-211.52.1.22.11.vz10, dm-ploop built
> out of tree with the series on top of the applied dm-ploop v2:
> - a chain whose top delta overwrote a cluster of the base, both deltas
> reloaded read-write, and a direct flip_upper_deltas: the message fails
> with EEXIST, the device keeps working and both images pass ploop
> check;
> - an online grow from 1G to 2G, both deltas reloaded read-write, a
> direct flip_upper_deltas and then a write past the old size: with v1
> the flip completes and the images no longer open after unmount, the
> ploop target fails the table with EPROTO. With patch 2 alone and with
> the series the flip fails with EBADSLT, and the data below and past
> the old size survives a remount;
> - an online grow, a write past the old size, ploop snapshot-delete of
> the base snapshot (the reverse merge of the library) and another write
> past the old size: the flip goes through, the merged image passes
> ploop check and keeps all writes across a remount;
> - the ploop pytest suite, ploop and qcow2 formats, passes.
>
> Changes since v1:
> - patch 1: drop the read-only and EACCES argument for the library from
> the message, the library reloads the lower delta read-write before
> the flip;
> - new patch 2: refuse the flip when the lower delta has fewer BAT
> entries than the device, outside PLOOP_DEBUG;
> - patch 3 (was 2/2): say in the message where the old stop matched and
> what it skipped, split the first paragraph, leave the loop with a
> plain break;
> - the grow test writes past the old size after the flip.
>
> v1: http://lore.virtuozzo.com/kernel/20261104214635.2063009-1-den@openvz.org/
>
>
> Denis V. Lunev (3):
> dm-ploop: fix flip_upper_deltas returning with two md_locks held
> dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the
> device
> dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry
>
> drivers/md/dm-ploop-cmd.c | 33 ++++++++++++++++++---------------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
>
> base-commit: 1f21db982845109040d1feb279e9ee34f8e6f065
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held
2026-11-05 14:57 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
@ 2026-11-05 15:01 ` no-reply
0 siblings, 0 replies; 11+ messages in thread
From: no-reply @ 2026-11-05 15:01 UTC (permalink / raw)
To: Denis V. Lunev, khorenko; +Cc: devel
> From: Denis V. Lunev <den@openvz.org>
>
> ploop_check_delta_before_flip() takes the md_lock of a live BAT page
> and of the matching page of the lower delta before it compares them.
> When it finds a cluster both deltas map, it jumps to unmap past both
> unlocks: the cmd returns -EEXIST with the locks held and interrupts
> disabled, after freeing the page of the lower delta with its lock still
> taken. dmsetup comes back to userspace in atomic context, and the next
> pio touching that BAT page spins on its md_lock for good, a hard
> lockup.
>
> A flip_upper_deltas message on a chain where the top delta overwrote a
> cluster of the lower one gets there. The ploop library does not: its
> reverse merge clears those entries in the lower delta with the device
> suspended before it flips.
>
> Leave the scan only after both locks are dropped.
>
> Fixes: 0d4b4d0a20a9 ("dm-ploop: introduce per-md page locking")
> https://virtuozzo.atlassian.net/browse/VSTOR-153445
> 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>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261105145749.2643035-1-den@openvz.org?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held
2026-11-05 14:57 Denis V. Lunev
@ 2026-11-05 14:57 ` Denis V. Lunev
2026-11-05 15:01 ` no-reply
0 siblings, 1 reply; 11+ messages in thread
From: Denis V. Lunev @ 2026-11-05 14:57 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Denis V. Lunev <den@openvz.org>
ploop_check_delta_before_flip() takes the md_lock of a live BAT page
and of the matching page of the lower delta before it compares them.
When it finds a cluster both deltas map, it jumps to unmap past both
unlocks: the cmd returns -EEXIST with the locks held and interrupts
disabled, after freeing the page of the lower delta with its lock still
taken. dmsetup comes back to userspace in atomic context, and the next
pio touching that BAT page spins on its md_lock for good, a hard
lockup.
A flip_upper_deltas message on a chain where the top delta overwrote a
cluster of the lower one gets there. The ploop library does not: its
reverse merge clears those entries in the lower delta with the device
suspended before it flips.
Leave the scan only after both locks are dropped.
Fixes: 0d4b4d0a20a9 ("dm-ploop: introduce per-md page locking")
https://virtuozzo.atlassian.net/browse/VSTOR-153445
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-cmd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 45fa4fe7a45a..d6abbdc3c7e3 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1146,11 +1146,13 @@ static int ploop_check_delta_before_flip(struct ploop *ploop, struct file *file)
d_bat_entries[i] != BAT_ENTRY_NONE) {
ret = -EEXIST;
stop = true;
- goto unmap;
+ break;
}
}
spin_unlock(&d_md->md_lock);
spin_unlock_irq(&md->md_lock);
+ if (stop)
+ break;
clu = ploop_page_clu_idx_to_bat_clu(md->id, i);
if (clu == nr_be - 1) {
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-17 10:13 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 18:55 [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 2/3] dm-ploop: refuse flip_upper_deltas onto a lower delta smaller than the device Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:55 ` [Devel] [PATCH hci-8.1 v2 3/3] dm-ploop: fix the flip_upper_deltas check skipping the last BAT entry Denis V. Lunev
2026-11-10 18:58 ` no-reply
2026-11-10 18:59 ` [Devel] [PATCH hci-8.1 v2 0/3] dm-ploop: fix flip_upper_deltas panicking the host in its pre-flip check Denis V. Lunev
2026-11-17 10:11 ` Andrey Zhadchenko
-- strict thread matches above, loose matches on Subject: below --
2026-11-05 14:57 Denis V. Lunev
2026-11-05 14:57 ` [Devel] [PATCH hci-8.1 v2 1/3] dm-ploop: fix flip_upper_deltas returning with two md_locks held Denis V. Lunev
2026-11-05 15:01 ` no-reply
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox