From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5D9076C943 for ; Mon, 9 Aug 2021 13:09:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 50AC42102E for ; Mon, 9 Aug 2021 13:09:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 23B692101D for ; Mon, 9 Aug 2021 13:09:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E5944430A2 for ; Mon, 9 Aug 2021 13:09:35 +0200 (CEST) To: pve-devel@lists.proxmox.com References: <20210806091106.48473-1-f.ebner@proxmox.com> From: Fabian Ebner Message-ID: <06d87a8a-184e-4dc5-b0ed-2e0e20f6fe36@proxmox.com> Date: Mon, 9 Aug 2021 13:09:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210806091106.48473-1-f.ebner@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.421 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH storage] zfs: improve get_latest_snapshot X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 11:09:37 -0000 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 > --- > 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.