all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage 3/3] lvm plugin: do not hold inherited locks in cleanup workers
Date: Thu,  5 Nov 2026 17:36:37 +0100	[thread overview]
Message-ID: <20261105163637.1318072-4-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20261105163637.1318072-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.

Since the cleanup worker of a rollback no longer holds the guest
migration lock, another rollback of the same volume can start while the
previous volume is still being wiped. Renaming the current volume to
del-<name> then fails, but only after the guest was already locked for
the rollback, leaving it locked. Check in volume_rollback_is_possible()
that del-<name> does not exist, so such a rollback is refused before the
guest is locked.

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

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index a6a5eb70..f9e6936f 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -50,7 +50,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 {
@@ -1645,6 +1653,12 @@ sub volume_rollback_is_possible {
     die "can't rollback, '$snap' is not most recent snapshot on '$volname'\n"
         if scalar($blockers->@*) > 0;
 
+    my $vg = $scfg->{vgname};
+    my $name = ($class->parse_volname($volname))[1];
+    my $lvs = lvm_list_volumes($vg);
+    die "can't rollback, previous volume '$vg/del-$name' is still being removed\n"
+        if $lvs->{$vg}->{"del-$name"};
+
     return 1;
 }
 
-- 
2.47.3





      parent reply	other threads:[~2026-11-05 16:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 16:36 [PATCH common/storage 0/3] fix #8286: do not hold inherited locks in volume cleanup workers Michael Köppl
2026-11-05 16:36 ` [PATCH common 1/3] tools: lock file: add helper to close inherited lock handles Michael Köppl
2026-11-05 16:36 ` [PATCH storage 2/3] fix #8286: vdisk free: do not hold inherited locks in cleanup worker Michael Köppl
2026-11-05 16:36 ` 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=20261105163637.1318072-4-m.koeppl@proxmox.com \
    --to=m.koeppl@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal