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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 95926912ED for ; Tue, 20 Dec 2022 14:17:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 68764333D0 for ; Tue, 20 Dec 2022 14:16:43 +0100 (CET) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 20 Dec 2022 14:16:42 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 61A1F44B6B for ; Tue, 20 Dec 2022 14:16:42 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 20 Dec 2022 14:16:38 +0100 Message-Id: <20221220131638.223940-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221220131638.223940-1-f.ebner@proxmox.com> References: <20221220131638.223940-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [zfspoolplugin.pm] Subject: [pve-devel] [PATCH v2 storage 3/3] zfs: list images: code cleanup 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: Tue, 20 Dec 2022 13:17:13 -0000 Signed-off-by: Fiona Ebner --- New in v2. PVE/Storage/ZFSPoolPlugin.pm | 42 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 0899894..f829b86 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -254,36 +254,30 @@ sub free_image { sub list_images { my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; - my $zfs_list = $class->zfs_list_zvol($scfg); + my $zfs_list = $class->zfs_list_zvol($scfg) // {}; my $res = []; - if (my $dat = $zfs_list) { + for my $info (values $zfs_list->%*) { + my $volname = $info->{name}; + my $parent = $info->{parent}; + my $owner = $info->{vmid}; - foreach my $image (keys %$dat) { - - my $info = $dat->{$image}; - - my $volname = $info->{name}; - my $parent = $info->{parent}; - my $owner = $info->{vmid}; - - if ($parent && $parent =~ m/^(\S+)\@__base__$/) { - my ($basename) = ($1); - $info->{volid} = "$storeid:$basename/$volname"; - } else { - $info->{volid} = "$storeid:$volname"; - } - - if ($vollist) { - my $found = grep { $_ eq $info->{volid} } @$vollist; - next if !$found; - } else { - next if defined ($vmid) && ($owner ne $vmid); - } + if ($parent && $parent =~ m/^(\S+)\@__base__$/) { + my ($basename) = ($1); + $info->{volid} = "$storeid:$basename/$volname"; + } else { + $info->{volid} = "$storeid:$volname"; + } - push @$res, $info; + if ($vollist) { + my $found = grep { $_ eq $info->{volid} } @$vollist; + next if !$found; + } else { + next if defined ($vmid) && ($owner ne $vmid); } + + push @$res, $info; } return $res; } -- 2.30.2