]> git.proxmox.com Git - pve-storage.git/commitdiff
Added code to abort a snapshot rollback in ZFS if the snapshot selected is not the...
authorChris Allen <Chris Allen>
Wed, 12 Mar 2014 00:32:17 +0000 (17:32 -0700)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 25 Jun 2014 07:14:03 +0000 (09:14 +0200)
Signed-off-by: Chris Allen <Chris Allen>
PVE/Storage/ZFSPlugin.pm

index 208e718f404fe4d47beb45a119932515a4ea9a4f..cb733d156bf54676850d2742ce410139f57e24a8 100644 (file)
@@ -607,6 +607,21 @@ sub volume_snapshot {
 sub volume_snapshot_rollback {
     my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
+    # abort rollback if snapshot is not the latest
+    my @params = ('-t', 'snapshot', '-o', 'name', '-s', 'creation');
+    my $text = zfs_request($scfg, undef, 'list', @params);
+    my @snapshots = split(/\n/, $text);
+    my $recentsnap = undef;
+    foreach (@snapshots) {
+        if (/$scfg->{pool}\/$volname/) {
+            s/^.*@//;
+            $recentsnap = $_;
+        } 
+    }
+    if ($snap ne $recentsnap) {
+        die "cannot rollback, more recent snapshots exist\n";
+    }
+
     zfs_delete_lu($scfg, $volname);
 
     zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");