xen_disk: add discard support

Implement discard support for xen_disk. It makes use of the existing
discard code in qemu.

The discard support is enabled unconditionally. The tool stack may
provide a property "discard-enable" in the backend node to optionally
disable discard support.  This is helpful in case the backing file was
intentionally created non-sparse to avoid fragmentation.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
This commit is contained in:
Olaf Hering 2014-05-07 13:40:04 +00:00 committed by Stefano Stabellini
parent 8b6bb0ad17
commit f31352041b
3 changed files with 52 additions and 0 deletions

View file

@ -144,6 +144,13 @@ static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
{
return -ENOSYS;
}
/* The followings are only to compile op_discard related code on older
* Xen releases. */
#define BLKIF_OP_DISCARD 5
struct blkif_request_discard {
uint64_t nr_sectors;
uint64_t sector_number;
};
#else
static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
uint64_t addr, uint32_t data)