From patchwork Mon Nov 25 07:06:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884499 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 1FF941547DE for ; Mon, 25 Nov 2024 08:07:45 +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=1732522068; cv=none; b=nChHgAbOXTepBCrHzcJLXxMYbNU7JahJgRIsxscq9vPLSUo7jmiKhV/siVm8v63SvRx058urQ2OemnduCQt1t23dWLPkXBtAIT95tWAcgyTHiITXIYheWsiLazjapJlRMI8XIU9DUEsMwEQyCxW8YFfc8CXzblxPdRBawke3TMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522068; c=relaxed/simple; bh=z3oZCEUpNWP6ssVVNnvaEMGwTgZ5HxAO2xsIC7OVOu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KJTERPpxQEdg0FP5Xm5W3Eph4cv8LRSTrrzErvFZvkQOQ9Z7axhcVCJ+BM2TZkNa76cEVnsa5j757ErtFj+r9xgnlZGI3FplG2KDJPl0htoPR9vwaTgfaEkXn0Pvdg1cH5WD8j9rW9ceFlOJMoAYBoLKXC8tbjjdJN43VaIX5xg= 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=KPQQ4qq0; 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="KPQQ4qq0" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241125080738epoutp04cc9cfcde82ed0bbfc66ad04582a71fe2~LJ6H9iO6L1500215002epoutp04N for ; Mon, 25 Nov 2024 08:07:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241125080738epoutp04cc9cfcde82ed0bbfc66ad04582a71fe2~LJ6H9iO6L1500215002epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522058; bh=n6LNHR2UxOEOGCqUSfrJ4D/dcAXYHqklNM5hsVN/lLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPQQ4qq0F2GQmM9lj3VtsGROUJmsMBBrfw5KnvdHSnq5fQBk9090qrAG1J9Q2rRkD 5qRfS9FAv1CyoCjykZ4xkDESzBfxIWD62r6up42zjORtCoTVfh4pewZQsswXfCNzfA qroBlYPPfS0+IVyo9g6yjw6AbvixlWAZYoYw0CDY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241125080737epcas5p110d91d6478e4741866935487bbcfe3c4~LJ6HdKTCM0753607536epcas5p1Y; Mon, 25 Nov 2024 08:07:37 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Xxdbq2q8yz4x9QC; Mon, 25 Nov 2024 08:07:35 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 90.86.19710.74034476; Mon, 25 Nov 2024 17:07:35 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241125071449epcas5p1f1d44ee61d1af7c847920680767637e7~LJMATL_Db0075500755epcas5p1a; Mon, 25 Nov 2024 07:14:49 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071448epsmtrp25d2c9e189a97be238e69b4a4f56dac3d~LJMAQ7JPR0291702917epsmtrp2K; Mon, 25 Nov 2024 07:14:48 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-75-67443047379a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.F7.35203.8E324476; Mon, 25 Nov 2024 16:14:48 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071446epsmtip187adfcb57fadac6d0e10bd8a9f220b58~LJL97JGsg0181001810epsmtip1c; Mon, 25 Nov 2024 07:14:46 +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 v10 01/10] block: define set of integrity flags to be inherited by cloned bip Date: Mon, 25 Nov 2024 12:36:24 +0530 Message-Id: <20241125070633.8042-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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: H4sI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ZoH0f4l By3mMIuuPPygVHHavFdf+e6ImzcG+Ybdf3crXOpE1sYFWw5fYXt5Pm9aH8/DX1UJrGvfrP+i cESAIf5FddKD6SI3ZviyfWWR5P+09EXZ7dYbp/N9H9tt1wo/foX5WtvizZoB8Y6pR9M8Xv3v mHBp8gEvtf8rfFoXX7yxffNGo6ArOzwL3735t+S+jc/+4JOStdt6Tye995JxW3/66qrWVVv/ X65ncFZiKc5INNRiLipOBACyDTlAIgMAAA== X-CMS-MailID: 20241125071449epcas5p1f1d44ee61d1af7c847920680767637e7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071449epcas5p1f1d44ee61d1af7c847920680767637e7 References: <20241125070633.8042-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 Mon Nov 25 07:06:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884500 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 0D018189B80 for ; Mon, 25 Nov 2024 08:07:46 +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=1732522068; cv=none; b=TaFC7WVYOx79vJNrl6Gpquc3972ZI2EELDhGGBE8PfOI5P0cBSdLrDOMixvCCoIh2amb/4mzhLXt2ttqFymIsjYxS/f8hmwnApjNmI50xAPzDuiT0AZtkxM6C6pi1uXjDCkP5zsJRI4a1JjdTx1jtABn7kuzHnhiLvJSsXBwE3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522068; c=relaxed/simple; bh=g2fp64Elfp9R80cl3zu6i89Ehrxw1OCNHe/eXuK93qM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=gBLgluEjEnUyq1KViTKu66aPewXRWfl3OCCXyVvFCRl8Kci93PFHDivyWHaVronE2nIDOmggrLU+/NDztZUNIMvXubvezms8G88Avd/nZPTsMFb/CaSFDJgkPRIJx1jIUQW3S6CS4Qzuds3PVEa8/6cvTQJr+r5HCRwur8Jhxro= 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=pHoaV3Pg; 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="pHoaV3Pg" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241125080745epoutp03145ca0deba747a40c2b3accdbaff7f65~LJ6OYDZs30743407434epoutp03o for ; Mon, 25 Nov 2024 08:07:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241125080745epoutp03145ca0deba747a40c2b3accdbaff7f65~LJ6OYDZs30743407434epoutp03o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522065; bh=FQM1oME+yjLcszh/NNdlGeevLgEVh+e4WfItNIpaOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHoaV3PgaywxXbtOMUqSSZ0pGIdYAoyWZI4/eN5w3TJq6NRoPtljYrV6zoPpIzuAS V/h+/8ecPfFYYfvcDJQI7aBY9+sE3KEUD2UmP2m/lK0dhvMgb0zWgj55rPAp4kUSDb pZ9AjZLb10sn9E2SWiOBptwrRWGZXNDqXYiycMOw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241125080744epcas5p1e5c279f254c7b11203f99bd831ef6e13~LJ6NyW-R60753007530epcas5p1c; Mon, 25 Nov 2024 08:07:44 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xxdby6n4qz4x9QD; Mon, 25 Nov 2024 08:07:42 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 31.9F.20052.C4034476; Mon, 25 Nov 2024 17:07:40 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241125071451epcas5p2e50329d88842569e5a2a07b918406d28~LJMCttwXl1898818988epcas5p2y; Mon, 25 Nov 2024 07:14:51 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241125071451epsmtrp1aba047449d1481e7d1338a2e2d227525~LJMCsyB3q0302403024epsmtrp1m; Mon, 25 Nov 2024 07:14:51 +0000 (GMT) X-AuditID: b6c32a49-3d20270000004e54-7d-6744304c1831 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4D.F7.35203.BE324476; Mon, 25 Nov 2024 16:14:51 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071449epsmtip16e62cc014438b6259563f1686ec18e7c~LJMAXyNEe0365203652epsmtip1N; Mon, 25 Nov 2024 07:14:48 +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 v10 02/10] block: copy back bounce buffer to user-space correctly in case of split Date: Mon, 25 Nov 2024 12:36:25 +0530 Message-Id: <20241125070633.8042-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrJJsWRmVeSWpSXmKPExsWy7bCmuq6PgUu6wfsd2hYfv/5msWia8JfZ Ys6qbYwWq+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJotJh64xWuy9pW2xZ+9JFov5 y56yW3Rf38Fmsfz4PyaL83+Ps1qcnzWH3UHQY+esu+wel8+Wemxa1cnmsXlJvcfumw1sHh+f 3mLx6NuyitHjzIIj7B6fN8l5bHrylimAKyrbJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ 19DSwlxJIS8xN9VWycUnQNctMwfoHSWFssScUqBQQGJxsZK+nU1RfmlJqkJGfnGJrVJqQUpO gUmBXnFibnFpXrpeXmqJlaGBgZEpUGFCdsbn2U1MBav5KlY1TGNrYJzE08XIySEhYCLR0NzB 1sXIxSEksJtRYuPMaewQzidGid7WDYwgVUIC3xgldh4whenY2v0Cqmgvo8TB1nNMEM5nRolJ Cx8zg1SxCahLHHneygiSEBHYAzRq4WkWEIdZ4CWjxNJVi1hAqoQFUiR+7wSZxcnBIqAq8Xjt MVYQm1fAQuL8nF8sEPvkJWZe+g5WwylgKfG27QALRI2gxMmZT8BsZqCa5q2zmSHqz3BI/FjL CGG7SCzq+8kEYQtLvDq+hR3ClpJ42d8GZadL/Lj8FKqmQKL52D6oXnuJ1lP9QDM5gOZrSqzf pQ8RlpWYemodE8RaPone30+gWnkldsyDsZUk2lfOgbIlJPaea4CyPSTedL1mhYRWD6PEqePn 2CcwKsxC8s4sJO/MQli9gJF5FaNkakFxbnpqsWmBYV5qOTyak/NzNzGC07iW5w7Guw8+6B1i ZOJgPMQowcGsJMLLJ+6cLsSbklhZlVqUH19UmpNafIjRFBjeE5mlRJPzgZkkryTe0MTSwMTM zMzE0tjMUEmc93Xr3BQhgf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7GxhGzps96svU5xrMSlyb7dcWsvpN2xNlu0byfybevftkTlOMsNyM8+0uI 8CWTlY+UzwhmnD2uHHF1Wkirw+FFT47c2Rj98fNJZUO+HVezLs3cWDPJUPPPtrWSr6bzW9dk z7ym2Vk6If6079XvK/9Xflxtqc7Y8kw6uFPBS3zNZSnNT82hSbyH63R11x7fM4dX6k2aeXbr cofUBp0tHAe9nCx3+JvmZr3rKDh0dsafBUeW8u/0kVv7tDmHnfnSq44f7SmSf0+GdP9szo86 8z70aansLWaBH75HNzjdCXaqrs9oTXjTP/FLVqxzVGZKoUjQls2bA0S6Cvi9kxuKvsrNuV3z VomlOCPRUIu5qDgRAPuIJN0jAwAA X-CMS-MailID: 20241125071451epcas5p2e50329d88842569e5a2a07b918406d28 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071451epcas5p2e50329d88842569e5a2a07b918406d28 References: <20241125070633.8042-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 Mon Nov 25 07:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884501 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 F2127154BE3 for ; Mon, 25 Nov 2024 08:07:54 +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=1732522076; cv=none; b=LNpn9rk/JdfCsqcV9pUpg/GFrvhsBmarANMKIRwFWhYnocvEkTagk+k+L7OKOA8HLkuxe4Qz0VP33I48xlP+7nhuwg3TBW57B4rqtAXnYfM/NnYiBPweG8jyXAXiJdwNolIeIMHMK3XcsSYzPAEmLYGd0DE/Y4j/R9HUOd/Ondg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522076; c=relaxed/simple; bh=ZIkdyJlOm3c2bE0cQ6pelSYB5Gra8HNzZg1GmGSloUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=tPuxDQNOSGs8VuI7o7o6FQ/0sVKzXDEhS9V8uHsUkCBhB72/d+Yum2LxJX3u9bNbowF/FDdP/etrRVcM1N/60Q7/RlFcefBwup28buRB0vilRhAnZj1K5XDeoa68PA1oOLXrvkhvDu6TPsKIyH7dWeevGMDwJRpxpnahgUBYN7c= 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=AuPjSbr+; 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="AuPjSbr+" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241125080753epoutp03c8b09afc1b45241fbd8bd1aecc84b173~LJ6V5qAEX0866608666epoutp03B for ; Mon, 25 Nov 2024 08:07:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241125080753epoutp03c8b09afc1b45241fbd8bd1aecc84b173~LJ6V5qAEX0866608666epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522073; bh=r23oSTZl50mKsH838ytL5lDlNxkmkMYy4oR7U1Ruz2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuPjSbr+wwrj35VTO1a0GWubB8L9zZIQo92dC+7Bx8cLn4jaqMeN9HGhL34OF944s DgZLid3RhclwFSl5VmpEaYfyts+BXOMiBWSIIhrrkI4P9xWzjDZ8FdPVf/xWWHuRzH nMrHSTAItpL0DARdjI55gr49mmgoW6B734KYWa7Q= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241125080752epcas5p4faeaf8c214c343ab0d6e74bdafb82e59~LJ6VZUXaz1615316153epcas5p40; Mon, 25 Nov 2024 08:07:52 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xxdc64ygzz4x9QB; Mon, 25 Nov 2024 08:07:50 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 97.9F.20052.65034476; Mon, 25 Nov 2024 17:07:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241125071454epcas5p449a4b9a80f6bfe2ffa1181e3af6c2ac6~LJMFPjhPU1933019330epcas5p4H; Mon, 25 Nov 2024 07:14:54 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071454epsmtrp2a685c9fea5b8dd07aca582f547795d7a~LJMFNgE_x0286002860epsmtrp2Z; Mon, 25 Nov 2024 07:14:54 +0000 (GMT) X-AuditID: b6c32a49-3fffd70000004e54-94-67443056a5ba Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id FE.7E.18937.EE324476; Mon, 25 Nov 2024 16:14:54 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071451epsmtip13040f1ba58cb8551b4a7e4a8acfc959c~LJMCy34Cw0361403614epsmtip1b; Mon, 25 Nov 2024 07:14:51 +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 v10 03/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Mon, 25 Nov 2024 12:36:26 +0530 Message-Id: <20241125070633.8042-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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: H4sIAAAAAAAAA01Te0xTVxjfuff2AQvkUlk4oEK9mSzybGeBgwN1gW2XAAkJbAlsGXZw01bK bdeHQ/4YxFqIoAPdg0nrRLbIxGljoQwsGEQYgzFk4GYAIfxRJmpgKPKICFvpBed/v+87v0e+ 75wjxEWT/CChijUwOlaupvjeRMutPWGRH0iSFRLbw1D0eHGVQMeq13BkbWwB6PJEFR89uvUE oNHONgxdutyDoTnzIIEsNSYM9fw7y0dnuv4CqGMsHLV39BHo/MVpAaq828pHDb3rGLq91stD t2utgoMiuq12QkCP/G6k7Y0n+HTTDyW0c7SUTz+eHiPoL5obAT1Q1y2gF+zBtN01i2V45xQk KBl5PqMTM2yeJl/FKhKp1MzcpNyYWIk0UhqP4igxKy9kEqnktIzId1Vq90yU+IhcbXS3MuR6 PRW9P0GnMRoYsVKjNyRSjDZfrZVpo/TyQr2RVUSxjGGfVCJ5M8ZNPFSgnJ5ZwLTtwUXOEboU tARWAC8hJGXw2c1VUAG8hSLSCWDXmWObxRMAv126wntRrDgHBFuSdatFwB20Abg2tIRxxQKA 80PHwQaLT74Bu++bPV7+ZDuApy78RmwUOFmNwfLTVo/XNvIQHO+748EEuRu6uis82IdE8N61 izwuLwSeHV729L3IeDhb1klwHD/Yd9blwbibY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BjYBdYkjz1vBikQETjBKzJ/oBlLELDCDSaLn1wo2kISwQJzEpMYOFhCbRUBV4smRLrBm XgELiTsbl7FCbJCXmHnpO1icU8BS4m3bARaIiywkZnWuZIWoF5Q4OfMJWJwZqL5562zmCYwC s5CkZiFJLWBkWsUomlpQnJuem1xgqFecmFtcmpeul5yfu4kRHGdaQTsYl63/q3eIkYmD8RCj BAezkggvn7hzuhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe5ZzOFCGB9MSS1OzU1ILUIpgsEwen VANTb/uMW3dvdUadXLK774Ju9ZRdQqXmqk6lZc2PJk6Y/HhNpPP9cquIsgsVLIerAy4Yf/Ge fKht/VcniW63vLMt/PHGPXExah8Fjj36MO1RyjyHKe/mz560NNfqD5+W7wdx1cWnuUOZM3dO 5k9f9UQsfIdAymfhuUFrmvUM80Vq/e9IP1K1vnvcwutP1OTQl5e/LUoT4+ift2X6iXj+uZaW JU/dtcVPSe2Qt+g9bfbzYGmkRZt07OOPQbaiS15dWD1dUiamt33zLqkNj60Pvgwo2rvibQjb 81jODAaJb/O293Yuuv20ZreR1sT1+qXev64vEZ4rGyj4fTWnaP+p6MgZll/dL2wNKS6YLMOW dnKhEktxRqKhFnNRcSIAGBu+8CIDAAA= X-CMS-MailID: 20241125071454epcas5p449a4b9a80f6bfe2ffa1181e3af6c2ac6 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071454epcas5p449a4b9a80f6bfe2ffa1181e3af6c2ac6 References: <20241125070633.8042-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 Mon Nov 25 07:06:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884502 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 897A61714CF for ; Mon, 25 Nov 2024 08:08: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=1732522085; cv=none; b=O64HRlyPsOds1foXQsIB/2+SVDVGUuP6Gx1l7QF/zYNHNFmhDve8JljcBMc8CiZ2hJgZckcA50OZhCKQXrWfnKWa4f1QLH4rB2coB/UVfywHuELPprsSEf36tXhPQI6SqRvjovLph1T/CriPjDjNEIyPbTeri6XHKBuVLf+VA/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522085; c=relaxed/simple; bh=uDUb87C52DXoVA3KvOoAoNEyjHqrw30MJR/Iqxaidaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=tp9kZNbuORY3LRauCeFUcrVoB3+iaaAFk9qZAA9zjLV1HedgPNVdoKkWpheyIJithRPHYvxLcv31L8RgQzzIFwVJWXwdyHdAQZ/pRRKExK8jgsXQGc/ZlH8kNCL0w06eY4FyoeDpX+FJOzfMyXyKCTFUAVyLRitf4vcs5Qe1jxw= 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=Ru9C0F3d; 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="Ru9C0F3d" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241125080800epoutp01194bfe86a9686903e1c7688a84e3c193~LJ6dBIRzi0952109521epoutp01j for ; Mon, 25 Nov 2024 08:08:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241125080800epoutp01194bfe86a9686903e1c7688a84e3c193~LJ6dBIRzi0952109521epoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522080; bh=sPCiH7C8otAPeKBQxafGfpBc//4CVwTtOappMXTNYFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ru9C0F3d+Dy26aoNa98nsBCvTS8TU5C8wCuGirg5DOUAAXMm1BGUTIH/OniOEpHk1 zR3xoDmojCNirdNtI6Mevbwvs5JixZxMTo0GPN0hCjCt2rn+0ZXhCS9CSLwoF44+s9 mdTmhe5yIdSEhT22wC1dpwc8QqiUk77X3vU+qQbs= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241125080800epcas5p412d9a5f2601abac0647e31defe6716bc~LJ6cX-_xj1833918339epcas5p43; Mon, 25 Nov 2024 08:08:00 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XxdcG48MDz4x9Q3; Mon, 25 Nov 2024 08:07:58 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id DB.66.29212.E5034476; Mon, 25 Nov 2024 17:07:58 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241125071457epcas5p498c0641542bed9057e23cfff9cfc5ff0~LJMH1hjqt1933019330epcas5p4R; Mon, 25 Nov 2024 07:14:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241125071457epsmtrp1eaefa71b882c902d9317ca201b91da3d~LJMH0gPoA0302303023epsmtrp1z; Mon, 25 Nov 2024 07:14:57 +0000 (GMT) X-AuditID: b6c32a50-801fa7000000721c-87-6744305e1ece Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 20.08.35203.0F324476; Mon, 25 Nov 2024 16:14:56 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071454epsmtip149999c09d59b464adb11470b42b63af9~LJMFUPWGQ0361403614epsmtip1c; Mon, 25 Nov 2024 07:14:54 +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 v10 04/10] fs, iov_iter: define meta io descriptor Date: Mon, 25 Nov 2024 12:36:27 +0530 Message-Id: <20241125070633.8042-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmlm6cgUu6wa818hYfv/5msWia8JfZ Ys6qbYwWq+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJouj/9+yWUw6dI3RYu8tbYs9 e0+yWMxf9pTdovv6DjaL5cf/MVmc/3uc1eL8rDnsDkIeO2fdZfe4fLbUY9OqTjaPzUvqPXbf bGDz+Pj0FotH35ZVjB5nFhxh9/i8Sc5j05O3TAFcUdk2GamJKalFCql5yfkpmXnptkrewfHO 8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUA/KSmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0ts lVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyM5ZM0y24wlux+NpCtgbG2dxdjJwcEgIm Eiv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NTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orhsUlJzMstSi/TtErgylkzTLbjCW7H4 2kK2BsbZ3F2MnBwSAiYSy65OZuti5OIQEtjNKNH5rJ8NIiEhcerlMkYIW1hi5b/n7BBFHxkl Wqe8YwZJsAmoSxx53gpWJCJwglFi/kQ3kCJmgRlMEj2/VoBNEhZwkth1ZgILiM0ioCpxcdl/ VhCbV8BC4tDUg0wQG+QlZl76zg5icwpYSrxtOwBWLwRUM6tzJVS9oMTJmU/A4sxA9c1bZzNP YBSYhSQ1C0lqASPTKkbJ1ILi3PTcYsMCw7zUcr3ixNzi0rx0veT83E2M4IjT0tzBuH3VB71D jEwcjIcYJTiYlUR4+cSd04V4UxIrq1KL8uOLSnNSiw8xSnOwKInzir/oTRESSE8sSc1OTS1I LYLJMnFwSjUwTeHhszZ0u35bxWvHoXC/TEdD7/BYxWXvd9jmrbk9nXnKSVWvxzaTth0w1c/6 7RTW/v712/MOkpxHVyw40XbusPC77/1rZntGnL/1RoHT6izTNyu7U6bV934evveu9kDCSqXi 7Q1dS8sVik9/4j42MbhHinmrq4VCmVP7LGtb/4MWWs8X5lz4cCBR5njTossnlzdP6eCepCVd oFetW5G4s9992U+DvU/0D0bdusVvWTM1QVzUj2/GRcfrAWaBySdfLI//3WztvPudCrv6Rf32 Cf4H/F10M5ir2F5WpXBePrVav5ItISyXZ8cKCWGLBX6PeFpUg5k/R1fFaUYoSp63v/4/eNbS VzKWlXbGX9OUWIozEg21mIuKEwGNW3FuJwMAAA== X-CMS-MailID: 20241125071457epcas5p498c0641542bed9057e23cfff9cfc5ff0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071457epcas5p498c0641542bed9057e23cfff9cfc5ff0 References: <20241125070633.8042-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: 13884503 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 DB8A1189B80 for ; Mon, 25 Nov 2024 08:08:10 +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=1732522092; cv=none; b=rUALtpTc7Ssd1EpnpRS/iFP/QLFN74VqArBJvgvG0dqg8RfQTN6GgnPNzX7Fdo/at1M5UfW7laEEiTISTtXUuAIM1abcus/5EnhqIO/dFbYWOUj6WsRstjtylzuiuXE/NvuCXREG26tc/gvO+CRoMisyp4FEbufb9JanjNHp2xM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522092; c=relaxed/simple; bh=mlLpOADJdimbzMrJqxVCIky165ZgGg3a+54zC1LiT88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=qBx9u65KSGHfPaJlYVaGBNN1jk6R0sKhP8nr/tz9zAvT8Aw8XYHeeHk0u6bHHmhw+ozcQmfahi5xXGJYFckpIJ2xEcUNLnsH6hBtOy7NX455ejeWknFUQqAMpRLgtpCcsjnwjJygR8GvLzHYwTWXJLLluOkzeZZM4LYtlrC6ijA= 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=smbc0ws0; 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="smbc0ws0" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241125080809epoutp0341df97663f39fd6fceda2b1052b88db8~LJ6kmeRlR0684806848epoutp03B for ; Mon, 25 Nov 2024 08:08:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241125080809epoutp0341df97663f39fd6fceda2b1052b88db8~LJ6kmeRlR0684806848epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522089; bh=cRuOygxyfLjl7ybgQ+EVk9IvCIBAqSeYwRZ/zr1tr/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=smbc0ws0smxYmZG/CN7HVxuM6t7MWsPu1ZeXvsgB5MNj6A6nhjUaXoeri2hI37nUS 1K2G9kfk2mdlt0AXni41gERpc/n78v0lnyxA7ZVLJUgRLj5THnSX9S3VxSMc9XLoJc SS+cb8YaMXeKtnh0KebK3fydemKw5FmW/SsTSaNA= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241125080808epcas5p2b7dd75e2725ca299b9ea22c81ac446c2~LJ6jzKWdX0648106481epcas5p28; Mon, 25 Nov 2024 08:08:08 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XxdcQ1smBz4x9QB; Mon, 25 Nov 2024 08:08:06 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id B2.ED.19956.36034476; Mon, 25 Nov 2024 17:08:03 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241125071459epcas5p3f603d511a03c790476cce37505e61a0b~LJMKR1yvq1112911129epcas5p34; Mon, 25 Nov 2024 07:14:59 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241125071459epsmtrp1ed6807f767e39f81d65beacab6a7ddc4~LJMKPu7VC0302403024epsmtrp1z; Mon, 25 Nov 2024 07:14:59 +0000 (GMT) X-AuditID: b6c32a4b-fd1f170000004df4-30-674430635e64 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 83.45.19220.3F324476; Mon, 25 Nov 2024 16:14:59 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071457epsmtip1090cf8f1a1638fb76db36ee392448f28~LJMH4TYPm0365203652epsmtip1U; Mon, 25 Nov 2024 07:14:57 +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 v10 05/10] fs: introduce IOCB_HAS_METADATA for metadata Date: Mon, 25 Nov 2024 12:36:28 +0530 Message-Id: <20241125070633.8042-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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: H4sIAAAAAAAAA02Te0xTVxzHd+697S2wwpWHHFGh3rgZNEA7KFwMOA1s3sgwJCZmY4nspj1p SZ/2Mba5YAcDIj5AFzYEBFEEKRkLVRCRKqswxApsQ3yQkeiEuU4QqBtuMehaWjf/+/we3/N7 nHMEeOgdfpQgX2tCBi2npvmBRNfV2A1xMnGmQtww8Dqz8NczgimqXMKZOmsXYNomK/jMo6tu wNztu4gxrW0DGPO4ZIRgar8pxphjjluAsU9sYnrtQwTT0DxNMgdvd/OZlsHnGDO6NMhjRmvq yK0r2Is1kyQ7NmxmbdYDfPZc03720l0Ln12YniDYI+etgL1xsp9kn9iiWdvULJYTmKtKUyJO jgwipJXp5PlaRTqdtSsvI0+aLJbESVKZFFqk5TQonc58Lyfu3Xy1Zxxa9DGnNntcOZzRSCds STPozCYkUuqMpnQa6eVqfZI+3shpjGatIl6LTJslYvFbUk/iRyqle7CFp7/J+2TI+g9uAbeI ciAQQCoJzrXFl4NAQSh1CcCW8S/5PsMN4PeuccxnLAJ42z3kiQQsK+6VXvMH7ADOdFkJbyCU egKgy7L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ydzA eI2li5GTQ0LAROJB2wmmLkYuDiGB3YwSM28fh0pISJx6uYwRwhaWWPnvOTtE0UdGie17JrKC JNgE1CWOPG8FKxIROMEoMX+iG0gRM0jRhC+zwSYJC7hL7O3az9bFyMHBIqAqcXyRFUiYV8BC 4siKp8wQC+QlZl76zg5icwpYSrxtOwDWKgRUM6tzJStEvaDEyZlPwOLMQPXNW2czT2AUmIUk NQtJagEj0ypGydSC4tz03GLDAqO81HK94sTc4tK8dL3k/NxNjOA409Lawbhn1Qe9Q4xMHIyH GCU4mJVEePnEndOFeFMSK6tSi/Lji0pzUosPMUpzsCiJ83573ZsiJJCeWJKanZpakFoEk2Xi 4JRqYLK44/y6f1+ZkHfC1nUW5aWafll1Zz9Z3LPZYclX+4H5zbsXSux3U46YruS02rHVNKBB y9E9wHf/k9o/q477MXdP+yi9NXNKeR5j6AwbtZ/f3l+wOrhe7o5r+Yp+puiT5qf4M1aWVqyM +K44O3l2idUjixBjo5uXnO846zioV4eunBA2o+nrgXvrEvckRtczb91bGcX/vFBjZd1dq65a 5iNu/CqOZq3H90Wpf/wur3dnZsf0sit8VsvrP9a/3fZORSQobmHg/7MJ6ncSzS4+m7/DN/ht wL5DDiLrL7lOqagUajQMaTWOF5u+vfLV5X0xSxlWyvpnxeZZSCkvPtK9jlfn33exbjGXyqMb BQL4lFiKMxINtZiLihMB9+Bh4yIDAAA= X-CMS-MailID: 20241125071459epcas5p3f603d511a03c790476cce37505e61a0b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071459epcas5p3f603d511a03c790476cce37505e61a0b References: <20241125070633.8042-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 Mon Nov 25 07:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884504 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 1ACE01547DE for ; Mon, 25 Nov 2024 08:08:21 +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=1732522104; cv=none; b=G3k8VRSDkFecYBmBpwk9rbIXBh6R5uiVzylguiYhSrEzofbNWKWMdts2EB4MKyA8ZcBLUoa+IQToIres0GA6rmmjoLetNHXYzdXvguEaLZMqteEajia6iAlYQbn6v1YzmgE+M0xlXrI80hafPAHvanZd4+8zJUFtlMNii6SMLQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522104; c=relaxed/simple; bh=c+P5GWK64P6uvOS5S4lo6E9Ft1ukPyp92Zww4rzKibo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=ixV3roqmsd5ZNJ+0hQpz6qC8glWQqdFqbLaawSaiPx62SngHP297L2C8+Q8ZpqMbxhag/lkExuK+tDZrS1xqV4axl3cDSJCOtB7fXnTEqOHs8KnQl9csUGx6m6dZv+hBHXrsTntkFYjgMr2ZP41KVx8xpK6jSL3mry8hHot0xDU= 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=nO82tyHu; 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="nO82tyHu" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241125080819epoutp02a1f963772930ad0508b5c16cf214633c~LJ6uTADBX2099820998epoutp02j for ; Mon, 25 Nov 2024 08:08:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241125080819epoutp02a1f963772930ad0508b5c16cf214633c~LJ6uTADBX2099820998epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522099; bh=oSIHEQgo5+twq6ZY9Vqvg0w2/SzcvR7jssNhix7seL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nO82tyHuXl74MF42HwMoAPb+GpCVyeAiYMAHYneLGeEWYt6P66UeW24tHj86Zx0Sw Dj1Z71BpV2kLascBZ6+h49KJHuZLXjRMtzl3lWmKaoLdvhxUvrgXeEyTbCI+HxLoTc eQUaIshYWIaTx2lTirEaBEtN2vob4DpQ4xu9rnj8= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241125080818epcas5p36e1c9876f4c6006f02558a9f9764b88c~LJ6tXNY2N0905409054epcas5p3J; Mon, 25 Nov 2024 08:08:18 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Xxdcc4v6Mz4x9QM; Mon, 25 Nov 2024 08:08:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F3.F1.19933.07034476; Mon, 25 Nov 2024 17:08:16 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241125071502epcas5p46c373574219a958b565f20732797893f~LJMM0X9GY1896918969epcas5p4y; Mon, 25 Nov 2024 07:15:02 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241125071502epsmtrp138f304d34c6c9f5c13a6d81ea8f61796~LJMMzIGWO0343503435epsmtrp1K; Mon, 25 Nov 2024 07:15:02 +0000 (GMT) X-AuditID: b6c32a4a-c1fda70000004ddd-09-67443070df7e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F9.45.19220.6F324476; Mon, 25 Nov 2024 16:15:02 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071459epsmtip17c73e13dbfc7db4011a0cc888ee952d2~LJMKVj5TP0361403614epsmtip1f; Mon, 25 Nov 2024 07:14:59 +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 v10 06/10] io_uring: introduce attributes for read/write and PI support Date: Mon, 25 Nov 2024 12:36:29 +0530 Message-Id: <20241125070633.8042-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrLJsWRmVeSWpSXmKPExsWy7bCmlm6BgUu6wfRGVYuPX3+zWDRN+Mts MWfVNkaL1Xf72SxeH/7EaHHzwE4mi5WrjzJZvGs9x2Ixe3ozk8XR/2/ZLCYdusZosfeWtsWe vSdZLOYve8pu0X19B5vF8uP/mCzO/z3OanF+1hx2ByGPnbPusntcPlvqsWlVJ5vH5iX1Hrtv NrB5fHx6i8Wjb8sqRo8zC46we3zeJOex6clbpgCuqGybjNTElNQihdS85PyUzLx0WyXv4Hjn eFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKCflBTKEnNKgUIBicXFSvp2NkX5pSWpChn5xSW2 SqkFKTkFJgV6xYm5xaV56Xp5qSVWhgYGRqZAhQnZGVf2TGEtmO1QcfvLJ8YGxmaTLkZODgkB E4n5exYwdjFycQgJ7GaUeLCslQ3C+cQose7DNmaQKiGBb4wSXTfUYTrWv57CAlG0l1Fi76ZH 7BDOZ0aJRVcmM4JUsQmoSxx53go2V0RgD6NE78LTYC3MAhOYJNonzgFq4eAQFoiU+Lw0GKSB RUBVomfBE1YQm1fAQmLh1+dMEOvkJWZe+s4OYnMKWEq8bTvAAlEjKHFy5hMwmxmopnnrbGaQ +RICNzgkzlzpZQOZLyHgIjG9XR5ijrDEq+Nb2CFsKYmX/W1QdrrEj8tPoXYVSDQf28cIYdtL tJ7qZwYZwyygKbF+lz5EWFZi6ql1TBBr+SR6fz+BauWV2DEPxlaSaF85B8qWkNh7rgHK9pA4 sXwPNOR6GCVOP2him8CoMAvJO7OQvDMLYfUCRuZVjJKpBcW56anFpgVGeanl8FhOzs/dxAhO 51peOxgf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mbGMExp6W1g3HPqg96 hxiZOBgPMUpwMCuJ8PKJO6cL8aYkVlalFuXHF5XmpBYfYpTmYFES5/32ujdFSCA9sSQ1OzW1 ILUIJsvEwSnVwDTpzdEU4yYBX5ObnGyXyoxDhfR2T5SNnN7U1iW9jT3lg2nUv85jKkpLHepW +G/nXlRvu1PMbInev2KDiXN4VMsXcB7es6L0q5HO33kTi3NLjl7hWqTH88l/siRPiZTk9cj/ 3WcY5S+sE/4QEbD+iv2irlchze3a1jmVApqzLNw4ti+vyn09Zcvng5N5/r3U2M9YeCCnXpZL bNILCwPp9u/eZkbMnzNS9h8LP+u2d4/Juvbnkx7q1F3Y9FryQeKbnQ5yl5ZGebv2dbCtyHAX zY16+urDw8TXi7OtZu2/bM/40U1ATbbwkkiljFjksacHEj0lqx699lB7vZ5z5lme4IbuaVGG ciudUgoTWnYxKrEUZyQaajEXFScCANJ8jAcoAwAA X-CMS-MailID: 20241125071502epcas5p46c373574219a958b565f20732797893f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071502epcas5p46c373574219a958b565f20732797893f References: <20241125070633.8042-1-anuj20.g@samsung.com> Add the ability to pass additional attributes along with read/write. Application can populate attribute type and attibute specific information in 'struct io_uring_attr' 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 'ATTR_TYPE_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 | 31 +++++++++++++ io_uring/io_uring.c | 2 + io_uring/rw.c | 82 ++++++++++++++++++++++++++++++++++- io_uring/rw.h | 14 +++++- 4 files changed, 126 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index aac9a4f8fa9a..bf28d49583ad 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,33 @@ struct io_uring_sqe { }; }; + +/* Attributes to be passed with read/write */ +enum io_uring_attr_type { + ATTR_TYPE_PI, + /* max supported attributes */ + ATTR_TYPE_LAST = 64, +}; + +/* sqe->attr_type_mask flags */ +#define ATTR_FLAG_PI (1U << ATTR_TYPE_PI) +/* PI attribute information */ +struct io_uring_attr_pi { + __u16 flags; + __u16 app_tag; + __u32 len; + __u64 addr; + __u64 seed; + __u64 rsvd; +}; + +/* attribute information along with type */ +struct io_uring_attr { + enum io_uring_attr_type attr_type; + /* type specific struct here */ + struct io_uring_attr_pi pi; +}; + /* * 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 c3a7d0197636..02291ea679fb 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3889,6 +3889,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..71bfb74fef96 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -257,11 +257,54 @@ 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) +{ + 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_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.attr_type != ATTR_TYPE_PI) + return -EINVAL; + + if (pi_attr.pi.rsvd) + return -EINVAL; + + io = req->async_data; + io->meta.flags = pi_attr.pi.flags; + io->meta.app_tag = pi_attr.pi.app_tag; + io->meta.seed = READ_ONCE(pi_attr.pi.seed); + ret = import_ubuf(ddir, u64_to_user_ptr(pi_attr.pi.addr), + pi_attr.pi.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 +322,27 @@ 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; + + if (attr_type_mask != 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,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 (rw->kiocb.ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); iov_iter_restore(&io->iter, &io->iter_state); } @@ -794,7 +856,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 +890,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 +976,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 (kiocb->ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); do { /* @@ -1125,6 +1201,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + if (kiocb->ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); 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 Mon Nov 25 07:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13884505 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 55743154BE3 for ; Mon, 25 Nov 2024 08:08:56 +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=1732522138; cv=none; b=NXUr/NECXKUMJxivG+sfPyhVVUgHhripnfi5Ag62JuyLps+pMuqi5QdHlxr4esBgT7cR1SZLb+L02Ncfzqp9TzOhQSyvTTF6uSxC/TE2BZRiHiBv+DXSktlvDm601pa+d8vCTp3FDQDQIH8J708vlWe4hmFoaL80t8NgS1MKHp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522138; c=relaxed/simple; bh=4bwNPqd2mgS/me72gS6c9qKx3N7iAIorybNdKO8yxVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=G//kvcnwr66Qy8HAdsDcMIJK6uVuMgFKB12Eqpj6OvCexb8is6GFQ4yRYnA8+avJkC6edDZYYl4ezRW9CtPLD+Dop79BSBrcKEpPFYZj/MctGGuizwVfQbf9PUTiSn6LM6ML3w16hllUWO3y7N99w5VNHZLQx8N5ViGFWagW3K4= 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=Gi51t0L7; 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="Gi51t0L7" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241125080854epoutp03386dc56fa846b8296bb3b4950d07ba2e~LJ7PGiwNM0866508665epoutp03W for ; Mon, 25 Nov 2024 08:08:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241125080854epoutp03386dc56fa846b8296bb3b4950d07ba2e~LJ7PGiwNM0866508665epoutp03W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522134; bh=1yhnn/JEQDkJO7MPiDYhPt3P6x3KI+3HedoJWLZAeh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gi51t0L7ERwclevYi5LtaTTQDtEm28SxoSUzGiVe1vOoNSxF+JmKWMnKNREjsUNbN NvIqJE8LimufJU92nWHsBzRKGd9kZU4FkmGieGART11J9zK9L/2ZFrisPallKt2z0P qH8B03alLKFtITqP/6HZiojUi75u+tZxT5dLydmU= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241125080854epcas5p28027fe1fdf39dbf760d7f276354c4abc~LJ7OoAKUy2571325713epcas5p2o; Mon, 25 Nov 2024 08:08:54 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XxddJ1b3Kz4x9QF; Mon, 25 Nov 2024 08:08:52 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id C0.96.29212.29034476; Mon, 25 Nov 2024 17:08:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241125071505epcas5p34469830c74b82603c57cb4122d0850f7~LJMPZnSRq1112311123epcas5p37; Mon, 25 Nov 2024 07:15:05 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071505epsmtrp227628f991ca4fb5f4a3720189936742f~LJMPYs44Y0299802998epsmtrp2x; Mon, 25 Nov 2024 07:15:05 +0000 (GMT) X-AuditID: b6c32a50-7ebff7000000721c-0b-67443092d7ea Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id FF.45.19220.9F324476; Mon, 25 Nov 2024 16:15:05 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071502epsmtip199c59c7e4832cf9b10800d051cb2fdc4~LJMM6vyav0365203652epsmtip1o; Mon, 25 Nov 2024 07:15:02 +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 v10 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Mon, 25 Nov 2024 12:36:30 +0530 Message-Id: <20241125070633.8042-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmlu4kA5d0g+lTFS0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZ/QfvclY8Eyy4vvkvSwNjMtFuxg5OSQE TCRONfxn7GLk4hAS2MMo8fnSUmaQhJDAJ0aJDbflIRLfGCXmHF/ABtOx9f5MqI69jBJTVm5k gnA+M0os2jGLHaSKTUBd4sjzVrAqEZC5vQtPs4A4zAITmCTaJ84BqxIWCJVYdesrkM3BwSKg KrFwn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vmQK4orhsUlJzMstSi/TtErgy+o/eZCx4Jlnx ffJelgbG5aJdjJwcEgImElvvz2QEsYUEdjNKrHmvABGXkDj1chkjhC0ssfLfc3aImo+MEtfv 5IPYbALqEkeet4LViAicYJSYP9Gti5GLg1lgBpNEz68VbCAJYYFgiYeT/7J2MXJwsAioSizc 5w0S5hWwkLi+dR87xHx5iZmXvoPZnAKWEm/bDrBA7LKQmNW5khWiXlDi5MwnYHFmoPrmrbOZ JzAKzEKSmoUktYCRaRWjZGpBcW56brFhgVFearlecWJucWleul5yfu4mRnC0aWntYNyz6oPe IUYmDsZDjBIczEoivHzizulCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeb+97k0REkhPLEnNTk0t SC2CyTJxcEo1MEkv0lxdVastm8chtmdVE6fU9+vGuVsi1s185C2vfdg0fpe5yl7uSQ7Mi88F XJvLk9F3csLnr1vnid4/mGa4WlPk5baYL8F7/+uuFnRN9fMo8+0W3Fbjb+pgI1UXk/urs41B X/SQ+5cDNya1Nn46Hjv//gMdhZmKckujOhx2Ofvw+PXM+u4ZpeslvWjyw12H3jhM/hh8hu3c IUFpiWLxwuAmk/m/HzS5xrT2T7/8562Wje7Kt1K+DSfPPOQ5eHKWpcujvDsLvpv37pknkzH7 7d6URWmxbH7Xrot2+LySDop3lrttH5Tl/eQq48UM45XnrebOn/q5+qRx9Ef/q5+n/Lxb9uKG NMujcDV7ea/FUkosxRmJhlrMRcWJANX3MgolAwAA X-CMS-MailID: 20241125071505epcas5p34469830c74b82603c57cb4122d0850f7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071505epcas5p34469830c74b82603c57cb4122d0850f7 References: <20241125070633.8042-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 Mon Nov 25 07:06: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: 13884533 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 EFBC5188A0C for ; Mon, 25 Nov 2024 08:08:59 +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=1732522144; cv=none; b=NSjZTjboiBvxipGYztwEhKcaDDLhzmE5n3fSRw1La1CNB9/L1UAdoctd7Yl758F58zc8IHgHZwUvVr99K6sBBlIGjV5dSlGIa5c8Ja5BDryBYnh5s0PcOBQTHTXcdbGcMm1UuyTGGlvB1P7EwtXq+vj1QCFMU2nhuX593KoiTwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522144; c=relaxed/simple; bh=R0ISA8yY2JMwXPEw3NvAC6mLoQ+w67YWfMlsx0QA4Ss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KyDm3UF0dDl+InmMbpYcEgwYjlxHWlJ4eJB8rIhfsnRWiou8lW4ch9AmgNHjCuzGlYM/VwjwdVCYwQK0KndOHc8xk/5Dw85SIkfsdDr2bVJHNsINnjZCw4ixY8CjXHVk40fIE6t8pa9C36BnIB6fyNz16ym1BDLyEMQjgIRgZ2Y= 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=Wt8PsEQJ; 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="Wt8PsEQJ" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241125080858epoutp04d72c0a4c46ccc2f1545b1e9e1f6a9c1e~LJ7SbSS2H1536915369epoutp04h for ; Mon, 25 Nov 2024 08:08:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241125080858epoutp04d72c0a4c46ccc2f1545b1e9e1f6a9c1e~LJ7SbSS2H1536915369epoutp04h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522138; bh=fOhAPjepG8IxDxWR0+S1vjp4KvMbiHG0tXmeE420F+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wt8PsEQJqgbearHYu3fxl9O/us75Sad3mB+eMUgTK9AlfNtXSu92nygcWca7gJCO/ xx++6j/ky446EuecC/GtaxeIFFlCLRkRZjiYjVl5uwR0A4+/yjsjqcATF1G71ER+wJ 7ruOq/4mVaRD+me1cyOXPVHunD+Et/U1cijyyddw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241125080857epcas5p4d06759959548551aef4833f8d9ddad7a~LJ7R9g1tx2124121241epcas5p4g; Mon, 25 Nov 2024 08:08:57 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XxddN0wM2z4x9Q7; Mon, 25 Nov 2024 08:08:56 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 2E.02.19933.79034476; Mon, 25 Nov 2024 17:08:55 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241125071507epcas5p3b898d0960fb411cd176aea29029d820a~LJMR62Uuv1555015550epcas5p3e; Mon, 25 Nov 2024 07:15:07 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071507epsmtrp29b66bfee5a18f9c38f5643a13d4bc316~LJMR52bbv0316003160epsmtrp25; Mon, 25 Nov 2024 07:15:07 +0000 (GMT) X-AuditID: b6c32a4a-c1fda70000004ddd-72-674430975f8d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 75.55.19220.BF324476; Mon, 25 Nov 2024 16:15:07 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071505epsmtip1c600a3a362de2346338329f5f8a11561~LJMPdOokE0361903619epsmtip1t; Mon, 25 Nov 2024 07:15:05 +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 v10 08/10] nvme: add support for passing on the application tag Date: Mon, 25 Nov 2024 12:36:31 +0530 Message-Id: <20241125070633.8042-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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: H4sIAAAAAAAAA02Te1BUVRzHO3evd3eppctrODJqO3cm2+W5aywdFCKT8kZW2GMYa4rusLdd ZLm7s3dXMcdxlZZK5WUQgmAgjQxQEU8RWAZBIEiQgYmEUkAhLIIJGJEZBmmXi+V/n9/vfL/n 9/udh0TkeZvwkyRyFtbMMQaKcMMbOpSKoDxVtE514n4Emr+/gqOTWasiVFjRAFDlrUwCzXQs ADTSdgVD5ZWdGJqz9+PofF4qhjrXZgl0tn0YIMdoAGpx9ODom0tTYnT610YClXU/xNCN1e5N 6EZBofglT/pKwS0xPdRnpWsqviTo2m+P080jNoKenxrF6Yy6CkBfL74mphdrttE1k7NYrNv7 SRF6ltGyZjnLJRi1iZwuknr9nfg98ZowlTpIHY5eoOQck8xGUtH7YoNeTTQ4Z6LkhxiD1ZmK ZXieCnkxwmy0Wli53shbIinWpDWYQk3BPJPMWzldMMdad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9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orhsUlJzMstSi/TtErgyJq5+yF6whbvi 7NPNTA2MRzm7GDk5JARMJFofbWXuYuTiEBLYzSgx6/4MJoiEhMSpl8sYIWxhiZX/nrNDFH1k lNhybT9Ygk1AXeLI81YwW0TgBKPE/IluIEXMAjOYJH7/WcACkhAW8JfYOOUEmM0ioCpx6eV/ sA28AhYSLY++s0BskJeYeek7O4jNKWAp8bbtAFhcCKhmVudKVoh6QYmTM5+AxZmB6pu3zmae wCgwC0lqFpLUAkamVYySqQXFuem5xYYFRnmp5XrFibnFpXnpesn5uZsYwTGnpbWDcc+qD3qH GJk4GA8xSnAwK4nw8ok7pwvxpiRWVqUW5ccXleakFh9ilOZgURLn/fa6N0VIID2xJDU7NbUg tQgmy8TBKdXAtODahuqDRdWZy09ohrTu+7Zg2vsTHB8XPWfOXBiy+/z/ntV3HphqvuW883KV +6fzDWdWHdmrz+CTsituX+azRTwhIdbnpi7dyL9z4UMrJvnYNW+Kmqos13zpY5sWEND+brl5 rGB4qNgcj+9VM981rE8wfVKU38kbor786n0me7P7Xxvf3Dv7Mvvt/I/n1Zyfua/zNzgmse1j 48/2aau99v4x+uTlWidRuvv4c4vj/brR4R0a0YuZ5249LXDBauPzurkl4qEzddzteeMDK07o d1aHznKbFf3Aa5km6+cDp4r3vtaZ1xQuZqyqFbLSVnOBojEHM0PW9tA9mSmazYd27VgnXLwj LOCjXTNruOePd0osxRmJhlrMRcWJAIiWypgoAwAA X-CMS-MailID: 20241125071507epcas5p3b898d0960fb411cd176aea29029d820a X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071507epcas5p3b898d0960fb411cd176aea29029d820a References: <20241125070633.8042-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 Mon Nov 25 07:06: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: 13884534 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 3550416FF37 for ; Mon, 25 Nov 2024 08:09:05 +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=1732522146; cv=none; b=b776/O5bK3Bb4p4vfBaMPpbTFTAm7cbaL0RJYm57AP1sFn+Z9Dho+rTMQJMkXUY0jbJqntmc0Rg08iB4rHTFixDj2DU7+1ypsm+ISK9A9ucQU/QEPriG/Lo7hR3TywgpvUb+d3TViKJl3EnMdkzR/suUo+xltdAQ8baxSHx1pPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522146; c=relaxed/simple; bh=wf16SXbPE7IKcuRRSTK3G6OqCzknXrmBf1Mn0Cr7weM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=i7QYczUo594SPV+CLPWOaCXKxEUikYNTD7JSudDWbWsxoleK3gO8rJv358CiSfsefWRIcjwo7g8IArYOf4Ks6kk6Wu9y9JOBsTU4L83CQ/Jat++GI4AVavvCxW6mpsfDH8nOZhKKcetiFrG4PIagvw7Rg2yTBVTkqCA3lBlQRRU= 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=I0l+aS0/; 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="I0l+aS0/" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241125080903epoutp0183b9efa4d57a306274d0d366b9cb955d~LJ7XTizKC1216712167epoutp01l for ; Mon, 25 Nov 2024 08:09:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241125080903epoutp0183b9efa4d57a306274d0d366b9cb955d~LJ7XTizKC1216712167epoutp01l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522143; bh=DV5DBIpEJMoashvJk+4uhGWWufd3TPgC6b7DXtx2rfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I0l+aS0/4sNUdfdntSSEN/eqWE9k6Zxq2/rFWVJQTCB3D9pNMWjRom90tLyaFULhK Gjq/H76aXcofLWgubfLDGwVu8EVM3cN7HjGvlF3wMrF6VGgUcAuTQhB3PwFn+SI66n 9gsQKsA3RVW775xNdrBgJ1QXu5I2VJhdYyUf9Rj4= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241125080902epcas5p4974fd53f6f0600871071d337ac22d246~LJ7WgZ6QY1684116841epcas5p4R; Mon, 25 Nov 2024 08:09:02 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XxddS48Kqz4x9Q9; Mon, 25 Nov 2024 08:09:00 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D8.C6.19710.C9034476; Mon, 25 Nov 2024 17:09:00 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241125071510epcas5p47a424c419577f1e5c09375ce39a880c3~LJMUXmqzs1933019330epcas5p46; Mon, 25 Nov 2024 07:15:10 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071510epsmtrp2709d00e20d479c3c192298df43eb9d77~LJMUWsvqX0316003160epsmtrp2G; Mon, 25 Nov 2024 07:15:10 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-4c-6744309c17b8 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 1E.9E.18937.EF324476; Mon, 25 Nov 2024 16:15:10 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071508epsmtip1759915efa0c70e6cd4a3435cfd11f706~LJMSCDVT50361903619epsmtip1u; Mon, 25 Nov 2024 07:15:07 +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 v10 09/10] scsi: add support for user-meta interface Date: Mon, 25 Nov 2024 12:36:32 +0530 Message-Id: <20241125070633.8042-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrFJsWRmVeSWpSXmKPExsWy7bCmhu4cA5d0g+ZL8hYfv/5msWia8JfZ Ys6qbYwWq+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJotJh64xWuy9pW2xZ+9JFov5 y56yW3Rf38Fmsfz4PyaL83+Ps1qcnzWH3UHQY+esu+wel8+Wemxa1cnmsXlJvcfumw1sHh+f 3mLx6NuyitHjzIIj7B6fN8l5bHrylimAKyrbJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ 19DSwlxJIS8xN9VWycUnQNctMwfoHSWFssScUqBQQGJxsZK+nU1RfmlJqkJGfnGJrVJqQUpO gUmBXnFibnFpXrpeXmqJla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+/2s1m8PvyJ0eLmgZ1MFitXH2WyeNd6jsVi9vRmJotJh64xWuy9pW2xZ+9JFov5 y56yW3Rf38Fmsfz4PyaL83+Ps1qcnzWH3UHQY+esu+wel8+Wemxa1cnmsXlJvcfumw1sHh+f 3mLx6NuyitHjzIIj7B6fN8l5bHrylimAK4rLJiU1J7MstUjfLoEr4+nBm6wF50Ur3p7/xNjA eEWwi5GDQ0LAROLraecuRi4OIYHtjBLH//5m7WLkBIpLSJx6uYwRwhaWWPnvOTtE0UdGiTvH m5lBEmwC6hJHnreCFYkInGCUmD/RDaSIGaRowpfZLCAJYQEXiV83rrGD2CwCqhJbFr9gA7F5 BSwl9k3dxQSxQV5i5qXvYDWcQPG3bQfAeoUELCRmda5khagXlDg58wlYnBmovnnrbOYJjAKz kKRmIUktYGRaxSiaWlCcm56bXGCoV5yYW1yal66XnJ+7iREcX1pBOxiXrf+rd4iRiYPxEKME B7OSCC+fuHO6EG9KYmVValF+fFFpTmrxIUZpDhYlcV7lnM4UIYH0xJLU7NTUgtQimCwTB6dU AxPvprzW2VHrDhx5efZFRIOtgf/OyMXW5+Y9+63++enRVoEcsbSlaowpKioqvcofarsd9Sy7 ogR23Pery7TlCVw1O2h2TKzdgZvCD3wN2med/PbmSdiFyryzz06Ilqu4/r7TbRMqLfO6+P4W y5TzZnU/zfWV92i9drY/Zhz+W/7D4XSf2Ws2Pz4oOM3sa8WtXexneEXE7b3e/ZJcVmPsLf/1 TdKN1uZ7ezotu9g5Ntff/aTIe928od34X1vb6nytoIU+R/M5lj6cmpwXdiurWEW788hpMeP+ NQ4H3d9amTJO/6F7q9545TeZN7c9ffzeO9boditlH1UtynFZyD6JaZnnIRZhBtMtRS+/PzJ5 rcRSnJFoqMVcVJwIACZk9b4eAwAA X-CMS-MailID: 20241125071510epcas5p47a424c419577f1e5c09375ce39a880c3 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071510epcas5p47a424c419577f1e5c09375ce39a880c3 References: <20241125070633.8042-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 Mon Nov 25 07:06: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: 13884535 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 0524618A6C1 for ; Mon, 25 Nov 2024 08:09: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=1732522149; cv=none; b=jZQF2VjX6egFza4pxDmUz+QJpLGqpJgCoMLmJcAWgfeTS0VAyi0x6qmI8fFHDfZ74pEG2CknR3NDSejCt4E0yGX6QB1+T1YNIIg2Wbk52FrG7OYyvFKIO6V0avqNL3s8rxsjeeI1wLn++0nB7ddqkL3c8VBlT7t3xTKv4lso0gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732522149; c=relaxed/simple; bh=3+EpeSIcCbF/6ZjkqBAtW4O9T46NdqwVVHXXGudPBqs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=uaum63dKhybEPSsmr6EizRVMjo4sUm3V2YKhHX2l4fADkMOPGJMfK6RzHkBHDBm4jrm2SgIYPfj533BrkMb2LppBonOR7DCIBwarXVIneM7PTQoPtUuUOgMOoXWuB/HjSxvSHF2geQLtUfWqg8Kz+adxR+DSj44GM/NQV1PAhTo= 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=IiOBRd3V; 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="IiOBRd3V" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241125080905epoutp04a9a2750474bf9e86d2a98bc40df67e1c~LJ7ZIGOvj1536915369epoutp04p for ; Mon, 25 Nov 2024 08:09:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241125080905epoutp04a9a2750474bf9e86d2a98bc40df67e1c~LJ7ZIGOvj1536915369epoutp04p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732522145; bh=wQsh5MEv2xvuMdMfRC5hx+1fVZ+6hqXmEyHQLubiY3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiOBRd3VdE0CFYnDxLYf7yWZhycFvdyYIgUBc7YGjpAeHUvhAJiZZ3FDdCgoireTf rrNHcWUEPiX9jaq9FJEEAsqokfuLtm8OAVI5FwI7Qf8iWCfxOJUtH+DRE36hzuuaJp UXwPKrk7xgydaNeSDXNy0ENK1A4WktaDAErjX+5g= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241125080904epcas5p2a2b062f3df3661b7c9fe3be95daea41d~LJ7YhXdLs2571325713epcas5p2K; Mon, 25 Nov 2024 08:09:04 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XxddW1Qxdz4x9QG; Mon, 25 Nov 2024 08:09:03 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D5.DF.20052.F9034476; Mon, 25 Nov 2024 17:09:03 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241125071513epcas5p28b1c27bc43262eb575d576e32f8e3d7b~LJMW5CQMt0301003010epcas5p2U; Mon, 25 Nov 2024 07:15:13 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241125071513epsmtrp2809e4950879250e1150cd3cc9f0925d8~LJMW4MfQc0299802998epsmtrp2d; Mon, 25 Nov 2024 07:15:13 +0000 (GMT) X-AuditID: b6c32a49-3d20270000004e54-49-6744309fc76d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 32.AE.18937.10424476; Mon, 25 Nov 2024 16:15:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241125071510epsmtip1805f7c732c008101b63f5dc352fc2828~LJMUcCQnb0361903619epsmtip1w; Mon, 25 Nov 2024 07:15:10 +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 v10 10/10] block: add support to pass user meta buffer Date: Mon, 25 Nov 2024 12:36:33 +0530 Message-Id: <20241125070633.8042-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241125070633.8042-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+NgFrrLJsWRmVeSWpSXmKPExsWy7bCmlu58A5d0g8VnWC0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZxzbep+xoNuy4vrllYwNjBf0uhg5OSQE TCT+tZ1l6mLk4hAS2M0osX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CYdusZosfeWtsWe vSdZLOYve8pu0X19B5vF8uP/mCzO/z3OanF+1hx2ByGPnbPusntcPlvqsWlVJ5vH5iX1Hrtv NrB5fHx6i8Wjb8sqRo8zC46we3zeJOex6clbpgCuKC6blNSczLLUIn27BK6MY1vvMxZ0W1Zc v7ySsYHxgl4XIyeHhICJxPaDl1i7GLk4hAS2M0p8XXyLESIhIXHq5TIoW1hi5b/n7BBFHxkl 1q/vAkuwCahLHHneCmaLCJxglJg/0Q2kiFlgBpPE7z8LWEASwgJuEnt7v7KD2CwCqhKd62aA xXkFLCUOXj0CtUFeYual72A1nEDxt20HwGqEBCwkZnWuZIWoF5Q4OfMJWJwZqL5562zmCYwC s5CkZiFJLWBkWsUomlpQnJuem1xgqFecmFtcmpeul5yfu4kRHGtaQTsYl63/q3eIkYmD8RCj BAezkggvn7hzuhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe5ZzOFCGB9MSS1OzU1ILUIpgsEwen VAOTQd1Ei7M/V8/buv6vYvySJkGdnMe7bk5pW/Fy+af430nn+R7dZ7vuzdXw08h38Zngjxr3 5zbHXt7RJdS+Ztecmvsu0qff7woOrNp5bekBFQ2+L38PbTSRm+27aeNxvz2z/jas8Usym7i6 dh5H+qxv5739D2ZMTeyW3q7s4sqz7sZZxVsMb5PXvGhd0auSa2g277v1ITvJBr2Mt+qbTWtk Yk5nHd+vE8PAV5H8UKJ+e2zZ1O9tzoUmC1SPrI5YFSRSascwaY3mtwv8r5IcGS690Lxy5NYZ L/kjBz+rXlf45mHWf3vKnmQ154lL9/rMk/zGwfr6jtj6iIgi999Raj+vnWXXXldjkWwbHSpt taDipxJLcUaioRZzUXEiAAgRP4okAwAA X-CMS-MailID: 20241125071513epcas5p28b1c27bc43262eb575d576e32f8e3d7b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241125071513epcas5p28b1c27bc43262eb575d576e32f8e3d7b References: <20241125070633.8042-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 2d01c9007681..412ae74032ad 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) { }