[pve-devel] [PATCH] rbd: get volume size for volumes list

Alexandre DERUMIER aderumier at odiso.com
Wed Oct 17 08:23:26 CEST 2012


Currently, rbd ls command don't display volume size.

so we need an extra call rbd info.


this is to display it in list_images sub.


Do you think It'll add too much overhead with a lot of images  ? (I see you have done same thing with nexentaplugin)

----- Mail original ----- 

De: "Dietmar Maurer" <dietmar at proxmox.com> 
À: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com 
Envoyé: Mercredi 17 Octobre 2012 06:39:29 
Objet: RE: [pve-devel] [PATCH] rbd: get volume size for volumes list 

I do not understand this patch? What is the purpose? 

> -----Original Message----- 
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel- 
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier 
> Sent: Dienstag, 16. Oktober 2012 16:38 
> To: pve-devel at pve.proxmox.com 
> Subject: [pve-devel] [PATCH] rbd: get volume size for volumes list 
> 
> 
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com> 
> --- 
> PVE/Storage/RBDPlugin.pm | 38 ++++++++++++++++++++++---------------- 
> 1 file changed, 22 insertions(+), 16 deletions(-) 
> 
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm index 
> b05d299..33ae853 100644 
> --- a/PVE/Storage/RBDPlugin.pm 
> +++ b/PVE/Storage/RBDPlugin.pm 
> @@ -56,7 +56,7 @@ sub rbd_ls { 
> 
> $list->{$scfg->{pool}}->{$image} = { 
> name => $image, 
> - size => 0, 
> + size => rbd_volume_size($scfg, $storeid, $image), 
> vmid => $owner 
> }; 
> } 
> @@ -72,6 +72,26 @@ sub rbd_ls { 
> return $list; 
> } 
> 
> +sub rbd_volume_size { 
> + my ($scfg, $storeid, $volname) = @_; 
> + 
> + my $cmd = &$rbd_cmd($scfg, $storeid, 'info', $volname); 
> + my $size = undef; 
> + my $parser = sub { 
> + my $line = shift; 
> + 
> + if ($line =~ m/size (\d+) MB in (\d+) objects/) { 
> + $size = $1; 
> + } 
> + }; 
> + 
> + run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc 
> + => $parser); 
> + 
> + $size = $size*1024*1024 if $size; 
> + 
> + return $size; 
> +} 
> + 
> sub addslashes { 
> my $text = shift; 
> $text =~ s/;/\\;/g; 
> @@ -282,21 +302,7 @@ sub deactivate_volume { sub volume_size_info { 
> my ($class, $scfg, $storeid, $volname, $timeout) = @_; 
> 
> - my $cmd = &$rbd_cmd($scfg, $storeid, 'info', $volname); 
> - my $size = undef; 
> - my $parser = sub { 
> - my $line = shift; 
> - 
> - if ($line =~ m/size (\d+) MB in (\d+) objects/) { 
> - $size = $1; 
> - } 
> - }; 
> - 
> - run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => 
> $parser); 
> - 
> - $size = $size*1024*1024 if $size; 
> - 
> - return $size; 
> + return rbd_volume_size($scfg, $storeid, $volname); 
> } 
> 
> sub volume_resize { 
> -- 
> 1.7.10.4 
> 
> _______________________________________________ 
> pve-devel mailing list 
> pve-devel at pve.proxmox.com 
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 



More information about the pve-devel mailing list