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 v6 12/12] dm-ploop: truncate unused tail of top delta on suspend
Date: Tue, 13 Oct 2026 11:38:17 +0000 [thread overview]
Message-ID: <010701a1350e61fe-081a10ef-015a-4b2f-a854-028f6374f46d-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261013111604.142989-13-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dm-ploop: ploop_postsuspend() holds ctl_rwsem across unbounded waits and fs I/O
--
commit 1aa3a8ea27bee4e747c238df1ff3b02cb36cb3fd
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
dm-ploop: truncate unused tail of top delta on suspend
This patch adds ploop_calc_used_end() and ploop_truncate_unused_tail().
ploop_postsuspend() now truncates the unused tail of the top delta. It
does this under ctl_rwsem, so that ploop messages don't change the image
in parallel.
Link: https://virtuozzo.atlassian.net/browse/VSTOR-148171
> 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 void ploop_postsuspend(struct dm_target *ti)
> {
> struct ploop *ploop = ti->private;
> + unsigned int noio_flags;
>
> + down_write(&ploop->ctl_rwsem);
> /*
> * Let the next resumed ploop (maybe of reloaded table)
> * see final size of the top delta. Don't wait in standby
[ ... ]
> wait_event(ploop->inflight_md_wq, !atomic_read(&ploop->inflight_md));
> - ploop_set_suspended(ti, true);
> + /* The device is suspended, see ploop_preresume() */
> + noio_flags = memalloc_noio_save();
> + ploop_truncate_unused_tail(ploop);
> + memalloc_noio_restore(noio_flags);
> + ploop->suspended = true;
> + up_write(&ploop->ctl_rwsem);
> }
[Severity: Low]
Is it necessary to take ctl_rwsem for write before the waits in
ploop_postsuspend()?
The write lock is now taken before the killable ploop_wait_prealloc() and
the uninterruptible wait_event(ploop->inflight_md_wq, ...), and it stays
held through ploop_truncate_unused_tail(), which calls vfs_iter_read()
(via ploop_calc_used_end()), vfs_fsync() and do_ftruncate().
Before this patch the lock was only taken briefly in ploop_set_suspended(),
after both waits. Those waits could already block for a long time. In
standby, or with a dead or stuck backing file, inflight_md may never reach
zero. Now other ctl_rwsem users block behind them as well:
ploop_status()
down_read(&ploop->ctl_rwsem); /* STATUSTYPE_TABLE */
ploop_message()
if (read)
down_read(&ploop->ctl_rwsem);
else
down_write(&ploop->ctl_rwsem);
Every message handler except get_event would hang while postsuspend is
stalled. The same stall can come from a slow vfs_fsync() or do_ftruncate()
on a stuck filesystem.
I don't see a deadlock. Nothing on the inflight_md completion path or in
the allocator takes ctl_rwsem. dm_suspend() also already hangs in that
state with md->suspend_lock held, so the practical impact looks small.
The two waits don't appear to need the lock. Only
ploop_truncate_unused_tail() and the store to ploop->suspended do. Would
it make sense to take the lock after the waits? That would avoid
extending the blocking to status and message handlers while the wait
phase is stuck.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261013111604.142989-1-alexander.ivanov@virtuozzo.com?part=12
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-13 11:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 11:15 [Devel] [PATCH hci-8.1 v6 00/12] dm-ploop: give back " Alexander Ivanov
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 01/12] dm-ploop: fix u32 overflow of the delta BAT byte size Alexander Ivanov
2026-10-13 11:23 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 02/12] dm-ploop: fix lost wakeup in ploop_allocator() Alexander Ivanov
2026-10-13 11:21 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 03/12] dm-ploop: reject a delta header whose BAT does not cover the target Alexander Ivanov
2026-10-13 11:22 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 04/12] dm-ploop: reject empty deltas Alexander Ivanov
2026-10-13 11:24 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 05/12] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-10-13 11:24 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 06/12] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-10-13 11:25 ` no-reply
2026-10-13 11:15 ` [Devel] [PATCH hci-8.1 v6 07/12] dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole() Alexander Ivanov
2026-10-13 11:26 ` no-reply
2026-10-13 11:16 ` [Devel] [PATCH hci-8.1 v6 08/12] dm-ploop: use wake_up() for inflight_md_wq and dispatcher_wq_prealloc Alexander Ivanov
2026-10-13 11:26 ` no-reply
2026-10-13 11:16 ` [Devel] [PATCH hci-8.1 v6 09/12] dm-ploop: fix use-after-free on the last inflight_md decrement Alexander Ivanov
2026-10-13 11:30 ` no-reply
2026-10-13 11:16 ` [Devel] [PATCH hci-8.1 v6 10/12] dm-ploop: fix flip_upper_deltas racing with resume Alexander Ivanov
2026-10-13 11:28 ` no-reply
2026-10-13 11:16 ` [Devel] [PATCH hci-8.1 v6 11/12] dm-ploop: reload metadata on resume Alexander Ivanov
2026-10-13 11:35 ` no-reply
2026-10-13 12:46 ` Alexander Ivanov
2026-10-13 11:16 ` [Devel] [PATCH hci-8.1 v6 12/12] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-13 11:38 ` no-reply [this message]
2026-10-13 12:53 ` 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=010701a1350e61fe-081a10ef-015a-4b2f-a854-028f6374f46d-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