[pve-devel] [PATCH storage 2/2] zfs: list zvol: list single pool only for remote ZFS

Fiona Ebner f.ebner at proxmox.com
Mon Nov 7 12:00:35 CET 2022


The remote ZFS plugin doesn't use a cache (would need a separate cache
for each target host), so this can speed up the operation.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/Storage/ZFSPlugin.pm     | 2 +-
 PVE/Storage/ZFSPoolPlugin.pm | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 1379bcf..cd5a3b6 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -422,7 +422,7 @@ sub deactivate_volume {
 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, 1);
     return $class->zfs_list_images($storeid, $scfg, $vmid, $vollist, $zfs_list);
 }
 
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 0fa18ce..2f75fba 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -379,9 +379,11 @@ sub zfs_delete_zvol {
 }
 
 sub zfs_list_zvol {
-    my ($class, $scfg) = @_;
+    my ($class, $scfg, $single_pool) = @_;
 
-    my $text = $class->zfs_request($scfg, 10, 'list', '-o', 'name,volsize,origin,type,refquota', '-t', 'volume,filesystem', '-Hrp');
+    my @param = ('-o', 'name,volsize,origin,type,refquota', '-t', 'volume,filesystem', '-Hrp');
+    push @param, $scfg->{pool} if $single_pool;
+    my $text = $class->zfs_request($scfg, 10, 'list', @param);
     my $zvols = zfs_parse_zvol_list($text);
     return undef if !$zvols;
 
-- 
2.30.2






More information about the pve-devel mailing list