From 51065626eff9c2b7685fbb62ed86ab13dde81dd0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 19 Jan 2016 13:47:24 +0100 Subject: [PATCH] Don't hold flock for whole backup operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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.39.5