debuggers.hg

changeset 22822:78e2e5a50daa

xen-unstable/blkif: Add trim operation interface

Trim operation is a request for the underlying block device to mark
extents to be erased. Add the operation code and ring data structure
to the public header file.

Trim operations are passed with sector_number as the sector index to
begin trim operations at and nr_sectors as the number of sectors to
be trimmed. The specified sectors should be trimmed if the underlying
block device supports trim operations, or a BLKIF_RSP_EOPNOTSUPP
should be returned. More information about trim operations at;
http://t13.org/Documents/UploadedDocuments/docs2008/
e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc

Signed-off-by: Owen Smith <owen.smith@citrix.com>
author Keir Fraser <keir@xen.org>
date Tue Jan 18 10:28:22 2011 +0000 (2011-01-18)
parents e4688c57c230
children 1e7594758b28
files xen/include/public/io/blkif.h
line diff
     1.1 --- a/xen/include/public/io/blkif.h	Tue Jan 18 09:04:04 2011 +0000
     1.2 +++ b/xen/include/public/io/blkif.h	Tue Jan 18 10:28:22 2011 +0000
     1.3 @@ -81,6 +81,26 @@
     1.4   * contained within the request. Reserved for that purpose.
     1.5   */
     1.6  #define BLKIF_OP_RESERVED_1        4
     1.7 +/*
     1.8 + * Recognised only if "feature-trim" is present in backend xenbus info.
     1.9 + * The "feature-trim" node contains a boolean indicating whether trim
    1.10 + * requests are likely to succeed or fail. Either way, a trim request
    1.11 + * may fail at any time with BLKIF_RSP_EOPNOTSUPP if it is unsupported by
    1.12 + * the underlying block-device hardware. The boolean simply indicates whether
    1.13 + * or not it is worthwhile for the frontend to attempt trim requests.
    1.14 + * If a backend does not recognise BLKIF_OP_TRIM, it should *not*
    1.15 + * create the "feature-trim" node!
    1.16 + * 
    1.17 + * Trim operation is a request for the underlying block device to mark
    1.18 + * extents to be erased. Trim operations are passed with sector_number as the
    1.19 + * sector index to begin trim operations at and nr_sectors as the number of
    1.20 + * sectors to be trimmed. The specified sectors should be trimmed if the
    1.21 + * underlying block device supports trim operations, or a BLKIF_RSP_EOPNOTSUPP
    1.22 + * should be returned. More information about trim operations at:
    1.23 + * http://t13.org/Documents/UploadedDocuments/docs2008/
    1.24 + *     e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc
    1.25 + */
    1.26 +#define BLKIF_OP_TRIM              5
    1.27  
    1.28  /*
    1.29   * Maximum scatter/gather segments per request.
    1.30 @@ -113,6 +133,20 @@ struct blkif_request {
    1.31  };
    1.32  typedef struct blkif_request blkif_request_t;
    1.33  
    1.34 +/*
    1.35 + * Cast to this structure when blkif_request.operation == BLKIF_OP_TRIM
    1.36 + * sizeof(struct blkif_request_trim) <= sizeof(struct blkif_request)
    1.37 + */
    1.38 +struct blkif_request_trim {
    1.39 +    uint8_t        operation;    /* BLKIF_OP_TRIM                        */
    1.40 +    uint8_t        reserved;     /*                                      */
    1.41 +    blkif_vdev_t   handle;       /* same as for read/write requests      */
    1.42 +    uint64_t       id;           /* private guest value, echoed in resp  */
    1.43 +    blkif_sector_t sector_number;/* start sector idx on disk             */
    1.44 +    uint64_t       nr_sectors;   /* number of contiguous sectors to trim */
    1.45 +};
    1.46 +typedef struct blkif_request_trim blkif_request_trim_t;
    1.47 +
    1.48  struct blkif_response {
    1.49      uint64_t        id;              /* copied from request */
    1.50      uint8_t         operation;       /* copied from request */