[pve-devel] [PATCH storage] Automatically round up to the next valid size when resizing a ZFS volume
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Dec 5 12:13:56 CET 2019
On December 5, 2019 11:47 am, Fabian Ebner wrote:
> 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>
> ---
> PVE/Storage/ZFSPoolPlugin.pm | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
> index 456fb40..9bc3fcf 100644
> --- a/PVE/Storage/ZFSPoolPlugin.pm
> +++ b/PVE/Storage/ZFSPoolPlugin.pm
> @@ -662,6 +662,17 @@ sub volume_resize {
>
> my $attr = $format eq 'subvol' ? 'refquota' : 'volsize';
>
> + # for ZFS volumes, size has to be a multiple of the volume block size,
> + # so we round up to the next valid size
> + if ($format eq 'raw') {
> + my $volblocksize = int($class->zfs_get_properties($scfg, 'volblocksize', "$scfg->{pool}/$vname"));
> + if ($volblocksize >= 2048) {
> + $volblocksize = int($volblocksize / 1024);
> + my $remainder = $new_size % $volblocksize;
> + $new_size = $new_size + $volblocksize - $remainder if $remainder;
> + }
we already align/pad to 1M on allocation (zfs_create_zvol), maybe we
could do the same here to increase consistency, and avoid a round-trip
via zfs_get_properties?
> + }
> +
> $class->zfs_request($scfg, undef, 'set', "$attr=${new_size}k", "$scfg->{pool}/$vname");
>
> return $new_size;
> --
> 2.20.1
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
More information about the pve-devel
mailing list