[pve-devel] [PATCH storage 3/3] zfs: list zvol: limit recursion depth to 1

Fiona Ebner f.ebner at proxmox.com
Tue Jan 10 13:52:43 CET 2023


To be correct in all cases, it's still necessary to filter by "pool"
in zfs_parse_zvol_list(), because $scfg->{pool} could be e.g.
'foo/vm-123-disk-0' which looks like an image name and would pass the
other "should skip"-checks in zfs_parse_zvol_list().

No change in the result of zfs_list_zvol() is intended.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/Storage/ZFSPoolPlugin.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index b971c7a..9fbd149 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -377,9 +377,12 @@ sub zfs_list_zvol {
 	'name,volsize,origin,type,refquota',
 	'-t',
 	'volume,filesystem',
-	'-Hrp',
+	'-d1',
+	'-Hp',
 	$scfg->{pool},
     );
+    # It's still required to have zfs_parse_zvol_list filter by pool, because -d1 lists
+    # $scfg->{pool} too and while unlikely, it could be named to be mistaken for a volume.
     my $zvols = zfs_parse_zvol_list($text, $scfg->{pool});
     return {} if !$zvols;
 
-- 
2.30.2






More information about the pve-devel mailing list