From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: l.sichert@proxmox.com
Subject: [PATCH common/storage v2 0/4] fix #8286: do not hold inherited locks in volume cleanup workers
Date: Thu, 19 Nov 2026 15:12:58 +0100 [thread overview]
Message-ID: <20261119141302.600137-1-m.koeppl@proxmox.com> (raw)
Destroying a VM through the API with a disk on an LVM storage with
saferemove=1 leaves its VMID locked until the wipe of the disk is done.
The imgdel worker is forked while the qmdestroy worker holds the
config lock and inherits the locked file handle. The worker keeps the
lock held after the qmdestroy worker exited. Re-creating a VM with the
same VMID fails with a lock timeout in the meantime.
This series tries to keep the fix targeted, since closing all inherited
file descriptors in fork_worker() has a lot of regression
potential [0]. An opt-in helper is added in pve-common to close the
lock handles a forked child inherited from its ancestors. This call is
added to vdisk_free before running the cleanup workers of the
respective plugin. At the moment, this affects only the LVM plugin,
which only operates on volumes that are not referenced anymore and
takes the storage lock on its own where needed. Thus, this also
expects external plugins with cleanup workers to not rely on the
cleanup worker holding the caller's lock.
The last patch also closes the inherited lock handles in the cleanup
workers the LVM plugin forks itself for snapshot rollback and deletion
and for failed imports. It is not needed to fix the bug, but these
workers inherit their caller's locks too. For example, restoring a VM
over an existing one with qcow2 snapshots on LVM deletes the snapshots
of disks excluded from the backup under the config lock.
Since the cleanup workers no longer hold their caller's locks, a volume
can now be freed while an earlier volume with the same name is still
being wiped, e.g. when deleting a snapshot right after a rollback.
Renaming the volume to del-<name> would then fail, but only after the
guest was already locked for the operation. 2/4 avoids such name
collisions by falling back to del-<N>-<name>. This also fixes
destroying a VM right after a rollback, which already left the disk
behind before. Lukas S. and I discussed this for a bit off-list were
both wondering if this is a sensible approach and, in general, if these
naming collisions couldn't be avoided entirely by e.g. having
del-<N>-<name>-snapshot and del-<N>-<name> for different actions.
Tested on a single node by destroying a VM with a disk on an LVM
storage with saferemove through the API and re-creating it right after
the destroy task finished, while the wipe was still running. The last
patch was tested by restoring a backup through the API over an existing
VM with a qcow2 snapshot on an LVM storage with saferemove and a disk
excluded from the backup. The config of the VM could be changed while
the snapshot of the excluded disk was still being wiped. Both cleanup
workers finished successfully. The new logic for avoiding name
collisions was tested manually by rolling back a stopped VM to its only
snapshot and then deleting the snapshot, and by rolling back and then
destroying the VM, both while the volume replaced by the rollback was
still being wiped. In both cases, the freed volume was renamed to
del-1-<name> and all cleanup workers finished successfully.
Also passed the full set of E2E tests from proxmox-e2e-tests.
Dependencies: 3/4 and 4/4 call the new helper from pve-common, so
pve-storage needs a bumped dependency on libpve-common-perl.
Changes since v1 [1]:
* Add a patch that avoids name collisions with volumes pending
removal, instead of refusing a rollback while the volume replaced by
a previous rollback is still being wiped. Unlike the rollback check,
this also covers deleting a snapshot right after a rollback, and
deleting a snapshot with RAM again after re-creating it under the
same name, which the vdisk_free patch otherwise makes possible.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=8286
[1] https://lore.proxmox.com/pve-devel/20261105163637.1318072-1-m.koeppl@proxmox.com/
common:
Michael Köppl (1):
tools: lock file: add helper to close inherited lock handles
src/PVE/Tools.pm | 23 +++++++++++++++-----
test/lock_file.pl | 54 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 5 deletions(-)
storage:
Michael Köppl (3):
lvm plugin: avoid name collisions with volumes pending removal
fix #8286: vdisk free: do not hold inherited locks in cleanup worker
lvm plugin: do not hold inherited locks in cleanup workers
src/PVE/Storage.pm | 10 +-
src/PVE/Storage/LVMPlugin.pm | 71 +++++++----
src/test/Makefile | 5 +-
src/test/run_test_lvm_cleanup_name.pl | 165 ++++++++++++++++++++++++++
4 files changed, 228 insertions(+), 23 deletions(-)
create mode 100755 src/test/run_test_lvm_cleanup_name.pl
Summary over all repositories:
6 files changed, 300 insertions(+), 28 deletions(-)
--
Generated by murpp 0.12.1
next reply other threads:[~2026-11-19 14:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 14:12 Michael Köppl [this message]
2026-11-19 14:12 ` [PATCH common v2 1/4] tools: lock file: add helper to close inherited lock handles Michael Köppl
2026-11-19 14:13 ` [PATCH storage v2 2/4] lvm plugin: avoid name collisions with volumes pending removal Michael Köppl
2026-11-19 14:13 ` [PATCH storage v2 3/4] fix #8286: vdisk free: do not hold inherited locks in cleanup worker Michael Köppl
2026-11-19 14:13 ` [PATCH storage v2 4/4] lvm plugin: do not hold inherited locks in cleanup workers Michael Köppl
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=20261119141302.600137-1-m.koeppl@proxmox.com \
--to=m.koeppl@proxmox.com \
--cc=l.sichert@proxmox.com \
--cc=pve-devel@lists.proxmox.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.