From patchwork Thu Nov 28 11:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887939 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 4F891199234 for ; Thu, 28 Nov 2024 11:45:53 +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=1732794355; cv=none; b=s2QX/RTjllKTmdxDX5t/SJ2CPr9L1v8fZdWyjuw0I8NX1AoGtD7PA9YisNkbnsoKC7cHYsDDXF16UcpGtGKzb/QnDFguf6cUTXh+PJtA8wz6HTSA2ECOFbMWDfluQWjOTxkNRLIRsP/Gwi/Oh/Cu5rU0CKN8F52XbOg2M/HIaHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794355; c=relaxed/simple; bh=z3oZCEUpNWP6ssVVNnvaEMGwTgZ5HxAO2xsIC7OVOu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=phLZzWnxIaB9iihVaB14kXGcRsDC1jCdmkyLuBwBq/zREYSzhleqFmcTtHyOf8KWCxpImRF646RTjBZ7J4JAJy3mkSQk6KafZiGPhTqHkcgEGCLn2pjTK6dWvlbpqlIgblMcjx+RX3Gpu04XQWLY5SABu8PKmx1R9P68s6Jg3E4= 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=Ve7TH4UT; 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="Ve7TH4UT" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241128114545epoutp01cfd794bed0f44b9104e79eddb6e17990~MH0bSt0R02993029930epoutp01B for ; Thu, 28 Nov 2024 11:45:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241128114545epoutp01cfd794bed0f44b9104e79eddb6e17990~MH0bSt0R02993029930epoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794345; bh=n6LNHR2UxOEOGCqUSfrJ4D/dcAXYHqklNM5hsVN/lLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ve7TH4UTrjaoxzxaVyMJPYLKmL3vANY90GJjHN+VnY21CbYuMJrOdMJegkLXxCz78 bT852QMNgL9IvFwKsR4cPeX6OCa0jPz5njFOjVb0Q09Pw1/v/S0UD/3nNcQcMORfFo Xc5AF2u9oz9dV4iU1+xJcpUmaThhDslPikwBw/Gg= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241128114545epcas5p315c08a232c61583b6ce602548eb40a87~MH0avYkSY0770307703epcas5p3G; Thu, 28 Nov 2024 11:45:45 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4XzZJ737Jcz4x9Pq; Thu, 28 Nov 2024 11:45:43 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B2.5F.20052.7E758476; Thu, 28 Nov 2024 20:45:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241128113056epcas5p2c9278736c88c646e6f3c7480ffb2211f~MHneuWfpJ0944809448epcas5p2b; Thu, 28 Nov 2024 11:30:56 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241128113055epsmtrp125914b31a9851fd5bfa2fbb23d18fb34~MHnetfzXq0051900519epsmtrp1w; Thu, 28 Nov 2024 11:30:55 +0000 (GMT) X-AuditID: b6c32a49-3fffd70000004e54-5f-674857e7096b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 50.58.33707.F6458476; Thu, 28 Nov 2024 20:30:55 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113053epsmtip25c3e70b93be3b37eee03a79d53577f2a~MHnceONJ52429524295epsmtip2f; Thu, 28 Nov 2024 11:30:53 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v11 01/10] block: define set of integrity flags to be inherited by cloned bip Date: Thu, 28 Nov 2024 16:52:31 +0530 Message-Id: <20241128112240.8867-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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: H4sIAAAAAAAA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ozuLiK2lzhSHG5blM9 RfQn68qEgywd3N7aCds3l7053HJli6+46Qm5aVxXX3ZouTn6dalUCjekh100SyrzL7ges8n5 24HZoncEZobFndXbPPfXk6mSti4zvgRnOva/NU5jqN76Y89rJRmnb9GSbDXOIVfOhy/jaxZ0 KK95EPn09Ixwjd9nb++TXXuF+UxYqfO7+59nBPm+3xAlEPh0VXGc4SXH2Y6sp3R+C2oG1Cqx FGckGmoxFxUnAgALE1Q0HgMAAA== X-CMS-MailID: 20241128113056epcas5p2c9278736c88c646e6f3c7480ffb2211f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113056epcas5p2c9278736c88c646e6f3c7480ffb2211f References: <20241128112240.8867-1-anuj20.g@samsung.com> Introduce BIP_CLONE_FLAGS describing integrity flags that should be inherited in the cloned bip from the parent. Suggested-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Keith Busch --- block/bio-integrity.c | 2 +- include/linux/bio-integrity.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 2a4bd6611692..a448a25d13de 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -559,7 +559,7 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vec = bip_src->bip_vec; 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_CLONE_FLAGS; return 0; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index dbf0f74c1529..0f0cf10222e8 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -30,6 +30,9 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + #ifdef CONFIG_BLK_DEV_INTEGRITY #define bip_for_each_vec(bvl, bip, iter) \ From patchwork Thu Nov 28 11:22:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887940 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 834DA19AD8B for ; Thu, 28 Nov 2024 11:45:57 +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=1732794359; cv=none; b=T1znoa0OwMeu/aPn5REvsZP4fO1ssWiAVhBgM+TW4lJFgim7u19xzj5WTINbrCplUE8HMc3D9r9KZbrICYqkbJVoQBf2qjxJVCiO3oHb+KpiDyQa76B9+21CZhH4ieVO0CvJrflW1+ODUPHVP21B06CvVPJFvI0TS3tRRyOkok0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794359; c=relaxed/simple; bh=g2fp64Elfp9R80cl3zu6i89Ehrxw1OCNHe/eXuK93qM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=XUa20qcIeyTgZN2fcd2chzNtpyObkimgOdIIjs25sst7VNS2GYKVBJvn4SGbX+KgpQqq9Am94wC1/zFGbSCjzjF5PJyiTYe9YE0U9rQrBZBXtrj7iBuGg0BLMCaxAJieAnZQBZd7SPZX7kxXMA9jApC3DDcexs9R0ZlksRpKnm4= 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=r2RGuylJ; 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="r2RGuylJ" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241128114555epoutp026fcafc63c5a3e0b145b6036c5f2d2f83~MH0kRIQne1279812798epoutp02C for ; Thu, 28 Nov 2024 11:45:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241128114555epoutp026fcafc63c5a3e0b145b6036c5f2d2f83~MH0kRIQne1279812798epoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794355; bh=FQM1oME+yjLcszh/NNdlGeevLgEVh+e4WfItNIpaOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2RGuylJhHYpxtovtgeiOV8PXusomywuf6dxPTVuD7qsu6x25+7l7nupUO0uQQ9pS OHWViXD4dn1uwF+hGKT964g+3kF8H2ksy5TYSS56ykSi0C8e+yC4l4xHaoBiZVsoYf 8I0Is1T8TEBRReviGiuH7+NbR6lBo6nN4uTI3C+c= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241128114554epcas5p2c9df787ad8145e598d3817c5db00bcca~MH0jhfO8m1857618576epcas5p28; Thu, 28 Nov 2024 11:45:54 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.182]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XzZJH2fn4z4x9Pr; Thu, 28 Nov 2024 11:45:51 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E6.B3.19710.FE758476; Thu, 28 Nov 2024 20:45:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94~MHnhJguS-1316913169epcas5p1r; Thu, 28 Nov 2024 11:30:58 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113058epsmtrp2b79823e07685711bd53938c807451bc2~MHnhIiCRN3231632316epsmtrp2k; Thu, 28 Nov 2024 11:30:58 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-81-674857efef9e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 32.58.33707.27458476; Thu, 28 Nov 2024 20:30:58 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113056epsmtip211016eab1dc2a7836a08fd9d6c853c49~MHne1hoN12660826608epsmtip2H; Thu, 28 Nov 2024 11:30:56 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v11 02/10] block: copy back bounce buffer to user-space correctly in case of split Date: Thu, 28 Nov 2024 16:52:32 +0530 Message-Id: <20241128112240.8867-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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+NgFrrNJsWRmVeSWpSXmKPExsWy7bCmuu77cI90g4mX+S0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBaTDl1jtNh7S9tiz96TLBbz lz1lt+i+voPNYvnxf0wW5/8eZ7U4P2sOu4Ogx85Zd9k9Lp8t9di0qpPNY/OSeo/dNxvYPD4+ vcXi0bdlFaPHmQVH2D0+b5Lz2PTkLVMAV1S2TUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGh rqGlhbmSQl5ibqqtkotPgK5bZg7QO0oKZYk5pUChgMTiYiV9O5ui/NKSVIWM/OISW6XUgpSc ApMCveLE3OLSvHS9vNQSK0MDAyNToMKE7IzPs5uYClbzVaxqmMbWwDiJp4uRk0NCwETi0LJ9 TF2MXBxCArsZJe70nGeFcD4xShy5fpgFzunpOcII03LqxUtmiMRORomXB3awQzifGSXuT/vN BlLFJqAuceR5KyNIQkRgD6NE78LTYLOYBV4ySixdtYgFpEpYIEXi/J+P7CA2i4CqxI0Ph8G6 eQUsJFa8PcEKsU9eYual72A1nAKWErOvfWOFqBGUODnzCdgcZqCa5q2zwW6SEDjDIfF8dSvU sS4Sb479YIKwhSVeHd/CDmFLSXx+t5cNwk6X+HH5KVRNgUTzsX1QvfYSraf6gYZyAC3QlFi/ Sx8iLCsx9dQ6Joi9fBK9v59AtfJK7JgHYytJtK+cA2VLSOw91wBle0g8vLeKDRJcPcAQ7rjM NIFRYRaSf2Yh+WcWwuoFjMyrGCVTC4pz01OTTQsM81LL4RGdnJ+7iRGcyrVcdjDemP9P7xAj EwfjIUYJDmYlEd4Cbvd0Id6UxMqq1KL8+KLSnNTiQ4ymwACfyCwlmpwPzCZ5JfGGJpYGJmZm ZiaWxmaGSuK8r1vn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NTk0tSC2CyTJxcEo1MNno pP9VfOB4/6PV8fkHMidMq/31/YhhS8TkefkXdXw77f5L+Lq4zBSZ+tfrDUOziqPV6ivvueXX VuxnDbE8t7pr2d0/fNaXPfQjUy4vKO8VZ5R8+28+w/LQqbEa29bPcg97f7x+wZ5JLypdn701 1dXY8XiughXPK6fu9Nd3Cti/Xr8cnH176ez1h65rvH+imfFRo5TVVPbs5ML0zeJ+CxSNln/s OznzaLesdOPm+JrreessCuc5HNkmdJDxIH/Liqf5SWd+vShvCVp+LsDkSu8B/jTPeRt1TatF 5zQJHAi133D8Zoe05LslTUaHRMTOr3okrexjNv2yReZhH7NDAms7Q0onyXLu/1IpOv2ac4oS S3FGoqEWc1FxIgB2wfXMHwMAAA== X-CMS-MailID: 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94 References: <20241128112240.8867-1-anuj20.g@samsung.com> From: Christoph Hellwig Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers") Signed-off-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Keith Busch --- block/bio-integrity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index a448a25d13de..4341b0d4efa1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { - 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; - struct iov_iter iter; + unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1; + struct bio_vec *orig_bvecs = &bip->bip_vec[1]; + struct bio_vec *bounce_bvec = &bip->bip_vec[0]; + size_t bytes = bounce_bvec->bv_len; + struct iov_iter orig_iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true); } /** From patchwork Thu Nov 28 11:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887941 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 4371419CC24 for ; Thu, 28 Nov 2024 11:46:02 +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=1732794364; cv=none; b=OHL5DoFNqKlwJ3KJM6qLK2laIB2fw2pXvhrrRh8UnXPDVvP+qCcztz37AAGuFYvOXwoNHpKbFBtBxUnLNh0keP4ljKyDA+fTyI5btniWmgmpmsGQplY2G2jSuQnprsuHJ2fCFEO17Bm6QyH0e52pUVSoKtvS95tWT1/RqcpaXGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794364; c=relaxed/simple; bh=ZIkdyJlOm3c2bE0cQ6pelSYB5Gra8HNzZg1GmGSloUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=SoIpGb8Qkl8Y7J9cN1LKTCCsAYIG4RWK38uUmdHNOhL+mk2iksC8iENugTeBah01tHmEiML+W5Svkj27wcqdDVYeC+0uO1Sbr4R/3hvlOl8iWarrPe2FIuatFOejonfA7uHjEiZJh2CqChuMAE5cWPi4COaij8gdSFPaOWOkt+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=Q2unj1Sh; 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="Q2unj1Sh" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241128114600epoutp01feebf5cea24b1ecb6f3aecb87c66778d~MH0o9kwWW2980929809epoutp01J for ; Thu, 28 Nov 2024 11:46:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241128114600epoutp01feebf5cea24b1ecb6f3aecb87c66778d~MH0o9kwWW2980929809epoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794360; bh=r23oSTZl50mKsH838ytL5lDlNxkmkMYy4oR7U1Ruz2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2unj1ShZtgvlk2yRO3idObv1vytSo5DVSiniR/4MNoGEBz4drzVLN8SJAzjiUerv rSF1W7R9Lh+xKqCYVFcxBmFME/oZga+nJIfzlHtfy4wqgBBEvpQgbZN+y33FNYIrwm x4IKDB0m0AqN/CxB/wFUPEihRz2atHUKDOPyWQzI= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241128114559epcas5p4de7b1ade7af45ae9ef8be4d17549089f~MH0oL_Y7l1496914969epcas5p4W; Thu, 28 Nov 2024 11:45:59 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XzZJP6Fj4z4x9Pp; Thu, 28 Nov 2024 11:45:57 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D1.6F.20052.5F758476; Thu, 28 Nov 2024 20:45:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241128113101epcas5p3fefab67892c16c7bbaba8063c5c4a2c1~MHnjpWL2V2753027530epcas5p3_; Thu, 28 Nov 2024 11:31:01 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113101epsmtrp22eed36114a530ac46f9ef1b852596c9f~MHnjoKm1w0053700537epsmtrp2k; Thu, 28 Nov 2024 11:31:01 +0000 (GMT) X-AuditID: b6c32a49-3fffd70000004e54-79-674857f59385 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id FD.4E.18949.57458476; Thu, 28 Nov 2024 20:31:01 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113058epsmtip24543a12bd1e65a89a01572043324f0af~MHnhO3wlj2509525095epsmtip2V; Thu, 28 Nov 2024 11:30:58 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v11 03/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Thu, 28 Nov 2024 16:52:33 +0530 Message-Id: <20241128112240.8867-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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+NgFrrHJsWRmVeSWpSXmKPExsWy7bCmlu7XcI90gycbDS0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZzx98ZmpYI9cxe7LHg2M2yS7GDk5JARM JG5N2MLUxcjFISSwm1Fi3oxNbBDOJ0aJmS9vMEM43xglzr78xwbTMvfoUqjEXkaJ5iO3oPo/ M0ocXPofrIpNQF3iyPNWRpCEiMAeRonehadZQBxmgQlMEu0T57CDVAkLJEjM6lnMDGKzCKhK nDn/iwXE5hWwkNhx4wQrxD55iZmXvoPVcwpYSsy+9o0VokZQ4uTMJ2D1zE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/ipCxCUkTr1cxghhC0us/PecvYuRC6jmI6NE T8NcdpAEm4C6xJHnrWBFIgInGCXmT3QDKWIWmMEk0fNrBRtIQlggTuLOpIlgDSwCqhJnzv9i AbF5BSwkdtw4wQqxQV5i5qXvYDWcApYSs699Y4W4yELi8uPrrBD1ghInZz4B62UGqm/eOpt5 AqPALCSpWUhSCxiZVjFKphYU56bnFhsWGOWllusVJ+YWl+al6yXn525iBMebltYOxj2rPugd YmTiYDzEKMHBrCTCW8Dtni7Em5JYWZValB9fVJqTWnyIUZqDRUmc99vr3hQhgfTEktTs1NSC 1CKYLBMHp1QD04oefuHpb1vcQs8Fb7pUvUw0/h7jVp66HoGlOrsCV1Q/1tdkK36u2slQe9l5 c7K6/dMpNn4fLRcmd4cETTvTxxOxcHlb5L7l2acXuh/4eJBp97b3n2ycA+ucCpIVtFeIrOwP bSu79j1B9hvfQZbiq7nemQYmfuvsTbS/cKba7TaXv2d6cOd2BanZG9ifLfTvlfFRr2Zd23HB j+tQ1XmLRQYLFX+ve6juZnVy7+uN5X/tlhTHnsyIP75r+ok1hppb7keeZV5ik5fa/cDu3ucL UUnqNhNCl1+94qKosmYZy9fai4o2wRwnNkjnvzw+c67eCQYhRQe2zeXnH3/9skBFtPzKx2qG 137Ru455LDqTrMRSnJFoqMVcVJwIAFS07ZImAwAA X-CMS-MailID: 20241128113101epcas5p3fefab67892c16c7bbaba8063c5c4a2c1 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113101epcas5p3fefab67892c16c7bbaba8063c5c4a2c1 References: <20241128112240.8867-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 Reviewed-by: Keith Busch --- block/bio-integrity.c | 12 +++++------- block/blk-integrity.c | 10 +++++++++- include/linux/bio-integrity.h | 5 ++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 4341b0d4efa1..f56d01cec689 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -302,16 +302,15 @@ 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) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = blk_lim_dma_alignment_and_pad(&q->limits); 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)) @@ -324,8 +323,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) { @@ -335,8 +333,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/block/blk-integrity.c b/block/blk-integrity.c index b180cac61a9d..4a29754f1bc2 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -115,8 +115,16 @@ EXPORT_SYMBOL(blk_rq_map_integrity_sg); int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, ssize_t bytes) { - int ret = bio_integrity_map_user(rq->bio, ubuf, bytes); + int ret; + struct iov_iter iter; + unsigned int direction; + if (op_is_write(req_op(rq))) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, ubuf, bytes); + ret = bio_integrity_map_user(rq->bio, &iter); if (ret) return ret; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 0f0cf10222e8..58ff9988433a 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -75,7 +75,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr); int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -101,8 +101,7 @@ static inline void bioset_integrity_free(struct bio_set *bs) { } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len) +static int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) { return -EINVAL; } From patchwork Thu Nov 28 11:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887942 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 D97B719C54E for ; Thu, 28 Nov 2024 11:46:07 +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=1732794370; cv=none; b=V9C3TuBsfcYXAtGAmxd0Q+B4SKf2xH5ZNOA8mK2F0IyRskchcASomrtuiuE0VqNt7/Kvg6MJb86oDq0vqgcaXZ+vR13dR02SQpULwlSmq3hkrsEV77vYkC+1LoOq2+L4LsVGQykbWQKNf+tjN/MWTR2eIHlKEBFg+1MvDwtjd4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794370; c=relaxed/simple; bh=uDUb87C52DXoVA3KvOoAoNEyjHqrw30MJR/Iqxaidaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=JpLN/og2gpY7Pc3MiDfX3GTIDmwJSokt87WhPFb6S6rpuRYXrNAWZUBacGxrcA8w9uu72zir5idHCKIl9AqC333bkQ6KT89INYLYcL7MgqOXaAslXBKx1oXUpPTuzoP7nDlMEdRTLSq69F/nK5RSq9yL/ExJJivmQphfaCO4U0M= 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=uMtaylQL; 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="uMtaylQL" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241128114606epoutp04eb88a88d01c4176ced9e6a4e1487ed86~MH0uYMS6g1096710967epoutp04B for ; Thu, 28 Nov 2024 11:46:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241128114606epoutp04eb88a88d01c4176ced9e6a4e1487ed86~MH0uYMS6g1096710967epoutp04B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794366; bh=sPCiH7C8otAPeKBQxafGfpBc//4CVwTtOappMXTNYFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMtaylQLnoirBb+DALUMMNs1Sq6fESXvIKCK1CfhBlWipmk573SecHhPh+FWPF4Mi Q3qR+G9hFjKwCCsvxBX9xaiuvAO60ZJw/vP/bGrZ6qc5tjhQQwd+muNC2DRbpuHQAh AUW3uuKGooTmrDIcg/N3O5D31I+c+VmKhoEiK3ys= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241128114605epcas5p1cec9fb18659d8b581ddfd082482705c0~MH0tcaPjF1146111461epcas5p1h; Thu, 28 Nov 2024 11:46:05 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4XzZJW2JG3z4x9Pw; Thu, 28 Nov 2024 11:46:03 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 23.29.29212.BF758476; Thu, 28 Nov 2024 20:46:03 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241128113104epcas5p4c4bd9f936403295e4cbac7c1f52d9b30~MHnmLIkgM1913419134epcas5p4B; Thu, 28 Nov 2024 11:31:03 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241128113103epsmtrp142fbee2b6480ba49bc6b2a5d7da9e078~MHnmIgq-70051900519epsmtrp1R; Thu, 28 Nov 2024 11:31:03 +0000 (GMT) X-AuditID: b6c32a50-7ebff7000000721c-d0-674857fbb6d9 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 12.5E.18949.77458476; Thu, 28 Nov 2024 20:31:03 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113101epsmtip2c8b97814a32da798b63cc7169b26c181~MHnjvILQO2660826608epsmtip2P; Thu, 28 Nov 2024 11:31:01 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v11 04/10] fs, iov_iter: define meta io descriptor Date: Thu, 28 Nov 2024 16:52:34 +0530 Message-Id: <20241128112240.8867-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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+NgFrrHJsWRmVeSWpSXmKPExsWy7bCmpu7vcI90g99nuC0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGR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filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113104epcas5p4c4bd9f936403295e4cbac7c1f52d9b30 References: <20241128112240.8867-1-anuj20.g@samsung.com> Add flags to describe checks for integrity meta buffer. Also, introduce a new 'uio_meta' structure that upper layer can use to pass the meta/integrity information. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- include/linux/uio.h | 9 +++++++++ include/uapi/linux/fs.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/uio.h b/include/linux/uio.h index 853f9de5aa05..8ada84e85447 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -82,6 +82,15 @@ struct iov_iter { }; }; +typedef __u16 uio_meta_flags_t; + +struct uio_meta { + uio_meta_flags_t flags; + u16 app_tag; + u64 seed; + struct iov_iter iter; +}; + static inline const struct iovec *iter_iov(const struct iov_iter *iter) { if (iter->iter_type == ITER_UBUF) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..9070ef19f0a3 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -40,6 +40,15 @@ #define BLOCK_SIZE_BITS 10 #define BLOCK_SIZE (1< X-Patchwork-Id: 13887943 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 E1F1819DF4A for ; Thu, 28 Nov 2024 11:46:10 +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=1732794372; cv=none; b=W6v1OLmXA+gddrVBZAhR8Ahqp9+RWc3WZ6KAvEDBPGQf62yqMDDP9IY3rT4ap9JkbCr0jnqfHk/7DmDnTcf9ie0CuTvXOLPWOgc3xUII5VMylhGlB+jsyzK9AQUmgUM/WcBFv0kAb+MsdJXUrowYEs3FrlzZcDBR31zj6PXYjtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794372; c=relaxed/simple; bh=mlLpOADJdimbzMrJqxVCIky165ZgGg3a+54zC1LiT88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=rczqMS962yuzz4syty0O/T50rRPHy+RIynt2h/RqNuq1hQK+LnQDFtDXvR5nts3/TMjsf76QBgL59Wouso2u/906KiiGzWY4jAHhWTqZ7/Y+D8WV9azhaG8QMrOISvhrzH/F9xiaUUd4GF9faGBk9SgIiVDORKVRjz4ioNEPtIU= 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=JzLRZu9i; 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="JzLRZu9i" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241128114609epoutp04bf045647eacc4f0c949ed79bb6c98c5a~MH0xFUXVl1139711397epoutp04k for ; Thu, 28 Nov 2024 11:46:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241128114609epoutp04bf045647eacc4f0c949ed79bb6c98c5a~MH0xFUXVl1139711397epoutp04k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794369; bh=cRuOygxyfLjl7ybgQ+EVk9IvCIBAqSeYwRZ/zr1tr/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JzLRZu9ihGM6g1beIxWgzgI5b0ZoECOIlcbkGAf4edK8wugmOSwVFL27tKcQ+oJci CUj1LAkSGkpVharDM4exT0ZuOMNY1qbUypvBWCpaJN/S/9KzehiJuO8gbTiIrNyjU/ eq42oGTDSXLf7UR0C+JfP1slhwbmE/+i/50imHZE= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241128114608epcas5p19b71a782a4aaf32b6af0939969df31a4~MH0woohAk2942729427epcas5p1x; Thu, 28 Nov 2024 11:46:08 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XzZJb1LSxz4x9Pr; Thu, 28 Nov 2024 11:46:07 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9B.B3.19710.FF758476; Thu, 28 Nov 2024 20:46:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241128113106epcas5p1b5b06683bfa72225f3c1ab102b9f361c~MHnok8sA41555015550epcas5p1s; Thu, 28 Nov 2024 11:31:06 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113106epsmtrp2ce54218dc402e02bcb6731b7b6bf72f8~MHnokAPLv0091000910epsmtrp2a; Thu, 28 Nov 2024 11:31:06 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-9f-674857fee0ec Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E4.5E.18949.A7458476; Thu, 28 Nov 2024 20:31:06 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113104epsmtip27d46969dee4538ebbdc537c9a941345f~MHnmQAdcM2660826608epsmtip2Q; Thu, 28 Nov 2024 11:31:03 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v11 05/10] fs: introduce IOCB_HAS_METADATA for metadata Date: Thu, 28 Nov 2024 16:52:35 +0530 Message-Id: <20241128112240.8867-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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: H4sIAAAAAAAAA01Tf0xTVxTe7WtfH2VdHj+2XZoI9WVG+U2l1FsiY4l1PMeSQYYhWaLwhLcW KG1ti05jsrrKFphMQIVQioA61BK3gIggrY7CVkHFicqAhG0usIkEEn46wurW0ur877vnfOd8 5zv3XgILHsFFRIHGyOo1jJrCBdzOvsjI2H+zaWXCchuG5pfXuOiLSjeGrLZOgFonTuBopm8B oLEfujnoUuuPHDRXOsRF9bVmDqp2jgDkGI9GdscAFzW2TPHR17904eiC6zkH3XO7eOiexcp/ L4jutkzw6Qd3S+h2WxlOXzn/Od0zZsLp+alxLv1Nhw3Qd5r6+fRiezjdPjnLyRB8UrRdxTL5 rF7MavK0+QUaZQqV/nHOjpwkWYIkViJH2yixhilmUyjFhxmx7xeoPXYo8QFGXeIJZTAGAxX/ 7na9tsTIilVagzGFYnX5ap1UF2dgig0lGmWchjUmSxIStiZ5iLlFqgXXBZ7uIe+zAdsqZgIj 3HIQQEBSCi8u9GLlQEAE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H7ZgObx8en t1g8+rasYvQ4s+AIu8fnTXIem568ZQrgiuKySUnNySxLLdK3S+DK+HR8OWvBFdaKk6t+Mjcw XmPpYuTkkBAwkXgy6yB7FyMXh5DAbkaJ1t872CASEhKnXi5jhLCFJVb+ew5V9JFRYuvc16wg CTYBdYkjz1vBikQETjBKzJ/oBlLEDFI04ctssBXCAu4SP1csBurm4GARUJX49kIWJMwrYCHx 7PBeJogF8hIzL31nB7E5BSwlZl/7BjZfCKjm8uPrrBD1ghInZz4BG8kMVN+8dTbzBEaBWUhS s5CkFjAyrWKUTC0ozk3PLTYsMMpLLdcrTswtLs1L10vOz93ECI4zLa0djHtWfdA7xMjEwXiI UYKDWUmEt4DbPV2INyWxsiq1KD++qDQntfgQozQHi5I477fXvSlCAumJJanZqakFqUUwWSYO TqkGpnj/NUfKv+w2+ZMjUKGzUiFWbOucDx5nnBh/eO09sD05XN87+c6vUMlp19zULJY9+7dw Dd+enyyn1gm5sF/9fDr67ea/sWyRjnL7eM00YxgkW50ET6653f4z19h2arids/SL4E13t2ww vzpbZ8kWn3U3tuxeKHbO7oz0lv4SpSlrftQvb90YGqx1ZI7zioM3zxbKa2ywOxA06WXvBu5N dc13Fi+NDj2QbOj/svFl1xfZWGl/5qO5F2LeHNlzrERZuEasa+MhmUWO56MLcqMXf0iNC63i DnqjqlsZdWBZ4g7PI01q1S7sqUUxPsKnM6002p4fOpWYWaS+6oBwS2/F3q1qxwIXdP35Jjt5 9okvB5VYijMSDbWYi4oTAaMA8ZgiAwAA X-CMS-MailID: 20241128113106epcas5p1b5b06683bfa72225f3c1ab102b9f361c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113106epcas5p1b5b06683bfa72225f3c1ab102b9f361c References: <20241128112240.8867-1-anuj20.g@samsung.com> Introduce an IOCB_HAS_METADATA flag for the kiocb struct, for handling requests containing meta payload. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- include/linux/fs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 7e29433c5ecc..2cc3d45da7b0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -348,6 +348,7 @@ struct readahead_control; #define IOCB_DIO_CALLER_COMP (1 << 22) /* kiocb is a read or write operation submitted by fs/aio.c. */ #define IOCB_AIO_RW (1 << 23) +#define IOCB_HAS_METADATA (1 << 24) /* for use in trace events */ #define TRACE_IOCB_STRINGS \ From patchwork Thu Nov 28 11:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887944 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 CF61E19DF8B for ; Thu, 28 Nov 2024 11:46:15 +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=1732794377; cv=none; b=FK9ClSPDg7dmEifAqx93cSP04DpEb6//GRuUXds8d5+sSOGppYSu9LHY8HACUyQTIK3DCoqjxujTl1WPgszdQ8m66tYe4r2AENSc7OCETsBkodr0rmDBfQDJPrH57AsLBWe7ISvlLOp/hpqgtvwPVEOzd1J1T4WjcDChFwxYwDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794377; c=relaxed/simple; bh=5J3NXYra2/YxPZxu5qRQTtUikmlmRPaCldNiAhVHLLQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=Nh1ZFmcBYyIGNLCVjgiKqtGJFIGgu3Oc2hvA2JySYZe73JuDGQz7WbmaHF8A0aEa8b4OHIlxA3KvrwdzJGu6wuV7JY6paT/Dm5ggtsDYQbdLeuXgtH4QV9YU0kREsH2o+l493NdUuAGQ9Vn/Q3h387TDzDQrmf8vQ9xWw/RavOE= 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=pLogFCxh; 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="pLogFCxh" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241128114613epoutp01c9f585f2f07f4d42cf566b7a53707854~MH01cZBbM2993029930epoutp01Q for ; Thu, 28 Nov 2024 11:46:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241128114613epoutp01c9f585f2f07f4d42cf566b7a53707854~MH01cZBbM2993029930epoutp01Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794373; bh=282tku0al61IXFMRfq2A0Kwta4pxflaZcBhYE+AaiEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLogFCxhynHZyXGhC8S3ai9ccMcmCcUAOide6FOdRJJ2nERsYKE1Nv6dBotXjV8Xx 3vQ8upIHIKgXH9QlJo+T4gGxJhhJ1cPqVQ7S+YvFVz6ok3ZA7XKzhz2bBwwhKW42gJ 5PzZdHs9BnnLueLyoLvoTdCZ8/HI0qwwMOHQXv9A= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241128114613epcas5p3bbeff532cffe0119eed07eb0e2dccff3~MH00841Rg2826028260epcas5p3k; Thu, 28 Nov 2024 11:46:13 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XzZJg6jyKz4x9Py; Thu, 28 Nov 2024 11:46:11 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.29.29212.30858476; Thu, 28 Nov 2024 20:46:11 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241128113109epcas5p46022c85174da65853c85a8848b32f164~MHnrNiK-T1913419134epcas5p4d; Thu, 28 Nov 2024 11:31:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241128113109epsmtrp18368a72fd836e00ec7ed9d4dd183dc91~MHnrMBRWd0066100661epsmtrp1y; Thu, 28 Nov 2024 11:31:09 +0000 (GMT) X-AuditID: b6c32a50-801fa7000000721c-e3-674858030750 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 56.0D.18729.D7458476; Thu, 28 Nov 2024 20:31:09 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113106epsmtip2d1db4db4999be4111c857546de05b560~MHnoodbys2693826938epsmtip2F; Thu, 28 Nov 2024 11:31:06 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v11 06/10] io_uring: introduce attributes for read/write and PI support Date: Thu, 28 Nov 2024 16:52:36 +0530 Message-Id: <20241128112240.8867-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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: H4sIAAAAAAAAA02Te0xTVxzHOfeW9tKtcFcwO2EZIzcuGxoexbYeOhEFHzcZmJppNrcEdqU3 BSlt04duZGPdClN0hdKIxBYUsmUqsBewCs4agjwmAt1EYRgQWdpsijjBAJOHW0vL5n+f8zvf 3/eb33kQuHCCG03kqw2sTs2oKC6f47waFxePv0Mrk05ZktHM3BIHfWZdwVFNgxOgxvEKLpq6 OgvQaEc7hi40dmPoYekgBzmqzRjq/meai2ydwwC5bm9El13XOOjs114eOjHSxkXnep9iyL3S G4rc9hreNiHdbh/n0UMDRrq5oYxLt3z1Cf3TqIlLz3hvc+jy1gZA99d18ejHzTF0s2cak/Pf LdiSxzIKVhfLqnM1iny1MpV6862cjByJNEkUL0pBm6lYNVPIplI7MuXxu/JVvpmo2MOMyugr yRm9nkrcukWnMRrY2DyN3pBKsVqFSivWJuiZQr1RrUxQswaZKCkpWeITvl+Q9+iElad1pn3Q tPBlqAnUbjoOwghIiuH1RhP3OOATQvIygGZzOQgsZgGceODgBBbzAHrOevC1ll8HvFhgwwXg 79VLof4NIfkYwPPncv3MJV+DXX+UrlpF+X0t9ddXrXDSisGjlTU8vyqSPACPPWnF/MwhX4WL LTOrEQISQet4CS8Q9wo8fWNhlcPIFOgYng8NaF6A1057OH7GfRrzjw7cHwDJMQJ6vGPB5h3w SosNBDgS3u9tDdaj4b2Kz4OshH8PebEAa6G550pQnwZL+yp8poQvIA5+dykxUH4ZVvV9iwVy w6FlyRNsFcC2M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mExYQmxmovnnr bOYJjAKzkKRmIUktYGRaxSiZWlCcm55bbFhgmJdarlecmFtcmpeul5yfu4kRHHNamjsYt6/6 oHeIkYmD8RCjBAezkghvAbd7uhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe8Re9KUIC6Yklqdmp qQWpRTBZJg5OqQamTL3Tz3PNxYQ+TN/ab1J8/3pj7vIbuTKbEzMfee5R8ZpYnmx+rjKDYf39 m9vbdZsu7Zwq4XR7gop1ayhrTudPv093exmdGp/v+KtlcnWnrV3C0kusTQlvpKyqJ0qnxkdN +5x9avXlexFFpzcyvW+et+Z7Ya/9udc9F/Z+dpBe6rDo+c5XkkevOu1jmfLKWn/HJJFGMYH/ BqZVq633C8Vempkht1CoK3JyAEe1jTNTSLR6i3C4WuH1E/ZVTk82hTzc/VGN5z33/E6/xbad Ql25V/b88eJJs5p9vUzgpiRzt2luUPGyfy+O3JZW4uYpO1woGjdt2iWhljD2PPHCNRsbZKw/ f97PvPM+X7j26ftKLMUZiYZazEXFiQAQ1UYJKAMAAA== X-CMS-MailID: 20241128113109epcas5p46022c85174da65853c85a8848b32f164 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113109epcas5p46022c85174da65853c85a8848b32f164 References: <20241128112240.8867-1-anuj20.g@samsung.com> Add the ability to pass additional attributes along with read/write. Application can prepare attibute specific information and pass its address using the SQE field: __u64 attr_ptr; Along with setting a mask indicating attributes being passed: __u64 attr_type_mask; Overall 64 attributes are allowed and currently one attribute 'IORING_RW_ATTR_FLAG_PI' is supported. With PI attribute, userspace can pass following information: - flags: integrity check flags IO_INTEGRITY_CHK_{GUARD/APPTAG/REFTAG} - len: length of PI/metadata buffer - addr: address of metadata buffer - seed: seed value for reftag remapping - app_tag: application defined 16b value Process this information to prepare uio_meta_descriptor and pass it down using kiocb->private. PI attribute is supported only for direct IO. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/uapi/linux/io_uring.h | 16 +++++++ io_uring/io_uring.c | 2 + io_uring/rw.c | 83 ++++++++++++++++++++++++++++++++++- io_uring/rw.h | 14 +++++- 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index aac9a4f8fa9a..38f0d6b10eaf 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -98,6 +98,10 @@ struct io_uring_sqe { __u64 addr3; __u64 __pad2[1]; }; + struct { + __u64 attr_ptr; /* pointer to attribute information */ + __u64 attr_type_mask; /* bit mask of attributes */ + }; __u64 optval; /* * If the ring is initialized with IORING_SETUP_SQE128, then @@ -107,6 +111,18 @@ struct io_uring_sqe { }; }; +/* sqe->attr_type_mask flags */ +#define IORING_RW_ATTR_FLAG_PI (1U << 0) +/* PI attribute information */ +struct io_uring_attr_pi { + __u16 flags; + __u16 app_tag; + __u32 len; + __u64 addr; + __u64 seed; + __u64 rsvd; +}; + /* * 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 06ff41484e29..e4891f1ce52d 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3893,6 +3893,8 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); BUILD_BUG_SQE_ELEM(48, __u64, addr3); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); + BUILD_BUG_SQE_ELEM(48, __u64, attr_ptr); + BUILD_BUG_SQE_ELEM(56, __u64, attr_type_mask); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); BUILD_BUG_ON(sizeof(struct io_uring_files_update) != diff --git a/io_uring/rw.c b/io_uring/rw.c index 0bcb83e4ce3c..04e4467ab0ee 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -257,11 +257,53 @@ static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) return 0; } +static inline void io_meta_save_state(struct io_async_rw *io) +{ + io->meta_state.seed = io->meta.seed; + iov_iter_save_state(&io->meta.iter, &io->meta_state.iter_meta); +} + +static inline void io_meta_restore(struct io_async_rw *io, struct kiocb *kiocb) +{ + if (kiocb->ki_flags & IOCB_HAS_METADATA) { + io->meta.seed = io->meta_state.seed; + iov_iter_restore(&io->meta.iter, &io->meta_state.iter_meta); + } +} + +static int io_prep_rw_pi(struct io_kiocb *req, struct io_rw *rw, int ddir, + u64 attr_ptr, u64 attr_type_mask) +{ + struct io_uring_attr_pi pi_attr; + struct io_async_rw *io; + int ret; + + if (copy_from_user(&pi_attr, u64_to_user_ptr(attr_ptr), + sizeof(pi_attr))) + return -EFAULT; + + if (pi_attr.rsvd) + return -EINVAL; + + io = req->async_data; + io->meta.flags = pi_attr.flags; + io->meta.app_tag = pi_attr.app_tag; + io->meta.seed = pi_attr.seed; + ret = import_ubuf(ddir, u64_to_user_ptr(pi_attr.addr), + pi_attr.len, &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + rw->kiocb.ki_flags |= IOCB_HAS_METADATA; + io_meta_save_state(io); + return ret; +} + static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, int ddir, bool do_import) { struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); unsigned ioprio; + u64 attr_type_mask; int ret; rw->kiocb.ki_pos = READ_ONCE(sqe->off); @@ -279,11 +321,28 @@ 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(ret)) + return ret; + + attr_type_mask = READ_ONCE(sqe->attr_type_mask); + if (attr_type_mask) { + u64 attr_ptr; + + /* only PI attribute is supported currently */ + if (attr_type_mask != IORING_RW_ATTR_FLAG_PI) + return -EINVAL; + + attr_ptr = READ_ONCE(sqe->attr_ptr); + ret = io_prep_rw_pi(req, rw, ddir, attr_ptr, attr_type_mask); + } + return ret; } int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe) @@ -409,7 +468,9 @@ 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); + io_meta_restore(io, &rw->kiocb); iov_iter_restore(&io->iter, &io->iter_state); } @@ -744,6 +805,10 @@ static bool io_rw_should_retry(struct io_kiocb *req) if (kiocb->ki_flags & (IOCB_DIRECT | IOCB_HIPRI)) return false; + /* never retry for meta io */ + if (kiocb->ki_flags & IOCB_HAS_METADATA) + return false; + /* * just use poll if we can, and don't attempt if the fs doesn't * support callback based unlocks @@ -794,7 +859,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; @@ -828,6 +893,18 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) kiocb->ki_complete = io_complete_rw; } + if (kiocb->ki_flags & IOCB_HAS_METADATA) { + struct io_async_rw *io = req->async_data; + + /* + * We have a union of meta fields with wpq used for buffered-io + * in io_async_rw, so fail it here. + */ + if (!(req->file->f_flags & O_DIRECT)) + return -EOPNOTSUPP; + kiocb->private = &io->meta; + } + return 0; } @@ -902,6 +979,7 @@ 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); + io_meta_restore(io, kiocb); do { /* @@ -1125,6 +1203,7 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + io_meta_restore(io, kiocb); 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..2d7656bd268d 100644 --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -2,6 +2,11 @@ #include +struct io_meta_state { + u32 seed; + struct iov_iter_state iter_meta; +}; + struct io_async_rw { size_t bytes_done; struct iov_iter iter; @@ -9,7 +14,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 io_meta_state meta_state; + }; + }; }; int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); From patchwork Thu Nov 28 11:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887945 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 D238C19ABCB for ; Thu, 28 Nov 2024 11:46:20 +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=1732794383; cv=none; b=WlM4bNgRhEiptbnOLRDUBzuGGD2Xr9Bz4JiApfGFk53fQW+TaTfcffRgUQa6oSQPxk8/1OLg6kTZYC0f9EyTFevNW6lVdzXZK2KSbglqHIxt4c3Cc9Km0JK7Yz5b3cuDH+m9ep6OnJoGclLZE5wdlLI4Ey7vQT1y7GtkZ/a7ZKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794383; c=relaxed/simple; bh=4bwNPqd2mgS/me72gS6c9qKx3N7iAIorybNdKO8yxVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=MO/tELRXk4Rde/nagW6foEH3/XcaDIuBmS//cGfR8Olb0Xg7B98YWIwPD7kH9ffw+cs3I0U+q6o7CHBN22a1fvgaxgmoFsK+oq6dg9VKuSCL4AzPb5bFsvMBpP0nBwPAy7l0dkdLm+gQ5KBUQ69ai5NpbeyzcZuxGJCE4SEHLRI= 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=F3Y1uDVN; 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="F3Y1uDVN" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241128114618epoutp03f6b36c52a55823602e49d5f7d00c4bf4~MH06TeAfm3197531975epoutp03O for ; Thu, 28 Nov 2024 11:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241128114618epoutp03f6b36c52a55823602e49d5f7d00c4bf4~MH06TeAfm3197531975epoutp03O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794379; bh=1yhnn/JEQDkJO7MPiDYhPt3P6x3KI+3HedoJWLZAeh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F3Y1uDVNHO04Ku4DjWtzVtqj3/wnub/RCvMqJ8tlBpb8ctucKLggP+FU/ATCXPE50 Vd6my0dIOwzW2b+LLx8hoZw1nwPUtnu7EEtr1f4skmA0wo8XNUWdBZrc7GC1bBCC5+ c5Ls2Z/Dwaclt2ldUBqnIDId+V9icFnvlhDBwvew= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241128114618epcas5p3f9f6ccf5ec4f291d7f4098c9d987ebaa~MH052gaEm0106501065epcas5p3T; Thu, 28 Nov 2024 11:46:18 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XzZJm5NH1z4x9Py; Thu, 28 Nov 2024 11:46:16 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id AE.29.29212.80858476; Thu, 28 Nov 2024 20:46:16 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241128113112epcas5p186ef86baaa3054effb7244c54ee2f991~MHntuBwUR1791917919epcas5p1c; Thu, 28 Nov 2024 11:31:12 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113112epsmtrp25d1f830f2feb39b0e70c41359d978bd0~MHntswlK40091000910epsmtrp2i; Thu, 28 Nov 2024 11:31:12 +0000 (GMT) X-AuditID: b6c32a50-801fa7000000721c-f1-67485808a646 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A8.0D.18729.F7458476; Thu, 28 Nov 2024 20:31:11 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113109epsmtip2bdc64c13144c3424731d23c2f580c086~MHnrRmIYR2660826608epsmtip2V; Thu, 28 Nov 2024 11:31:09 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v11 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Thu, 28 Nov 2024 16:52:37 +0530 Message-Id: <20241128112240.8867-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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: H4sIAAAAAAAAA02Tf1DTZRzHe77fL9sXdN13E+WRLprfjhCLsenAB3HhqcXXgpxweOVZ6+v4 3uAY224/KqurGYcmQfw6MjdKZ5zGxjlaalCM+CmHpYYSApdG3SAPDkw5ocOI9ovyv9fned7v 5/PjeR4SF43xYslCnZkz6lgtzYsiLnQnJiSRLzMaafdAPLp7/wGBPqhaxFG98wJArpuVPDTV fQ+gkY5WDDW6ejE0U3qFQPZjJRjqXZrmoZquIYC8o0+jNm8/gU6cHuejj2608NCZvn8wdHWx LwJdtdXzt4mYVttNPnP9soXxOI/ymK8b3me+G7HymLvjowTz8TknYH482cNnZj1xjMc3jSmj 9hVtLeDYfM4o5nRqfX6hTqOgX8xV7VClpEplSbI0tJkW69hiTkHvzFImPV+o9fdEi99gtRb/ kpI1mejkZ7ca9RYzJy7Qm8wKmjPkaw1yg8TEFpssOo1Ex5m3yKTSjSl+4etFBZW9I8Awsfat +VovYQVnVpeBSBJSctjoGybKQBQpotoA/OTXwXBwD8CBP6f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OqTjaPzUvqPXbf bGDz+Pj0FotH35ZVjB5nFhxh9/i8Sc5j05O3TAFcUVw2Kak5mWWpRfp2CVwZ/UdvMhY8k6z4 PnkvSwPjctEuRk4OCQETiTW3Oli6GLk4hAR2M0rcuf+EFSIhIXHq5TJGCFtYYuW/5+wQRR8Z JSaf28QMkmATUJc48rwVrEhE4ASjxPyJbiBFzAIzmCR6fq1gA0kICwRL7GybwgJiswioSkxd tB5oAwcHr4CFxPFlnhAL5CVmXvrODmJzClhKzL72DewIIaCSy4+vg9m8AoISJ2c+ARvDDFTf vHU28wRGgVlIUrOQpBYwMq1ilEwtKM5Nzy02LDDMSy3XK07MLS7NS9dLzs/dxAiOOC3NHYzb V33QO8TIxMF4iFGCg1lJhLeA2z1diDclsbIqtSg/vqg0J7X4EKM0B4uSOK/4i94UIYH0xJLU 7NTUgtQimCwTB6dUA5OF6vZOac1bjvZz1BRePnr/tYztdv370z5Pdx/N//gz+uH/zVG+0a2P J9pW553hXL5NRfwal36Sxq7fd3S2vFJ2flOfon/dQ+/wnykblmnIPjgtq8W7/LBT6V2TNeaO D0pKWb2cT+1M9VG7VL3S0P0m/+/GK2ufqtYLFjR3e3J9/an10D3ZSMn3+fwsjsCcEpudn764 NSlZltzaWnp+mbWAed/JQx5+LyN8mZP1r3666fSpjMu/i+Upt9Drifuq34ezepQvfMT/+NnO zJlzDu6R0zO/Jfrb0HPN5jP2Xz84+IZEKc6ZfqVcn23udNOnG4TSXLbGnv73/dyH4C/z/065 UHPomW1R8pQ40a7rZgxKLMUZiYZazEXFiQCST9uyJwMAAA== X-CMS-MailID: 20241128113112epcas5p186ef86baaa3054effb7244c54ee2f991 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113112epcas5p186ef86baaa3054effb7244c54ee2f991 References: <20241128112240.8867-1-anuj20.g@samsung.com> This patch introduces BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags which indicate how the hardware should check the integrity payload. BIP_CHECK_GUARD/REFTAG are conversion of existing semantics, while BIP_CHECK_APPTAG is a new flag. The driver can now just rely on block layer flags, and doesn't need to know the integrity source. Submitter of PI decides which tags to check. This would also give us a unified interface for user and kernel generated integrity. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 11 +++-------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index f56d01cec689..3bee43b87001 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -434,6 +434,11 @@ bool bio_integrity_prep(struct bio *bio) if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) bip->bip_flags |= BIP_IP_CHECKSUM; + /* describe what tags to check in payload */ + if (bi->csum_type) + bip->bip_flags |= BIP_CHECK_GUARD; + if (bi->flags & BLK_INTEGRITY_REF_TAG) + bip->bip_flags |= BIP_CHECK_REFTAG; if (bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)) < len) { printk(KERN_ERR "could not attach integrity payload\n"); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 40e7be3b0339..e4e3653c27fb 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1017,18 +1017,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_PRINFO_PRACT; } - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: + if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD)) 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 (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) { + control |= NVME_RW_PRINFO_PRCHK_REF; if (op == nvme_cmd_zone_append) control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); - break; } } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 58ff9988433a..fe2bfe122db2 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -11,6 +11,9 @@ enum bip_flags { BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 6, /* guard check */ + BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ }; struct bio_integrity_payload { @@ -31,7 +34,8 @@ struct bio_integrity_payload { }; #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Thu Nov 28 11:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887946 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 4267219E998 for ; Thu, 28 Nov 2024 11:46:24 +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=1732794386; cv=none; b=JnW1zCP1xYnpvApsWUo/BwNhJJkTzbMUfm+pJqFGhra5+vSbRS/6WB4KxKLc4cCYpq/jko9s5XANIbyUVGS12Cqdy6kbsscC+o6noELjhV+b491icXLXwkrIG02LEjSy3rviN/q+rtWCEPM4/WD/IQf4NeO3nCndNgL6H0sU+FI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794386; c=relaxed/simple; bh=R0ISA8yY2JMwXPEw3NvAC6mLoQ+w67YWfMlsx0QA4Ss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=URNSh+LolzFYUAWegj9SGIdbVTR5DUNpWyMp75r68Nnz4zLHe/AjRs5emlI5jV16fHtSD2CLGKL2zhT24xvM4dtsUAiJ8rGT1Npx8ZhGXdTkwukWEVP+0oXIy7MVK6/kYUrQrBWuY9lhE0GaNaumdQswuPWqMQCRB8etUc4JeT4= 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=KuFCgKXz; 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="KuFCgKXz" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241128114622epoutp02ee50f97d7fde7232d4aea9c8ba74128e~MH09rdTvC1279912799epoutp02U for ; Thu, 28 Nov 2024 11:46:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241128114622epoutp02ee50f97d7fde7232d4aea9c8ba74128e~MH09rdTvC1279912799epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794382; bh=fOhAPjepG8IxDxWR0+S1vjp4KvMbiHG0tXmeE420F+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KuFCgKXzp1SsDif2l+hjopVG6RLMKOUAVxFGf7S7lm8uOZtoK3GEV9cEqak5aJ2tR /GAb2hnLhD7czwYPtiU2T6bqP1dUVTXQtnC9pQObzCqxud+G637+SN1iO7IZcC0D/j Vh6yHqXbqwjLQZCreqfTmFUA2jRqIWCeLNKDPcVg= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241128114622epcas5p27eed31a1a09e6201c42b3f54b0b14231~MH09VMcTr1842118421epcas5p28; Thu, 28 Nov 2024 11:46:22 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XzZJr50Mjz4x9Pv; Thu, 28 Nov 2024 11:46:20 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B1.C3.19710.C0858476; Thu, 28 Nov 2024 20:46:20 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241128113114epcas5p29c7e2a71a136cb50c636a9fe5d87bb0b~MHnwUalBa1770017700epcas5p2Y; Thu, 28 Nov 2024 11:31:14 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113114epsmtrp22a238ddd34832bc52d6039fb95e1e7e7~MHnwTesv90090800908epsmtrp2q; Thu, 28 Nov 2024 11:31:14 +0000 (GMT) X-AuditID: b6c32a44-363dc70000004cfe-c0-6748580c7014 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C8.5E.18949.28458476; Thu, 28 Nov 2024 20:31:14 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113112epsmtip2d2c774c38c40fa32e0b86c84bfc4bcd7~MHntznqrO2086720867epsmtip2h; Thu, 28 Nov 2024 11:31:12 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v11 08/10] nvme: add support for passing on the application tag Date: Thu, 28 Nov 2024 16:52:38 +0530 Message-Id: <20241128112240.8867-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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: H4sIAAAAAAAAA01TfUxbVRzdfa+0D7DsrTC5orLmJZsBB7RCy0UHnY6wpxhlbMlQiayhz0Io bdPXbtOoa4Z1H44NFgmugICZGyuOGWB8uJUiX834WgKMAZE5DOgmsq3gBlKHtn2g++/87j3n d+753XsJXDTJDyNytUbGoFVqKH4Ar6kzIiLqqQxaLWme24JcD908dLjoMY7KbU0A1U6e4qPZ znmAxttbMXShthtD9yyDPFRWWoCh7n/m+Oh0xyhA9okX0VX7NR6qPDcjQF/cbOGj884VDF1/ 7PRD163lgu0iutU6KaCHB0x0ve0Yn244e4i+Mm7m066ZCR59stEG6P6qLgG9UB9O10/PYWkB 7+Zty2GUKsYgZrTZOlWuVp1Ipe7O2pElk0ukUdIEFE+Jtcp8JpFKfjMtK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Filter-Loop: Reflected X-CMS-RootMailID: 20241128113114epcas5p29c7e2a71a136cb50c636a9fe5d87bb0b References: <20241128112240.8867-1-anuj20.g@samsung.com> From: Kanchan Joshi With user integrity buffer, there is a way to specify the app_tag. Set the corresponding protocol specific flags and send the app_tag down. Reviewed-by: Christoph Hellwig Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Keith Busch --- drivers/nvme/host/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e4e3653c27fb..571d4106d256 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -885,6 +885,12 @@ 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 request *req, struct nvme_command *cmnd) +{ + cmnd->rw.lbat = cpu_to_le16(bio_integrity(req->bio)->app_tag); + cmnd->rw.lbatm = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -1025,6 +1031,10 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); } + if (bio_integrity_flagged(req->bio, BIP_CHECK_APPTAG)) { + control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(req, cmnd); + } } cmnd->rw.control = cpu_to_le16(control); From patchwork Thu Nov 28 11:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887947 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 AF22D19AD8B for ; Thu, 28 Nov 2024 11:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794390; cv=none; b=MJPJEkSdacbrFAIlrBMoNvpA8UDTRafSAZXaAcqtYGmk7MI5Ca+ezXOKRUDDDXftNWXxkHxDCw7selZvLCuPRv59ZT3XjwmyuTo0dhtRUJYOWkp+/bnp7vekSqu3f7OnkNHPPqXV2r0bsQEr66J2olvp+WoYu1TV9OeRZEjBsBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794390; c=relaxed/simple; bh=wf16SXbPE7IKcuRRSTK3G6OqCzknXrmBf1Mn0Cr7weM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=d5LL8lDICANQS0KnV8TpY11CYh9IPkgeA+H10/E5PfdDPPAGnK32oK08HugGdPihyyPHdkw2fAm35irobiitDBjnnSweQHyEr/VZjWKFldJ5Eumuj+FqRB/cA4MpeQxHuHyl1PnyvWXJC6lfpWE1CEauEGjPZz4wL6TH+mc31vg= 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=cTuRySV7; 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="cTuRySV7" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241128114627epoutp022012b61f974890d7366dc43b32382a29~MH1B7731u1307013070epoutp02I for ; Thu, 28 Nov 2024 11:46:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241128114627epoutp022012b61f974890d7366dc43b32382a29~MH1B7731u1307013070epoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794387; bh=DV5DBIpEJMoashvJk+4uhGWWufd3TPgC6b7DXtx2rfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cTuRySV7DlvhvJbVsB0nUI0Jc49zWMChkx1O2QVNG8iicrx8xvH6qFcWH2Kl5l1vi IjJjNHXlmuwyfNIO6+tpbyjhEsdp2wTy9imzuyG/tIogt+GYKZtogukrdH1dD28GI3 VabQuy12fi5pfGKRzTOfe77r7UQJuDvSH7eS9NXw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241128114626epcas5p1c79a7d04daa6cf1c04dbe201992990a5~MH1BhLDsc0896108961epcas5p1H; Thu, 28 Nov 2024 11:46:26 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.174]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XzZJx3KsGz4x9Pt; Thu, 28 Nov 2024 11:46:25 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id C1.39.29212.11858476; Thu, 28 Nov 2024 20:46:25 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241128113117epcas5p3b0387c302753c5424ba410f5b38ddeb9~MHnypyjjI2977029770epcas5p3Z; Thu, 28 Nov 2024 11:31:17 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241128113117epsmtrp19dfd1807f91694943717847289ec2216~MHnyoz-sR0066100661epsmtrp1D; Thu, 28 Nov 2024 11:31:17 +0000 (GMT) X-AuditID: b6c32a50-7ebff7000000721c-fe-67485811ff12 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 1A.5E.18949.58458476; Thu, 28 Nov 2024 20:31:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113114epsmtip21bde63d90efc764733812a48cb33dd6b~MHnwYXNXU2084920849epsmtip2i; Thu, 28 Nov 2024 11:31:14 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v11 09/10] scsi: add support for user-meta interface Date: Thu, 28 Nov 2024 16:52:39 +0530 Message-Id: <20241128112240.8867-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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+NgFrrNJsWRmVeSWpSXmKPExsWy7bCmhq5ghEe6wcy9ohYfv/5msWia8JfZ Ys6qbYwWq+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJotJh64xWuy9pW2xZ+9JFov5 y56yW3Rf38Fmsfz4PyaL83+Ps1qcnzWH3UHQY+esu+wel8+Wemxa1cnmsXlJvcfumw1sHh+f 3mLx6NuyitHjzIIj7B6fN8l5bHrylimAKyrbJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ 19DSwlxJIS8xN9VWycUnQNctMwfoHSW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b38ddeb9 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113117epcas5p3b0387c302753c5424ba410f5b38ddeb9 References: <20241128112240.8867-1-anuj20.g@samsung.com> Add support for sending user-meta buffer. Set tags to be checked using flags specified by user/block-layer. With this change, BIP_CTRL_NOCHECK becomes unused. Remove it. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 4 ++-- include/linux/bio-integrity.h | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8947dab132d7..cb7ac8736b91 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -814,14 +814,14 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, if (bio_integrity_flagged(bio, BIP_IP_CHECKSUM)) scmd->prot_flags |= SCSI_PROT_IP_CHECKSUM; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_GUARD)) scmd->prot_flags |= SCSI_PROT_GUARD_CHECK; } if (dif != T10_PI_TYPE3_PROTECTION) { /* DIX/DIF Type 0, 1, 2 */ scmd->prot_flags |= SCSI_PROT_REF_INCREMENT; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_REFTAG)) scmd->prot_flags |= SCSI_PROT_REF_CHECK; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index fe2bfe122db2..2195bc06dcde 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -7,13 +7,12 @@ enum bip_flags { BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */ BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */ - BIP_CTRL_NOCHECK = 1 << 2, /* disable HBA integrity checking */ - BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ - BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ - BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ - BIP_CHECK_GUARD = 1 << 6, /* guard check */ - BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ - BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ + BIP_DISK_NOCHECK = 1 << 2, /* disable disk integrity checking */ + BIP_IP_CHECKSUM = 1 << 3, /* IP checksum */ + BIP_COPY_USER = 1 << 4, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 5, /* guard check */ + BIP_CHECK_REFTAG = 1 << 6, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 7, /* apptag check */ }; struct bio_integrity_payload { @@ -33,8 +32,7 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; -#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_IP_CHECKSUM | \ BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Thu Nov 28 11:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887948 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 0D81319CC24 for ; Thu, 28 Nov 2024 11:46:33 +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=1732794395; cv=none; b=gWJic12dk6kGauAxr+DTX1Jj2r8J0akmacWNxRYXY9D9mzOVv0l4lKZIkU+nwVn0uucKNAiJgUWpjXciwrwrM5MRBuv9Mdx8ELQ9c52kUlKjIBQ3DTzFDNSQ8wt7E9knWvMF4gcJ42GX1QcBr+qT5i2s47ZpPbCzkyT51j+FLso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794395; c=relaxed/simple; bh=kEqfDPfi0xZPoMx7TbXTPzl3V67dpIdB/wO9T8QGsD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=plIr5WyDlSlpPg3zVmnQUiIMCuiVktyw7hRFdXjMANyBxqO0bRl40FgOc/VMEHvn7a4hrcPPWyE0k8h/4o7PH7AtVNFHj3c3Dat30/oZnPJsZlyDhAE8jUTZ37R+jdcWc38YiDfEwmWdW0wb/MdLPjnk5v2v9nf2MO13klzNroc= 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=vBSD/cGu; 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="vBSD/cGu" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241128114632epoutp02ed8369d9cac65708252103e8538c5e8f~MH1GttaPT1307013070epoutp02L for ; Thu, 28 Nov 2024 11:46:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241128114632epoutp02ed8369d9cac65708252103e8538c5e8f~MH1GttaPT1307013070epoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794392; bh=d7IuD/yxn+cNW60OVSwUUjLSGF7ezLOBWTKcR1ap47Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBSD/cGuPXdNYoc2oCmQOSKikC7TQfg5dtAe821TM5qqv0eem9qNMsE0PERik59jr JBEOAJelK41a33oW89N1Ryxo1Wo/fJsVoHpoA11mxx9bcvRPq6f8amkrCmAzKcmhFA iCS9BVMrJBylzUCCgFEq6FF6NyPtHFT6lJgygYew= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241128114631epcas5p17b378bbf8f41f4d6f91d9e4032f4a1ec~MH1GTxa743041830418epcas5p1B; Thu, 28 Nov 2024 11:46:31 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.178]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4XzZK20WNzz4x9Pq; Thu, 28 Nov 2024 11:46:30 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 1E.6A.19956.51858476; Thu, 28 Nov 2024 20:46:29 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241128113120epcas5p3bd415b5a09b3d5b793cbdda0b4102a62~MHn1O4bZj2976029760epcas5p32; Thu, 28 Nov 2024 11:31:20 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241128113120epsmtrp192704f60e46ce0995d3c92d7924b2b06~MHn1M6lbu0066100661epsmtrp1K; Thu, 28 Nov 2024 11:31:20 +0000 (GMT) X-AuditID: b6c32a4b-fe9f470000004df4-75-67485815dcf7 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CB.0D.18729.88458476; Thu, 28 Nov 2024 20:31:20 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113117epsmtip2b6d67c9095883ad831492e3125ab3f15~MHnyv0CSu2086720867epsmtip2k; Thu, 28 Nov 2024 11:31:17 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v11 10/10] block: add support to pass user meta buffer Date: Thu, 28 Nov 2024 16:52:40 +0530 Message-Id: <20241128112240.8867-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-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+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmuq5ohEe6wYJdVhYfv/5msWia8JfZ Ys6qbYwWq+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJouj/9+yWUw6dI3RYu8tbYs9 e0+yWMxf9pTdovv6DjaL5cf/MVmc/3uc1eL8rDnsDkIeO2fdZfe4fLbUY9OqTjaPzUvqPXbf bGDz+Pj0FotH35ZVjB5nFhxh9/i8Sc5j05O3TAFcUdk2GamJKalFCql5yfkpmXnptkrewfHO 8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUA/KSmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0ts lVILUnIKTAr0ih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APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113120epcas5p3bd415b5a09b3d5b793cbdda0b4102a62 References: <20241128112240.8867-1-anuj20.g@samsung.com> From: Kanchan Joshi If an iocb contains metadata, extract that and prepare the bip. Based on flags specified by the user, set corresponding guard/app/ref tags to be checked in bip. Reviewed-by: Christoph Hellwig Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Keith Busch --- block/bio-integrity.c | 50 +++++++++++++++++++++++++++++++++++ block/fops.c | 45 ++++++++++++++++++++++++------- include/linux/bio-integrity.h | 7 +++++ 3 files changed, 92 insertions(+), 10 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 3bee43b87001..5d81ad9a3d20 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -364,6 +364,55 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) return ret; } +static void bio_uio_meta_to_bip(struct bio *bio, struct uio_meta *meta) +{ + struct bio_integrity_payload *bip = bio_integrity(bio); + + if (meta->flags & IO_INTEGRITY_CHK_GUARD) + bip->bip_flags |= BIP_CHECK_GUARD; + if (meta->flags & IO_INTEGRITY_CHK_APPTAG) + bip->bip_flags |= BIP_CHECK_APPTAG; + if (meta->flags & IO_INTEGRITY_CHK_REFTAG) + bip->bip_flags |= BIP_CHECK_REFTAG; + + bip->app_tag = meta->app_tag; +} + +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; + + /* should fit into two bytes */ + BUILD_BUG_ON(IO_INTEGRITY_VALID_FLAGS >= (1 << 16)); + + if (meta->flags && (meta->flags & ~IO_INTEGRITY_VALID_FLAGS)) + return -EINVAL; + + it.count = integrity_bytes; + ret = bio_integrity_map_user(bio, &it); + if (!ret) { + bio_uio_meta_to_bip(bio, meta); + bip_set_seed(bio_integrity(bio), meta->seed); + iov_iter_advance(&meta->iter, integrity_bytes); + meta->seed += bio_integrity_intervals(bi, bio_sectors(bio)); + } + return ret; +} + /** * bio_integrity_prep - Prepare bio for integrity I/O * @bio: bio to prepare @@ -564,6 +613,7 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vec = bip_src->bip_vec; bip->bip_iter = bip_src->bip_iter; bip->bip_flags = bip_src->bip_flags & BIP_CLONE_FLAGS; + bip->app_tag = bip_src->app_tag; return 0; } diff --git a/block/fops.c b/block/fops.c index 13a67940d040..6d5c4fc5a216 100644 --- a/block/fops.c +++ b/block/fops.c @@ -54,6 +54,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, struct bio bio; ssize_t ret; + WARN_ON_ONCE(iocb->ki_flags & IOCB_HAS_METADATA); if (nr_pages <= DIO_INLINE_BIO_VECS) vecs = inline_vecs; else { @@ -124,12 +125,16 @@ 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_sync = dio->flags & DIO_IS_SYNC; if (bio->bi_status && !dio->bio.bi_status) dio->bio.bi_status = bio->bi_status; + if (!is_sync && (dio->iocb->ki_flags & IOCB_HAS_METADATA)) + bio_integrity_unmap_user(bio); + if (atomic_dec_and_test(&dio->ref)) { - if (!(dio->flags & DIO_IS_SYNC)) { + if (!is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret; @@ -221,14 +226,16 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, * a retry of this from blocking context. */ if (unlikely(iov_iter_count(iter))) { - bio_release_pages(bio, false); - bio_clear_flag(bio, BIO_REFFED); - bio_put(bio); - blk_finish_plug(&plug); - return -EAGAIN; + ret = -EAGAIN; + goto fail; } bio->bi_opf |= REQ_NOWAIT; } + if (!is_sync && (iocb->ki_flags & IOCB_HAS_METADATA)) { + ret = bio_integrity_map_iter(bio, iocb->private); + if (unlikely(ret)) + goto fail; + } if (is_read) { if (dio->flags & DIO_SHOULD_DIRTY) @@ -269,6 +276,12 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, bio_put(&dio->bio); return ret; +fail: + bio_release_pages(bio, false); + bio_clear_flag(bio, BIO_REFFED); + bio_put(bio); + blk_finish_plug(&plug); + return ret; } static void blkdev_bio_end_io_async(struct bio *bio) @@ -286,6 +299,9 @@ static void blkdev_bio_end_io_async(struct bio *bio) ret = blk_status_to_errno(bio->bi_status); } + if (iocb->ki_flags & IOCB_HAS_METADATA) + bio_integrity_unmap_user(bio); + iocb->ki_complete(iocb, ret); if (dio->flags & DIO_SHOULD_DIRTY) { @@ -330,10 +346,8 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, bio_iov_bvec_set(bio, iter); } else { ret = bio_iov_iter_get_pages(bio, iter); - if (unlikely(ret)) { - bio_put(bio); - return ret; - } + if (unlikely(ret)) + goto out_bio_put; } dio->size = bio->bi_iter.bi_size; @@ -346,6 +360,13 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, task_io_account_write(bio->bi_iter.bi_size); } + if (iocb->ki_flags & IOCB_HAS_METADATA) { + ret = bio_integrity_map_iter(bio, iocb->private); + WRITE_ONCE(iocb->private, NULL); + if (unlikely(ret)) + goto out_bio_put; + } + if (iocb->ki_flags & IOCB_ATOMIC) bio->bi_opf |= REQ_ATOMIC; @@ -360,6 +381,10 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, submit_bio(bio); } return -EIOCBQUEUED; + +out_bio_put: + bio_put(bio); + return ret; } static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 2195bc06dcde..de0a6c9de4d1 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -23,6 +23,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 app_tag; /* application tag value */ struct bvec_iter bio_iter; /* for rewinding parent bio */ @@ -78,6 +79,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter); +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -108,6 +110,11 @@ static 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_user(struct bio *bio) { }