Added code to abort a snapshot rollback in ZFS if the snapshot selected is not the most recent. This is to avoid lu deletion when trying to rollback to a snapshot that isn't the newest.
Signed-off-by: Chris Allen <Chris Allen>
This commit is contained in:
committed by
Dietmar Maurer
parent
454c15e270
commit
a315b9ff56
@ -607,6 +607,21 @@ sub volume_snapshot {
|
|||||||
sub volume_snapshot_rollback {
|
sub volume_snapshot_rollback {
|
||||||
my ($class, $scfg, $storeid, $volname, $snap) = @_;
|
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_delete_lu($scfg, $volname);
|
||||||
|
|
||||||
zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");
|
zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");
|
||||||
|
|||||||
Reference in New Issue
Block a user