]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/RBDPlugin.pm
add lvmthinscan to CLI
[pve-storage.git] / PVE / Storage / RBDPlugin.pm
index e600ec151ac6e68c2fe169b5dba852c7b5385f55..730fb859a32db8227ec1b946a9d68ac7013f954a 100644 (file)
@@ -407,6 +407,8 @@ sub free_image {
        }
     }
 
+    $class->deactivate_volume($storeid, $scfg, $volname);
+
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge',  $name);
     run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
 
@@ -487,12 +489,18 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
+
+    my $path = "/dev/rbd/$pool/$name";
+    $path .= '@'.$snapname if $snapname;
+    return if -b $path;
 
+    $name .= '@'.$snapname if $snapname;
     my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
     run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
 
@@ -500,7 +508,7 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
@@ -508,6 +516,9 @@ sub deactivate_volume {
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
 
     my $path = "/dev/rbd/$pool/$name";
+    $path .= '@'.$snapname if $snapname;
+    return if ! -b $path;
+
     my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
     run_rbd_command($cmd, errmsg => "can't unmount rbd volume $name");
 
@@ -558,6 +569,8 @@ sub volume_snapshot_delete {
 
     return 1 if $running;
 
+    $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
+
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);