From: no-reply@sashiko.virtuozzo.com
To: den@openvz.org, Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v5 11/11] dm-ploop: truncate unused tail of top delta on suspend
Date: Tue, 13 Oct 2026 08:20:30 +0000 [thread overview]
Message-ID: <010701a134594e79-b508879f-2883-48f0-951f-4da29d820327-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261013075513.90618-12-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dm-ploop: no fsync between BAT writeback and top delta truncation in postsuspend
- [Low] dm-ploop: calc_used_end() WARNs on a clean-check that postsuspend does not fully wait for
--
commit 847969f12202a7013753f4e3c79c265f1c673b03
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
dm-ploop: truncate unused tail of top delta on suspend
This patch makes ploop_postsuspend() truncate the unused tail of the top
delta. The used end is computed by the new ploop_calc_used_end(), which
reads the on-disk BAT and the format extension offset. The truncation is
skipped for read-only, raw and standby devices, and when the file size
differs from top->file_size.
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
[ ... ]
> +loff_t ploop_calc_used_end(struct ploop *ploop, struct file *file)
> +{
> + u32 i, end, nr_be, dst_clu, used_clus, *bat_entries;
[ ... ]
> + /* BAT on disk may miss allocated clusters until writeback is done */
> + if (WARN_ON_ONCE(!ploop_md_pages_are_clean(ploop)))
> + return -EBUSY;
[Severity: Low]
The commit message says "Skip it if md pages are not clean", but this
code raises a kernel WARN and then the caller logs an error.
ploop_postsuspend() only waits for inflight_md:
wait_event(ploop->inflight_md_wq, !atomic_read(&ploop->inflight_md));
ploop_md_pages_are_clean() also tests MD_DIRTY, MD_UPDATING,
wb_batch_llist, md->piwb and md->wait_llist.
In the error paths of ploop_process_one_deferred_bio(), the sequence is:
ploop_break_bat_update(ploop, md, piwb); /* drops inflight_md */
ploop_pio_endio(pio);
spin_lock_irqsave(&ploop->bat_lock, flags);
if (add_to_wblist)
clear_bit(MD_DIRTY, &md->status);
clear_bit(MD_UPDATING, &md->status);
Can suspend complete and reach ploop_postsuspend() with inflight_md == 0
while MD_DIRTY or MD_UPDATING are still set? If so, this would hit the
WARN_ON_ONCE and the truncation would be silently skipped.
Would it make sense to treat unclean md pages as an expected skip, without
the WARN and without the error message from ploop_truncate_unused_tail()?
[ ... ]
> 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
[ ... ]
> + end = ploop_calc_used_end(ploop, top->file);
> + if (end < 0) {
> + PL_ERR("Can't find used end of top delta: %lld", end);
> + return;
> + }
> + if (end >= top->file_size)
> + return;
> +
> + ret = do_ftruncate(top->file, end, 0);
[Severity: Medium]
Is a flush of the top delta needed before this truncate?
ploop_calc_used_end() reads the BAT back with vfs_iter_read(), which can be
served from the page cache. The BAT page writes are issued by
ploop_index_wb_submit() as plain writes, with no flush or FUA. The only
vfs_fsync() of the top delta in the suspend path is in ploop_presuspend(),
which runs before ploop_postsuspend() waits for inflight_md:
ploop_presuspend()
vfs_fsync(ploop_top_delta(ploop)->file, 0);
ploop_postsuspend()
wait_event(ploop->inflight_md_wq, !atomic_read(&ploop->inflight_md));
ploop_truncate_unused_tail()
do_ftruncate(top->file, end, 0);
A BAT writeback that completes in that wait, for example one zeroing a
discarded cluster, is not covered by the earlier fsync.
If the host crashes after the size change is committed but before those BAT
pages are durable, the on-disk BAT can still reference clusters beyond the
new EOF. The next ploop_ctr() or ploop_reload_metadata() would then fail in
ploop_convert_bat_entries() with -EPROTO, which is the failure the commit
message says it is avoiding.
Should a vfs_fsync() of top->file be done before do_ftruncate()?
[ ... ]
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261013075513.90618-1-alexander.ivanov@virtuozzo.com?part=11
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-13 8:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 7:55 [Devel] [PATCH hci-8.1 v5 00/11] dm-ploop: give back " Alexander Ivanov
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 01/11] dm-ploop: fix u32 overflow of the delta BAT byte size Alexander Ivanov
2026-10-13 8:02 ` no-reply
2026-10-13 9:24 ` Alexander Ivanov
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 02/11] dm-ploop: fix lost wakeup in ploop_allocator() Alexander Ivanov
2026-10-13 8:00 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 03/11] dm-ploop: reject a delta header whose BAT does not cover the target Alexander Ivanov
2026-10-13 8:01 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 04/11] dm-ploop: reject empty deltas Alexander Ivanov
2026-10-13 8:02 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 05/11] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-10-13 8:03 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 06/11] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-10-13 8:04 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 07/11] dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole() Alexander Ivanov
2026-10-13 8:06 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 08/11] dm-ploop: use wake_up() for inflight_md_wq and dispatcher_wq_prealloc Alexander Ivanov
2026-10-13 8:04 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 09/11] dm-ploop: fix use-after-free on the last inflight_md decrement Alexander Ivanov
2026-10-13 8:11 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 10/11] dm-ploop: reload metadata on resume Alexander Ivanov
2026-10-13 8:16 ` no-reply
2026-10-13 7:55 ` [Devel] [PATCH hci-8.1 v5 11/11] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-13 8:20 ` no-reply [this message]
2026-10-13 11:00 ` 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=010701a134594e79-b508879f-2883-48f0-951f-4da29d820327-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox