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 C8F971FF0DF for ; Thu, 05 Nov 2026 17:37:11 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id F1D78216AB; Thu, 05 Nov 2026 17:36:44 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH common/storage 0/3] fix #8286: do not hold inherited locks in volume cleanup workers Date: Thu, 5 Nov 2026 17:36:34 +0100 Message-ID: <20261105163637.1318072-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: 1793896598344 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.211 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: WIOZPXRIVSESVSGXQQG374FT3OYX6ZPM X-Message-ID-Hash: WIOZPXRIVSESVSGXQQG374FT3OYX6ZPM 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 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 does the same for 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 kept disks under the config lock. Since the rollback cleanup worker then no longer holds the guest migration lock, the patch also adds a rollback check that the volume replaced by a previous rollback is not still being wiped. Otherwise, the rollback would fail after the guest was already locked for it. 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 kept disk was still being wiped. Both cleanup workers finished successfully. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=8286 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 (2): 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 | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) Summary over all repositories: 4 files changed, 96 insertions(+), 7 deletions(-) -- Generated by murpp 0.12.1