From patchwork Wed Jun 26 10:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712779 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 39F5317DE11 for ; Wed, 26 Jun 2024 11:41:50 +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=1719402113; cv=none; b=AXci8AWTcChc1zF0M0o2ljNtuDGMHnGo0CHPxEqSdzb9t9nkajh29c4s3T8rLxKE/dgUTDdstqajFlxz5lqgbPmLzDs2RrJfWiD8xjgYiAF54ls487fkyGOA8sC3kvUhskPdr7MrJFhRcUBNAdqUtMe94h1zTben616YTokZ8jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402113; c=relaxed/simple; bh=AEgBDzVQGk844Eegt8iw9oiuaHP/1nnfap0SBngaKCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=FFNjWzNTCOENeQGZqMvwMyTrJKrfiVTpJvrn06mbcQNd9K1EH47QS396YEf1Z/eF0gk3WxyKd2AcMr+ItjRBVzHH0l9bZ51YarMYJdgoDsr1CP66NdE27gqh54ylNXtOD1ifzQ7kenykGPa3HK96NvODwPvfOodUBV2HulBXnKs= 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=FUyKPipq; 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="FUyKPipq" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240626114148epoutp033e5100398ebbf00df28344aab6e1ea1f~cixuYOLMN0690706907epoutp03x for ; Wed, 26 Jun 2024 11:41:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240626114148epoutp033e5100398ebbf00df28344aab6e1ea1f~cixuYOLMN0690706907epoutp03x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402108; bh=ongxes/b/I2rMYT+M/pu4NPysiQI4JNAWQtlTRipnbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUyKPipq2IMISo6NPjwdgYBjYsubH+2PqPaV9GYtdbDA71E2N0xjUbxdP3b/ouW+Q O0G7yqhVj56yG2j/RS6fle6ramvmPGNB92nEZZ+c4B5AoWYCEToBEVUH5NjB9C9MYu eR/lf2XbzFbmTD+K0v7GUPy7W5VBBkgyk+8GWrbM= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240626114147epcas5p480cd2670856e62bac64e977c3d60ce1a~cixt7nv2X2886328863epcas5p4L; Wed, 26 Jun 2024 11:41:47 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4W8KY611YWz4x9Q0; Wed, 26 Jun 2024 11:41:46 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 5A.55.19174.97EFB766; Wed, 26 Jun 2024 20:41:46 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240626101511epcas5p31c95b67da58d408c371c49f8719140fc~chmGs7YSQ0746707467epcas5p3f; Wed, 26 Jun 2024 10:15:11 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101511epsmtrp13ad2443a21871fb5c01cdf4592ecaa63~chmGsLC0s1024010240epsmtrp1Y; Wed, 26 Jun 2024 10:15:11 +0000 (GMT) X-AuditID: b6c32a50-87fff70000004ae6-9f-667bfe79f6f0 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id AD.4C.18846.F2AEB766; Wed, 26 Jun 2024 19:15:11 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101509epsmtip1c766cdc5fcd86fdcbf2919baa2f862c6~chmE1-8hw0147101471epsmtip1O; Wed, 26 Jun 2024 10:15:09 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v2 01/10] block: change rq_integrity_vec to respect the iterator Date: Wed, 26 Jun 2024 15:36:51 +0530 Message-Id: <20240626100700.3629-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrKJsWRmVeSWpSXmKPExsWy7bCmhm7Vv+o0g0fdzBZNE/4yW8xZtY3R YvXdfjaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lb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RN8lafVYcXW lQ/2hnO+bkpSDvcUr1ViKc5INNRiLipOBABObQ/H+wIAAA== X-CMS-MailID: 20240626101511epcas5p31c95b67da58d408c371c49f8719140fc X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101511epcas5p31c95b67da58d408c371c49f8719140fc References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Mikulas Patocka If we allocate a bio that is larger than NVMe maximum request size, attach integrity metadata to it and send it to the NVMe subsystem, the integrity metadata will be corrupted. Splitting the bio works correctly. The function bio_split will clone the bio, trim the iterator of the first bio and advance the iterator of the second bio. However, the function rq_integrity_vec has a bug - it returns the first vector of the bio's metadata and completely disregards the metadata iterator that was advanced when the bio was split. Thus, the second bio uses the same metadata as the first bio and this leads to metadata corruption. This commit changes rq_integrity_vec, so that it calls mp_bvec_iter_bvec instead of returning the first vector. mp_bvec_iter_bvec reads the iterator and uses it to build a bvec for the current position in the iterator. The "queue_max_integrity_segments(rq->q) > 1" check was removed, because the updated rq_integrity_vec function works correctly with multiple segments. Signed-off-by: Mikulas Patocka Reviewed-by: Christoph Hellwig Reviewed-by: Kanchan Joshi Reviewed-by: Anuj Gupta --- drivers/nvme/host/pci.c | 6 +++--- include/linux/blk-integrity.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 102a9fb0c65f..5d8035218de9 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -826,9 +826,9 @@ static blk_status_t nvme_map_metadata(struct nvme_dev *dev, struct request *req, struct nvme_command *cmnd) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); + struct bio_vec bv = rq_integrity_vec(req); - iod->meta_dma = dma_map_bvec(dev->dev, rq_integrity_vec(req), - rq_dma_dir(req), 0); + iod->meta_dma = dma_map_bvec(dev->dev, &bv, rq_dma_dir(req), 0); if (dma_mapping_error(dev->dev, iod->meta_dma)) return BLK_STS_IOERR; cmnd->rw.metadata = cpu_to_le64(iod->meta_dma); @@ -967,7 +967,7 @@ static __always_inline void nvme_pci_unmap_rq(struct request *req) struct nvme_iod *iod = blk_mq_rq_to_pdu(req); dma_unmap_page(dev->dev, iod->meta_dma, - rq_integrity_vec(req)->bv_len, rq_dma_dir(req)); + rq_integrity_vec(req).bv_len, rq_dma_dir(req)); } if (blk_rq_nr_phys_segments(req)) diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index d201140d77a3..c58634924782 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -90,14 +90,13 @@ static inline bool blk_integrity_rq(struct request *rq) } /* - * Return the first bvec that contains integrity data. Only drivers that are - * limited to a single integrity segment should use this helper. + * Return the current bvec that contains the integrity data. bip_iter may be + * advanced to iterate over the integrity data. */ -static inline struct bio_vec *rq_integrity_vec(struct request *rq) +static inline struct bio_vec rq_integrity_vec(struct request *rq) { - if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1)) - return NULL; - return rq->bio->bi_integrity->bip_vec; + return mp_bvec_iter_bvec(rq->bio->bi_integrity->bip_vec, + rq->bio->bi_integrity->bip_iter); } #else /* CONFIG_BLK_DEV_INTEGRITY */ static inline int blk_rq_count_integrity_sg(struct request_queue *q, @@ -146,9 +145,10 @@ static inline int blk_integrity_rq(struct request *rq) return 0; } -static inline struct bio_vec *rq_integrity_vec(struct request *rq) +static inline struct bio_vec rq_integrity_vec(struct request *rq) { - return NULL; + /* the optimizer will remove all calls to this function */ + return (struct bio_vec){ }; } #endif /* CONFIG_BLK_DEV_INTEGRITY */ From patchwork Wed Jun 26 10:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712780 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 5F7AD17DE11 for ; Wed, 26 Jun 2024 11:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402125; cv=none; b=Hsztitm4pkOZJGoeHCqbNuzDiruHlh4oKiwG1y4Z2+TS7Ez+2IKQndf6tfFKPcSwQcM18uUcdVAxJGwjNNewsF9z6fnITK+7N0uTOF5EvxLnBo0/Fe0lHrBJ5YKPvUb7Wp11hIFgFz30sGeE2Sy4pMoMStYZzDGWV8uSHqfv4Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402125; c=relaxed/simple; bh=bDM2mzF+qYf4eY9qLWRjxBr8gqKFq4pksnmaibWnQtw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=HwnqjPZS132udkGB0yFlkNwYsfML4qVGRk+ASLzD4u+v4Olk6u86j7Tn0XP6zymkpBbHhhN0E9i9P1oBOHPA2dzBNrteRJgTPxkCWEZgN6uDIT/Sq9b/dokqqeQuORdTpAHbua4HXj8OTRrOk8EJLFziMjOGnqdWNfp5XwQhb3M= 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=gnq1+7sh; arc=none smtp.client-ip=203.254.224.24 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="gnq1+7sh" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240626114200epoutp01e83ecd3f45b0ea657f1b58dc1e574980~cix537ew91613316133epoutp01M for ; Wed, 26 Jun 2024 11:42:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240626114200epoutp01e83ecd3f45b0ea657f1b58dc1e574980~cix537ew91613316133epoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402120; bh=CddwOBmVKHfCIekEQ0xwuipaf4radU9oHxoG3DHT28I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gnq1+7shfd+oITixvUjmZ4W3xtAcCtdITQSIMn2cv/PzwOBGxQI7IchYE1ObDxj+/ CmPQpsw9QMlv1GBnnkxn32tr45JZNf7ZPMmqxLA7nz+OE2pTyzOVcfvCz5HH//g+lA 0qYVtJO+is6uV8cTHY9MfB0JBTcTiW48Cgdc1KKw= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240626114200epcas5p3d0f26fedd94965b2a16a9a978e7d1d34~cix5anObS2803828038epcas5p3D; Wed, 26 Jun 2024 11:42:00 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.179]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4W8KYK6Zjkz4x9Pp; Wed, 26 Jun 2024 11:41:57 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 29.08.09989.58EFB766; Wed, 26 Jun 2024 20:41:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240626101513epcas5p10b3f8470148abb10ce3edfb90814cd94~chmIrqYUZ0829808298epcas5p1f; Wed, 26 Jun 2024 10:15:13 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240626101513epsmtrp2eeaa7a869685d6ca50a408eaa6d5ffab~chmIq6IEq1237112371epsmtrp2N; Wed, 26 Jun 2024 10:15:13 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-25-667bfe853d33 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.6B.29940.13AEB766; Wed, 26 Jun 2024 19:15:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101512epsmtip15b7099c4bf924e901811582bd44caed0~chmG6euMQ0147101471epsmtip1P; Wed, 26 Jun 2024 10:15:11 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v2 02/10] block: set bip_vcnt correctly Date: Wed, 26 Jun 2024 15:36:52 +0530 Message-Id: <20240626100700.3629-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrKJsWRmVeSWpSXmKPExsWy7bCmpm7rv+o0g8nrjS2aJvxltpizahuj xeq7/WwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFsuP/2OymNhxlcmB22PnrLvs HpfPlnpsWtXJ5rF5Sb3H7psNbB4fn95i8Xi/7yqbR9+WVYwenzfJBXBGZdtkpCampBYppOYl 56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAN2qpFCWmF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AA+NgFnrHLMWRmVeSWpSXmKPExsWy7bCSnK7hq+o0g2OnTSyaJvxltpizahuj xeq7/WwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFsuP/2OymNhxlcmB22PnrLvs HpfPlnpsWtXJ5rF5Sb3H7psNbB4fn95i8Xi/7yqbR9+WVYwenzfJBXBGcdmkpOZklqUW6dsl cGV0LX7LXnCdo2L91JlsDYwL2LsYOTkkBEwk+hsOsHQxcnEICexmlHhwdDcbREJC4tTLZYwQ trDEyn/P2SGKPjJKPNq7HKybTUBd4sjzVkaQhIhAK6PEgaktYA6zwEpGiduLXjCBVAkLmEtM vPobrINFQFXiUcsnsDivgIXE9vc3WCBWyEvMvPQdrIZTwFLizubtYKuFgGoePG9mhagXlDg5 8wlYPTNQffPW2cwTGAVmIUnNQpJawMi0ilEytaA4Nz232LDAMC+1XK84Mbe4NC9dLzk/dxMj OEq0NHcwbl/1Qe8QIxMH4yFGCQ5mJRHe0JKqNCHelMTKqtSi/Pii0pzU4kOM0hwsSuK84i96 U4QE0hNLUrNTUwtSi2CyTBycUg1M60paLqz4qGbaPqlBUb7t4O+avsyVJWEHm1+3tEdu7bI7 XcPWKHAyyLvYXUB5Zd77k1s3m8TX8KyK5/kToejXJ70m7UPQ2teV9z5Xc7rd99y4XjtJ9N2r 9is52cn1zxIcbRImbXNMP8aYIHvk05yISYFPPgmJbjjyPHxlW1TskmlHJC1VT6d9/X+G34Kx on32VH+h5Lg1WVq24vzm4eyxAiUyu+U+Bmea9WZrruHMfya9x07A7vYeOcsFjTOsIxcY5uXd Dnu42ugfq9iWWy8nys+ZsE2BVfQ1/8kj2/pVTfN2eakbf9m3/Oty0zOaD9vXKz03mSfZ8b/E yGFnzMKrc2bUczwzkkx49H9G1hMlluKMREMt5qLiRABZ/IQIAQMAAA== X-CMS-MailID: 20240626101513epcas5p10b3f8470148abb10ce3edfb90814cd94 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101513epcas5p10b3f8470148abb10ce3edfb90814cd94 References: <20240626100700.3629-1-anuj20.g@samsung.com> Set the bip_vcnt correctly in bio_integrity_init_user and bio_integrity_copy_user. If the bio gets split at a later point, this value is required to set the right bip_vcnt in the cloned bio. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index dab70370b2c7..af79d9fbf413 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -276,6 +276,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_INTEGRITY_USER | BIP_COPY_USER; bip->bip_iter.bi_sector = seed; + bip->bip_vcnt = nr_vecs; return 0; free_bip: bio_integrity_free(bio); @@ -297,6 +298,7 @@ static int bio_integrity_init_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_INTEGRITY_USER; bip->bip_iter.bi_sector = seed; bip->bip_iter.bi_size = len; + bip->bip_vcnt = nr_vecs; return 0; } From patchwork Wed Jun 26 10:06:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712781 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 65ACD17FAA9 for ; Wed, 26 Jun 2024 11:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402133; cv=none; b=hHYwWOmXda6iqBk0BJ5Z0wWLS4lKYSH08PN19TtDMWQ3kE78xTFhTQPWwYIjWV0V4D1pGZcHwL1DNgvXvaNo3+1F4/IWDp7k2MYeWHGDbNR2c4fQvtP9Xuj/QdgcqfhqNjcZs8J9EDrCWct/0GNHlWPpuU8nhLBtq4D8R4EuQDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402133; c=relaxed/simple; bh=/abOTLXTWq6MnTNy0iTo95+c8un+ioDHLrWRw9LnUYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=RCDQbWiwM/o1U2OJULBZgOrNkhYVOt/t5Utp9wcQGXA7YnPaalYHpEjy25oFx4KrXI4saET8TY4K0c7eBqZK8uAuH0acDglWU2CFbC8FN99028LsOC8OS35bHBvxAG8ObXDuC2Hn8G1ikF32sJbmlGhC/LwNUonHvyYG6Mox//A= 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=eUZfU5Ar; arc=none smtp.client-ip=203.254.224.24 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="eUZfU5Ar" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240626114207epoutp01cad90b8c14b6e8705288e12e88895cae~ciyAj2rlW1762517625epoutp01b for ; Wed, 26 Jun 2024 11:42:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240626114207epoutp01cad90b8c14b6e8705288e12e88895cae~ciyAj2rlW1762517625epoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402127; bh=xg1hUcooavawNWfL5YZpGfpv2h4Dx6Xk84lE11bhOzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eUZfU5ArMlR2jfRNg3OA59bzYxiu4nuc5Geuadf2xALych19fZEjRZbcdEhOoc2nf f/QiqUSry3AaUP9kfWTYuFeXusAg768CmZgE8h8+/Y534tr91QxYDYdyXmrwv3LlMu Njj95P1lJf5PAfIlpDNgdLh7Vxxz1WQpnYm4ut4A= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240626114207epcas5p2348478597814e6bdf5adbe9223618dac~cix-79sCc0959509595epcas5p2i; Wed, 26 Jun 2024 11:42:07 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4W8KYT3mPYz4x9Pp; Wed, 26 Jun 2024 11:42:05 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id BC.08.09989.D8EFB766; Wed, 26 Jun 2024 20:42:05 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240626101516epcas5p19fb40e8231d1832cab3d031672f0109e~chmK1jLgO0829808298epcas5p1j; Wed, 26 Jun 2024 10:15:16 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101516epsmtrp13052680d2b3b838252dd658696b5d8b2~chmK02-LG1024010240epsmtrp1c; Wed, 26 Jun 2024 10:15:16 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-33-667bfe8d61ce Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id DE.4C.18846.43AEB766; Wed, 26 Jun 2024 19:15:16 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101514epsmtip132e399ece14b53def07176d7d9a70188~chmI6SqZH0147101471epsmtip1Q; Wed, 26 Jun 2024 10:15:13 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v2 03/10] block: copy bip_max_vcnt vecs instead of bip_vcnt during clone Date: Wed, 26 Jun 2024 15:36:53 +0530 Message-Id: <20240626100700.3629-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrCJsWRmVeSWpSXmKPExsWy7bCmum7vv+o0g8ffxC2aJvxltpizahuj xeq7/WwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFsuP/2OymNhxlcmB22PnrLvs HpfPlnpsWtXJ5rF5Sb3H7psNbB4fn95i8Xi/7yqbR9+WVYwenzfJBXBGZdtkpCampBYppOYl 56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAN2qpFCWmFMKFApILC5W0rez KcovLUlVyMgvLrFVSi1IySkwKdArTswtLs1L18tLLbEyNDAwMgUqTMjO+P35BVvBFo6KPbse sDYw/mfrYuTkkBAwkTjbu5C1i5GLQ0hgN6PEh6atLCAJIYFPjBKvHyhDJIDsL4dvMsJ0vN26 GapjJ6PE+f+TmCCcz4wSB5ffA2tnE1CXOPK8FaxDRKBWYmXrdHaQImaBpUA7HlxnBkkIC0RJ rFjfyARiswioSrycsBrsKF4BC4nWz6+gDpSXmHnpOzuIzS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lzFC 2MISK/89Z4co+sgoce34PHaQBJuAusSR562MIAkRgVZGiQNTW8AcZoGVjBK3F71gAqkSFoiQ +N24F2wfi4CqxMsJq8FsXgELidbPr6DukJeYeek72FROAUuJO5u3g60WAqp58LyZFaJeUOLk zCdg5zED1Tdvnc08gVFgFpLULCSpBYxMqxhFUwuKc9NzkwsM9YoTc4tL89L1kvNzNzGCo0Mr aAfjsvV/9Q4xMnEwHmKU4GBWEuENLalKE+JNSaysSi3Kjy8qzUktPsQozcGiJM6rnNOZIiSQ nliSmp2aWpBaBJNl4uCUamBy+GDx9MnWu3rNhxYt5sh5EF557Fk0w32hiRbb+x985P1WrPBQ 0a3p3i3De/e7A6bHtd3aXLVmGkPY5AC3Dyvuh255f32DW3DGi/O1+Ud8Ta7cZeoJ/GP+Wdtk q0CAi9v63D8LrktkHGP6mFeXev3yTn63xN+nFh1NOOnio6dwy6jrioKq1qod/qzyK6psrrLs blTecPrQ/SaulO0b3nfOX26Y8+6D6BHz6vQf5fPD5CMFDybzvgrrORvvXOXgkvH7aaDt+dfX z8nH1nptM1WpmXMsIj/e51dHa/BOVXWJxsg7kQ+KWlYf1d0x4fvOrauF36+aa5m7fILwrD5n f+P7vKv9ej9fKVn++6ebeq23EktxRqKhFnNRcSIAfis1Jv0CAAA= X-CMS-MailID: 20240626101516epcas5p19fb40e8231d1832cab3d031672f0109e X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101516epcas5p19fb40e8231d1832cab3d031672f0109e References: <20240626100700.3629-1-anuj20.g@samsung.com> If bio_integrity_copy_user is used to process the meta buffer, bip_max_vcnt is one greater than bip_vcnt. In this case bip_max_vcnt vecs needs to be copied to cloned bip. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index af79d9fbf413..5e7596b74ef1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -647,12 +647,12 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, BUG_ON(bip_src == NULL); - bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt); + bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_max_vcnt); if (IS_ERR(bip)) return PTR_ERR(bip); memcpy(bip->bip_vec, bip_src->bip_vec, - bip_src->bip_vcnt * sizeof(struct bio_vec)); + bip_src->bip_max_vcnt * sizeof(struct bio_vec)); bip->bip_vcnt = bip_src->bip_vcnt; bip->bip_iter = bip_src->bip_iter; From patchwork Wed Jun 26 10:06:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712782 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 2087917DE11 for ; Wed, 26 Jun 2024 11:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; cv=none; b=avpyPrPhLs2AAJZKjcjn4hggtxPR+jSlNt1Xx0dy4bs3EixEJT6IhlVBbs4HfsTp9V781Y1Cax4EO6aYlSB6BBSTRWXFZeOjFCoJyFDLg47tfM2XNcWiJDonz02Vo8aNad1vpu4TQ6IgHZ0pMiCuOpwxPlv/jBbRHpY6ctI7x0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; c=relaxed/simple; bh=U0+9g6uGyk6RBIlhWHM+buH6yhOwIpW4Oftxk4/M+tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=pcTeHPpVnvOSNet8Az6U1w1Ov3I6ePtxR9kEseozwd29pGCsH5FXCUXT83R0Jrlw+LOPpz3oUHrB0jF9r1BNC3cd0ILLS1ex5kxdN98cNcW8CzEIzqZmN0imIkY0LSZ6/u4HLkL7zOLUF8IKgpwy6Ckd2OUxxOp0M+olhmG/FeM= 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=Fj6QdUHN; arc=none smtp.client-ip=203.254.224.24 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="Fj6QdUHN" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240626114223epoutp019522b4630e3f6110af027493b164c125~ciyOxdndA1613316133epoutp01S for ; Wed, 26 Jun 2024 11:42:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240626114223epoutp019522b4630e3f6110af027493b164c125~ciyOxdndA1613316133epoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402143; bh=Lc4MBkJJg5V7b9dh7JN4sQekrc8Uu39ar65ub5yzidI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fj6QdUHNB4opKGxHiICO6NGQANYtMqtxPwuIyIeFAeyj4Y8gUHmSPdM+sfIx48UMm 4zZcfItGTW0jeTjKcCHIkAjTIl35igqfjZHnhlTq0zj1NjifdniioOTSz8RIEOPO2z yviER/qlDQlGBPO0gfdV3mz9H2GWBCpAkbltHG/U= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240626114222epcas5p10bd1c047e8792f9dab1b780604d44b44~ciyOQVgNm3039430394epcas5p1j; Wed, 26 Jun 2024 11:42:22 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8KYm29XLz4x9Pq; Wed, 26 Jun 2024 11:42:20 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7A.56.07307.C9EFB766; Wed, 26 Jun 2024 20:42:20 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240626101518epcas5p17e046bca77b218fc6914ddeb182eb42e~chmMexGyY1565315653epcas5p1C; Wed, 26 Jun 2024 10:15:18 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240626101518epsmtrp280c286a42092f5e508e450312f9596b8~chmMeCAQH1237112371epsmtrp2R; Wed, 26 Jun 2024 10:15:18 +0000 (GMT) X-AuditID: b6c32a44-3f1fa70000011c8b-f4-667bfe9cc062 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 9F.4C.18846.53AEB766; Wed, 26 Jun 2024 19:15:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101516epsmtip1583ec8eff4ee86836d17d00a6e74a766~chmLATaVu0147101471epsmtip1R; Wed, 26 Jun 2024 10:15:16 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Anuj Gupta Subject: [PATCH v2 04/10] block: Handle meta bounce buffer correctly in case of split Date: Wed, 26 Jun 2024 15:36:54 +0530 Message-Id: <20240626100700.3629-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmuu6cf9VpBqt381k0TfjLbDFn1TZG i9V3+9ksVq4+ymTxrvUci8WkQ9cYLfbe0raYv+wpu8Xy4/+YLCZ2XGVy4PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5vHx6e3WDze77vK5tG3ZRWjx+dNcgGcUdk2GamJKalFCql5yfkpmXnp tkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBnKimUJeaUAoUCEouLlfTtbIryS0tS FTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyM/b8mchY8Jun4sjVNSwNjA+5 uhg5OSQETCS2f93E3sXIxSEksJtRYv3Nk2wgCSGBT4wSD2ZFQySA7CePnwJVcYB1POp1gYjv ZJRoXvGMEcL5zChxYs5VRpBuNgF1iSPPW8FsEYFaiZWt09lBbGaBOolZN/6D2cIC4RL7tm1m AbFZBFQljk9cA7aAV8BC4vg5Fojr5CVmXvoOVs4pYClxZ/N2sJG8AoISJ2c+YYEYKS/RvHU2 M8gNEgIzOSQ2tP5mg2h2kdg4cz4jhC0s8er4FnYIW0ri87u9UDXpEj8uP2WCsAskmo/tg6q3 l2g91c8Mcg+zgKbE+l36EGFZiamn1jFB7OWT6P39BKqVV2LHPBhbSaJ95RwoW0Ji77kGKNtD 4ubZx8yQwO1hlOjq5ZvAqDALyTuzkLwzC2HzAkbmVYySqQXFuempyaYFhnmp5fAoTs7P3cQI TrdaLjsYb8z/p3eIkYmD8RCjBAezkghva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ILYLJMnFwSjUwzf7QLnUq27/vkpKufd8kxtTbMZ6r1uyZ9PpS9XnmWybvXr+ZWP95 zZeZX6KmqN+f+em0n0+k17bH+8zlNmu9qrjFXmn0S154vm9NuF/1vxSHbX8+pokLXlGfmlN3 Zm29XWfo06tbH3v+msyu9OBwuqPGgtTlim37/yVczjnafZxtYsPFrS7R677fmSM4/+4cj/nP 81fkbey7Zae4kId3xep92h6qpoutHjolbVr/5eush44M3it2ZtmlbDz0l6lde6eMVm6D6MJG xtjd3P9KtN/+u+l+qk3r102d9K1FW3/Gn1MX+JS9cFHS+x3OxaWzH/TWzp20TlU8r+TmtuLU Mq/EU/eehfEHpi7dJ1ZtOkeJpTgj0VCLuag4EQBUMUEj9gIAAA== X-CMS-MailID: 20240626101518epcas5p17e046bca77b218fc6914ddeb182eb42e X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101518epcas5p17e046bca77b218fc6914ddeb182eb42e References: <20240626100700.3629-1-anuj20.g@samsung.com> Do not inherit BIP_COPY_USER for cloned bio. Also make sure that bounce buffer is copied back to user-space in entirety when the parent bio completes. Signed-off-by: Anuj Gupta --- block/bio-integrity.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 5e7596b74ef1..845d4038afb1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -105,9 +105,12 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { + struct bio *bio = bip->bip_bio; + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); unsigned short nr_vecs = bip->bip_max_vcnt - 1; struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; + size_t bytes = bio_integrity_bytes(bi, + bvec_iter_sectors(bip->bio_iter)); struct iov_iter iter; int ret; @@ -277,6 +280,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_INTEGRITY_USER | BIP_COPY_USER; bip->bip_iter.bi_sector = seed; bip->bip_vcnt = nr_vecs; + bip->bio_iter = bio->bi_iter; return 0; free_bip: bio_integrity_free(bio); @@ -656,8 +660,8 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vcnt = bip_src->bip_vcnt; bip->bip_iter = bip_src->bip_iter; - bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY; - + bip->bip_flags = bip_src->bip_flags & ~(BIP_BLOCK_INTEGRITY | + BIP_COPY_USER); return 0; } From patchwork Wed Jun 26 10:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712783 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 AB95A17F4E8 for ; Wed, 26 Jun 2024 11:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; cv=none; b=s61gtf6eKgpe/Ncc8gFssALtTWbze1pndfLnXjeWGJTKUxRWnyesEScvKi+bEz+HaSlVjP2xjh6peQtgBgOwYX4lSRdRMOKCOSuUtQMSl1zaLe0QtgLwAsh5e/tN1HyN0kx5v8qWtgq9cfbi+yujSNdwY/ge0nNsazXqBYrJLd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; c=relaxed/simple; bh=8hu2gELgAaPO9ThdtDrVOBEQrck8AWf/89L08gXHjvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=ltyuaBbeXGesZxu1gXiDTXu5kfanPvYdMNtO/0Qjacdv3Ech039CScqKA9/iwQl/zLMc6QLD4FZWBeP0/m4i/iNXYyCpHuo70/ihfqHbQlynvd6URj6IzVP3F8/mUKp8pSFkepMQ6VZOxjAX5CSl/c/4Y8eG3EqeY7Rwxoq2E+I= 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=hRXcryWv; arc=none smtp.client-ip=203.254.224.24 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="hRXcryWv" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240626114225epoutp010fbf0f844a90b2da688b056f65c15f5e~ciyQlEJyc1762517625epoutp01f for ; Wed, 26 Jun 2024 11:42:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240626114225epoutp010fbf0f844a90b2da688b056f65c15f5e~ciyQlEJyc1762517625epoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402145; bh=nXGPzER1JF01Eq/Va1G8I1f4os1fOKXD7EF9v6r4iM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRXcryWvbC7asq2VcYxnTBbOYtFDaTYfkNgjxiJlp2tLW/cX4zDKGCyauZFQU2R5G 5ruNTFaba0MTGGQamO/0P5TJG87NOReVLPFMUonV1fU4Pvy1DJsihVaeWYjIc+PyzS sGXSo0/GHkpizyFleaeRvRsQD2vaTgET+K2aQd64= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240626114224epcas5p47a3e3da5c0bc0c406bfb9ed989ec64e6~ciyP1O5oC0207802078epcas5p4I; Wed, 26 Jun 2024 11:42:24 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.178]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4W8KYp3v2nz4x9Pp; Wed, 26 Jun 2024 11:42:22 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id EC.75.19174.E9EFB766; Wed, 26 Jun 2024 20:42:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240626101519epcas5p163b0735c1604a228196f0e8c14773005~chmOOAph61565315653epcas5p1H; Wed, 26 Jun 2024 10:15:19 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101519epsmtrp1fd3887d9cd4992b3258841181ca9ce27~chmONJVY91023810238epsmtrp1k; Wed, 26 Jun 2024 10:15:19 +0000 (GMT) X-AuditID: b6c32a50-87fff70000004ae6-ed-667bfe9ebdf3 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D9.6A.19057.73AEB766; Wed, 26 Jun 2024 19:15:19 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101518epsmtip1c3b688bf7716f6795f14ab17527fc687~chmMm6_kR0370603706epsmtip1C; Wed, 26 Jun 2024 10:15:18 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi Subject: [PATCH v2 05/10] block: introduce BIP_CLONED flag Date: Wed, 26 Jun 2024 15:36:55 +0530 Message-Id: <20240626100700.3629-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrAJsWRmVeSWpSXmKPExsWy7bCmpu68f9VpBvO2yFrMWbWN0WL13X42 i5WrjzJZvGs9x2Jx9P9bNotJh64xWuy9pW0xf9lTdovlx/8xWUzsuMrkwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPj09vsXi833eVzaNvyypGj8+b5AI4o7JtMlITU1KLFFLzkvNTMvPS bZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4DOVFIoS8wpBQoFJBYXK+nb2RTll5ak KmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZ+y63cxasIK3Ys/OLsYGxudc XYycHBICJhLnHtxi7mLk4hAS2MMosefjXFYI5xOjxPWerVDON0aJCfNXsMC0rJ0yixXEFhLY yyhxdF4qRNFnRomvjS2MIAk2AXWJI89bwWwRgVqJla3T2UGKmAUaGCW6J3xnB0kIC1hJXPp7 Hmg5BweLgKrEtEtg9bwCFhLfz5xmhVgmLzHzEkQ5p4ClxJ3N26FqBCVOznwCdhAzUE3z1tlg P0gITOWQ2PL6KyPITAkBF4ln73wh5ghLvDq+hR3ClpJ42d8GZadL/Lj8lAnCLpBoPraPEcK2 l2g91Q92GrOApsT6XfoQYVmJqafWMUGs5ZPo/f0EqpVXYsc8GFtJon3lHChbQmLvuQYo20Pi 3LqJ0ADtYZR4eXk2ywRGhVlI3pmF5J1ZCKsXMDKvYpRKLSjOTU9NNi0w1M1LLYfHcnJ+7iZG cNLVC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Uovy44tKc1KLDzFKc7AoifN+e92bIiSQ nliSmp2aWpBaBJNl4uCUamAKnqtV5diQwRkfYNPmOdHZoyvWi18yL0qv+0Da5yWbqneWJRdX ps214tto656VPPWPVqGaopz3fJH6OM8LFU9dFP663astTP9b8a8l+wNDT1PvRN6IAxv2Wtux N/pz7vZftPaiRIjyA9v6o/veKk3zYt02y3XF/IIZ8fy/4+5/Z7MWKAj9mxm/+9Myj55/Rftl v3cYZ239e9LkeNW2H4mmDKfN/900rtoiFW+TKWfFbP6c4cqTR/IXlk06nj2vQjQ/uunms7kB r7dY1jN7eIZ/4GrwPHrg3eLfDjtT3n81LkrdySgw4UpaQm7CtoCZ+3KW9OqFLtmfVpH7SzXn 1+nNy2+tK8iNWZJrteBlkRJLcUaioRZzUXEiAHW0shj7AgAA X-CMS-MailID: 20240626101519epcas5p163b0735c1604a228196f0e8c14773005 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101519epcas5p163b0735c1604a228196f0e8c14773005 References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Kanchan Joshi Set the BIP_CLONED flag when bip is cloned. Use that flag to ensure that integrity is freed for cloned user bip. Note that a bio may have BIO_CLONED flag set but it may still not be sharing the integrity vecs. Signed-off-by: Kanchan Joshi Signed-off-by: Christoph Hellwig --- block/bio-integrity.c | 5 ++++- include/linux/bio.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 845d4038afb1..8f07c4d0fada 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -147,7 +147,8 @@ void bio_integrity_free(struct bio *bio) struct bio_integrity_payload *bip = bio_integrity(bio); struct bio_set *bs = bio->bi_pool; - if (bip->bip_flags & BIP_INTEGRITY_USER) + if (bip->bip_flags & BIP_INTEGRITY_USER && + !(bip->bip_flags & BIP_CLONED)) return; if (bip->bip_flags & BIP_BLOCK_INTEGRITY) kfree(bvec_virt(bip->bip_vec)); @@ -662,6 +663,8 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_iter = bip_src->bip_iter; bip->bip_flags = bip_src->bip_flags & ~(BIP_BLOCK_INTEGRITY | BIP_COPY_USER); + bip->bip_flags |= BIP_CLONED; + return 0; } diff --git a/include/linux/bio.h b/include/linux/bio.h index 818e93612947..44226fcb4d00 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -329,6 +329,7 @@ enum bip_flags { BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_INTEGRITY_USER = 1 << 5, /* Integrity payload is user address */ BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ + BIP_CLONED = 1 << 7, /* Indicates that bip is cloned */ }; /* From patchwork Wed Jun 26 10:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712784 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 780AC17F4E8 for ; Wed, 26 Jun 2024 11:42:29 +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=1719402151; cv=none; b=dUO5Ej6P9zneqBMu+IzFKwuC9C+ANvcsKQ4xbztYX/9w/utsMgIFpy9GPPhUWIXsaFkFB/z6cM1HKUwuCDofz5xDHm3KdpQr2bUuwNQ5L9qBb/Ft06XFhljWX3+Ktw6k9N6i6R7rEyvOCpwAPNJW+Irz7D/3FR/5wy6sdG5d3IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402151; c=relaxed/simple; bh=pAcrVqvzIHK6gcFDcS2qtFzmbz2pTTMoSzKWX8SsNnw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=bRRgdF9NmHsDvMAwGKNoQZExL4q9yyAVxSxSlD3KPJ2ijglV985mhwc7LG/iVc5MshWrvncr07yujGWnHrv4GW/P+EURxpKn7Vw5DIyO5nMGSu/Kw64wgNDtxnxa9lnhL5WzLSt8AacVRg00BoazCOMAS9oQr7pbcEXckDE/SPI= 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=YMbcZapM; 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="YMbcZapM" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240626114227epoutp0279daa4d57eccb28f447810a18978ca59~ciyS-1E3I3194731947epoutp02j for ; Wed, 26 Jun 2024 11:42:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240626114227epoutp0279daa4d57eccb28f447810a18978ca59~ciyS-1E3I3194731947epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402147; bh=pO3eGbVZcPQlxKtRYSdD+0t2tpPWLie9HfulaNqkz/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMbcZapM4i/SKlRvfcqV4Z9tnRv7p5llGvLx+FKpvarxM8OQYlBqWOQ0U75y1zu2z C9sa3K84bSRgvF+B6DO3zIY6JxD7DK3DQz9M9tEL3cdJufOdIDeMRzZ496RMpBMF1i Ok5RM5J7kMhX9i0XTlnEf4PSicHzmBYUl+/zVvvI= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240626114227epcas5p4f56c41f4aaffacff454027f720ff5870~ciySkmlkC0207802078epcas5p4Q; Wed, 26 Jun 2024 11:42:27 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8KYs3yNlz4x9Pv; Wed, 26 Jun 2024 11:42:25 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C4.18.09989.1AEFB766; Wed, 26 Jun 2024 20:42:25 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240626101521epcas5p42b0c1c0e123996b199e058bae9a69123~chmP_YtvB2295722957epcas5p4V; Wed, 26 Jun 2024 10:15:21 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101521epsmtrp1590517e3aa77fb307b919163c4b00bcd~chmP9oZzM1024010240epsmtrp1i; Wed, 26 Jun 2024 10:15:21 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-63-667bfea1aa2e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 50.7B.29940.93AEB766; Wed, 26 Jun 2024 19:15:21 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101519epsmtip125c4bbfe3a765009cf04a8051d5a62d3~chmOQxHOo0370603706epsmtip1D; Wed, 26 Jun 2024 10:15:19 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v2 06/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Wed, 26 Jun 2024 15:36:56 +0530 Message-Id: <20240626100700.3629-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrOJsWRmVeSWpSXmKPExsWy7bCmpu7Cf9VpBqtvy1g0TfjLbDFn1TZG i9V3+9ksVq4+ymTxrvUci8XR/2/ZLCYdusZosfeWtsX8ZU/ZLZYf/8dkMbHjKpMDt8fOWXfZ PS6fLfXYtKqTzWPzknqP3Tcb2Dw+Pr3F4vF+31U2j74tqxg9Pm+SC+CMyrbJSE1MSS1SSM1L zk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvMAbpVSaEsMacUKBSQWFyspG9n U5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqXrpeXWmJlaGBgZApUmJCdMeHnaeaCZ/IVE3+t ZmlgnCLVxcjJISFgItHdt4+pi5GLQ0hgN6PEncnL2CCcT4wSlxrWMEI43xglLuzfzALT0te3 DSqxl1Hi2oqJUP2fGSVmLpzGCFLFJqAuceR5K5gtIlArsbJ1OjtIEbPAUkaJDw+uM4MkhAXi JfYtXgxmswioSuxZ/ZUJxOYVsJA4s3s3E8Q6eYmZl76zg9icApYSdzZvZ4SoEZQ4OfMJ2EnM QDXNW2czgyyQEJjLIfH+2CeoZheJQ23vmCFsYYlXx7ewQ9hSEi/726DsdIkfl59C1RdINB/b xwhh20u0nuoH6uUAWqApsX6XPkRYVmLqqXVMEHv5JHp/P4Fq5ZXYMQ/GVpJo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1Tdvnc08gVFgFpLULCSpBYxMqxglUwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLzczcx gqNES3MH4/ZVH/QOMTJxMB5ilOBgVhLhDS2pShPiTUmsrEotyo8vKs1JLT7EKM3BoiTOK/6i N0VIID2xJDU7NbUgtQgmy8TBKdXAtOLh3wOsB/p/WCn8c9q/REzJu3DHerOfV0101J8dDMyX OF3KwvZqx5bufhYjSZHDCzRswwKVahdPsD9VP/2cwEETW+WPsTPDNucwJAUl3Pt0zu3+33fH Vtb76eqdn+vf93xXyBKL1VcvlswWO1Hr8ZMl6laS5rG0+z+u7jf2Xv2HaY2IePN36Z+vej+o z4vgkf96f8btzUcyFyyWVX4q0C7tcUj43Op4Xq4Ve++5pYvY5GvcKdBmFs3+sfHUnoYPAlK3 +hh+idTx66xYd/7Z3bWykzI1/F7HT72a+vyLaFt6fkzaywcGWR7XS/8VzY27d9w62/33/6QD 6zQfRWgbugU2XV0yl6fKq8pTUKkzV4mlOCPRUIu5qDgRAE5UtRkBAwAA X-CMS-MailID: 20240626101521epcas5p42b0c1c0e123996b199e058bae9a69123 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101521epcas5p42b0c1c0e123996b199e058bae9a69123 References: <20240626100700.3629-1-anuj20.g@samsung.com> This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 12 +++++------- drivers/nvme/host/ioctl.c | 11 +++++++++-- include/linux/bio.h | 8 +++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 8f07c4d0fada..38418be07139 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -337,17 +337,16 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = q->dma_pad_mask | queue_dma_alignment(q); struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages; struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec; + size_t offset, bytes = iter->count; unsigned int direction, nr_bvecs; - struct iov_iter iter; int ret, nr_vecs; - size_t offset; bool copy; if (bio_integrity(bio)) @@ -360,8 +359,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, else direction = ITER_SOURCE; - iov_iter_ubuf(&iter, direction, ubuf, bytes); - nr_vecs = iov_iter_npages(&iter, BIO_MAX_VECS + 1); + nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS + 1); if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { @@ -371,8 +369,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 8b69427a4476..e77ea1e7be03 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -152,8 +152,15 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, if (bdev) { bio_set_dev(bio, bdev); if (meta_buffer && meta_len) { - ret = bio_integrity_map_user(bio, meta_buffer, meta_len, - meta_seed); + struct iov_iter iter; + unsigned int direction; + + if (bio_data_dir(bio) == READ) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, meta_buffer, meta_len); + ret = bio_integrity_map_user(bio, &iter, meta_seed); if (ret) goto out_unmap; req->cmd_flags |= REQ_INTEGRITY; diff --git a/include/linux/bio.h b/include/linux/bio.h index 44226fcb4d00..c90168274188 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -731,7 +731,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); void bio_integrity_unmap_free_user(struct bio *bio); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); @@ -804,11 +804,13 @@ static inline int bio_integrity_add_page(struct bio *bio, struct page *page, return 0; } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len, u32 seed) +static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, + u32 seed) + { return -EINVAL; } + static inline void bio_integrity_unmap_free_user(struct bio *bio) { } From patchwork Wed Jun 26 10:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712785 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 0015A17DE11 for ; Wed, 26 Jun 2024 11:42:42 +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=1719402165; cv=none; b=cJkYODkTbqGNi9m91t26600sURPps05nBbFQn6lhniDWYjnfQeip3CpQ5uV7E1Ck7SDfwtYLQh/gd/q6HpiBTE5qUxmAJYRKe9pMY1ozuj3GMajaEQGWlykO8r57NYV0dJOXitbe//CX2Ch7qRAkyY/x4KO5vgnvEq+8DddmxrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402165; c=relaxed/simple; bh=Ye60aMacrW6f9lG8I1I8yRoH+wWZJi7uruWP6l4rL6s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=kx0bLhI7YVwnmCB5nA9h0jDsCn2Gk9nVKVMuM0QKYoiQc/oOpi0lIeYoDgJqmqdJhxwi7FzNHwM4ABtir9HTZgFf4dwWRkIJt8JE/Ao4TTmeKDQzdY3HWLe0wD6NaNGDmc9iTjcxpAjX7uYoUh4JUBmTeveVF6SuMATSFkY8eNk= 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=TGUTI+ph; 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="TGUTI+ph" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240626114240epoutp0273c451de41f89fd0429f847586d0c1c0~ciye_eh1O3227832278epoutp02h for ; Wed, 26 Jun 2024 11:42:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240626114240epoutp0273c451de41f89fd0429f847586d0c1c0~ciye_eh1O3227832278epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402160; bh=5kTE0BFBF0NkwRuxNrhjo9kS5g5kwSIAlNctz7NPi7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TGUTI+phcjZ1TYfhStHM/mQEDWWq8mcUG/ouaZgdlw2l0AMEECtrpVlROHMuxg0fH V4NMiQaU4u6+iUCgHhYoJ5OBjpt8FYRJR52NyfCjh5f3VEk7w6fw/EpzyDBfLJ0h22 LHJXdj8ORAWpiSfYgxCzP+hPbDCoRtCnVM1hDkjk= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240626114240epcas5p18ae0d2cffa9a01de8d3875c1abd5d0c2~ciyedy0ae2539325393epcas5p1g; Wed, 26 Jun 2024 11:42:40 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8KZ55tlVz4x9Pq; Wed, 26 Jun 2024 11:42:37 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id CF.18.09989.CAEFB766; Wed, 26 Jun 2024 20:42:36 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240626101523epcas5p2616cf568575685bd251d28fc1398d4cd~chmRklWea2650826508epcas5p25; Wed, 26 Jun 2024 10:15:23 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240626101523epsmtrp26c71078e361bf1739cf506d2c5548f49~chmRj1d7j1237112371epsmtrp2S; Wed, 26 Jun 2024 10:15:23 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-79-667bfeaca198 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.6A.19057.B3AEB766; Wed, 26 Jun 2024 19:15:23 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101521epsmtip19437341e5e71640b9f53f9f64293488b~chmQE0-LX0147101471epsmtip1U; Wed, 26 Jun 2024 10:15:21 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi Subject: [PATCH v2 07/10] block: define meta io descriptor Date: Wed, 26 Jun 2024 15:36:57 +0530 Message-Id: <20240626100700.3629-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrEJsWRmVeSWpSXmKPExsWy7bCmpu6af9VpBrsmaVnMWbWN0WL13X42 i5WrjzJZvGs9x2Jx9P9bNotJh64xWuy9pW0xf9lTdovlx/8xWUzsuMrkwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPj09vsXi833eVzaNvyypGj8+b5AI4o7JtMlITU1KLFFLzkvNTMvPS bZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4DOVFIoS8wpBQoFJBYXK+nb2RTll5ak KmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZ9x8/4K9YCtrxfG25+wNjCtZ uhg5OSQETCTePHrJ2sXIxSEksJtRYurzb1DOJ0aJlke7mCCcb4wSD+fNYYVpubpiOVTVXkaJ zfefQzmfGSVmNt0CG8wmoC5x5HkrI4gtIlArsbJ1OjtIEbNAA6NE94Tv7CAJYQEriX2rz7KB 2CwCqhLH/nSANfMKWEgcvbiOHWKdvMTMSxD1nAKWEnc2b2eEqBGUODnzCVg9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i0MoocWBqC5jDLNDCKDG3tYUdpEpYwEpi3+qzbCA2 i4CqxLE/HWDdvAIWEkcvrmOHWCEvMfPSdzCbU8BS4s7m7WCrhYBqHjxvZoWoF5Q4OfMJWC8z UH3z1tnMExgFZiFJzUKSWsDItIpRMrWgODc9t9iwwCgvtVyvODG3uDQvXS85P3cTIzg2tLR2 MO5Z9UHvECMTB+MhRgkOZiUR3tCSqjQh3pTEyqrUovz4otKc1OJDjNIcLErivN9e96YICaQn lqRmp6YWpBbBZJk4OKUamEwbCiXftgctNahYVMLcIOVX8u7Z8ZU7JP7OU5wrudv3eb3OUo2F cyv2556QWJ/mbBqpdFUvtOXuvFp/l6VHSre0qsdNNM85XXH38I0SzflG03OnOKezaGqdLrS/ tqJleZD8iXPtf29ZRT1dXXCZMYBBKrQx8cSGix/Oya8xqop7HRScc85c9mR62ZGqfZwJU1k4 GFa/OnCD9ZS3l+Fl2aJfGxUftL803Xn/3abe2bxvY9azflzDoON04EnWRIsKuRnOzIt41T99 0U07l8lkunqBSW3Rmjv2W9cGl54qrLgyV0hN59XUc7sf+i0pVHr8TTl//6b45Uc8+LI7lU9d /97t8uJrOOv8R/cNDly7XqTEUpyRaKjFXFScCADxPj0i/AIAAA== X-CMS-MailID: 20240626101523epcas5p2616cf568575685bd251d28fc1398d4cd X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101523epcas5p2616cf568575685bd251d28fc1398d4cd References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Kanchan Joshi Introduces a new 'uio_meta' structure that upper layer can use to pass the meta/integrity information. This is a prep patch. Signed-off-by: Kanchan Joshi --- include/linux/bio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index c90168274188..966e22a04996 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -332,6 +332,12 @@ enum bip_flags { BIP_CLONED = 1 << 7, /* Indicates that bip is cloned */ }; +struct uio_meta { + u16 flags; + u16 apptag; + struct iov_iter iter; +}; + /* * bio integrity payload */ From patchwork Wed Jun 26 10:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712786 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 9510F17DE11 for ; Wed, 26 Jun 2024 11:43:00 +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=1719402182; cv=none; b=iQjQd25UX37SeuyRbwH2Hl91/W77sSTVMvDnA8ozegvzBp0eP4ILIVZlJJFsWWxLMWoMrskYItyb5u2ehMvbjSkJp3X1dATq3OBfQsrPblc75ggYPNK1R/h+Trtjc1ykT5FLZpAA9YFaBCB8Tk0uWYwlzlWXHa8OFG46g5PC+bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402182; c=relaxed/simple; bh=EpWtZHYTQiB3/19IHJw0HPh6rzE07MqEQ9BceeF06eg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=FH1wyFtPVA11vcYl6RpXstAhIQmxsSHGs6PhnMSEc/RJKc2PFvj0o4na4VRTHm7cuAP14e1oL9ryfcZfn3iG8SqMUu+9h2Fvn1VOXYBV7+gXRjauEoIuZbs1pLPDCHUvIAmypeiIbfKOq5p7QdnP/mfCAU3Ak4buNxR0WxSu4Wo= 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=jzrBw7G4; 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="jzrBw7G4" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240626114258epoutp046ef1c7c3af2649d58f3e08042773707c~ciyvtaL7X2384423844epoutp04j for ; Wed, 26 Jun 2024 11:42:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240626114258epoutp046ef1c7c3af2649d58f3e08042773707c~ciyvtaL7X2384423844epoutp04j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402178; bh=cyyohgc9kguPnz4TuUAHQZPA34igWJ87jYDppv5Wf+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzrBw7G4mTLzoN/bY+GOhAAXf4ukJg2fvJ5B6UOXsDcc8rDmA3MNtMbSZaZX74AIi JZxn81vJTH+b7oofDKX69/npB9WX5aI+3iMScyIqWTbND9fJrQbDZsDYy15jWul+Xs IbaHpyQEU5/NCmeUdZhtBJhmU+TzpCmQqxD6MoF4= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240626114257epcas5p28023ccbe8f36aaa55565c3c4778dab9e~ciyuT4IaD2974929749epcas5p2M; Wed, 26 Jun 2024 11:42:57 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4W8KZR1By4z4x9Pw; Wed, 26 Jun 2024 11:42:55 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 08.75.11095.FBEFB766; Wed, 26 Jun 2024 20:42:55 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240626101525epcas5p4dbcef84714e4e9214b951fe2ff649521~chmTVXSrt2295722957epcas5p4h; Wed, 26 Jun 2024 10:15:25 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101525epsmtrp128101f7cce08a95e97aa20203016d957~chmTUot2E1052710527epsmtrp1F; Wed, 26 Jun 2024 10:15:25 +0000 (GMT) X-AuditID: b6c32a49-423b770000012b57-ec-667bfebfd1a0 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A1.7B.29940.D3AEB766; Wed, 26 Jun 2024 19:15:25 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101523epsmtip1c44f5558bf00537373e796428a83c878~chmRrELpQ0256902569epsmtip1k; Wed, 26 Jun 2024 10:15:23 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v2 08/10] io_uring/rw: add support to send meta along with read/write Date: Wed, 26 Jun 2024 15:36:58 +0530 Message-Id: <20240626100700.3629-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrMJsWRmVeSWpSX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+Wrc4vzhDZ9w7/+AWzaCZz6Fckd2PNn8+sRm x25D953lbUsn36zOl7BoNsn0YOu/dbBYIcCv7c7hvwuuhdwSz/416ca0/7O1nhns/tXWOdf0 nnVG9GGbHZyCc1du2mx+6V+08p1yJZbijERDLeai4kQAt/q5rf8CAAA= X-CMS-MailID: 20240626101525epcas5p4dbcef84714e4e9214b951fe2ff649521 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101525epcas5p4dbcef84714e4e9214b951fe2ff649521 References: <20240626100700.3629-1-anuj20.g@samsung.com> This patch adds the capability of sending meta along with read/write. This meta is represented by a newly introduced 'struct io_uring_meta' which specifies information such as meta type/flags/buffer/length and apptag. Application sets up a SQE128 ring, prepares io_uring_meta within the SQE at offset pointed by sqe->cmd. The patch processes the user-passed information to prepare uio_meta descriptor and passes it down using kiocb->private. Meta exchange is supported only for direct IO. Also vectored read/write operations with meta are not supported currently. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 30 +++++++++++++++- io_uring/io_uring.c | 7 ++++ io_uring/rw.c | 68 +++++++++++++++++++++++++++++++++-- io_uring/rw.h | 9 ++++- 5 files changed, 110 insertions(+), 5 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index db26b4a70c62..0132565288c2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -330,6 +330,7 @@ struct readahead_control; #define IOCB_NOIO (1 << 20) /* can use bio alloc cache */ #define IOCB_ALLOC_CACHE (1 << 21) +#define IOCB_HAS_META (1 << 22) /* * IOCB_DIO_CALLER_COMP can be set by the iocb owner, to indicate that the * iocb completion can be passed back to the owner for execution from a safe diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 2aaf7ee256ac..9140c66b315b 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -101,12 +101,40 @@ struct io_uring_sqe { __u64 optval; /* * If the ring is initialized with IORING_SETUP_SQE128, then - * this field is used for 80 bytes of arbitrary command data + * this field is starting offset for 80 bytes of data. + * This data is opaque for uring command op. And for meta io, + * this contains 'struct io_uring_meta'. */ __u8 cmd[0]; }; }; +enum io_uring_sqe_meta_type_bits { + META_TYPE_INTEGRITY_BIT, + /* not a real meta type; just to make sure that we don't overflow */ + META_TYPE_LAST_BIT, +}; + +/* meta type flags */ +#define META_TYPE_INTEGRITY (1U << META_TYPE_INTEGRITY_BIT) + +struct io_uring_meta { + __u16 meta_type; + __u16 meta_flags; + __u32 meta_len; + __u64 meta_addr; + /* the next 64 bytes goes to SQE128 */ + __u16 apptag; + __u8 pad[62]; +}; + +/* + * flags for integrity meta + */ +#define INTEGRITY_CHK_GUARD (1U << 0) /* enforce guard check */ +#define INTEGRITY_CHK_APPTAG (1U << 1) /* enforce app tag check */ +#define INTEGRITY_CHK_REFTAG (1U << 2) /* enforce ref tag check */ + /* * If sqe->file_index is set to this for opcodes that instantiate a new * direct descriptor (like openat/openat2/accept), then io_uring will allocate diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 7ed1e009aaec..0d26ee1193ca 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3704,6 +3704,13 @@ static int __init io_uring_init(void) /* top 8bits are for internal use */ BUILD_BUG_ON((IORING_URING_CMD_MASK & 0xff000000) != 0); + BUILD_BUG_ON(sizeof(struct io_uring_meta) > + 2 * sizeof(struct io_uring_sqe) - + offsetof(struct io_uring_sqe, cmd)); + + BUILD_BUG_ON(META_TYPE_LAST_BIT > + 8 * sizeof_field(struct io_uring_meta, meta_type)); + io_uring_optable_init(); /* diff --git a/io_uring/rw.c b/io_uring/rw.c index c004d21e2f12..e8f5b5af4d2f 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -23,6 +23,8 @@ #include "poll.h" #include "rw.h" +#define INTEGRITY_VALID_FLAGS (INTEGRITY_CHK_GUARD | INTEGRITY_CHK_APPTAG | \ + INTEGRITY_CHK_REFTAG) struct io_rw { /* NOTE: kiocb has the file as the first member, so don't do it here */ struct kiocb kiocb; @@ -247,6 +249,42 @@ static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) return 0; } +static int io_prep_rw_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe, + struct io_rw *rw, int ddir) +{ + const struct io_uring_meta *md = (struct io_uring_meta *)sqe->cmd; + u16 meta_type = READ_ONCE(md->meta_type); + const struct io_issue_def *def; + struct io_async_rw *io; + int ret; + + if (!meta_type) + return 0; + if (!(meta_type & META_TYPE_INTEGRITY)) + return -EINVAL; + + /* should fit into two bytes */ + BUILD_BUG_ON(INTEGRITY_VALID_FLAGS >= (1 << 16)); + + def = &io_issue_defs[req->opcode]; + if (def->vectored) + return -EOPNOTSUPP; + + io = req->async_data; + io->meta.flags = READ_ONCE(md->meta_flags); + if (io->meta.flags & ~INTEGRITY_VALID_FLAGS) + return -EINVAL; + + io->meta.apptag = READ_ONCE(md->apptag); + ret = import_ubuf(ddir, u64_to_user_ptr(READ_ONCE(md->meta_addr)), + READ_ONCE(md->meta_len), &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + rw->kiocb.ki_flags |= IOCB_HAS_META; + iov_iter_save_state(&io->meta.iter, &io->iter_meta_state); + return ret; +} + static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, int ddir, bool do_import) { @@ -269,11 +307,16 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, rw->kiocb.ki_ioprio = get_current_ioprio(); } rw->kiocb.dio_complete = NULL; + rw->kiocb.ki_flags = 0; rw->addr = READ_ONCE(sqe->addr); rw->len = READ_ONCE(sqe->len); rw->flags = READ_ONCE(sqe->rw_flags); - return io_prep_rw_setup(req, ddir, do_import); + ret = io_prep_rw_setup(req, ddir, do_import); + + if (unlikely(req->ctx->flags & IORING_SETUP_SQE128 && !ret)) + ret = io_prep_rw_meta(req, sqe, rw, ddir); + return ret; } int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe) @@ -400,7 +443,10 @@ static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req) static void io_resubmit_prep(struct io_kiocb *req) { struct io_async_rw *io = req->async_data; + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + if (unlikely(rw->kiocb.ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); iov_iter_restore(&io->iter, &io->iter_state); } @@ -768,8 +814,12 @@ static inline int io_iter_do_read(struct io_rw *rw, struct iov_iter *iter) static bool need_complete_io(struct io_kiocb *req) { + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + + /* Exclude meta IO as we don't support partial completion for that */ return req->flags & REQ_F_ISREG || - S_ISBLK(file_inode(req->file)->i_mode); + S_ISBLK(file_inode(req->file)->i_mode) || + !(rw->kiocb.ki_flags & IOCB_HAS_META); } static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) @@ -786,7 +836,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) if (!(req->flags & REQ_F_FIXED_FILE)) req->flags |= io_file_get_flags(file); - kiocb->ki_flags = file->f_iocb_flags; + kiocb->ki_flags |= file->f_iocb_flags; ret = kiocb_set_rw_flags(kiocb, rw->flags, rw_type); if (unlikely(ret)) return ret; @@ -815,6 +865,14 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) kiocb->ki_complete = io_complete_rw; } + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) { + struct io_async_rw *io = req->async_data; + + if (!(req->file->f_flags & O_DIRECT)) + return -EOPNOTSUPP; + kiocb->private = &io->meta; + } + return 0; } @@ -881,6 +939,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) * manually if we need to. */ iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); do { /* @@ -1091,6 +1151,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); if (kiocb->ki_flags & IOCB_WRITE) io_req_end_write(req); return -EAGAIN; diff --git a/io_uring/rw.h b/io_uring/rw.h index 3f432dc75441..49944b539c51 100644 --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -9,7 +9,14 @@ struct io_async_rw { struct iovec fast_iov; struct iovec *free_iovec; int free_iov_nr; - struct wait_page_queue wpq; + /* wpq is for buffered io, while meta fields are used with direct io*/ + union { + struct wait_page_queue wpq; + struct { + struct uio_meta meta; + struct iov_iter_state iter_meta_state; + }; + }; }; int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); From patchwork Wed Jun 26 10:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712787 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 236B117F50F for ; Wed, 26 Jun 2024 11:43:02 +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=1719402185; cv=none; b=XQmF5QNbW+LuRcd7H8q0m6LA7B1clB4P852IXa63XJ3m6gh/+R+efWqukyn1EaM9Pkfp0Ggg+HJvllKcDvhX69qkuJRpNv6tKeypb8aZPKYZA5uGw1TP+TMMSuC3QkoWiC5PgKf9pRPFhVC8sQ4GUfYDeYK7trW4GUfLfTA41Dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402185; c=relaxed/simple; bh=5jIjcP8xRXDjWvr2WGjD3BoRgUVdc77PFesx1qBBvyI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=XkilnDKjwmtXSE3290o3JqH4vSqoKNfw1TxoeFNU22LdgMQunUUGxG9cANQnQz2cOcggV7I0X9/oMvJmp0RYNb4ux12BUeT1NNzorTnnPdGFXX3MgLA5RgOfX1TySOQsR6NsZ6dlbpWwXGJtoPifgQgKsjwzEg/G/lNESQHk2hE= 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=TWQdpJWS; 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="TWQdpJWS" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240626114300epoutp042d27a9c4d5506b52e1342e2a9df8df60~ciyxaP2bc2386023860epoutp04c for ; Wed, 26 Jun 2024 11:43:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240626114300epoutp042d27a9c4d5506b52e1342e2a9df8df60~ciyxaP2bc2386023860epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402180; bh=Ms96jkmQ0kuaCcPQfmnfod94T8OohipgnI02PQvTjo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWQdpJWSVXt6fwQA668mibYDtcPydd+2U1afNb6JaAAtiQ6PAgYRl7GzYoOEq7EVN jy6Q8RFKI4aDUCDClVHhnYMlXFzDtLMW2jjyLNcEDvIIRsIgD3w+ecY1W0oJ4OCpnP fGR6rcqssCgZIvHfRWfzsLnQcNpRtQe96NAVWWLU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240626114259epcas5p1b6818f7576e9665da59304f5e9b015e4~ciyw6V50m1003510035epcas5p1q; Wed, 26 Jun 2024 11:42:59 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8KZV1NqTz4x9Pq; Wed, 26 Jun 2024 11:42:58 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 36.48.09989.2CEFB766; Wed, 26 Jun 2024 20:42:58 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240626101527epcas5p23e10a6701f552d16bd6a999418009ba0~chmVION0E2207822078epcas5p2-; Wed, 26 Jun 2024 10:15:27 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101527epsmtrp19e14a3ce1656ea45bee13c5af862a824~chmVGgijU1052710527epsmtrp1H; Wed, 26 Jun 2024 10:15:27 +0000 (GMT) X-AuditID: b6c32a4a-e57f970000002705-a4-667bfec2bc8f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.6A.19057.F3AEB766; Wed, 26 Jun 2024 19:15:27 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101525epsmtip1585e16aa5c4eb50dd6c82ce8c3bc9c15~chmTc1YNM0324303243epsmtip16; Wed, 26 Jun 2024 10:15:25 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v2 09/10] block: add support to pass user meta buffer Date: Wed, 26 Jun 2024 15:36:59 +0530 Message-Id: <20240626100700.3629-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrMJsWRmVeSWpSXmKPExsWy7bCmpu6hf9VpBoc/sVg0TfjLbDFn1TZG i9V3+9ksVq4+ymTxrvUci8XR/2/ZLCYdusZosfeWtsX8ZU/ZLZYf/8dkMbHjKpMDt8fOWXfZ PS6fLfXYtKqTzWPzknqP3Tcb2Dw+Pr3F4vF+31U2j74tqxg9Pm+SC+CMyrbJSE1MSS1SSM1L zk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvMAbpVSaEsMacUKBSQWFyspG9n U5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqXrpeXWmJlaGBgZApUmJCdsfFNSEGHRcW2N3uY Ghi36HYxcnJICJhILL25h7mLkYtDSGA3o8SbOZ+YQBJCAp8YJW7+04JIfGOUmNv7nQWm4+m7 1SwQib2MElvfzWOCcD4zSnx+fJ8NpIpNQF3iyPNWRhBbRKBWYmXrdHaQImaBpYwSB3atB0sI C7hKLLm6iB3EZhFQlXg3/yXQIRwcvAKWEnPuOUBsk5eYeek7WAknUPjO5u1grbwCghInZz4B u4gZqKZ562ywHyQE5nJIzFt4hwVkjoSAi8TNUwEQc4QlXh3fwg5hS0m87G+DstMlflx+ygRh F0g0H9vHCGHbS7Se6gc7h1lAU2L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8AO ZQaqb946m3kCo8AsJKlZSFILGJlWMUqmFhTnpucWGxYY5aWW6xUn5haX5qXrJefnbmIER4eW 1g7GPas+6B1iZOJgPMQowcGsJMIbWlKVJsSbklhZlVqUH19UmpNafIhRmoNFSZz32+veFCGB 9MSS1OzU1ILUIpgsEwenVAPTlPyVX7+fPbac321yaWjX/Rtvzs+KvPN5dpvHd1EWWdlvs8pD RD1yXE6p2v58oB7g5jPzxQpV9/ccU8pmNyzY27bR4qnZvqIXa7sWPNc0W8M624Nh8o9tal+3 yZycJMVyYZFXohNfDdvHHwyXt4mc2D2vui1YRf5Lc/PPN5sctjX+XbVMQ6GNaekhteMbvlr1 2B36Fhmm7540+cML153rZ8ncyGdKMXFqMGE9s/qffcXpjV9ZlFqduaUj/llc9wrLa7w9Y4fv t+zr0gccXzBn5U999VJpsuocjpOn8948d18qr/Mq7WLvquMHLmzfe0bgYnfbavf/X1sWJXSZ XL/ziWvjpIb9NsYpEV/nHvPZLaXEUpyRaKjFXFScCACHBxPA/QIAAA== X-CMS-MailID: 20240626101527epcas5p23e10a6701f552d16bd6a999418009ba0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101527epcas5p23e10a6701f552d16bd6a999418009ba0 References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Kanchan Joshi If iocb contains the meta, extract that and prepare the bip. Extend bip so that can it can carry three new integrity-check flags and application tag. Make sure that ->prepare_fn and ->complete_fn are skipped for user-owned meta buffer. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 44 +++++++++++++++++++++++++++++++++++++++++++ block/fops.c | 28 ++++++++++++++++++++++++++- block/t10-pi.c | 6 ++++++ include/linux/bio.h | 10 ++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 38418be07139..599f39999174 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "blk.h" static struct kmem_cache *bip_slab; @@ -337,6 +338,49 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } +static void bio_uio_meta_to_bip(struct bio *bio, struct uio_meta *meta) +{ + struct bio_integrity_payload *bip = bio_integrity(bio); + u16 bip_flags = 0; + + if (meta->flags & INTEGRITY_CHK_GUARD) + bip_flags |= BIP_USER_CHK_GUARD; + if (meta->flags & INTEGRITY_CHK_APPTAG) + bip_flags |= BIP_USER_CHK_APPTAG; + if (meta->flags & INTEGRITY_CHK_REFTAG) + bip_flags |= BIP_USER_CHK_REFTAG; + + bip->bip_flags |= bip_flags; + bip->apptag = meta->apptag; +} + +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); + unsigned int integrity_bytes; + int ret; + struct iov_iter it; + + if (!bi) + return -EINVAL; + /* + * original meta iterator can be bigger. + * process integrity info corresponding to current data buffer only. + */ + it = meta->iter; + integrity_bytes = bio_integrity_bytes(bi, bio_sectors(bio)); + if (it.count < integrity_bytes) + return -EINVAL; + + it.count = integrity_bytes; + ret = bio_integrity_map_user(bio, &it, 0); + if (!ret) { + bio_uio_meta_to_bip(bio, meta); + iov_iter_advance(&meta->iter, integrity_bytes); + } + return ret; +} + int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { diff --git a/block/fops.c b/block/fops.c index be36c9fbd500..6477424b4ebc 100644 --- a/block/fops.c +++ b/block/fops.c @@ -126,12 +126,13 @@ static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; bool should_dirty = dio->flags & DIO_SHOULD_DIRTY; + bool is_async = !(dio->flags & DIO_IS_SYNC); if (bio->bi_status && !dio->bio.bi_status) dio->bio.bi_status = bio->bi_status; if (atomic_dec_and_test(&dio->ref)) { - if (!(dio->flags & DIO_IS_SYNC)) { + if (is_async) { struct kiocb *iocb = dio->iocb; ssize_t ret; @@ -154,6 +155,9 @@ static void blkdev_bio_end_io(struct bio *bio) } } + if (is_async && (dio->iocb->ki_flags & IOCB_HAS_META)) + bio_integrity_unmap_free_user(bio); + if (should_dirty) { bio_check_pages_dirty(bio); } else { @@ -231,6 +235,16 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, } bio->bi_opf |= REQ_NOWAIT; } + if (!is_sync && unlikely(iocb->ki_flags & IOCB_HAS_META)) { + ret = bio_integrity_map_iter(bio, iocb->private); + if (unlikely(ret)) { + bio_release_pages(bio, false); + bio_clear_flag(bio, BIO_REFFED); + bio_put(bio); + blk_finish_plug(&plug); + return ret; + } + } if (is_read) { if (dio->flags & DIO_SHOULD_DIRTY) @@ -288,6 +302,9 @@ static void blkdev_bio_end_io_async(struct bio *bio) ret = blk_status_to_errno(bio->bi_status); } + if (unlikely(iocb->ki_flags & IOCB_HAS_META)) + bio_integrity_unmap_free_user(bio); + iocb->ki_complete(iocb, ret); if (dio->flags & DIO_SHOULD_DIRTY) { @@ -348,6 +365,15 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, task_io_account_write(bio->bi_iter.bi_size); } + if (unlikely(iocb->ki_flags & IOCB_HAS_META)) { + ret = bio_integrity_map_iter(bio, iocb->private); + WRITE_ONCE(iocb->private, NULL); + if (unlikely(ret)) { + bio_put(bio); + return ret; + } + } + if (iocb->ki_flags & IOCB_ATOMIC) bio->bi_opf |= REQ_ATOMIC; diff --git a/block/t10-pi.c b/block/t10-pi.c index cd7fa60d63ff..38c3da245b11 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -131,6 +131,8 @@ static void t10_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; @@ -180,6 +182,8 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) struct bio_vec iv; struct bvec_iter iter; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; void *p; @@ -305,6 +309,8 @@ static void ext_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; diff --git a/include/linux/bio.h b/include/linux/bio.h index 966e22a04996..ff22b627906d 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -330,6 +330,9 @@ enum bip_flags { BIP_INTEGRITY_USER = 1 << 5, /* Integrity payload is user address */ BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ BIP_CLONED = 1 << 7, /* Indicates that bip is cloned */ + BIP_USER_CHK_GUARD = 1 << 8, + BIP_USER_CHK_APPTAG = 1 << 9, + BIP_USER_CHK_REFTAG = 1 << 10, }; struct uio_meta { @@ -349,6 +352,7 @@ struct bio_integrity_payload { unsigned short bip_vcnt; /* # of integrity bio_vecs */ unsigned short bip_max_vcnt; /* integrity bio_vec slots */ unsigned short bip_flags; /* control flags */ + u16 apptag; /* apptag */ struct bvec_iter bio_iter; /* for rewinding parent bio */ @@ -738,6 +742,7 @@ static inline bool bioset_initialized(struct bio_set *bs) bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta); void bio_integrity_unmap_free_user(struct bio *bio); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); @@ -817,6 +822,11 @@ static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, return -EINVAL; } +static inline int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + return -EINVAL; +} + static inline void bio_integrity_unmap_free_user(struct bio *bio) { } From patchwork Wed Jun 26 10:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712788 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 9D76217FAD5 for ; Wed, 26 Jun 2024 11:43:05 +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=1719402187; cv=none; b=e6fbxGljVKSjVKZHxQX84a9Hz/7Fr1uiKxNGgPPt+gN4BKcnV2uz8+rL3p854/GaiL1QTp/bFPNL8PXkmXxUt9B0QFglDJbTXGNHvnnrEAmAVwUU/n/WwPlg8YDjb/8kEAZqYV5OEqAZKidYb2rpdgmQYuWSalr5bd9WSfIzhK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402187; c=relaxed/simple; bh=BR6YcHCHB1ivRnqbuz3YxQ4s/sYhuuun8DuDqSP5tr4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=oaUHDKvvCVs5PuEZjMA5zC+S1ZNldsdZn8/YST0NgULe3Vd/nIIH2Ze18tVqU7xHRG37erel5yQhPSJb+aVbm9uyhYdHk8u2gp0ARb99rvRAKDHK+dilrHZTmEyNzdqIlsOMbMFMVo+dHzl8Mp/x0ljAHeD5a35oQHdPZ2KczYc= 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=DvznAlIs; 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="DvznAlIs" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240626114303epoutp043e15f10d07f6069d59f2b2346b8cca21~ciy0N0I6Y2316323163epoutp044 for ; Wed, 26 Jun 2024 11:43:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240626114303epoutp043e15f10d07f6069d59f2b2346b8cca21~ciy0N0I6Y2316323163epoutp044 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402183; bh=8L/mX8O6BFJO/aguMkBtonWEoWBnd7DsBSRj6RxPZwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvznAlIs9UqqQJ6VYiRGTQeuIL+sVKtUYCJn325AgNl/3rUvDhWUoEgTdONJwJK9g NHH12vhlGL0LSeZ8iw+Q56J2uwbzP1blJsEUYHIriTl3Jvk3Y5lXiF2JOe4oMBVl5U AFfaDVFAg09iwDtAo74Asv1fz6G+3KduFpGCl2sE= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240626114302epcas5p35cf1dce423571350bd5b717f6e19a8e8~ciyzyVQun2534525345epcas5p3F; Wed, 26 Jun 2024 11:43:02 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8KZY09f7z4x9Px; Wed, 26 Jun 2024 11:43:01 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id BD.95.19174.4CEFB766; Wed, 26 Jun 2024 20:43:00 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240626101529epcas5p49976c46701337830c400cefd8f074b40~chmW58ILl2295722957epcas5p45; Wed, 26 Jun 2024 10:15:29 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240626101529epsmtrp284792c42758cdf9b87c024ce28673c1a~chmW5ITko1237112371epsmtrp2i; Wed, 26 Jun 2024 10:15:29 +0000 (GMT) X-AuditID: b6c32a50-87fff70000004ae6-41-667bfec42212 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.04.07412.14AEB766; Wed, 26 Jun 2024 19:15:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101527epsmtip1f357ba9816aaf746029621e642cca8bf~chmVN_59n0370603706epsmtip1I; Wed, 26 Jun 2024 10:15:27 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi Subject: [PATCH v2 10/10] nvme: add handling for user integrity buffer Date: Wed, 26 Jun 2024 15:37:00 +0530 Message-Id: <20240626100700.3629-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@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+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmlu6Rf9VpBu37zC3mrNrGaLH6bj+b xcrVR5ks3rWeY7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tK8FeBknTLT19tYsVd8o/Tq0pxPpiH79uhdM/vMvs7jPnea woRJ6w2Pdi1PSHquOlXk7vwzSizFGYmGWsxFxYkA2SNuovoCAAA= X-CMS-MailID: 20240626101529epcas5p49976c46701337830c400cefd8f074b40 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101529epcas5p49976c46701337830c400cefd8f074b40 References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Kanchan Joshi Create a new helper that contains the handling for both kernel and user generated integrity buffer. For user provided integrity buffer, convert bip flags (guard/reftag/apptag checks) to protocol specific flags. Also pass apptag and reftag down. Signed-off-by: Kanchan Joshi --- drivers/nvme/host/core.c | 85 ++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index ab0429644fe3..d17428a2b1dd 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -870,6 +870,13 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct nvme_command *cmnd, u16 apptag) +{ + cmnd->rw.apptag = cpu_to_le16(apptag); + /* use 0xfff as mask so that apptag is used in entirety*/ + cmnd->rw.appmask = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -927,6 +934,55 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns, return BLK_STS_OK; } +static blk_status_t nvme_setup_rw_meta(struct nvme_ns *ns, struct request *req, + struct nvme_command *cmnd, u16 *control, + enum nvme_opcode op) +{ + struct bio_integrity_payload *bip = bio_integrity(req->bio); + + if (!bip || !(bip->bip_flags & BIP_INTEGRITY_USER)) { + /* + * If formated with metadata, the block layer always provides a + * metadata buffer if CONFIG_BLK_DEV_INTEGRITY is enabled. Else + * we enable the PRACT bit for protection information or set the + * namespace capacity to zero to prevent any I/O. + */ + if (!blk_integrity_rq(req)) { + if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head))) + return BLK_STS_NOTSUPP; + *control |= NVME_RW_PRINFO_PRACT; + } + + switch (ns->head->pi_type) { + case NVME_NS_DPS_PI_TYPE3: + *control |= NVME_RW_PRINFO_PRCHK_GUARD; + break; + case NVME_NS_DPS_PI_TYPE1: + case NVME_NS_DPS_PI_TYPE2: + *control |= NVME_RW_PRINFO_PRCHK_GUARD | + NVME_RW_PRINFO_PRCHK_REF; + if (op == nvme_cmd_zone_append) + *control |= NVME_RW_APPEND_PIREMAP; + nvme_set_ref_tag(ns, cmnd, req); + break; + } + } else { + unsigned short bip_flags = bip->bip_flags; + + if (bip_flags & BIP_USER_CHK_GUARD) + *control |= NVME_RW_PRINFO_PRCHK_GUARD; + if (bip_flags & BIP_USER_CHK_REFTAG) { + *control |= NVME_RW_PRINFO_PRCHK_REF; + nvme_set_ref_tag(ns, cmnd, req); + } + if (bip_flags & BIP_USER_CHK_APPTAG) { + *control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(cmnd, bip->apptag); + } + } + return 0; +} + /* * NVMe does not support a dedicated command to issue an atomic write. A write * which does adhere to the device atomic limits will silently be executed @@ -963,6 +1019,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, { u16 control = 0; u32 dsmgmt = 0; + blk_status_t ret; if (req->cmd_flags & REQ_FUA) control |= NVME_RW_FUA; @@ -990,31 +1047,9 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, cmnd->rw.appmask = 0; if (ns->head->ms) { - /* - * If formated with metadata, the block layer always provides a - * metadata buffer if CONFIG_BLK_DEV_INTEGRITY is enabled. Else - * we enable the PRACT bit for protection information or set the - * namespace capacity to zero to prevent any I/O. - */ - if (!blk_integrity_rq(req)) { - if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head))) - return BLK_STS_NOTSUPP; - control |= NVME_RW_PRINFO_PRACT; - } - - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: - control |= NVME_RW_PRINFO_PRCHK_GUARD; - break; - case NVME_NS_DPS_PI_TYPE1: - case NVME_NS_DPS_PI_TYPE2: - control |= NVME_RW_PRINFO_PRCHK_GUARD | - NVME_RW_PRINFO_PRCHK_REF; - if (op == nvme_cmd_zone_append) - control |= NVME_RW_APPEND_PIREMAP; - nvme_set_ref_tag(ns, cmnd, req); - break; - } + ret = nvme_setup_rw_meta(ns, req, cmnd, &control, op); + if (unlikely(ret)) + return ret; } cmnd->rw.control = cpu_to_le16(control);