[pve-devel] [PATCH storage 2/2] disable jewel image features when using krdb

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Jun 7 08:45:43 CEST 2016


otherwise mapping those images will fail. disabling the
features only needs to be done once per image, so it makes
sense to do this when creating the images.

unfortunately, the command does not work in hammer, so
it needs a version check for jewel or higher.
---
 PVE/Storage/RBDPlugin.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 2b4ff9c..f208374 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -79,6 +79,19 @@ my $rados_cmd = sub {
     return $cmd;
 };
 
+# needed for volumes created using ceph jewel (or higher)
+my $krdb_feature_disable = sub {
+    my ($scfg, $storeid, $name) = @_;
+
+    return 1 if !$scfg->{krbd};
+
+    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 $ceph_version_parser = sub {
 	my $line = shift;
 	if ($line =~ m/^ceph version ((\d+)\.(\d+)\.(\d+))(?: \([a-fA-F0-9]+\))?$/) {
@@ -404,6 +417,8 @@ sub clone_image {
 
     run_rbd_command($cmd, errmsg => "rbd clone '$basename' error");
 
+    &$krdb_feature_disable($scfg, $storeid, $name);
+
     return $newvol;
 }
 
@@ -419,6 +434,8 @@ sub alloc_image {
     my $cmd = &$rbd_cmd($scfg, $storeid, 'create', '--image-format' , 2, '--size', int(($size+1023)/1024), $name);
     run_rbd_command($cmd, errmsg => "rbd create $name' error");
 
+    &$krdb_feature_disable($scfg, $storeid, $name);
+
     return $name;
 }
 
-- 
2.1.4





More information about the pve-devel mailing list