[pve-devel] [PATCH qemu-server] add discard_granularity to 4M for rbd storage

Alexandre DERUMIER aderumier at odiso.com
Fri Jun 29 08:12:13 CEST 2018


and for zfs , we can retrieve block size with:

zfs get volblocksize rpool/data/vm-105-disk-1
NAME                      PROPERTY      VALUE     SOURCE
rpool/data/vm-105-disk-1  volblocksize  8K        default



Maybe can we change current discard option to:

discard : 0 : disable
          1 : enable (with defaut qemu value)
          2 : enable : auto best value (zfs/rbd autodect and qemu for others storage)
          1024-... : custom user value

?




----- Mail original -----
De: "aderumier" <aderumier at odiso.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Jeudi 28 Juin 2018 17:53:22
Objet: Re: [pve-devel] [PATCH qemu-server] add discard_granularity to 4M for rbd storage

>>In my opinion it would be better to have Qemu figure it out automagically or 
>>use the discard config option to add the granularity. 

qemu seem to be able to get the value 

in qemu block/rbd.c 

static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi) 
{ 
BDRVRBDState *s = bs->opaque; 
rbd_image_info_t info; 
int r; 

r = rbd_stat(s->image, &info, sizeof(info)); 
if (r < 0) { 
return r; 
} 

bdi->cluster_size = info.obj_size; 
return 0; 
} 




or with rbd command: 

# rbd info vm-788-disk-1 
rbd image 'vm-788-disk-1': 
size 15360 MB in 3840 objects 
order 22 (4096 kB objects) 
block_name_prefix: rbd_data.caf396b8b4567 
format: 2 
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten 
flags: 



----- Mail original ----- 
De: "Alwin Antreich" <a.antreich at proxmox.com> 
À: "pve-devel" <pve-devel at pve.proxmox.com> 
Envoyé: Jeudi 28 Juin 2018 14:56:32 
Objet: Re: [pve-devel] [PATCH qemu-server] add discard_granularity to 4M for rbd storage 

On Thu, Jun 28, 2018 at 10:08:45AM +0200, Alexandre Derumier wrote: 
> when we have snapshots on rbd and do a trim, the space is increasing 
> http://tracker.ceph.com/issues/18352 
> 
> we need to trim a full object (4MB by default), to be able to free space. 
> 
> test: 
> 
> without discard_granularity 
> --------------------------- 
> vm-107-disk-1 20480M 2500M 
> vm-107-disk-1 20480M 2500M 
> 
> vm-107-disk-1 at snap1 20480M 2500M 
> vm-107-disk-1 20480M 90112k 
> 
> vm-107-disk-1 at snap1 20480M 2500M 
> vm-107-disk-1 20480M 1020M 
> 
> with discard_granularity=4M 
> --------------------------- 
> vm-107-disk-1 20480M 2500M 
> vm-107-disk-1 20480M 2500M 
> 
> vm-107-disk-1 at snap1 20480M 2500M 
> vm-107-disk-1 20480M 90112k 
> 
> vm-107-disk-1 at snap1 20480M 2500M 
> vm-107-disk-1 20480M 144M 
> --- 
> PVE/QemuServer.pm | 5 +++++ 
> 1 file changed, 5 insertions(+) 
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm 
> index 6a355f8..fd9754c 100644 
> --- a/PVE/QemuServer.pm 
> +++ b/PVE/QemuServer.pm 
> @@ -1695,6 +1695,11 @@ sub print_drivedevice_full { 
> $device .= ",serial=$serial"; 
> } 
> 
> + my $volid = $drive->{file}; 
> + if($volid && $drive->{discard}) { 
> + my $storage_name = PVE::Storage::parse_volume_id($volid); 
> + $device .= ",discard_granularity=4194304" if $storecfg->{ids}->{$storage_name}->{type} eq 'rbd'; 
> + } 
In my opinion it would be better to have Qemu figure it out automagically or 
use the discard config option to add the granularity. 

As example: discard=on / discard=4194304 (is on with granularity). 

This way it is configurable per disk image and can be set according to the 
needs of the storage (eg. zvol; 8K). 

For Ceph, the object size can be set when an image is created (--object-size). 

> 
> return $device; 
> } 
> -- 
> 2.11.0 
-- 
Cheers, 
Alwin 

_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 

_______________________________________________ 
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