From d3e3e5d6bd0864e8f1883aa497720879dacaab20 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 9 Dec 2019 08:25:53 +0100 Subject: [PATCH] When resizing a ZFS volume, align size to 1M The size is required to be a multiple of volblocksize. Make sure that the requirement is always met, so ZFS won't complain when we do things like 'qm resize 102 scsi1 +0.01G'. Signed-off-by: Fabian Ebner --- PVE/Storage/ZFSPoolPlugin.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 456fb40..42aeedb 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -662,6 +662,12 @@ sub volume_resize { my $attr = $format eq 'subvol' ? 'refquota' : 'volsize'; + # align size to 1M so we always have a valid multiple of the volume block size + if ($format eq 'raw') { + my $padding = (1024 - $new_size % 1024) % 1024; + $new_size = $new_size + $padding; + } + $class->zfs_request($scfg, undef, 'set', "$attr=${new_size}k", "$scfg->{pool}/$vname"); return $new_size;