]> git.proxmox.com Git - pve-container.git/commitdiff
Fix #576: Fix dangling files for Move Disk
authorDominic Jäger <d.jaeger@proxmox.com>
Wed, 12 Jun 2019 10:04:57 +0000 (12:04 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 14 Jun 2019 08:34:21 +0000 (10:34 +0200)
When Move Disk is called for a container rsync starts copying it to a
new destination. This initial rsync process gets killed when the Stop
button gets pressed. At this moment the destination file is not fully
copied and useless as a consequence. Our code already tries to remove
it. However, rsync has forked and those forks are still accessing the
destination file for some time. Thus, the attempt to remove it fails.

With the patch we wait for other processes to release the destination
files. As we are in a mount namespace and protected by a config lock,
those other processes should be children of rsync only. The waiting
time was less than a second when I tried it. Afterwards, the existing
remove procedure is carried out.

Co-developed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
src/PVE/LXC.pm

index 62b6b8ca62e233577cede2bbf52ec4adf03eb24b..4922fb00188ac0565a5819b847041df2b8eff828 100644 (file)
@@ -2024,8 +2024,13 @@ my $copy_volume = sub {
                                 "--bwlimit=$bwlimit", "$src/", $dest]);
     };
     my $err = $@;
+
+    # Wait for rsync's children to release dest so that
+    # consequent file operations (umount, remove) are possible
+    while ((system {"fuser"} "fuser",  "-s", $dest) == 0) {sleep 1};
+
     foreach my $mount (reverse @mounted) {
-       eval { PVE::Tools::run_command(['/bin/umount', '--lazy', $mount], errfunc => sub{})};
+       eval { PVE::Tools::run_command(['/bin/umount', $mount], errfunc => sub{})};
        warn "Can't umount $mount\n" if $@;
     }