[libvirt] [PATCH 3/5] storage: Add TRIM algorithm to storage volume API
Daniel P. Berrange
berrange at redhat.com
Mon Feb 1 12:14:28 UTC 2016
On Mon, Feb 01, 2016 at 01:12:13PM +0100, Ján Tomko wrote:
> 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 did not want to use ALG_ZERO, because that flag should not have a side
effect on the underlying physical storage allocation of the file. We added
the ALG_TRIM variant as one which explicitly does trimming of the underlying
storage.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list