From patchwork Wed Oct 14 20:00:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7397921 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 942AEBEEA4 for ; Wed, 14 Oct 2015 20:00:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BA1720623 for ; Wed, 14 Oct 2015 20:00:52 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5177F205E4 for ; Wed, 14 Oct 2015 20:00:51 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1AEF960511; Wed, 14 Oct 2015 13:00:51 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 0C09A60500 for ; Wed, 14 Oct 2015 13:00:50 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 14 Oct 2015 13:00:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,682,1437462000"; d="scan'208";a="792846510" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga001.jf.intel.com with ESMTP; 14 Oct 2015 13:00:49 -0700 Received: from orsmsx161.amr.corp.intel.com (10.22.240.84) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 14 Oct 2015 13:00:48 -0700 Received: from orsmsx107.amr.corp.intel.com ([169.254.1.53]) by ORSMSX161.amr.corp.intel.com ([169.254.4.249]) with mapi id 14.03.0248.002; Wed, 14 Oct 2015 13:00:48 -0700 From: "Williams, Dan J" To: "hch@infradead.org" Subject: Re: [PATCH 2/5] block: Consolidate static integrity profile properties Thread-Topic: [PATCH 2/5] block: Consolidate static integrity profile properties Thread-Index: AQHRBTHPad4QKqAso0uct3difWTxfZ5qpZAAgABnuICAAM6lAIAAAVwAgAADswA= Date: Wed, 14 Oct 2015 20:00:47 +0000 Message-ID: <1444852846.3409.8.camel@intel.com> References: <1444683912-7140-1-git-send-email-martin.petersen@oracle.com> <1444683912-7140-3-git-send-email-martin.petersen@oracle.com> <20151014072303.GA2544@infradead.org> <1444851760.3409.6.camel@intel.com> <20151014194732.GA14724@infradead.org> In-Reply-To: <20151014194732.GA14724@infradead.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.138] Content-ID: <1021F075E9D99F4C8399CD668D4C16B3@intel.com> MIME-Version: 1.0 Cc: "Busch, Keith" , "snitzer@redhat.com" , "martin.petersen@oracle.com" , "linux-nvdimm@ml01.01.org" , "linux-nvme@lists.infradead.org" , "axboe@fb.com" X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, 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 On Wed, 2015-10-14 at 12:47 -0700, hch@infradead.org wrote: > On Wed, Oct 14, 2015 at 07:42:40PM +0000, Williams, Dan J wrote: > > Sounds good, how about? > > Looks good. Note that NVMe has a copy of it that could now be > consolidate. Ah, cool, thanks for the heads up. 8<---- Subject: block, libnvdimm, nvme: provide a built-in blk_integrity nop profile From: Dan Williams The libnvidmm-btt and nvme drivers use blk_integrity to reserve space for per-sector metadata, but sometimes without protection checksums. This property is generically useful, so teach the block core to internally specify a nop profile if one is not provided at registration time. Cc: Keith Busch Cc: Matthew Wilcox Suggested-by: Christoph Hellwig Signed-off-by: Dan Williams Acked-by: Martin K. Petersen --- block/blk-integrity.c | 13 ++++++++++++- drivers/nvdimm/core.c | 12 +----------- drivers/nvme/host/pci.c | 18 +----------------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index dc4dea7b8a93..506cc16c1a92 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -384,6 +384,17 @@ static struct kobj_type integrity_ktype = { .sysfs_ops = &integrity_ops, }; +static int blk_integrity_nop_fn(struct blk_integrity_iter *iter) +{ + return 0; +} + +static struct blk_integrity_profile nop_profile = { + .name = "nop", + .generate_fn = blk_integrity_nop_fn, + .verify_fn = blk_integrity_nop_fn, +}; + /** * blk_integrity_register - Register a request_queue as being integrity-capable * @disk: struct request_queue pointer to make integrity-aware @@ -402,7 +413,7 @@ void blk_integrity_register(struct request_queue *q, struct blk_integrity *templ bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | template->flags; bi->interval_exp = ilog2(queue_logical_block_size(q)); - bi->profile = template->profile; + bi->profile = template->profile ? template->profile : &nop_profile; bi->tuple_size = template->tuple_size; bi->tag_size = template->tag_size; diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index eeedd58bbcad..2ed3c934256f 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -392,24 +392,14 @@ void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus) EXPORT_SYMBOL_GPL(nvdimm_bus_unregister); #ifdef CONFIG_BLK_DEV_INTEGRITY -static int nd_pi_nop_generate_verify(struct blk_integrity_iter *iter) -{ - return 0; -} - int nd_integrity_init(struct gendisk *disk, unsigned long meta_size) { struct blk_integrity bi; - static struct blk_integrity_profile profile = { - .name = "ND-PI-NOP", - .generate_fn = nd_pi_nop_generate_verify, - .verify_fn = nd_pi_nop_generate_verify, - }; if (meta_size == 0) return 0; - bi.profile = &profile; + bi.profile = NULL; bi.tuple_size = meta_size; bi.tag_size = meta_size; diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index e4a0cc7fb421..532b6a491fca 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -550,22 +550,6 @@ static void nvme_dif_remap(struct request *req, kunmap_atomic(pmap); } -static int nvme_noop_verify(struct blk_integrity_iter *iter) -{ - return 0; -} - -static int nvme_noop_generate(struct blk_integrity_iter *iter) -{ - return 0; -} - -struct blk_integrity_profile nvme_meta_noop = { - .name = "NVME_META_NOOP", - .generate_fn = nvme_noop_generate, - .verify_fn = nvme_noop_verify, -}; - static void nvme_init_integrity(struct nvme_ns *ns) { struct blk_integrity integrity; @@ -579,7 +563,7 @@ static void nvme_init_integrity(struct nvme_ns *ns) integrity.profile = &t10_pi_type1_crc; break; default: - integrity.profile = &nvme_meta_noop; + integrity.profile = NULL; break; } integrity.tuple_size = ns->ms;