From d99de0f898e8edc7bf1e2ae6e899bf16fbe298d0 Mon Sep 17 00:00:00 2001 From: Aaron Lauterer Date: Tue, 7 Apr 2020 14:25:35 +0200 Subject: [PATCH] ZFSPoolPlugin: fix #2662 get volume size correctly Getting the volume sizes as byte values instead of converted to human readable units helps to avoid rounding errors in the further processing if the volume size is more on the odd side. The `zfs list` command supports the -p(arseable) flag since a few years now. When returning the size in bytes there is no calculation performed and thus we need to explicitly cast the size to an integer before returning it. Signed-off-by: Aaron Lauterer --- PVE/Storage/ZFSPoolPlugin.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index b4fd65f..7da9e78 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -81,7 +81,7 @@ sub zfs_parse_size { $size = ceil($size); } - return $size; + return $size + 0; } @@ -400,7 +400,7 @@ sub zfs_delete_zvol { sub zfs_list_zvol { my ($class, $scfg) = @_; - my $text = $class->zfs_request($scfg, 10, 'list', '-o', 'name,volsize,origin,type,refquota', '-t', 'volume,filesystem', '-Hr'); + my $text = $class->zfs_request($scfg, 10, 'list', '-o', 'name,volsize,origin,type,refquota', '-t', 'volume,filesystem', '-Hrp'); my $zvols = zfs_parse_zvol_list($text); return undef if !$zvols;