[pve-devel] [PATCH v2 storage] When resizing a ZFS volume, align size to 1M

Fabian Ebner f.ebner at proxmox.com
Mon Dec 9 08:25:53 CET 2019


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 <f.ebner at proxmox.com>
---

Changes from v1:
    * Always align to 1M to avoid requesting volblocksize

 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;
-- 
2.20.1





More information about the pve-devel mailing list