From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id BAD571FF0DE for ; Thu, 19 Nov 2026 15:13:34 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5F8B92172D; Thu, 19 Nov 2026 15:13:13 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.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 Message-ID: <20261119141302.600137-1-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795097588042 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.180 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SCGYZYSF6FNL43FAKB5IZYZZUPZYCAWZ X-Message-ID-Hash: SCGYZYSF6FNL43FAKB5IZYZZUPZYCAWZ X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: l.sichert@proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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- 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--. 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---snapshot and del-- 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- 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