[pve-devel] [PATCH v2 container 2/2] Don't hold flock for whole backup operation

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Jan 19 13:47:24 CET 2016


Instead of holding the flock for the whole backup operation,
release it at the end of prepare(), and use
lock_container() to remove a potential 'backup' lock
from the config file when the backup is finished.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/VZDump/LXC.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 1ed6547..e2ed7b6 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -167,12 +167,14 @@ sub prepare {
 	$task->{snapshot_count} = scalar(@$volid_list);
     } elsif ($mode eq 'stop') {
 	&$lockconfig($self, $vmid);
+
 	my $rootdir = $default_mount_point;
 	mkpath $rootdir;
 	&$check_mountpoint_empty($rootdir);
 	PVE::Storage::activate_volumes($storage_cfg, $volid_list);
     } elsif ($mode eq 'suspend') {
 	&$lockconfig($self, $vmid);
+
 	my $pid = PVE::LXC::find_lxc_pid($vmid);
 	foreach my $disk (@$disks) {
 	    $disk->{dir} = "/proc/$pid/root$disk->{mp}";
@@ -182,6 +184,8 @@ sub prepare {
 	die "unknown mode '$mode'\n"; # should not happen
     }
 
+    PVE::LXC::lock_release($vmid);
+
     if ($mode ne 'suspend') {
 	# If we perform mount operations, let's unshare the mount namespace
 	# to not influence the running host.
@@ -192,16 +196,12 @@ sub prepare {
 
 sub lock_vm {
     my ($self, $vmid) = @_;
-
     PVE::LXC::lock_aquire($vmid);
 }
 
 sub unlock_vm {
     my ($self, $vmid) = @_;
-
-    &$unlockconfig($self, $vmid);
-
-    PVE::LXC::lock_release($vmid);
+    PVE::LXC::lock_container($vmid, 60, $unlockconfig, ($self, $vmid));
 }
 
 sub snapshot {
-- 
2.1.4





More information about the pve-devel mailing list