[Devel] [PATCH hci-8.2 v9 8/9] dm-ploop: reload metadata on resume
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Thu Nov 19 14:52:21 MSK 2026
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] dm-ploop: preresume silently skips metadata reload while a
message prealloc is in flight
- [Low] dm-ploop: standby skip in ploop_wait_prealloc() is checked once,
so late standby still hangs
- [Low] dm-ploop: ploop_preresume() waits for inflight_md under
ctl_rwsem
--
commit 168cc5688f3ec08094520c1dcd5ae48875d3f9d2
Author: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
dm-ploop: reload metadata on resume
This reloads the top delta header, the BAT of every delta and the delta file sizes in ploop_preresume(). It also reworks the postsuspend and message waits for BAT writeback and preallocation, and tracks standby per ploop.
> 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
[ ... ]
> +void ploop_wait_prealloc(struct ploop *ploop)
> +{
> + if (!READ_ONCE(ploop->standby))
> + wait_event(ploop->dispatcher_wq_prealloc,
> + ploop_no_pending_prealloc(ploop));
> +}
> +
> +void ploop_stop_prealloc(struct ploop *ploop)
> +{
> + ploop_drop_prealloc(ploop);
> + ploop_wait_prealloc(ploop);
> +}
[Severity: Low]
Does this skip only help when standby is already set on entry? The flag is tested once, before sleeping, and is not part of the wait_event() condition.
ploop_check_standby_mode() sets the flag with WRITE_ONCE(ploop->standby, true) but never wakes dispatcher_wq_prealloc. If standby is set after the waiter has gone to sleep and the allocator is stuck in truncate on a dead file, the uninterruptible wait in ploop_postsuspend() (or in ploop_message()) never ends. dm_replace() then cannot suspend the device to recover it, which is the case the commit message says this is meant to avoid.
Would it work to put the standby flag into the wait condition and call wake_up() on dispatcher_wq_prealloc when standby is set?
> 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 drop inflight_md late */
> + if (!ploop_is_standby(ploop))
> + wait_event(ploop->inflight_md_wq,
> + !atomic_read(&ploop->inflight_md));
> +
> down_write(&ploop->ctl_rwsem);
> + /* A message may have slipped in before the lock */
> + if (!ploop_is_standby(ploop))
> + wait_event(ploop->inflight_md_wq,
> + !atomic_read(&ploop->inflight_md));
[Severity: Low]
The commit message says waits are done outside ctl_rwsem so that a stuck writeback doesn't block status and messages. Doesn't this second wait break that for the window it covers? It is an unbounded, uninterruptible wait_event() with ctl_rwsem held for write, and standby is not rechecked while it sleeps. If BAT writeback started by a message in that gap never completes, status and other messages block behind ctl_rwsem as well as the resume.
> if (ploop->noresume) {
> ret = -EAGAIN;
> + } else if (!ploop_is_standby(ploop) &&
> + ploop_no_pending_prealloc(ploop)) {
> + reload = true;
[Severity: Medium]
Can this skip the reload silently and still resume the device? When a prealloc is pending, the branch is not taken, ret stays 0 and suspended is cleared, so the new ploop runs with the BAT, holes_bitmap and file sizes read in ploop_ctr(). That is the stale-metadata state this patch is meant to remove.
A pending prealloc is reachable from ploop_message(), which drops ctl_rwsem before waiting for the in-flight prealloc. target_message() does not take md->suspend_lock, so it can overlap with dm_resume():
CPU0 (message, e.g. resize) CPU1 (resume ioctl)
ploop_message()
ploop_drop_prealloc()
up_write(&ctl_rwsem)
ploop_preresume()
down_write(&ctl_rwsem)
ploop_no_pending_prealloc() == 0
reload skipped, suspended = false
<-- stale metadata
ploop_wait_prealloc()
The same silent skip happens after a standby postsuspend that did not wait. ploop_reload_metadata() also returns 0 without logging when the md pages are not clean. Could preresume wait for the prealloc to finish, or fail the resume (for example with -EAGAIN) instead of succeeding without a reload?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119113446.3579457-1-alexander.ivanov@virtuozzo.com?part=8
More information about the Devel
mailing list