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

Alwin Antreich a.antreich at proxmox.com
Wed Feb 28 18:50:00 CET 2018


Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
 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");
+    }
 };
 
 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;
+    	}
 
     };
 
     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





More information about the pve-devel mailing list