[pve-devel] [PATCH storage 3/3] Prefix backstores with the pool name

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Sep 26 15:37:43 CEST 2019


On 9/25/19 10:28 AM, Daniel Berteaud wrote:
> So it won't clash with another backstore in another pool
> 
> Signed-off-by: Daniel Berteaud <daniel at firewall-services.com>
> ---
>  PVE/Storage/LunCmd/LIO.pm | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

not tested but looks good to me.

> 
> diff --git a/PVE/Storage/LunCmd/LIO.pm b/PVE/Storage/LunCmd/LIO.pm
> index 5d7a21d..80133d4 100644
> --- a/PVE/Storage/LunCmd/LIO.pm
> +++ b/PVE/Storage/LunCmd/LIO.pm
> @@ -158,6 +158,14 @@ my $parser = sub {
>      }
>  };
>  
> +# Get prefix for backstores
> +my $get_backstore_prefix = sub {
> +    my ($scfg) = @_;
> +    my $pool = $scfg->{pool};
> +    $pool =~ s/\//-/g;
> +    return $pool . '-';
> +};
> +
>  # removes the given lu_name from the local list of luns
>  my $free_lu_name = sub {
>      my ($scfg, $lu_name) = @_;
> @@ -194,6 +202,15 @@ my $extract_volname = sub {
>      my $base = get_base;
>      if ($lunpath =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
>  	$volname = $1;
> +	my $prefix = $get_backstore_prefix->($scfg);
> +	foreach my $lun (@{$SETTINGS->{$scfg->{portal}.$scfg->{target}}->{luns}}) {
> +	    # If we have a lun with the pool prefix matching this vol, then return this one
> +	    # like pool-pve-vm-100-disk-0
> +	    # Else, just fallback to the old name scheme which is vm-100-disk-0
> +	    if ($lun->{storage_object} =~ /^$BACKSTORE\/($prefix$volname)$/) {
> +		return $1;
> +	    }
> +	}
>      }
>  
>      return $volname;
> @@ -245,6 +262,9 @@ my $create_lun = sub {
>  
>      my $device = $params[0];
>      my $volname = $extract_volname->($scfg, $device);
> +    # Here we create a new device, so we didn't get the volname prefixed with the pool name
> +    # as extract_volname couldn't find a matching vol yet
> +    $volname = $get_backstore_prefix->($scfg) . $volname;
>      my $tpg = $scfg->{lio_tpg} || die "Target Portal Group not set, aborting!\n";
>  
>      # step 1: create backstore for device
> 





More information about the pve-devel mailing list