All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>, den@openvz.org
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v3 2/5] dm-ploop: set delta is_raw before applying its mappings
Date: Thu, 8 Oct 2026 14:09:24 +0000	[thread overview]
Message-ID: <010701a11bd8f1e7-a54a0285-1251-4b24-93c5-4e767f6278b0-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261008140333.614909-3-alexander.ivanov@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dm-ploop: if (nr_be) guard in ploop_add_delta() skips the top delta header copy
--

commit fadb633bf83be4165d2be5c5a7e26f5f3b0c5554
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>

dm-ploop: set delta is_raw before applying its mappings

This commit sets deltas[level].is_raw before ploop_apply_delta_mappings()
runs, so that raw deltas are no longer handled as non-raw ones. It also
skips applying mappings when the delta is empty (nr_be == 0).

Link: https://virtuozzo.atlassian.net/browse/VSTOR-148171

> diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
> --- a/drivers/md/dm-ploop-bat.c
> +++ b/drivers/md/dm-ploop-bat.c

[ ... ]

> @@ -501,7 +501,10 @@ int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_r
>  	if (level != ploop_top_level(ploop) && nr_be > deltas[level + 1].nr_be)
>  		goto out;
>  
> -	ploop_apply_delta_mappings(ploop, deltas, level, &md_root, nr_be);
> +	deltas[level].is_raw = is_raw;
> +	/* Empty delta has no mappings, and BAT iterators can't handle it */
> +	if (nr_be)
> +		ploop_apply_delta_mappings(ploop, deltas, level, &md_root, nr_be);

[Severity: Low]
Can this unconditional if (nr_be) guard skip the top-level header copy?
The commit message only justifies the guard for an empty raw delta.

In ploop_apply_delta_mappings(), the on-disk header is copied into md0
only here:

    if (is_top_level && md->id == 0 && !is_raw) {
            /* bat_entries before PLOOP_MAP_OFFSET is hdr */
            memcpy(bat_entries, d_bat_entries,
                   sizeof(struct ploop_pvd_header));
    }

A non-raw top delta with m_Size == 0 appears to reach this path.
ploop_add_deltas_stack() calls ploop_check_top_delta() and then
ploop_add_delta().  ploop_check_top_delta() does not reject m_Size == 0,
and ploop_read_delta_metadata() can then return nr_be == 0.

Before the patch, ploop->bat_entries held md page 0 in this case, so the
loop body ran once and the memcpy was executed.  With the guard, the whole
function is skipped.

ploop_check_top_delta() only allocates md pages through
ploop_prealloc_md_pages().  Those pages are filled with BAT_ENTRY_NONE and
do not get the header.

Would md0 then keep the BAT_ENTRY_NONE fill instead of the header?
ploop_resize() reads hdr->m_SizeInSectors_v2 from md0, and writeback or
grow writes it back.

This looks limited to crafted or corrupt images, since a device with
nr_bat_entries == 0 cannot serve normal I/O.

Would it be better to apply the guard only for the raw case, or to still
copy the header for a non-raw top delta?  The later ploop_read_delta() and
ploop_reload_metadata() changes in the series keep the same if (nr_be)
guard, so it does not look like this is fixed later.

>  
>  	deltas[level].file = file;
>  	deltas[level].mtfile = kcalloc(ploop->nkt_runners, sizeof(*file),

[ ... ]

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261008140333.614909-1-alexander.ivanov@virtuozzo.com?part=2

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

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 14:03 [Devel] [PATCH hci-8.1 v3 0/5] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-08 14:03 ` [Devel] [PATCH hci-8.1 v3 1/5] dm-ploop: fix lost wakeup in ploop_allocator() Alexander Ivanov
2026-10-08 14:07   ` no-reply
2026-10-08 16:51   ` Denis V. Lunev
2026-10-08 14:03 ` [Devel] [PATCH hci-8.1 v3 2/5] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-10-08 14:09   ` no-reply [this message]
2026-10-08 16:51   ` Denis V. Lunev
2026-10-09  6:28   ` Alexander Ivanov
2026-10-08 14:03 ` [Devel] [PATCH hci-8.1 v3 3/5] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-10-08 14:08   ` no-reply
2026-10-08 16:51   ` Denis V. Lunev
2026-10-08 14:03 ` [Devel] [PATCH hci-8.1 v3 4/5] dm-ploop: reload metadata on resume Alexander Ivanov
2026-10-08 14:18   ` no-reply
2026-10-08 16:51   ` Denis V. Lunev
2026-10-08 14:03 ` [Devel] [PATCH hci-8.1 v3 5/5] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-08 14:15   ` no-reply
2026-10-08 16:51   ` Denis V. Lunev

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=010701a11bd8f1e7-a54a0285-1251-4b24-93c5-4e767f6278b0-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=den@openvz.org \
    --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 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.