[pve-devel] [PATCH storage 1/3] Fix #1574: could not disable krbd-incompatible image features

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Mar 1 09:42:32 CET 2018


On Wed, Feb 28, 2018 at 06:50:00PM +0100, Alwin Antreich wrote:
> Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>

some kind of explanation in the commit message on WHY we need to do this
roundabout thing would be nice (now we know, but in 6 months? 2 years?)

> ---
>  PVE/Storage/RBDPlugin.pm | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index 2ca14ef..804dded 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -109,8 +109,16 @@ my $krdb_feature_disable = sub {
>      my ($major, undef, undef, undef) = ceph_version();
>      return 1 if $major < 10;
>  
> -    my $feature_cmd = &$rbd_cmd($scfg, $storeid, 'feature', 'disable', $name, 'deep-flatten,fast-diff,object-map,exclusive-lock');
> -    run_rbd_command($feature_cmd, errmsg => "could not disable krbd-incompatible image features of rbd volume $name");
> +    my $krbd_feature_blacklist = ['deep-flatten', 'fast-diff', 'object-map', 'exclusive-lock'];
> +    my (undef, undef, undef, undef, $features) = rbd_volume_info($scfg, $storeid, $name);
> +
> +    my $active_features = { map { $_ => 1 } PVE::Tools::split_list($features)};
> +    my $incompatible_features = join(',', grep { %$active_features{$_} } @$krbd_feature_blacklist);
> +
> +    if ($incompatible_features) {
> +    	my $feature_cmd = &$rbd_cmd($scfg, $storeid, 'feature', 'disable', $name, $incompatible_features);
> +    	run_rbd_command($feature_cmd, errmsg => "could not disable krbd-incompatible image features of rbd volume $name");

these two lines are wrongly indented:
- spaces before tabs is always wrong :P
- indentation levels are:
-- 4 spaces
-- 1 tab
-- 1 tab + 4 spaces
-- 2 tabs
-- ...

so in this case, the leading spaces need to be dropped.

> +    }
>  };
>  
>  my $ceph_version_parser = sub {
> @@ -221,6 +229,7 @@ sub rbd_volume_info {
>      my $parent = undef;
>      my $format = undef;
>      my $protected = undef;
> +    my $features = undef;
>  
>      my $parser = sub {
>  	my $line = shift;
> @@ -233,13 +242,15 @@ sub rbd_volume_info {
>  	    $format = $1;
>  	} elsif ($line =~ m/protected:\s(\S+)/) {
>  	    $protected = 1 if $1 eq "True";
> -	}
> +	} elsif ($line =~ m/features:\s(.+)/) {
> +	    $features = $1;
> +    	}

same indentation problem here

>  
>      };
>  
>      run_rbd_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => $parser);
>  
> -    return ($size, $parent, $format, $protected);
> +    return ($size, $parent, $format, $protected, $features);
>  }
>  
>  # Configuration
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list