From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 v8 8/9] dm-ploop: reload metadata on resume
Date: Wed, 18 Nov 2026 13:30:31 +0000 [thread overview]
Message-ID: <010701a1eeda12f4-c30d528a-69d9-4a64-bab2-08385b5770f4-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261118131032.3372996-9-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] dm-ploop: prealloc_stopped drops resize allocation requests
on suspended device
- [Low] dm-ploop: top_flipped is not cleared when reload is skipped on
resume
- [Low] dm-ploop: preresume wait and reload clean check are not under
one lock
--
commit 240134d129537e6ddb55602e031529c851f3f05c
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
dm-ploop: reload metadata on resume
The patch reloads the top delta header, the BAT of every delta, the delta file sizes, the BAT tree and holes_bitmap in ploop_preresume(). Preallocation is requested after the reload. The patch also adds waits in postsuspend and preresume, and a per-ploop standby flag.
> 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
[ ... ]
> + /*
> + * Header of top delta is written with BAT page 0. Userspace doesn't
> + * mark the delta, which becomes top after flip_upper_deltas, as in
> + * use, and relies that the in-use signature of the old top delta
> + * will be written to it. So keep the signature we had. In other
> + * cases take it from disk: userspace may have changed it on the
> + * suspended device (e.g. marked the image closed on umount).
> + */
> + if (ploop->top_flipped) {
> + old_hdr = ploop_md_first_entry(&old_bat_entries)->kmpage;
> + hdr = ploop_md_first_entry(&ploop->bat_entries)->kmpage;
> + hdr->m_DiskInUse = old_hdr->m_DiskInUse;
> + ploop->top_flipped = false;
> + }
[Severity: Low]
Is top_flipped ever cleared if the reload is skipped?
It is cleared only here, after a full reload. ploop_reload_metadata() returns 0 early when the md pages are not clean, and ploop_preresume() skips the reload in standby or while preallocation is pending. In all those cases resume still succeeds and the flag stays set after flip_upper_deltas.
If userspace later marks the image closed on disk while suspended, the next successful reload copies the in-memory IN_USE over the on-disk value. Umount then trims the image and CBT is lost. That contradicts the commit message, which says the signature is taken from disk except right after flip_upper_deltas.
[ ... ]
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -1195,6 +1195,8 @@ static int ploop_preallocate_cluster(struct ploop *ploop, struct file *file)
>
> spin_lock_irqsave(&ploop->bat_lock, flags);
> prealloc_more:
> + if (READ_ONCE(ploop->prealloc_stopped))
> + ploop->prealloc_size = 0;
> ploop->prealloc_in_progress = ploop->prealloc_size;
> ploop->prealloc_size = 0;
[Severity: Medium]
Does this also drop the synchronous request that a resize message on a suspended device depends on?
ploop_postsuspend() sets prealloc_stopped and only a successful preresume clears it. A grow resize sent while suspended goes ploop_resize() -> ... -> ploop_prepare_reloc_index_wb() -> ploop_allocate_cluster(). That calls ploop_req_prealloc() and wakes the allocator. ploop_preallocate_cluster() then zeroes prealloc_size and grows nothing.
ploop_allocate_cluster() then sees end > top->file_size and logs "Prealloc failed". It retries three times, each dropped the same way, and returns -EIO. The resize fails whenever the relocation needs the top delta to grow.
The commit message says only pending requests are dropped. The flag cannot tell a stale background request from a required synchronous one. The last patch in the series, which truncates the unused tail on suspend, makes growth more likely and does not change this check.
[ ... ]
> diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
> --- a/drivers/md/dm-ploop-target.c
> +++ b/drivers/md/dm-ploop-target.c
[ ... ]
> static int ploop_preresume(struct dm_target *ti)
> {
> struct ploop *ploop = ti->private;
> + unsigned int noio_flags;
> + bool reload = false;
> int ret = 0;
>
> + /* A resize of the suspended device may leave BAT writeback in flight */
> + if (!ploop_is_standby(ploop))
> + wait_event(ploop->inflight_md_wq,
> + !atomic_read(&ploop->inflight_md));
> +
> down_write(&ploop->ctl_rwsem);
[Severity: Low]
Can a resize message slip in between this wait and down_write(&ploop->ctl_rwsem)?
ploop_resize() does not require the device to be suspended, so it can start BAT writeback or dirty md pages in that window. ploop_reload_metadata() then sees unclean pages and returns 0 without any log message. Resume succeeds and the device goes live with the stale BAT read in ploop_ctr(). That is the situation this patch is meant to prevent.
Would it work to wait for inflight_md and run the clean check under the same lock?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118131032.3372996-1-alexander.ivanov@virtuozzo.com?part=8
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-18 13:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:10 [Devel] [PATCH hci-8.2 v8 0/9] dm-ploop: give back unused tail of top delta on suspend Alexander Ivanov
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 1/9] dm-ploop: reject a delta header whose BAT does not cover the target Alexander Ivanov
2026-11-18 13:14 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 2/9] dm-ploop: reject empty deltas Alexander Ivanov
2026-11-18 13:15 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 3/9] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-11-18 13:12 ` Denis V. Lunev
2026-11-18 13:18 ` Alexander Ivanov
2026-11-18 13:16 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 4/9] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-11-18 13:16 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 5/9] dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole() Alexander Ivanov
2026-11-18 13:19 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 6/9] dm-ploop: fix use-after-free on the last inflight_md decrement Alexander Ivanov
2026-11-18 13:24 ` no-reply
2026-11-18 13:29 ` Alexander Ivanov
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 7/9] dm-ploop: fix flip_upper_deltas racing with resume Alexander Ivanov
2026-11-18 13:21 ` no-reply
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 8/9] dm-ploop: reload metadata on resume Alexander Ivanov
2026-11-18 13:30 ` no-reply [this message]
2026-11-18 14:07 ` Alexander Ivanov
2026-11-18 13:10 ` [Devel] [PATCH hci-8.2 v8 9/9] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-11-18 13:29 ` no-reply
2026-11-18 13:11 ` [Devel] [PATCH hci-8.2 v8 0/9] dm-ploop: give back " Andrey Zhadchenko
2026-11-18 13:41 ` Konstantin Khorenko
2026-11-18 15:07 ` Alexander Ivanov
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=010701a1eeda12f4-c30d528a-69d9-4a64-bab2-08385b5770f4-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--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 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.