[Devel] [PATCH hci-8.1 2/2] dm-ploop: fix flip_upper_deltas walking past the BAT of the lower delta

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 5 15:58:48 MSK 2026


I won't apply this version, please send v2 with the changes below.

On Wed, 04 Nov 2026 22:46:35 +0100, Denis V. Lunev wrote:
> -		clu = ploop_page_clu_idx_to_bat_clu(md->id, i);
> +		clu = ploop_page_clu_idx_to_bat_clu(md->id, end);
>  		if (clu == nr_be - 1) {
>  			stop = true;
>  			goto unmap;

- refuse the flip when the lower delta covers fewer BAT entries than
  the device (nr_be read from its header < ploop->nr_bat_entries),
  outside #ifdef PLOOP_DEBUG; keep the `end` fix;
- fix "the stop never matches" in the message and split its first
  paragraph;
- optional: `goto unmap` now jumps to the next line, a plain `break`
  does the same.

Item 2 of the cover letter reply. With the `end` fix the check returns
0 and the flip completes with a new top whose BAT is smaller than the
device's. 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, so the image no longer opens. Before the patch this flip
oopsed, now it damages the image silently. Compare entries, not pages:
fewer entries in the same number of pages gives a stack that
ploop_add_delta() refuses on the next load.

> after the scan of the page, when i is already one past end, so the stop
> never matches. Once the live BAT has more pages than the lower delta, as

Item 3 of the cover letter reply. On a full page i == end + 1 is the
first entry of the next page, so the old check matches when nr_be + 15
is a multiple of 1024 (nr_be = 1009, for example). The walk then stops
one page early and skips entry nr_be - 1. The patch fixes that too,
the message should say so. The paragraph has six sentences: the bug,
the oops and why the library does not get there are three paragraphs.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team



More information about the Devel mailing list