From patchwork Thu Apr 7 10:00:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 8770301 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 723799FBEA for ; Thu, 7 Apr 2016 10:04:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 737B120212 for ; Thu, 7 Apr 2016 10:04:28 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FAA72020F for ; Thu, 7 Apr 2016 10:04:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ao6jh-0007xu-1C; Thu, 07 Apr 2016 10:00:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ao6jf-0007xm-TV for xen-devel@lists.xen.org; Thu, 07 Apr 2016 10:00:24 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 53/62-12342-7BF26075; Thu, 07 Apr 2016 10:00:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRWlGSWpSXmKPExsXSO6nOVXebPlu 4wa9GVoslHxezODB6HN39mymAMYo1My8pvyKBNePxnn7mgk2yFf1/97E2MO6X6GLk4hASaGWS 2DxlNROE85VR4sOZT+wQzgZGieNdPWxQZYwSk680AjkcHGwCShLz76d3MXJyiAhIS1z7fJkRp IZZYCejxIuHW1hAEsICzhKPD/9nArFZBFQlOjfsYQOxeQWcJDr3/gSLSwgoSnQ/m8AGYRtKnH 64jXECI88CRoZVjBrFqUVlqUW6hsZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxi B3mcAgh2M/7Z5HmKU5GBSEuU9K8UWLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCd4MeUE6wKDU9 tSItMwcYhjBpCQ4eJRHexyBp3uKCxNzizHSI1ClGRSlx3v0gCQGQREZpHlwbLPQvMcpKCfMyA h0ixFOQWpSbWYIq/4pRnINRSZi3EmQKT2ZeCdz0V0CLmYAWX+AHW1ySiJCSamDkTWmdtW7Zye UiNzQ5fxouqz9utP7VAcmSCXdWqbN8uDnBzYz76hpH61Az/u8uWo8tFj1Q0twhud846In4hNu yftIv819t3sFXxH34B/eX3wdb35Y+3PXoUAvrlmnfg/d3LBC0dwpSaufTrZu9janYsuMVQ4Xj hdgggarED00zBOa4fTjK7FyjxFKckWioxVxUnAgA6ydNGngCAAA= X-Env-Sender: bob.liu@oracle.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1460023220!33501980!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8732 invoked from network); 7 Apr 2016 10:00:21 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-9.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Apr 2016 10:00:21 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u37A0HuI003401 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Apr 2016 10:00:18 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u37A0G0S006414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Apr 2016 10:00:17 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u37A0Egg004083; Thu, 7 Apr 2016 10:00:15 GMT Received: from boliuliu.home (/101.80.139.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Apr 2016 03:00:13 -0700 From: Bob Liu To: xen-devel@lists.xen.org Date: Thu, 7 Apr 2016 18:00:00 +0800 Message-Id: <1460023200-20255-1-git-send-email-bob.liu@oracle.com> X-Mailer: git-send-email 1.7.10.4 X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: jgross@suse.com, Bob Liu , Paul.Durrant@citrix.com, david.vrabel@citrix.com, Ian.Jackson@citrix.com, roger.pau@citrix.com Subject: [Xen-devel] [RFC PATCH] Data integrity extension support for xen-block X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * What's data integrity extension and why? Modern filesystems feature checksumming of data and metadata to protect against data corruption. However, the detection of the corruption is done at read time which could potentially be months after the data was written. At that point the original data that the application tried to write is most likely lost. The solution in Linux is the data integrity framework which enables protection information to be pinned to I/Os and sent to/received from controllers that support it. struct bio has been extended with a pointer to a struct bip which in turn contains the integrity metadata. The bip is essentially a trimmed down bio with a bio_vec and some housekeeping. * Issues when xen-block get involved. xen-blkfront only transmits the normal data of struct bio while the integrity metadata buffer(struct bio_integrity_payload in each bio) is ignored. * Proposal of transmitting bio integrity payload. Adding an extra request following the normal data request, this extra request contains the integrity payload. The xen-blkback will reconstruct an new bio with both received normal data and integrity metadata. Welcome any better ideas, thank you! [1] http://lwn.net/Articles/280023/ [2] https://www.kernel.org/doc/Documentation/block/data-integrity.txt Signed-off-by: Bob Liu --- xen/include/public/io/blkif.h | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/xen/include/public/io/blkif.h b/xen/include/public/io/blkif.h index 99f0326..3d8d39f 100644 --- a/xen/include/public/io/blkif.h +++ b/xen/include/public/io/blkif.h @@ -635,6 +635,28 @@ #define BLKIF_OP_INDIRECT 6 /* + * Recognized only if "feature-extra-request" is present in backend xenbus info. + * A request with BLKIF_OP_EXTRA_FLAG indicates an extra request is followed + * in the shared ring buffer. + * + * By this way, extra data like bio integrity payload can be transmitted from + * frontend to backend. + * + * The 'wire' format is like: + * Request 1: xen_blkif_request + * [Request 2: xen_blkif_extra_request] (only if request 1 has BLKIF_OP_EXTRA_FLAG) + * Request 3: xen_blkif_request + * Request 4: xen_blkif_request + * [Request 5: xen_blkif_extra_request] (only if request 4 has BLKIF_OP_EXTRA_FLAG) + * ... + * Request N: xen_blkif_request + * + * If a backend does not recognize BLKIF_OP_EXTRA_FLAG, it should *not* create the + * "feature-extra-request" node! + */ +#define BLKIF_OP_EXTRA_FLAG (0x80) + +/* * Maximum scatter/gather segments per request. * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE. * NB. This could be 12 if the ring indexes weren't stored in the same page. @@ -703,6 +725,34 @@ struct blkif_request_indirect { }; typedef struct blkif_request_indirect blkif_request_indirect_t; +enum blkif_extra_request_type { + BLKIF_EXTRA_TYPE_DIX = 1, /* Data integrity extension payload. */ +}; + +struct bio_integrity_req { + /* + * Grant mapping for transmitting bio integrity payload to backend. + */ + grant_ref_t *gref; + unsigned int nr_grefs; + unsigned int len; +}; + +/* + * Extra request, must follow a normal-request and a normal-request can + * only be followed by one extra request. + */ +struct blkif_request_extra { + uint8_t type; /* BLKIF_EXTRA_TYPE_* */ + uint16_t _pad1; +#ifndef CONFIG_X86_32 + uint32_t _pad2; /* offsetof(blkif_...,u.extra.id) == 8 */ +#endif + uint64_t id; + struct bio_integrity_req bi_req; +} __attribute__((__packed__)); +typedef struct blkif_request_extra blkif_request_extra_t; + struct blkif_response { uint64_t id; /* copied from request */ uint8_t operation; /* copied from request */