public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: l.sichert@proxmox.com
Subject: [PATCH storage v2 4/4] lvm plugin: do not hold inherited locks in cleanup workers
Date: Thu, 19 Nov 2026 15:13:02 +0100	[thread overview]
Message-ID: <20261119141302.600137-5-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20261119141302.600137-1-m.koeppl@proxmox.com>

The LVM plugin forks its own cleanup workers when rolling back or
deleting snapshots of qcow2 volumes and after failed imports. Like the
worker forked by vdisk_free(), they inherit the locks of their caller
and keep them held until the cleanup is done. This can happen, e.g.,
when restoring a backup over an existing VM with a qcow2 snapshot on LVM
and a disk excluded from the backup, which deletes that disk's snapshot
while holding the config lock. After the restore has finished, changing
or starting the VM then fails with a lock timeout until the cleanup is
done.

Close the inherited lock handles at the start of these workers too.

The cleanup worker of a rollback or snapshot deletion no longer keeps
the guest migration lock, so another rollback, snapshot deletion, or
migration can run while the previous volume is still being wiped. This
is safe, since the volumes pending removal no longer have colliding
names.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
 src/PVE/Storage/LVMPlugin.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index e12145bb..365dc21d 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -52,7 +52,15 @@ my sub fork_cleanup_worker {
     return if !$cleanup_worker;
     my $rpcenv = PVE::RPCEnvironment::get();
     my $authuser = $rpcenv->get_user();
-    $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
+    $rpcenv->fork_worker(
+        'imgdel',
+        undef,
+        $authuser,
+        sub {
+            PVE::Tools::close_inherited_lock_handles();
+            $cleanup_worker->(@_);
+        },
+    );
 }
 
 sub lvm_pv_info {
-- 
2.47.3





      parent 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 [PATCH common/storage v2 0/4] fix #8286: do not hold inherited locks in volume cleanup workers Michael Köppl
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 ` Michael Köppl [this message]

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-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal