[pve-devel] [PATCH storage 1/3] Lock storage when calling volume_import

Fabian Ebner f.ebner at proxmox.com
Mon Jan 13 12:56:07 CET 2020


Could I get some feedback for this? The same locking is done for 
'vdisk_alloc' and 'vdisk_clone' already (among others), so I thought it 
makes sense for 'volume_import' as well.

On 12/12/19 11:17 AM, Fabian Ebner wrote:
> to avoid a potential race for two processes trying to allocate the same volume.
> 
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
> 
> This is conceptually independent from patches 2+3 (but patch 3 modfies the same
> hunk as this one).
> 
>   PVE/Storage.pm | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index bb3b874..ae2ea53 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -1402,8 +1402,10 @@ sub volume_import {
>       die "cannot import into volume '$volid'\n" if !$storeid;
>       my $scfg = storage_config($cfg, $storeid);
>       my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
> -    return $plugin->volume_import($scfg, $storeid, $fh, $volname, $format,
> -                                  $base_snapshot, $with_snapshots);
> +    return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
> +	return $plugin->volume_import($scfg, $storeid, $fh, $volname, $format,
> +				      $base_snapshot, $with_snapshots);
> +    });
>   }
>   
>   sub volume_export_formats {
> 




More information about the pve-devel mailing list