[pve-devel] applied: [PATCH container v3] Fix #576: Fix dangling files for Move Disk

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jun 14 11:26:52 CEST 2019


On 6/12/19 12:04 PM, Dominic Jäger wrote:
> 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 at proxmox.com>
> Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
> ---
> v2: System call is not a single string anymore 
> v3: More exhaustive commit message

applied, thanks!

> 
>  src/PVE/LXC.pm | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 62b6b8c..4922fb0 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -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 $@;
>      }
>  
> 






More information about the pve-devel mailing list