[pve-devel] [PATCH storage 2/2] Implement the flag $map in the RBDPlugin

Alwin Antreich a.antreich at proxmox.com
Fri Aug 17 15:44:28 CEST 2018


Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
 PVE/Storage/RBDPlugin.pm | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index be88ad7..64dc1f1 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -72,9 +72,9 @@ my $librados_connect = sub {
 
 # needed for volumes created using ceph jewel (or higher)
 my $krbd_feature_disable = sub {
-    my ($scfg, $storeid, $name) = @_;
+    my ($scfg, $storeid, $name, $map) = @_;
 
-    return 1 if !$scfg->{krbd};
+    return 1 if !($scfg->{krbd} || $map);
 
     my ($major, undef, undef, undef) = ceph_version();
     return 1 if $major < 10;
@@ -302,14 +302,14 @@ sub parse_volname {
 }
 
 sub path {
-    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname, $map) = @_;
 
     my $cmd_option = PVE::Storage::CephTools::ceph_connect_option($scfg, $storeid);
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     $name .= '@'.$snapname if $snapname;
 
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-    return ("/dev/rbd/$pool/$name", $vmid, $vtype) if $scfg->{krbd};
+    return ("/dev/rbd/$pool/$name", $vmid, $vtype) if ($scfg->{krbd} || $map);
 
     my $path = "rbd:$pool/$name";
 
@@ -399,7 +399,7 @@ sub create_base {
 }
 
 sub clone_image {
-    my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_;
+    my ($class, $scfg, $storeid, $volname, $vmid, $snapname, $map) = @_;
 
     my $snap = '__base__';
     $snap = $snapname if length $snapname;
@@ -431,13 +431,13 @@ sub clone_image {
 
     run_rbd_command($cmd, errmsg => "rbd clone '$basename' error");
 
-    &$krbd_feature_disable($scfg, $storeid, $name);
+    &$krbd_feature_disable($scfg, $storeid, $name, $map);
 
     return $newvol;
 }
 
 sub alloc_image {
-    my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+    my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $map) = @_;
 
 
     die "illegal name '$name' - should be 'vm-$vmid-*'\n"
@@ -448,13 +448,13 @@ 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");
 
-    &$krbd_feature_disable($scfg, $storeid, $name);
+    &$krbd_feature_disable($scfg, $storeid, $name, $map);
 
     return $name;
 }
 
 sub free_image {
-    my ($class, $storeid, $scfg, $volname, $isBase) = @_;
+    my ($class, $storeid, $scfg, $volname, $isBase, $format, $map) = @_;
 
     my ($vtype, $name, $vmid, undef, undef, undef) =
 	$class->parse_volname($volname);
@@ -468,7 +468,7 @@ sub free_image {
 	}
     }
 
-    $class->deactivate_volume($storeid, $scfg, $volname);
+    $class->deactivate_volume($storeid, $scfg, $volname, undef, undef, $map);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge',  $name);
     run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
@@ -548,9 +548,9 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache, $map) = @_;
 
-    return 1 if !$scfg->{krbd};
+    return 1 if !($scfg->{krbd} || $map);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
@@ -567,9 +567,9 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache, $map) = @_;
 
-    return 1 if !$scfg->{krbd};
+    return 1 if !($scfg->{krbd} || $map);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
@@ -593,9 +593,9 @@ sub volume_size_info {
 }
 
 sub volume_resize {
-    my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $size, $running, $map) = @_;
 
-    return 1 if $running && !$scfg->{krbd};
+    return 1 if $running && !($scfg->{krbd} || $map);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
@@ -624,11 +624,11 @@ sub volume_snapshot_rollback {
 }
 
 sub volume_snapshot_delete {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $snap, $running, $map) = @_;
 
-    return 1 if $running && !$scfg->{krbd};
+    return 1 if $running && !($scfg->{krbd} || $map);
 
-    $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
+    $class->deactivate_volume($storeid, $scfg, $volname, $snap, {}, $map);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-- 
2.11.0





More information about the pve-devel mailing list