[libvirt] [PATCH 3/5] storage: Add TRIM algorithm to storage volume API

Ján Tomko jtomko at redhat.com
Mon Feb 1 12:12:13 UTC 2016


On Wed, Jan 27, 2016 at 11:20:07AM +0100, Wido den Hollander wrote:
> This new algorithm adds support for wiping volumes using TRIM.
> 
> It does not overwrite all the data in a volume, but it tells the
> backing storage pool/driver that all bytes in a volume can be
> discarded.
> 
> It depends on the backing storage pool how this is handled.
> 
> A SCSI backend might send UNMAP commands to remove all data present
> on a LUN.
> 
> A Ceph backend might use rbd_discard() to instruct the Ceph cluster
> that all data on that RBD volume can be discarded.
> 
> Signed-off-by: Wido den Hollander <wido at widodh.nl>
> ---
>  include/libvirt/libvirt-storage.h | 3 +++
>  src/storage/storage_backend.c     | 4 ++++
>  tools/virsh-volume.c              | 2 +-
>  tools/virsh.pod                   | 1 +
>  4 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-storage.h
> index 2c55c93..232b4d3 100644
> --- a/include/libvirt/libvirt-storage.h
> +++ b/include/libvirt/libvirt-storage.h
> @@ -153,6 +153,9 @@ typedef enum {
>  
>      VIR_STORAGE_VOL_WIPE_ALG_RANDOM = 8, /* 1-pass random */
>  
> +    VIR_STORAGE_VOL_WIPE_ALG_TRIM = 9, /* 1-pass, trim all data on the
> +                                          volume by using TRIM or DISCARD */
> +

Do we need a separate flag for that?

VIR_STORAGE_VOL_WIPE_ALG_ZERO already has a similar behavior
for sparse files, where we truncate the file size to 0,
then back to the original size.

We could treat it as 'rbd_discard' in the rbd driver, with a fallback to
writing zeroes if that's not supported.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160201/0d222c7e/attachment-0001.sig>


More information about the libvir-list mailing list