From: Owen Smith Subject: [PATCH 2/2 v2] Add trim operation to xen block devices Date: Wed, 22 Dec 2010 15:05:03 +0000 Message-ID: <1293030303-23301-5-git-send-email-owen.smith@citrix.com> References: <1292950702-15312-1-git-send-email-owen.smith@citrix.com> <1293030303-23301-1-git-send-email-owen.smith@citrix.com> <1293030303-23301-2-git-send-email-owen.smith@citrix.com> <1293030303-23301-3-git-send-email-owen.smith@citrix.com> <1293030303-23301-4-git-send-email-owen.smith@citrix.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1293030303-23301-4-git-send-email-owen.smith@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Owen Smith List-Id: xen-devel@lists.xenproject.org Add Trim command interface This patch adds the trim operation to the blkback ring protocol. Trim commands 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: http://t13.org/Documents/UploadedDocuments/docs2008/ e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc Signed-of-by: Owen Smith # HG changeset patch # User Owen Smith # Date 1292938216 0 # Node ID 6be1a23977b82e44eba80feeca3fb77acf6bb2bb # Parent 7015d7407eae8694ce1cc92e792b2087f109f6cb imported patch add-trim diff -r 7015d7407eae -r 6be1a23977b8 xen/include/public/io/blkif.h --- a/xen/include/public/io/blkif.h Tue Dec 21 13:28:48 2010 +0000 +++ b/xen/include/public/io/blkif.h Tue Dec 21 13:30:16 2010 +0000 @@ -76,6 +76,17 @@ * "feature-flush-cache" node! */ #define BLKIF_OP_FLUSH_DISKCACHE 3 +/* + * Recognised only if "feature-trim" is present in backend xenbus info. + * The "feature-trim" node contains a boolean indicating whether trim + * requests are likely to succeed or fail. Either way, a trim request + * may fail at any time with BLKIF_RSP_EOPNOTSUPP if it is unsupported by + * the underlying block-device hardware. The boolean simply indicates whether + * or not it is worthwhile for the frontend to attempt trim requests. + * If a backend does not recognise BLKIF_OP_TRIM, it should *not* + * create the "feature-trim" node! + */ +#define BLKIF_OP_TRIM 5 /* * Maximum scatter/gather segments per request. @@ -103,6 +114,11 @@ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; }; +struct blkif_request_trim { + blkif_sector_t sector_number;/* start sector idx on disk */ + uint64_t nr_sectors; +}; + struct blkif_request { uint8_t operation; /* BLKIF_OP_??? */ uint8_t nr_segments; /* number of segments */ @@ -110,6 +126,7 @@ uint64_t id; /* private guest value, echoed in resp */ union { struct blkif_request_rw rw; + struct blkif_request_trim trim; } u; }; typedef struct blkif_request blkif_request_t;