all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH storage] zfs: improve get_latest_snapshot
Date: Mon, 9 Aug 2021 13:09:31 +0200	[thread overview]
Message-ID: <06d87a8a-184e-4dc5-b0ed-2e0e20f6fe36@proxmox.com> (raw)
In-Reply-To: <20210806091106.48473-1-f.ebner@proxmox.com>

Am 06.08.21 um 11:11 schrieb Fabian Ebner:
> 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 <f.ebner@proxmox.com>
> ---
>   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;
>   }
>   
> 

After an off-list discussion with Fabian G. about bug #3111, the plan is 
to extend volume_rollback_is_possible to inform its caller which 
snapshots are preventing a rollback. volume_rollback_is_possible is the 
only caller of zfs_get_latest_snapshot, so this patch will most likely 
be superseded by the series fixing #3111.




      reply	other threads:[~2021-08-09 11:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  9:11 Fabian Ebner
2021-08-09 11:09 ` Fabian Ebner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06d87a8a-184e-4dc5-b0ed-2e0e20f6fe36@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal