From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage] lvm plugin: encode locking requirement into the name of two helper functions
Date: Fri, 13 Feb 2026 11:27:03 +0100 [thread overview]
Message-ID: <20260213102816.17672-1-f.ebner@proxmox.com> (raw)
Makes it easier to verify and keep track of the locking, and to not
forget taking the lock for future callers.
Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/Storage/LVMPlugin.pm | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 32a8339..3a35e38 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -279,7 +279,7 @@ sub lvm_list_volumes {
return $lvs;
}
-my sub free_lvm_volumes {
+my sub free_lvm_volumes_locked {
my ($class, $scfg, $storeid, $volnames) = @_;
my $vg = $scfg->{vgname};
@@ -759,13 +759,14 @@ my sub alloc_snap_image {
alloc_lvm_image($class, $storeid, $scfg, $vmid, $format, $volname, $size, $backing_snap);
}
-my sub free_snap_image {
+my sub free_snap_image_locked {
my ($class, $storeid, $scfg, $volname, $snap) = @_;
my $snap_volname = get_snap_name($class, $volname, $snap);
- return free_lvm_volumes($class, $scfg, $storeid, [$snap_volname]);
+ return free_lvm_volumes_locked($class, $scfg, $storeid, [$snap_volname]);
}
+# Must be called with the storage lock held.
sub free_image {
my ($class, $storeid, $scfg, $volname, $isBase, $format) = @_;
@@ -790,7 +791,7 @@ sub free_image {
}
}
- return free_lvm_volumes($class, $scfg, $storeid, $volnames);
+ return free_lvm_volumes_locked($class, $scfg, $storeid, $volnames);
}
my $check_tags = sub {
@@ -1123,7 +1124,8 @@ my sub volume_snapshot_rollback_locked {
die "can't rollback snapshot for '$format' volume\n" if $format ne 'qcow2';
- $cleanup_worker->$* = eval { free_snap_image($class, $storeid, $scfg, $volname, 'current'); };
+ $cleanup_worker->$* =
+ eval { free_snap_image_locked($class, $storeid, $scfg, $volname, 'current'); };
die "error deleting snapshot $snap $@\n" if $@;
eval { alloc_snap_image($class, $storeid, $scfg, $volname, $snap) };
@@ -1174,7 +1176,9 @@ sub volume_snapshot_delete {
$storeid,
$scfg->{shared},
undef,
- sub { return free_snap_image($class, $storeid, $scfg, $volname, $snap); },
+ sub {
+ return free_snap_image_locked($class, $storeid, $scfg, $volname, $snap);
+ },
);
};
die "error deleting snapshot $snap $@\n" if $@;
@@ -1219,8 +1223,9 @@ sub volume_snapshot_delete {
$scfg->{shared},
undef,
sub {
- my $cleanup_worker_sub =
- eval { free_snap_image($class, $storeid, $scfg, $volname, $childsnap) };
+ my $cleanup_worker_sub = eval {
+ free_snap_image_locked($class, $storeid, $scfg, $volname, $childsnap);
+ };
if ($@) {
die "error delete old snapshot volume $childvolname: $@\n";
}
@@ -1266,7 +1271,9 @@ sub volume_snapshot_delete {
$storeid,
$scfg->{shared},
undef,
- sub { return free_snap_image($class, $storeid, $scfg, $volname, $snap); },
+ sub {
+ return free_snap_image_locked($class, $storeid, $scfg, $volname, $snap);
+ },
);
};
die "error deleting old snapshot volume $snapvolname: $@\n" if $@;
--
2.47.3
reply other threads:[~2026-02-13 10:28 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=20260213102816.17672-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