]> git.proxmox.com Git - pve-storage.git/commitdiff
extend functionality to (de)activate_volumes with snapshots
authorWolfgang Link <w.link@proxmox.com>
Fri, 18 Sep 2015 09:57:07 +0000 (11:57 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 22 Sep 2015 10:18:09 +0000 (12:18 +0200)
this extension provide the capability to activate or deactivate snapshot,
so we can use this e.g. for LXC backup in snapshot mode.

PVE/Storage.pm
PVE/Storage/DRBDPlugin.pm
PVE/Storage/GlusterfsPlugin.pm
PVE/Storage/ISCSIDirectPlugin.pm
PVE/Storage/LVMPlugin.pm
PVE/Storage/Plugin.pm
PVE/Storage/RBDPlugin.pm
PVE/Storage/SheepdogPlugin.pm
PVE/Storage/ZFSPlugin.pm
PVE/Storage/ZFSPoolPlugin.pm

index 3637de205bede0fad45b4423b0e3de9ddd985765..c27e9cf30ecbae65523ef4e81a9a2192d272a25c 100755 (executable)
@@ -831,7 +831,7 @@ sub deactivate_storage {
 }
 
 sub activate_volumes {
-    my ($cfg, $vollist) = @_;
+    my ($cfg, $vollist, $snapname) = @_;
 
     return if !($vollist && scalar(@$vollist));
 
@@ -849,12 +849,12 @@ sub activate_volumes {
        my ($storeid, $volname) = parse_volume_id($volid);
        my $scfg = storage_config($cfg, $storeid);
        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-       $plugin->activate_volume($storeid, $scfg, $volname, $cache);
+       $plugin->activate_volume($storeid, $scfg, $volname, $snapname, $cache);
     }
 }
 
 sub deactivate_volumes {
-    my ($cfg, $vollist) = @_;
+    my ($cfg, $vollist, $snapname) = @_;
 
     return if !($vollist && scalar(@$vollist));
 
@@ -868,7 +868,7 @@ sub deactivate_volumes {
        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
 
        eval {
-           $plugin->deactivate_volume($storeid, $scfg, $volname, $cache);
+           $plugin->deactivate_volume($storeid, $scfg, $volname, $snapname, $cache);
        };
        if (my $err = $@) {
            warn $err;
index c4a5ee17ddc6b82b49808b96f4dced508d408ad3..89dfb628ace9c75f4ce1ded144fcee087659f470 100644 (file)
@@ -296,7 +296,9 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "Snapshot not implemented on DRBD\n" if $snapname;
 
     my $path = $class->path($scfg, $volname);
     
@@ -340,7 +342,9 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "Snapshot not implemented on DRBD\n" if $snapname;
 
     return undef; # fixme: should we unassign ?
 
index dee34c35c27b138c8d61bbe43db39db9fca5d076..3bae1009291fdfa15851c841b03a2ef56ff20038 100644 (file)
@@ -300,13 +300,13 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     # do nothing by default
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     # do nothing by default
 }
index cece023fea0d5eee64228e3c59f7764bac9639eb..f0c6c53853a8bf3bfa0afd7073f58b33c7449be5 100644 (file)
@@ -184,12 +184,18 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "volume snapshot is not possible on iscsi device" if $snapname;
+
     return 1;
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "volume snapshot is not possible on iscsi device" if $snapname;
+
     return 1;
 }
 
index e59c4a9033e62e34fa38d556da0dec4227e9d963..5dc732e29bd3e9bb713c6f7d8d5ebd7d78fe64cf 100644 (file)
@@ -421,9 +421,9 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     #fix me lvmchange is not provided on
-    my $path = $class->path($scfg, $volname);
+    my $path = $class->path($scfg, $volname, $snapname);
 
     my $lvm_activate_mode = 'ey';
 
@@ -432,9 +432,9 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
-    my $path = $class->path($scfg, $volname);
+    my $path = $class->path($scfg, $volname, $snapname);
     return if ! -b $path;
 
     my $cmd = ['/sbin/lvchange', '-aln', $path];
index c921174fac78730e4d016fdfb98196052984cb06..0eb9e73854f786e8d258f7295e7330040798eef5 100644 (file)
@@ -832,9 +832,9 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
-    my $path = $class->filesystem_path($scfg, $volname);
+    my $path = $class->filesystem_path($scfg, $volname, $snapname);
 
     # check is volume exists
     if ($scfg->{path}) {
@@ -845,7 +845,7 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     # do nothing by default
 }
index 4fe634511c37b816842dc4a5a103961b0aa22487..71edc8b51df081f8ae6910d745f95782c090077e 100644 (file)
@@ -489,7 +489,7 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
@@ -497,8 +497,10 @@ sub activate_volume {
     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");
 
@@ -506,7 +508,7 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
@@ -514,6 +516,7 @@ 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);
index 4241742e0b07be68b5cd84d8f9656b22b0f562ea..527c6c6f2f0170e03cc5d8f587b23a331162fdfa 100644 (file)
@@ -345,12 +345,12 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }
 
index 52e909057286cd4f75070f16e86e4390ac468fb2..df4c6d7d7a6e7ffaf40403aaf3a86a1fb603c003 100644 (file)
@@ -352,6 +352,29 @@ sub volume_has_feature {
 
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
+
+    return 1;
+}
+
+sub deactivate_storage {
+    my ($class, $storeid, $scfg, $cache) = @_;
+
+    return 1;
+}
+
+sub activate_volume {
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "unable to activate snapshot from remote zfs storage" if $snapname;
+
+    return 1;
+}
+
+sub deactivate_volume {
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+    die "unable to deactivate snapshot from remote zfs storage" if $snapname;
+
     return 1;
 }
 
index 880d5042ff2b1b55d5adc81d4e24877e9e02730c..632645fd3b9176ec9b965462f88940a02347e633 100644 (file)
@@ -505,12 +505,12 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }