[pve-devel] [PATCH storage 2/2] rbd: volume resize: avoid passing floating point value to rbd

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 6 19:37:00 CEST 2023


Am 28/04/2023 um 14:32 schrieb Fiona Ebner:
> which causes an error "the argument for option '--size' is invalid".
> Just round up to the nearest integer to have at least the requested
> size. This is similar to what is done for ZFS with d3e3e5d ("When
> resizing a ZFS volume, align size to 1M") and makes commands like 'qm
> resize 102 scsi1 +0.01G' work.
> 
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>  PVE/Storage/RBDPlugin.pm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index 9d59a14..c9e70a2 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -7,6 +7,7 @@ use Cwd qw(abs_path);
>  use IO::File;
>  use JSON;
>  use Net::IP;
> +use POSIX qw(ceil);
>  
>  use PVE::CephConfig;
>  use PVE::Cluster qw(cfs_read_file);;
> @@ -779,7 +780,7 @@ sub volume_resize {
>  
>      my ($vtype, $name, $vmid) = $class->parse_volname($volname);
>  
> -    my $cmd = $rbd_cmd->($scfg, $storeid, 'resize', '--size', ($size/1024/1024), $name);
> +    my $cmd = $rbd_cmd->($scfg, $storeid, 'resize', '--size', ceil($size/1024/1024), $name);


Hmm, but POSIX ceil is also returning a double `double ceil(double x)`, maybe wrap
that into an int(), hedging against (future) perl is often a relatively good idea ^^

FWIW: we often to something like int(($size + 1023)/1024/1024); (untested for this
specific case).


>      run_rbd_command($cmd, errmsg => "rbd resize '$volname' error");
>      return undef;
>  }






More information about the pve-devel mailing list