]> git.proxmox.com Git - pve-storage.git/commitdiff
zfs: list zvol: skip different pools during parsing already
authorFiona Ebner <f.ebner@proxmox.com>
Tue, 10 Jan 2023 12:52:42 +0000 (13:52 +0100)
committerWolfgang Bumiller <w.bumiller@errno.eu>
Tue, 10 Jan 2023 13:29:53 +0000 (14:29 +0100)
The 'pool' property in the result of zfs_parse_zvol_list() was not
used for anything else.

No functional change is intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/Storage/ZFSPoolPlugin.pm

index bce360fbb0973ef02dd7aa0343eb97a7feda0570..b971c7a2eec0c937b54548c9f9a95afa8eb3a13e 100644 (file)
@@ -58,7 +58,7 @@ sub options {
 # static zfs helper methods
 
 sub zfs_parse_zvol_list {
-    my ($text) = @_;
+    my ($text, $pool) = @_;
 
     my $list = ();
 
@@ -73,12 +73,12 @@ sub zfs_parse_zvol_list {
        my @parts = split /\//, $dataset;
        next if scalar(@parts) < 2; # we need pool/name
        my $name = pop @parts;
-       my $pool = join('/', @parts);
+       my $parsed_pool = join('/', @parts);
+       next if $parsed_pool ne $pool;
 
        next unless $name =~ m!^(vm|base|subvol|basevol)-(\d+)-(\S+)$!;
        $zvol->{owner} = $2;
 
-       $zvol->{pool} = $pool;
        $zvol->{name} = $name;
        if ($type eq 'filesystem') {
            if ($refquota eq 'none') {
@@ -380,14 +380,11 @@ sub zfs_list_zvol {
        '-Hrp',
        $scfg->{pool},
     );
-    my $zvols = zfs_parse_zvol_list($text);
+    my $zvols = zfs_parse_zvol_list($text, $scfg->{pool});
     return {} if !$zvols;
 
     my $list = {};
     foreach my $zvol (@$zvols) {
-       # The "pool" in $scfg is not the same as ZFS pool, so it's necessary to filter here.
-       next if $scfg->{pool} ne $zvol->{pool};
-
        my $name = $zvol->{name};
        my $parent = $zvol->{origin};
        if($zvol->{origin} && $zvol->{origin} =~ m/^$scfg->{pool}\/(\S+)$/){