From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC storage] lvm plugin: fix locking for rollback when using CLI
Date: Wed, 19 Nov 2025 18:22:57 +0100 [thread overview]
Message-ID: <20251119172304.417132-1-f.ebner@proxmox.com> (raw)
For some reason still to be determined, doing a rollback via CLI on an
LVM storage with snapshot-as-volume-chain and saferemove would run
into locking issues (likely trying to re-acquire the lock it already
holds a second time). The same issue does not happen when the rollback
is done via UI.
Avoid doing fork_cleanup_worker() inside the locked section to avoid
this.
Fixes: 8eabcc7 ("lvm plugin: snapshot-as-volume-chain: use locking for snapshot operations")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/Storage/LVMPlugin.pm | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 97f7bf4..164437a 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -1117,23 +1117,17 @@ sub volume_rollback_is_possible {
}
my sub volume_snapshot_rollback_locked {
- my ($class, $scfg, $storeid, $volname, $snap) = @_;
+ my ($class, $scfg, $storeid, $volname, $snap, $cleanup_worker) = @_;
my $format = ($class->parse_volname($volname))[6];
die "can't rollback snapshot for '$format' volume\n" if $format ne 'qcow2';
- my $cleanup_worker = eval { free_snap_image($class, $storeid, $scfg, $volname, 'current'); };
+ $cleanup_worker->$* = eval { free_snap_image($class, $storeid, $scfg, $volname, 'current'); };
die "error deleting snapshot $snap $@\n" if $@;
eval { alloc_snap_image($class, $storeid, $scfg, $volname, $snap) };
- my $alloc_err = $@;
-
- fork_cleanup_worker($cleanup_worker);
-
- if ($alloc_err) {
- die "can't allocate new volume $volname: $alloc_err\n";
- }
+ die "can't allocate new volume $volname: $@\n" if $@;
return undef;
}
@@ -1141,14 +1135,22 @@ my sub volume_snapshot_rollback_locked {
sub volume_snapshot_rollback {
my ($class, $scfg, $storeid, $volname, $snap) = @_;
- return $class->cluster_lock_storage(
+ my $cleanup_worker;
+
+ $class->cluster_lock_storage(
$storeid,
$scfg->{shared},
undef,
sub {
- return volume_snapshot_rollback_locked($class, $scfg, $storeid, $volname, $snap);
+ volume_snapshot_rollback_locked(
+ $class, $scfg, $storeid, $volname, $snap, \$cleanup_worker,
+ );
},
);
+
+ fork_cleanup_worker($cleanup_worker);
+
+ return;
}
sub volume_snapshot_delete {
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
reply other threads:[~2025-11-19 17:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251119172304.417132-1-f.ebner@proxmox.com \
--to=f.ebner@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