by only requesting snapshots for the relevant dataset, instead of all snapshots in all pools, and avoiding an unnecessary loop.
Signed-off-by: Fabian Ebner <[email protected]> --- PVE/Storage/ZFSPoolPlugin.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index c4be70f..fd7f844 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -400,19 +400,16 @@ sub zfs_get_latest_snapshot { my $vname = ($class->parse_volname($volname))[1]; - # abort rollback if snapshot is not the latest - my @params = ('-t', 'snapshot', '-o', 'name', '-s', 'creation'); + # can't use -S, because zfs list won't reverse order when creation time + # is the same second, breaking (at least) our tests. + my @params = ('-H', '-t', 'snapshot', '-o', 'name', '-s', 'creation', "$scfg->{pool}\/$vname"); my $text = $class->zfs_request($scfg, undef, 'list', @params); my @snapshots = split(/\n/, $text); my $recentsnap; - foreach (@snapshots) { - if (/$scfg->{pool}\/$vname/) { - s/^.*@//; - $recentsnap = $_; - } + if (scalar(@snapshots) > 0) { + ($recentsnap = $snapshots[-1]) =~ s/^.*@//; # last element } - return $recentsnap; } -- 2.30.2 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
