From patchwork Tue Jan 30 17:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13537799 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8BB71292F0 for ; Tue, 30 Jan 2024 17:19:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635171; cv=none; b=XfI3CWYV+9pO5+Vba0G3JRUOc/ih6x7+CEwkeyV7KUSnxHNHZeTHCJura2aL3E2/EaCpo/zR/mgX3wXUwAde89bDlV6/wmSc0+bBsYHDClofdvRvr+ZRqJsCwqWrxCdnUD/uoS5Msq5iQWvRWwRV5RJtcQZwKxQpXdeJcJT8u3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635171; c=relaxed/simple; bh=chWqlWw2pYyMEVgbVk269l1GzFrcCoTQDcdjewiasPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=UD+lng0Fjm5qJF27+vnsukRSzFcTtutNOpmL3Fg2YE7p6qy/1h9WIFF5q5XA2SxISZ2KvOUHOd4F7gPXvcK2kB259gCwKcq8kDe+HTHNbxc8JSQeeoDuvKLVUCMIS7I0uXuuWCxMfqcI1QlzEqsegwVMcVP1P48ENyhzf1AYAjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=czboqW6L; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="czboqW6L" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240130171926epoutp02d04bf6d4e21dba42e0f0cd27df9e1f6f~vL6RR0cV80391403914epoutp02W for ; Tue, 30 Jan 2024 17:19:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240130171926epoutp02d04bf6d4e21dba42e0f0cd27df9e1f6f~vL6RR0cV80391403914epoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706635166; bh=ALi6WQHoGA/cfYwa5637ScTtBXJR1LHhfdOZtxic6Kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czboqW6LLPb3hDW9qZkFd1oc8VELYNe8LbZL1g4Tz5c+wBeyKPvzDWUpEOske8n8i zaRW9y/OB7hSJNisxlAej21lCzMyKdfak3fKIsoshLz/iYehZnhXQ7fqJdugHeSb2l gVi/3LpzkObbpyAWMfNXbQStJHIYmYdUnfAIXmKI= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240130171925epcas5p43e53cc0bfc705f5647530a6dad166ee1~vL6QhS5ub0368303683epcas5p4q; Tue, 30 Jan 2024 17:19:25 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4TPX300YzBz4x9Px; Tue, 30 Jan 2024 17:19:24 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id D2.58.09672.B9F29B56; Wed, 31 Jan 2024 02:19:23 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240130171923epcas5p4610296779861b362ef98f3b6f819a060~vL6OfCIF70368303683epcas5p4l; Tue, 30 Jan 2024 17:19:23 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240130171923epsmtrp1a3dda622b729f517c933658ecc49ce3a~vL6Oect2H2451024510epsmtrp12; Tue, 30 Jan 2024 17:19:23 +0000 (GMT) X-AuditID: b6c32a4b-39fff700000025c8-a8-65b92f9ba434 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 7A.32.18939.B9F29B56; Wed, 31 Jan 2024 02:19:23 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240130171922epsmtip20a28b01d04b99caf8ec772b551b7b325~vL6NGotzk1616116161epsmtip20; Tue, 30 Jan 2024 17:19:21 +0000 (GMT) From: Kanchan Joshi To: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH 1/3] block: refactor guard helpers Date: Tue, 30 Jan 2024 22:42:04 +0530 Message-Id: <20240130171206.4845-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240130171206.4845-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOJsWRmVeSWpSXmKPExsWy7bCmlu5s/Z2pBv/XWFmsvtvPZnHzwE4m i5WrjzJZHP3/ls1i0qFrjBZ7b2lbzF/2lN1i+fF/TBbrXr9nceD0OH9vI4vH5bOlHptWdb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cas5p4610296779861b362ef98f3b6f819a060 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240130171923epcas5p4610296779861b362ef98f3b6f819a060 References: <20240130171206.4845-1-joshi.k@samsung.com> Allow computation using the existing guard value. This is a prep patch. Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- block/t10-pi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/t10-pi.c b/block/t10-pi.c index 914d8cddd43a..251a7b188963 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -12,14 +12,14 @@ #include #include -typedef __be16 (csum_fn) (void *, unsigned int); +typedef __be16 (csum_fn) (__be16, void *, unsigned int); -static __be16 t10_pi_crc_fn(void *data, unsigned int len) +static __be16 t10_pi_crc_fn(__be16 crc, void *data, unsigned int len) { - return cpu_to_be16(crc_t10dif(data, len)); + return cpu_to_be16(crc_t10dif_update(be16_to_cpu(crc), data, len)); } -static __be16 t10_pi_ip_fn(void *data, unsigned int len) +static __be16 t10_pi_ip_fn(__be16 csum, void *data, unsigned int len) { return (__force __be16)ip_compute_csum(data, len); } @@ -37,7 +37,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter, for (i = 0 ; i < iter->data_size ; i += iter->interval) { struct t10_pi_tuple *pi = iter->prot_buf; - pi->guard_tag = fn(iter->data_buf, iter->interval); + pi->guard_tag = fn(0, iter->data_buf, iter->interval); pi->app_tag = 0; if (type == T10_PI_TYPE1_PROTECTION) @@ -83,7 +83,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, goto next; } - csum = fn(iter->data_buf, iter->interval); + csum = fn(0, iter->data_buf, iter->interval); if (pi->guard_tag != csum) { pr_err("%s: guard tag error at sector %llu " \ @@ -280,9 +280,9 @@ const struct blk_integrity_profile t10_pi_type3_ip = { }; EXPORT_SYMBOL(t10_pi_type3_ip); -static __be64 ext_pi_crc64(void *data, unsigned int len) +static __be64 ext_pi_crc64(u64 crc, void *data, unsigned int len) { - return cpu_to_be64(crc64_rocksoft(data, len)); + return cpu_to_be64(crc64_rocksoft_update(crc, data, len)); } static blk_status_t ext_pi_crc64_generate(struct blk_integrity_iter *iter, @@ -293,7 +293,7 @@ static blk_status_t ext_pi_crc64_generate(struct blk_integrity_iter *iter, for (i = 0 ; i < iter->data_size ; i += iter->interval) { struct crc64_pi_tuple *pi = iter->prot_buf; - pi->guard_tag = ext_pi_crc64(iter->data_buf, iter->interval); + pi->guard_tag = ext_pi_crc64(0, iter->data_buf, iter->interval); pi->app_tag = 0; if (type == T10_PI_TYPE1_PROTECTION) @@ -343,7 +343,7 @@ static blk_status_t ext_pi_crc64_verify(struct blk_integrity_iter *iter, goto next; } - csum = ext_pi_crc64(iter->data_buf, iter->interval); + csum = ext_pi_crc64(0, iter->data_buf, iter->interval); if (pi->guard_tag != csum) { pr_err("%s: guard tag error at sector %llu " \ "(rcvd %016llx, want %016llx)\n", From patchwork Tue Jan 30 17:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13537800 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC264364AC for ; Tue, 30 Jan 2024 17:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635175; cv=none; b=Gi7hdUhXEZTkGUtJAB5BvPD2LIfFgt6u3C5nFUd9K1MujS5lNkKTWIPa3AEDSHVk0Xb6u3qYXVxu1tqliH/2zpdxsZAyT6XBNicgIHhFs3PLjVTQbchW29TJydZ4FWqFZt8b3DoftBKRlSyHDZPv95fO+I0KSDgdrQXjTxKi6FU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635175; c=relaxed/simple; bh=YkC204Hu24ySnSlTsJ1JPkFLP762YVmeCDZgwiLmigY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=o4v90d+F4yY6mEwDyjMk7zYRF/GYQRT2hQ4ExRFW3XlEUzXowqHGawlanEuWlp5eQR0R97R1C2LceEZ7orSiQNq4k2FdiwVDM+Z5SghMQpy7Kyk2Mwh/PejlAPbNhIckb7+Go1QFu0eOzLwEbfwcSIfTZOTDWigIihWvIl9j8wU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=FVhgH7gW; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="FVhgH7gW" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240130171930epoutp03abbf8ff1837224efea7e11e1e5fff5b2~vL6VTPyZX2939229392epoutp03O for ; Tue, 30 Jan 2024 17:19:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240130171930epoutp03abbf8ff1837224efea7e11e1e5fff5b2~vL6VTPyZX2939229392epoutp03O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706635170; bh=+ibPEb1+PjwBqvytPRwsK7lhJ44S079tcZ2oSt+6eJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FVhgH7gWFXMNIskXH/Je6SMIoet6pzye0hh/pzXsO/ncMXJWbXNq1SSbkSYy44Wx2 TMg5SdzYu5ZQQPEhfn9bxPnPpzULOEvLYwy2gjico/dfMEOcLDgCcrqqaegrOTapyp FFU1Ut+CxUCSQWlHr4dm644fiklsXF0v4lef/xoo= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240130171929epcas5p285a65e3b12113c2a6e9a94bad0e71d8f~vL6UbBJqN1569115691epcas5p2W; Tue, 30 Jan 2024 17:19:29 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4TPX343G0Wz4x9Pw; Tue, 30 Jan 2024 17:19:28 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.23.09634.0AF29B56; Wed, 31 Jan 2024 02:19:28 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240130171927epcas5p2814181a20402d08b96393ce4a5e06e03~vL6R1JhXB1569115691epcas5p2R; Tue, 30 Jan 2024 17:19:27 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240130171927epsmtrp2f798dc86393c95b3f035d03d77a1f6fb~vL6R0dqgO2665426654epsmtrp2E; Tue, 30 Jan 2024 17:19:27 +0000 (GMT) X-AuditID: b6c32a49-eebff700000025a2-09-65b92fa0453c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id A3.2D.08817.E9F29B56; Wed, 31 Jan 2024 02:19:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240130171925epsmtip271d50a415ad176aff8dd677b8f99f206~vL6QNSfbK1616116161epsmtip21; Tue, 30 Jan 2024 17:19:25 +0000 (GMT) From: Kanchan Joshi To: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Chinmay Gameti Subject: [PATCH 2/3] block: support PI at non-zero offset within metadata Date: Tue, 30 Jan 2024 22:42:05 +0530 Message-Id: <20240130171206.4845-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240130171206.4845-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDJsWRmVeSWpSXmKPExsWy7bCmhu4C/Z2pBv93ilisvtvPZvF9ex+L xc0DO5ksVq4+ymRx9P9bNotJh64xWuy9pW0xf9lTdovlx/8xWax7/Z7Fgcvj/L2NLB6Xz5Z6 bFrVyeaxeUm9x+6bDWweH5/eYvHo27KK0ePzJrkAjqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B4 53hTMwNDXUNLC3MlhbzE3FRbJRefAF23zBygC5UUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUl tkqpBSk5BSYFesWJucWleel6eaklVoYGBkamQIUJ2RnvWjexF6xxrViw8QNLA+NT8y5GTg4J AROJUz332LsYuTiEBHYzSlz7v5EdJCEk8IlR4uoiU4jEN0aJpfffs8N0PF19gQkisZdRomHS TUaIjs+MEjNvVHYxcnCwCWhKXJhcChIWEUiS2PbmMxtIPbPAUkaJOZMPgtULC3hKPPp7hwnE ZhFQlZj34ieYzStgLrFj2UI2iGXyEjMvfQdbzClgIdG38jEjRI2gxMmZT1hAbGagmuats5lB FkgITOSQ+LfgOyvIERICLhL9sw0g5ghLvDq+BeoBKYnP7/ZCzU+WuDTzHBOEXSLxe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YpW5xNI/Z5kh6gUlTs58wgIxX16ieets 5gmMArOQpGYhSS1gZFrFKJlaUJybnltsWGCUl1quV5yYW1yal66XnJ+7iREcCVpaOxj3rPqg d4iRiYPxEKMEB7OSCO9KuZ2pQrwpiZVVqUX58UWlOanFhxilOViUxHm/ve5NERJITyxJzU5N LUgtgskycXBKNTDlXd5hErzTOP5+69ILWVLKCivCD9n9OSS/8LuiZh1/7cLl9vb/Yx58Kfk8 efNuK5kHNs9n7+X/F8qWXl+x7+PC5o+KRkyRV8TPrZ8uaqC/o0Sn/bvL9SfGM+Y71XpOiOPV TlqwcGYiq8BFr9z7LxfVMlorsjNXcGzPZTBi9FXeF/LV9cPnGToMX4sVl4qcXHgya8ZB2TVs vCEKWWeq8hb3SnTd5oz6mCfRLRQXpGN8V0b4muKO88v+ej+YEq1d+/qvxcn/wke8y++J9U7K O1/S2PZ0UsY9KVY2m7V3NK1/fP92YPp8G+sTi2J4p78p9TD/K+i3YYm6XN+efy8Cy1b2V8cu DF+QfNOgK3XNA18lluKMREMt5qLiRADpUm5T8wIAAA== X-CMS-MailID: 20240130171927epcas5p2814181a20402d08b96393ce4a5e06e03 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240130171927epcas5p2814181a20402d08b96393ce4a5e06e03 References: <20240130171206.4845-1-joshi.k@samsung.com> The block integrity subsystem assumes that PI appears first in the metadata buffer. Abolish this assumption by adding the ability to handle PI starting at a non-zero offset. Calculation of the guard tag includes the metadata buffer up to this offset. Signed-off-by: Kanchan Joshi Signed-off-by: Chinmay Gameti Reviewed-by: Sagi Grimberg --- block/bio-integrity.c | 1 + block/blk-integrity.c | 1 + block/t10-pi.c | 52 +++++++++++++++++++++++++---------- include/linux/blk-integrity.h | 1 + include/linux/blkdev.h | 1 + 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index c9a16fba58b9..2e3e8e04961e 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -395,6 +395,7 @@ static blk_status_t bio_integrity_process(struct bio *bio, iter.tuple_size = bi->tuple_size; iter.seed = proc_iter->bi_sector; iter.prot_buf = bvec_virt(bip->bip_vec); + iter.pi_offset = bi->pi_offset; __bio_for_each_segment(bv, bio, bviter, *proc_iter) { void *kaddr = bvec_kmap_local(&bv); diff --git a/block/blk-integrity.c b/block/blk-integrity.c index d4e9b4556d14..ccbeb6dfa87a 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -370,6 +370,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template bi->profile = template->profile ? template->profile : &nop_profile; bi->tuple_size = template->tuple_size; bi->tag_size = template->tag_size; + bi->pi_offset = template->pi_offset; blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); diff --git a/block/t10-pi.c b/block/t10-pi.c index 251a7b188963..80029292ae4c 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -33,11 +33,15 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter, csum_fn *fn, enum t10_dif_type type) { unsigned int i; + u8 offset = iter->pi_offset; for (i = 0 ; i < iter->data_size ; i += iter->interval) { - struct t10_pi_tuple *pi = iter->prot_buf; + struct t10_pi_tuple *pi = iter->prot_buf + offset; pi->guard_tag = fn(0, iter->data_buf, iter->interval); + if (offset) + pi->guard_tag = fn(pi->guard_tag, iter->prot_buf, + offset); pi->app_tag = 0; if (type == T10_PI_TYPE1_PROTECTION) @@ -57,11 +61,12 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, csum_fn *fn, enum t10_dif_type type) { unsigned int i; + u8 offset = iter->pi_offset; BUG_ON(type == T10_PI_TYPE0_PROTECTION); for (i = 0 ; i < iter->data_size ; i += iter->interval) { - struct t10_pi_tuple *pi = iter->prot_buf; + struct t10_pi_tuple *pi = iter->prot_buf + offset; __be16 csum; if (type == T10_PI_TYPE1_PROTECTION || @@ -84,6 +89,8 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, } csum = fn(0, iter->data_buf, iter->interval); + if (offset) + csum = fn(csum, iter->prot_buf, offset); if (pi->guard_tag != csum) { pr_err("%s: guard tag error at sector %llu " \ @@ -134,9 +141,11 @@ static blk_status_t t10_pi_type1_verify_ip(struct blk_integrity_iter *iter) */ static void t10_pi_type1_prepare(struct request *rq) { - const int tuple_sz = rq->q->integrity.tuple_size; + struct blk_integrity *bi = &rq->q->integrity; + const int tuple_sz = bi->tuple_size; u32 ref_tag = t10_pi_ref_tag(rq); struct bio *bio; + u8 offset = bi->pi_offset; __rq_for_each_bio(bio, rq) { struct bio_integrity_payload *bip = bio_integrity(bio); @@ -154,7 +163,7 @@ static void t10_pi_type1_prepare(struct request *rq) p = bvec_kmap_local(&iv); for (j = 0; j < iv.bv_len; j += tuple_sz) { - struct t10_pi_tuple *pi = p; + struct t10_pi_tuple *pi = p + offset; if (be32_to_cpu(pi->ref_tag) == virt) pi->ref_tag = cpu_to_be32(ref_tag); @@ -183,10 +192,12 @@ static void t10_pi_type1_prepare(struct request *rq) */ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) { - unsigned intervals = nr_bytes >> rq->q->integrity.interval_exp; - const int tuple_sz = rq->q->integrity.tuple_size; + struct blk_integrity *bi = &rq->q->integrity; + unsigned intervals = nr_bytes >> bi->interval_exp; + const int tuple_sz = bi->tuple_size; u32 ref_tag = t10_pi_ref_tag(rq); struct bio *bio; + u8 offset = bi->pi_offset; __rq_for_each_bio(bio, rq) { struct bio_integrity_payload *bip = bio_integrity(bio); @@ -200,7 +211,7 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) p = bvec_kmap_local(&iv); for (j = 0; j < iv.bv_len && intervals; j += tuple_sz) { - struct t10_pi_tuple *pi = p; + struct t10_pi_tuple *pi = p + offset; if (be32_to_cpu(pi->ref_tag) == ref_tag) pi->ref_tag = cpu_to_be32(virt); @@ -289,11 +300,15 @@ static blk_status_t ext_pi_crc64_generate(struct blk_integrity_iter *iter, enum t10_dif_type type) { unsigned int i; + u8 offset = iter->pi_offset; for (i = 0 ; i < iter->data_size ; i += iter->interval) { - struct crc64_pi_tuple *pi = iter->prot_buf; + struct crc64_pi_tuple *pi = iter->prot_buf + offset; pi->guard_tag = ext_pi_crc64(0, iter->data_buf, iter->interval); + if (offset) + pi->guard_tag = ext_pi_crc64(be64_to_cpu(pi->guard_tag), + iter->prot_buf, offset); pi->app_tag = 0; if (type == T10_PI_TYPE1_PROTECTION) @@ -320,9 +335,10 @@ static blk_status_t ext_pi_crc64_verify(struct blk_integrity_iter *iter, enum t10_dif_type type) { unsigned int i; + u8 offset = iter->pi_offset; for (i = 0; i < iter->data_size; i += iter->interval) { - struct crc64_pi_tuple *pi = iter->prot_buf; + struct crc64_pi_tuple *pi = iter->prot_buf + offset; u64 ref, seed; __be64 csum; @@ -344,6 +360,10 @@ static blk_status_t ext_pi_crc64_verify(struct blk_integrity_iter *iter, } csum = ext_pi_crc64(0, iter->data_buf, iter->interval); + if (offset) + csum = ext_pi_crc64(be64_to_cpu(csum), iter->prot_buf, + offset); + if (pi->guard_tag != csum) { pr_err("%s: guard tag error at sector %llu " \ "(rcvd %016llx, want %016llx)\n", @@ -373,9 +393,11 @@ static blk_status_t ext_pi_type1_generate_crc64(struct blk_integrity_iter *iter) static void ext_pi_type1_prepare(struct request *rq) { - const int tuple_sz = rq->q->integrity.tuple_size; + struct blk_integrity *bi = &rq->q->integrity; + const int tuple_sz = bi->tuple_size; u64 ref_tag = ext_pi_ref_tag(rq); struct bio *bio; + u8 offset = bi->pi_offset; __rq_for_each_bio(bio, rq) { struct bio_integrity_payload *bip = bio_integrity(bio); @@ -393,7 +415,7 @@ static void ext_pi_type1_prepare(struct request *rq) p = bvec_kmap_local(&iv); for (j = 0; j < iv.bv_len; j += tuple_sz) { - struct crc64_pi_tuple *pi = p; + struct crc64_pi_tuple *pi = p + offset; u64 ref = get_unaligned_be48(pi->ref_tag); if (ref == virt) @@ -411,10 +433,12 @@ static void ext_pi_type1_prepare(struct request *rq) static void ext_pi_type1_complete(struct request *rq, unsigned int nr_bytes) { - unsigned intervals = nr_bytes >> rq->q->integrity.interval_exp; - const int tuple_sz = rq->q->integrity.tuple_size; + struct blk_integrity *bi = &rq->q->integrity; + unsigned intervals = nr_bytes >> bi->interval_exp; + const int tuple_sz = bi->tuple_size; u64 ref_tag = ext_pi_ref_tag(rq); struct bio *bio; + u8 offset = bi->pi_offset; __rq_for_each_bio(bio, rq) { struct bio_integrity_payload *bip = bio_integrity(bio); @@ -428,7 +452,7 @@ static void ext_pi_type1_complete(struct request *rq, unsigned int nr_bytes) p = bvec_kmap_local(&iv); for (j = 0; j < iv.bv_len && intervals; j += tuple_sz) { - struct crc64_pi_tuple *pi = p; + struct crc64_pi_tuple *pi = p + offset; u64 ref = get_unaligned_be48(pi->ref_tag); if (ref == ref_tag) diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 378b2459efe2..e253e7bd0d17 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -20,6 +20,7 @@ struct blk_integrity_iter { unsigned int data_size; unsigned short interval; unsigned char tuple_size; + unsigned char pi_offset; const char *disk_name; }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d7cac3de65b3..bb4d811fee46 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -108,6 +108,7 @@ struct blk_integrity { const struct blk_integrity_profile *profile; unsigned char flags; unsigned char tuple_size; + unsigned char pi_offset; unsigned char interval_exp; unsigned char tag_size; }; From patchwork Tue Jan 30 17:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13537801 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D90EA12BF09 for ; Tue, 30 Jan 2024 17:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635176; cv=none; b=gZu6k2t6a895IAy+GyslVgi/ADQ2pNftE4G9ynWe5WTpTnDRgV1UCMycTHx0j+5OfbowJqyUGgPBZbpOeVDvuCfUg2YVQZoTvTo7Ov2OVOVfrIjh+D8YvxB5F4TQ3mfCh+EJSJa0OvD3dkHQWlNmEVV9ZBtGnNmQ1PXNznjPCHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635176; c=relaxed/simple; bh=FaG92OKvVcuFrGyni+oNU1CWB6DFZBxTn2uqB0pAlYI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=tgqr1hC7ylPaMOY8aI1jFwlOouUdHPjuapN0DdFbp+RUalI9jRWgiAUjlH8G1YknKfz05Kq0fI61lgK08E1Fa5ofIq7l4P6upUs9SOgXPQy7njHZPx3gPo5N9xMNtcDhWY+mLhInX5BJWKrNbYhvbsJtBSFgOJ6g8LhS0CYguJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=a9xSckij; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="a9xSckij" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240130171932epoutp04049f71af70940ea324f6a117de81e820~vL6XB38G53181931819epoutp04Q for ; Tue, 30 Jan 2024 17:19:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240130171932epoutp04049f71af70940ea324f6a117de81e820~vL6XB38G53181931819epoutp04Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706635172; bh=O5jRUiGAz+tcp6NhwjqNzP4RxnO5dvmzye0jUTtojvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9xSckijHeS35oDky3U7rRjHpdvtQ9W2RgOc8YX1fElvBq8lwMsimc1pgSZwrf7gC k9aHsOUSD9my/HF1i4bTVa0FcAEM637JVRHXOjt1DzQ8ZD7CHWrXRrVa2XOYCGHH4M 4VqcYHFd9lHwHheh9RdSHfQx7PXSb349fcfTchWI= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240130171931epcas5p1224cdc8e535d31fb06a9a29becb5e3bf~vL6WPrc9G0856008560epcas5p1X; Tue, 30 Jan 2024 17:19:31 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4TPX364rs7z4x9Pq; Tue, 30 Jan 2024 17:19:30 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id C3.58.09672.2AF29B56; Wed, 31 Jan 2024 02:19:30 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240130171929epcas5p24f6c25d123d3cd6463cbef1aaf795276~vL6Uco8sg1569115691epcas5p2Y; Tue, 30 Jan 2024 17:19:29 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240130171929epsmtrp1669927c125c164e66e6f10ca67d07006~vL6UcC0rP2451024510epsmtrp13; Tue, 30 Jan 2024 17:19:29 +0000 (GMT) X-AuditID: b6c32a4b-39fff700000025c8-b0-65b92fa2902f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 1B.32.18939.1AF29B56; Wed, 31 Jan 2024 02:19:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240130171928epsmtip241351b7474fa8bde4e36f47adfcd1b71~vL6TITU8L1888718887epsmtip2E; Tue, 30 Jan 2024 17:19:28 +0000 (GMT) From: Kanchan Joshi To: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH 3/3] nvme: allow integrity when PI is not in first bytes Date: Tue, 30 Jan 2024 22:42:06 +0530 Message-Id: <20240130171206.4845-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240130171206.4845-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmuu4i/Z2pBtvmKVusvtvPZnHzwE4m i5WrjzJZHP3/ls1i0qFrjBZ7b2lbzF/2lN1i+fF/TBbrXr9nceD0OH9vI4vH5bOlHptWdbJ5 bF5S77H7ZgObx8ent1g8+rasYvT4vEkugCMq2yYjNTEltUghNS85PyUzL91WyTs43jne1MzA UNfQ0sJcSSEvMTfVVsnFJ0DXLTMH6DglhbLEnFKgUEBicbGSvp1NUX5pSapCRn5xia1SakFK ToFJgV5xYm5xaV66Xl5qiZWhgYGRKVBhQnbG/MdH2AsW81a0/DnD3sD4gquLkZNDQsBE4sv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9vI4vH5bOlHptWdbJ5 bF5S77H7ZgObx8ent1g8+rasYvT4vEkugCOKyyYlNSezLLVI3y6BK2P+4yPsBYt5K1r+nGFv YHzB1cXIySEhYCLxesJkxi5GLg4hge2MEksn72SGSIhLNF/7wQ5hC0us/PecHaLoI6PEjs13 WLoYOTjYBDQlLkwuBakREciQmL36G1gNs0ADo8S617uYQBLCAh4STx+eYQGxWQRUJU5s/w82 lFfAXGL3hhY2iAXyEjMvfQeLcwpYSPStfMwIYgsB1Sz9c5YZol5Q4uTMJ2BzmIHqm7fOZp7A KDALSWoWktQCRqZVjKKpBcW56bnJBYZ6xYm5xaV56XrJ+bmbGMGhrxW0g3HZ+r96hxiZOBgP MUpwMCuJ8K6U25kqxJuSWFmVWpQfX1Sak1p8iFGag0VJnFc5pzNFSCA9sSQ1OzW1ILUIJsvE wSnVwCR+TD7wqpbDPPmDmb3bV9RUxabwbKrwktZP/y63YunpyR7GjP/uhjj9vXfcPPxVZRxn dVbpzP7dYubTOJZeT5ba7uNZ/8ll3+ugotc1Mxw6a2UWZd/gE/VLmjTr1krZssqYrvVJBVd+ NXbvanloKyirMuscQ521ocDftN7Yg7XnFyReeHVkS69zTGNpmI1A8yzdX6qbbt7RexZ+/twD 2auG7xhusa9qlk82Z+qfuXbtsnunNjb/KBbYavTq0bkydYYHCeeXL+W2anm3JdmS+1pajdKX 48/bj8f9L0+2vfa80+ZZv+XczX8bpx6eGaTOvuG31yF9qbtWorKyQazfnz6+6xN/jvUYyzZb /VOObUosxRmJhlrMRcWJAPUrzOzsAgAA X-CMS-MailID: 20240130171929epcas5p24f6c25d123d3cd6463cbef1aaf795276 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240130171929epcas5p24f6c25d123d3cd6463cbef1aaf795276 References: <20240130171206.4845-1-joshi.k@samsung.com> NVM command set 1.0 (or later) mandate PI to be in last bytes of metadata. But this was not supported in the block-layer and driver registered a nop profile. Remove the restriction as the block integrity subsystem has grown the ability to support it. Signed-off-by: Kanchan Joshi Reviewed-by: Sagi Grimberg --- drivers/nvme/host/core.c | 8 +++++++- drivers/nvme/host/nvme.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 85ab0fcf9e88..4945d6259a13 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1726,6 +1726,7 @@ static void nvme_init_integrity(struct gendisk *disk, } integrity.tuple_size = head->ms; + integrity.pi_offset = head->pi_offset; blk_integrity_register(disk, &integrity); blk_queue_max_integrity_segments(disk->queue, max_integrity_segments); } @@ -1835,11 +1836,16 @@ static int nvme_init_ms(struct nvme_ctrl *ctrl, struct nvme_ns_head *head, free_data: kfree(nvm); set_pi: - if (head->pi_size && (first || head->ms == head->pi_size)) + if (head->pi_size && head->ms >= head->pi_size) head->pi_type = id->dps & NVME_NS_DPS_PI_MASK; else head->pi_type = 0; + if (first) + head->pi_offset = 0; + else + head->pi_offset = head->ms - head->pi_size; + return ret; } diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 030c80818240..281657320c3a 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -462,6 +462,7 @@ struct nvme_ns_head { u16 ms; u16 pi_size; u8 pi_type; + u8 pi_offset; u8 guard_type; u16 sgs; u32 sws;