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 1/4] dm-ploop: fix freeing the wrong clusters when a BAT writeback fails
Date: Wed, 28 Oct 2026 15:36:44 +0100	[thread overview]
Message-ID: <20261028143647.2972030-2-den@openvz.org> (raw)
In-Reply-To: <20261028143647.2972030-1-den@openvz.org>

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

When an index writeback fails, ploop_advance_local_after_bat_wb()
gives the clusters it allocated back to holes_bitmap. It passes
i + off, the virtual cluster number, to ploop_hole_set_bit(). Since
"dm-ploop: make new allocations immediately visible in BAT" it does
so for every mapped entry of the page, including the ones copied from
the local BAT that this writeback did not change.

This marks as free image clusters that are still in use: data
clusters of other virtual clusters, and also the clusters holding the
header and the BAT, since small virtual cluster numbers fall there.
Later allocations hand them out again, so a guest write can land on
live data or on the BAT, while the clusters really allocated for the
failed writeback stay leaked.

Free the image cluster the entry points to, and only for entries this
writeback changed: those differing from the local BAT, and those the
local BAT maps from a lower delta, which a COW replaced.

Fixes: 6ddad5a4d226 ("dm-ploop: Add ploop target driver")
https://virtuozzo.atlassian.net/browse/VSTOR-151979

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>

Feature: dm-ploop: ploop target driver
---
 drivers/md/dm-ploop-map.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 48466435dd19..34bf6487107f 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -868,8 +868,9 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
 		if (success) {
 			WRITE_ONCE(bat_entries[i], READ_ONCE(dst_clu[i]));
 			WRITE_ONCE(md->bat_levels[i], ploop_top_level(ploop));
-		} else {
-			ploop_hole_set_bit(i + off, ploop);
+		} else if (dst_clu[i] != bat_entries[i] ||
+			   md->bat_levels[i] < ploop_top_level(ploop)) {
+			ploop_hole_set_bit(dst_clu[i], ploop);
 		}
 	}
 #ifdef PLOOP_DELAYWB
-- 
2.53.0

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

  reply	other threads:[~2026-10-28 14:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 14:36 [Devel] [PATCH hci-8.1 v2 0/4] dm-ploop: fix acknowledged writes lost when discard and allocation share a BAT writeback Denis V. Lunev
2026-10-28 14:36 ` Denis V. Lunev [this message]
2026-10-28 15:00   ` [Devel] [PATCH hci-8.1 v2 1/4] dm-ploop: fix freeing the wrong clusters when a BAT writeback fails no-reply
2026-10-28 14:36 ` [Devel] [PATCH hci-8.1 v2 2/4] dm-ploop: renumber BAT levels when the latest snapshot is merged Denis V. Lunev
2026-10-28 15:00   ` no-reply
2026-10-28 14:36 ` [Devel] [PATCH hci-8.1 v2 3/4] dm-ploop: drop the dead PLOOP_DELAYWB code Denis V. Lunev
2026-10-28 15:00   ` no-reply
2026-10-28 14:36 ` [Devel] [PATCH hci-8.1 v2 4/4] dm-ploop: fix lost BAT updates when alloc and discard share a writeback Denis V. Lunev
2026-10-28 15:06   ` no-reply
2026-10-28 15:16 ` [Devel] [PATCH hci-8.1 v2 0/4] dm-ploop: fix acknowledged writes lost when discard and allocation share a BAT writeback Andrey Zhadchenko
2026-11-02 10:42 ` Konstantin Khorenko
2026-11-02 10:44 ` Konstantin Khorenko
2026-11-02 15:32 ` 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=20261028143647.2972030-2-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