From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: no-reply@sashiko.virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 v9 8/9] dm-ploop: reload metadata on resume
Date: Thu, 19 Nov 2026 15:16:26 +0100 [thread overview]
Message-ID: <aca23f31-6e6d-4935-a693-7ce9e680bb9a@virtuozzo.com> (raw)
In-Reply-To: <010701a1f3a69014-1a504b26-8af2-4ebd-8c11-5da13f14d6af-000000@eu-central-1.amazonses.com>
>> +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?
Standby is set only on completion of DM data and flush bios, and both
waits run on a suspended device, after DM has waited for all of them.
So the flag can't change while we sleep there.
>> 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.
Messages write BAT synchronously while holding ctl_rwsem. If that
writeback hangs, the message
itself already blocks status and other messages. By the time preresume
takes the lock, the writeback
has finished. Only the reference drop after complete() is left, and it
does no IO.
>> 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?
fixed: preresume now waits for the prealloc in flight the same way as
for inflight_md,
before ctl_rwsem and again under it, then reloads unconditionally
outside standby.
Also added a warning when dirty md pages skip the reload.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-19 14:18 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 11:34 [Devel] [PATCH hci-8.2 v9 0/9] dm-ploop: give back unused tail of top delta on suspend Alexander Ivanov
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 1/9] dm-ploop: reject a delta header whose BAT does not cover the target Alexander Ivanov
2026-11-19 11:39 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 2/9] dm-ploop: reject empty deltas Alexander Ivanov
2026-11-19 11:39 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 3/9] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-11-19 11:39 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 4/9] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-11-19 11:40 ` no-reply
2026-11-19 12:11 ` Konstantin Khorenko
2026-11-19 14:31 ` Alexander Ivanov
2026-11-19 14:38 ` Alexander Ivanov
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 5/9] dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole() Alexander Ivanov
2026-11-19 11:42 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 6/9] dm-ploop: fix use-after-free on the last inflight_md decrement Alexander Ivanov
2026-11-19 11:47 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 7/9] dm-ploop: fix flip_upper_deltas racing with resume Alexander Ivanov
2026-11-19 11:43 ` no-reply
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 8/9] dm-ploop: reload metadata on resume Alexander Ivanov
2026-11-19 11:52 ` no-reply
2026-11-19 14:16 ` Alexander Ivanov [this message]
2026-11-19 12:11 ` Konstantin Khorenko
2026-11-19 13:51 ` Alexander Ivanov
2026-11-19 11:34 ` [Devel] [PATCH hci-8.2 v9 9/9] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-11-19 11:52 ` no-reply
2026-11-19 14:22 ` Alexander Ivanov
2026-11-19 12:11 ` Konstantin Khorenko
2026-11-19 14:19 ` Alexander Ivanov
2026-11-19 12:11 ` [Devel] [PATCH hci-8.2 v9 0/9] dm-ploop: give back " Konstantin Khorenko
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=aca23f31-6e6d-4935-a693-7ce9e680bb9a@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=no-reply@sashiko.virtuozzo.com \
/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.