From patchwork Thu Nov 14 10:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875003 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 97C051F8F13 for ; Thu, 14 Nov 2024 11:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583226; cv=none; b=m2MkQA6InzVMcslyuQw03W8RAi4291wWxJS3BtiAZUTJAEPPXmiv0TE2y/YO9njG7qNF/VVgo8LsjqvCybpZzda5XJwfJiAsOMDKkK7BSmxbbecgkqJkbN1I733zXLMkwe1bHUHdDwvePZ7qFxH5Wb+asIwuaSrKIko2M5/ZY9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583226; c=relaxed/simple; bh=z3oZCEUpNWP6ssVVNnvaEMGwTgZ5HxAO2xsIC7OVOu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=d+EZkrvGXUapkJj9dNtuXUHDjJJ+8HvVCD05WcEpHm6GMKlT2TbZ+xQVLg+Io69L1o4aS4Atc+1Plv1F+tCQMAASWaJDOzLZLi9ZiAzIoxnXYCGZ2TeM3RM97xtxeC3iB/E6wtHGWMsYJuzzt8GmpVR08h9jHkdXca59t/SFcD0= 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=OM6NmlR5; 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="OM6NmlR5" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241114112022epoutp021a107a2d13dd3f2a186c3e70a7e9acc6~H0cRTf_nK0642406424epoutp02z for ; Thu, 14 Nov 2024 11:20:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241114112022epoutp021a107a2d13dd3f2a186c3e70a7e9acc6~H0cRTf_nK0642406424epoutp02z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583222; bh=n6LNHR2UxOEOGCqUSfrJ4D/dcAXYHqklNM5hsVN/lLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OM6NmlR52Cq2DMdAggMa8MQtckr72iZZ0CEu6K/p9h082lCqLnBe5ZijP0l5km1t3 r+Ye7UquJz5u61n5YE5ZjJGAi0AAoj9k25ScClzkPs4GaRwPz/fo72tk+KzqmDBarY +4T+lN++ZTNZKERnehHiqOxnUH859FzkYPj/6me8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241114112022epcas5p4dd08b555c954d3b09f3284c37456fadd~H0cQfbZ250985409854epcas5p4c; Thu, 14 Nov 2024 11:20:22 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4XpyPJ0wMlz4x9Q6; Thu, 14 Nov 2024 11:20:20 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id E6.4F.37975.43CD5376; Thu, 14 Nov 2024 20:17:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241114105352epcas5p109c1742fa8a6552296b9c104f2271308~H0FHthlII2293722937epcas5p1j; Thu, 14 Nov 2024 10:53:52 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105352epsmtrp1bd5dd694a5fd20726a4d1a142a50e997~H0FHsqFUZ1625716257epsmtrp1s; Thu, 14 Nov 2024 10:53:52 +0000 (GMT) X-AuditID: b6c32a50-0e7f370000049457-80-6735dc3485ee Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 07.5A.07371.FB6D5376; Thu, 14 Nov 2024 19:53:51 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105349epsmtip2dea0f764454904e67d42a12e5e3f9985~H0FFVzS1y1405814058epsmtip2G; Thu, 14 Nov 2024 10:53:49 +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 v9 01/11] block: define set of integrity flags to be inherited by cloned bip Date: Thu, 14 Nov 2024 16:15:07 +0530 Message-Id: <20241114104517.51726-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-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xioTJ/1dy9T4VWRpixqFX2T51n+1a/NOvj q0pd5Xc22QsUtv/dU1J/dcJX9cU7eitNTta27zQr9PAsiYlv3/39/Y23OYumyMccV12zQvKH fGd/9/7bGmGTFytG6Dg9vSXgqmJptufHfuNZPflKNvOi9RnOLF78rFPq7MtbMXvv7mdr3mWp 6XFm/8vjzfOaizxFFp6sLz3k9FjI+eL9z6Ey3pc/ms5xCkz4Z2zRwFto9vzFRlvTON73j1wM 1k3bzKfEUpyRaKjFXFScCABMjY5XHwMAAA== X-CMS-MailID: 20241114105352epcas5p109c1742fa8a6552296b9c104f2271308 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105352epcas5p109c1742fa8a6552296b9c104f2271308 References: <20241114104517.51726-1-anuj20.g@samsung.com> Introduce BIP_CLONE_FLAGS describing integrity flags that should be inherited in the cloned bip from the parent. Suggested-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Keith Busch --- block/bio-integrity.c | 2 +- include/linux/bio-integrity.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 2a4bd6611692..a448a25d13de 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -559,7 +559,7 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vec = bip_src->bip_vec; bip->bip_iter = bip_src->bip_iter; - bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY; + bip->bip_flags = bip_src->bip_flags & BIP_CLONE_FLAGS; return 0; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index dbf0f74c1529..0f0cf10222e8 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -30,6 +30,9 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + #ifdef CONFIG_BLK_DEV_INTEGRITY #define bip_for_each_vec(bvl, bip, iter) \ From patchwork Thu Nov 14 10:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875005 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 9CA621F8937 for ; Thu, 14 Nov 2024 11:20:46 +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=1731583248; cv=none; b=Q8FyOMqn4WyjlCpyfxMlL/NcHB8hyQEQFIRv5C1Pdra/ENbjXOgjrbRYLl17voxJHnJnDDurxxb/AQeMiTAHdEnA/S3WSFh6PjJBLq/TVsh9CP/tsXEL/ysB+UFkrS9GbQeQPt5B8M8VPgBtQrGtEy60ZQR5pFcmRUCOYrehBSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583248; c=relaxed/simple; bh=g2fp64Elfp9R80cl3zu6i89Ehrxw1OCNHe/eXuK93qM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=EzftFklJYoc+7RaRP9v70iGvoIdkzmekxSNbGXfgFDfX8pUHXgCNFXtGALXF6h5rKupMcGPjQxl7JLOsxkMEU5i6VDQuOA87aaiu2241+qRa31XyI3RInhNktV6G7c7wt3322nbvIJhtZXZ4N1TAwhNscetIxu8qAFwaNawddZM= 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=UMHPSSMg; 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="UMHPSSMg" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241114112044epoutp048938b124e707a63b57b4d50babc8c80e~H0cl3Rz072225122251epoutp04f for ; Thu, 14 Nov 2024 11:20:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241114112044epoutp048938b124e707a63b57b4d50babc8c80e~H0cl3Rz072225122251epoutp04f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583245; bh=FQM1oME+yjLcszh/NNdlGeevLgEVh+e4WfItNIpaOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMHPSSMgUy7DoAp2Niy8aMZX9VrO1q6ZpYsbiuegYn3KI/y/UmxP0L+042WcrG2mi NCA8yd9Q9buS4AOV9m9Zx3+vj+bdAAQ+MnjNbvvESFm4vvBL+P5HKZHOFh5+Lowca7 5HxV8zTCd0Snq4LUE5LuhUwK8dXXfJNDdK/ZQn9s= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114112044epcas5p201405b0548d1fcb4fafdee083cdf0e3c~H0clL8nuO2483624836epcas5p2v; Thu, 14 Nov 2024 11:20:44 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XpyPj5wmNz4x9QP; Thu, 14 Nov 2024 11:20:41 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 28.4F.37975.C3CD5376; Thu, 14 Nov 2024 20:17:16 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413~H0FKDmn8J3038330383epcas5p4N; Thu, 14 Nov 2024 10:53:54 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105354epsmtrp15b28b4f295e4fa2d17925eab21257562~H0FKB5O4R1625716257epsmtrp1v; Thu, 14 Nov 2024 10:53:54 +0000 (GMT) X-AuditID: b6c32a50-085ff70000049457-97-6735dc3caa88 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F8.5A.07371.2C6D5376; Thu, 14 Nov 2024 19:53:54 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105352epsmtip2e2b0eed35b9ebb8f60e972629024a793~H0FHuq9Fv1405814058epsmtip2H; Thu, 14 Nov 2024 10:53: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 Subject: [PATCH v9 02/11] block: copy back bounce buffer to user-space correctly in case of split Date: Thu, 14 Nov 2024 16:15:08 +0530 Message-Id: <20241114104517.51726-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Tf0xTVxTHc98rrwVX9igs3jRxkke2iQRose0eKI4BI484NxJi4n5k8AYv LevP9MfGcImNpDPIsM45DD8UcSjaRpgIAkKNlDIQpDBgMOSXmBJHcUxsNpwOXEvL5n+fc8/3 nG/OufdyUN40xucUqPSMVkUrCCyEdb07ekcsNiOWCsZGxeTKn89Y5JETayhZbbkOSOuMGSOX uh8DcvJWO0JetvYg5LLJySKrThcj5En7OCBtd2PITtttFllzcYFNlk60YWR97zpCDq31BpFD ldXslDCqvXKGTY0OGqgmSwlGXas7THVMGjFqZeEuizrebAHUnXMONuVpepVqcv2OZIV8KN8j Y+h8RhvJqPLU+QUqaTKxLzsnLUcsEQhjhYnkm0SkilYyyUT6u1mxGQUK7zhE5Oe0wuA9yqJ1 OiJ+7x6t2qBnImVqnT6ZYDT5Co1IE6ejlTqDShqnYvRJQoEgQewV5splnqojiMYaWmgxlmNG cPKlYyCYA3ERbL/jQI+BEA4P7wTw2lob2x88BvD+xEwg+AvA0iEjulkycr4syJ+wAdjwzSLL H3gAbJ33AJ8Kw9+Ajgcm4EtE+BqX1Q5sqFB8EcALlvMsnyocz4N9NwYxH7Pw1+DMkBvxMRdP hFPWWszvtx1WjKyyfRyMJ8FLxhbUrwmDtytcG31Qr6a4pWpjDIiPcWBjx6+B4nT4R6eH7edw 6O5tDjAfLpq/DrAUPhldQPysgcU/3QR+fgua+s3ephyvQTRsvBHvP94Gv+9vQPy+obDsmStQ yoVtZzeZgEcvVwcYQpvTGGAKDpSbA+suA7Cv9FTQCRBZ+cI8lS/MU/m/9TmAWgCf0eiUUiZP rBHGqpgv/rvpPLWyCWw8851ZbcD641qcHSAcYAeQgxIR3P60XVIeN5/+sojRqn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nDE7RUggPbEkNTs1tSC1CCbL xMEp1cDkIFsRyVHulKmw2yjgzaJTKxKvc8XqdnltcJTdmOt1lPUmm0q9X9K+Vv4vT0zv8fgf TTRvjFybmv1cUHfVq882/a0rck1erTXb8u37/E25elHyk/+flNhw9XlvmkbUV+V/DrnvoipW GHRvaNs4f0vv70kTb2dN8IrzKPr/9v5shusTVjzv6H3Ta/XfI3je7n0Cmq/r9nTNv1fNeFph z447yZtjwtZdMNjUJXNB+/mFE0zr4ve/fLjDYYHaM9tuDd5lfldt2l0vvsx7WJTSt+Ro2vHL 5nvnSaxcXiQdYG7FVD9p3r9sFRM5S64zLrPtePuM3OMOJZmLeAXvaOR8PG2BX/nZ6A2860uX 3Pd/LrlfiaU4I9FQi7moOBEAaCGCdiIDAAA= X-CMS-MailID: 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413 References: <20241114104517.51726-1-anuj20.g@samsung.com> From: Christoph Hellwig Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers") Signed-off-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Keith Busch --- block/bio-integrity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index a448a25d13de..4341b0d4efa1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { - unsigned short nr_vecs = bip->bip_max_vcnt - 1; - struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; - struct iov_iter iter; + unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1; + struct bio_vec *orig_bvecs = &bip->bip_vec[1]; + struct bio_vec *bounce_bvec = &bip->bip_vec[0]; + size_t bytes = bounce_bvec->bv_len; + struct iov_iter orig_iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true); } /** From patchwork Thu Nov 14 10:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875002 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 887CC1F892C for ; Thu, 14 Nov 2024 11:20:12 +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=1731583214; cv=none; b=gfdtFa3KtH1BdHAPxre0GwwutWg/CmYBldLugKRS4mFTwm8FD3UD1uY7jfCdcXHfi/hud67n8l9Z3w+nOyv71rw1tWFJ4CzLDib0KBS1x0UpP2hIcXCI2J313RpGgdX3DkzhDitRUKzcCzA/qlQ/Duc2H4nP3ALZ0cTC2pDJvkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583214; c=relaxed/simple; bh=ZIkdyJlOm3c2bE0cQ6pelSYB5Gra8HNzZg1GmGSloUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=N3PXfl3ipSZCiBLdOUg+9QF0USe4DiWfcyaxNm2jt8XSEZVQEScMevHSPKeh0g93A271LtE7ykq7sPrjdlKbjQdfMrtfksQGUFobzSULpV48FDXqEzf0kpGEBSMUY59Ci9rrGIkwfEB06PCqM0mY+OFZ2RFOTube6bte2N9Z+u4= 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=PF0mD+1U; 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="PF0mD+1U" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241114112010epoutp01534d2a1e6ba142e7dc2fdd84de4fc1aa~H0cGBzSZf2568725687epoutp01R for ; Thu, 14 Nov 2024 11:20:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241114112010epoutp01534d2a1e6ba142e7dc2fdd84de4fc1aa~H0cGBzSZf2568725687epoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583210; bh=r23oSTZl50mKsH838ytL5lDlNxkmkMYy4oR7U1Ruz2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PF0mD+1Uc3ABHp9igVRJZyx9VaORGt6+h0rso+f6Mcecfr7dCmURgXPMzqR0FXF3i BY/+AAww+r/cFmJQ79gWtASLesNIoEKUxQmzSzdmgeGtMUXKL3x7a6hMXJZxK7RwFP CDnbpAkXajupTBxeMhm3Gp2lMYUULrUmZiGhrLqU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114112010epcas5p2c05eedd7aade60c18125b1c28d7d0e6c~H0cFvN30Z0550505505epcas5p2J; Thu, 14 Nov 2024 11:20:10 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4XpyP45js1z4x9Px; Thu, 14 Nov 2024 11:20:08 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0B.DA.09420.44CD5376; Thu, 14 Nov 2024 20:17:24 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241114105357epcas5p41fd14282d4abfe564e858b37babe708a~H0FMtRb9B0515805158epcas5p4n; Thu, 14 Nov 2024 10:53:57 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105357epsmtrp1348781fd0532b9999f94192cc2b3c546~H0FMsY4QM1621616216epsmtrp1M; Thu, 14 Nov 2024 10:53:57 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-e0-6735dc44f93e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 00.C6.18937.5C6D5376; Thu, 14 Nov 2024 19:53:57 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105354epsmtip256d59d467f449bb7ec6122186b09da67~H0FKKnhPi1403514035epsmtip2R; Thu, 14 Nov 2024 10:53: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 v9 03/11] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Thu, 14 Nov 2024 16:15:09 +0530 Message-Id: <20241114104517.51726-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xbVRzHPfde2gux27WAHjBjeKfOzgAta7vLhE0tw6vz0ekSnXF2HdwV pLRNH+pM1ApjZGwUEAysKwNlDikGoXY8hPLoeGTgHhm4V4QsAgEcMKBhDyvTllt0/33O7/v7 5vc45+Aof4QTiWdojIxeo1STnBCs6axAEDPxu0QlzOt8llpY8mJUdtEyStnsTYCqGynkULfO LgLqelcrQtXW9SLUXO4FjDpRloNQvf/Mcqiv3VcA5brxPNXuOodRlacnuNTRqy0cqqb/AUJd XO4Poi5abdwX+XSrdYRLD5030Q77EQ7986kv6bbrZg69MHEDoy1OO6B/rerh0h5HFO0Yn0Xk Ie9nJqYzyjRGH81oUrVpGRpVErnzHYVMIZEKRTGiBGoLGa1RZjFJZPLr8piUDLVvJjL6Y6Xa 5AvJlQYDGbctUa81GZnodK3BmEQyujS1TqyLNSizDCaNKlbDGLeKhMJ4iS9xX2b6xJQH0bVH fdo2RJtBU0Q+CMYhIYZDU71IPgjB+UQbgN6/plC/wCcWAWzw7GEFH1flD3NWHd2j5iBWaAXQ 2fcbyh48Pru7BPFncYiNsGcyF/iFMKIdwIJvBzH/ASWKEJhX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4eEgInEwXsNrCC2kMB2Ronb72wg4hISp14uY4SwhSVW/nvO3sXIBVTzkVFi 0vpLLCAJNgF1iSPPW8GKRAROMErMn+gGUsQsMINJoufXCjaQhLBArMSOY3PBNrAIqEpMvt7O DmLzClhK3NveyAaxQV5i5qXvYHFOASuJFQ1bmbsYOYC2WUp8Xy8CUS4ocXLmE7C9zEDlzVtn M09gFJiFJDULSWoBI9MqRtHUguLc9NzkAkO94sTc4tK8dL3k/NxNjOAo0wrawbhs/V+9Q4xM HIyHGCU4mJVEeE85G6cL8aYkVlalFuXHF5XmpBYfYpTmYFES51XO6UwREkhPLEnNTk0tSC2C yTJxcEo1MDUWp14xbfkppsni9sziS/CE+Se+yV11mTbBNzr5iYTjkgO/KgSuBtgu3JeevVL0 4/23E3rv1X19t1r3b/kB07NMBzz+9PL7TFoRstI2rcJL+LI2/+8d3X6zbYIf7rJmPHA6cp5G GrdGGPPOANaOXCmfbKErcxTPpJ9/+muzS8qJ3JfZghNXL/01Idc3NnjVUelzvP35P13TnP8/ +b7rTLni0TINp186n5/yel7eoHj6PePm71MzVvImnM5ZemLFE+e/RzcdcVSZ6vp1yz/F3F1s t/vntjTZ88RtSHN+d+pvpUguG2dnk++CU/VF3VKsrCtmTphdtWtPkUXgjKfJRhltt+coK+f2 TSlIlROO7VZiKc5INNRiLipOBAClUBqXIQMAAA== X-CMS-MailID: 20241114105357epcas5p41fd14282d4abfe564e858b37babe708a X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105357epcas5p41fd14282d4abfe564e858b37babe708a References: <20241114104517.51726-1-anuj20.g@samsung.com> This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 12 +++++------- block/blk-integrity.c | 10 +++++++++- include/linux/bio-integrity.h | 5 ++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 4341b0d4efa1..f56d01cec689 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -302,16 +302,15 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = blk_lim_dma_alignment_and_pad(&q->limits); struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages; struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec; + size_t offset, bytes = iter->count; unsigned int direction, nr_bvecs; - struct iov_iter iter; int ret, nr_vecs; - size_t offset; bool copy; if (bio_integrity(bio)) @@ -324,8 +323,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) else direction = ITER_SOURCE; - iov_iter_ubuf(&iter, direction, ubuf, bytes); - nr_vecs = iov_iter_npages(&iter, BIO_MAX_VECS + 1); + nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS + 1); if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { @@ -335,8 +333,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/block/blk-integrity.c b/block/blk-integrity.c index b180cac61a9d..4a29754f1bc2 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -115,8 +115,16 @@ EXPORT_SYMBOL(blk_rq_map_integrity_sg); int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, ssize_t bytes) { - int ret = bio_integrity_map_user(rq->bio, ubuf, bytes); + int ret; + struct iov_iter iter; + unsigned int direction; + if (op_is_write(req_op(rq))) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, ubuf, bytes); + ret = bio_integrity_map_user(rq->bio, &iter); if (ret) return ret; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 0f0cf10222e8..58ff9988433a 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -75,7 +75,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr); int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -101,8 +101,7 @@ static inline void bioset_integrity_free(struct bio_set *bs) { } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len) +static int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) { return -EINVAL; } From patchwork Thu Nov 14 10:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875000 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 4ACE91F8900 for ; Thu, 14 Nov 2024 11:19:51 +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=1731583193; cv=none; b=cvqlYHi3EIhEVmMVcc5tS0yEJfHqTZrTZxLDY2pabW1GbZArMdbtb0NW4mAApffWOerXbJ35KH77pu/aOO5Gh7SQFWDcFsAUx8KMyg3hCvmJjSK1tI3mGNrUgAyq2syHo1ohtVNy/Tc1K3gmMwK4tcggyXez2fubwgAcgQ/CHPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583193; c=relaxed/simple; bh=uDUb87C52DXoVA3KvOoAoNEyjHqrw30MJR/Iqxaidaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=kSiC/ZHLgc+FXYDb8k5LphkPn1QBPAIe5QMkxULII5M/v/MGgRwa6tfvqSzYyNkf0+g474QyWsaDBfmErRUveF5jyS3v9fcgv7oYefdgpu/5/wctiyjcx3eE5uzk4g3Jzcwayg2nBMAAgMQfve5KaJ4orOAET6+44cTMWOEMDm4= 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=RlgF5xNM; 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="RlgF5xNM" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241114111948epoutp024b3940948c8ac732b8b9740bba0c8293~H0bxtplmU0645406454epoutp02G for ; Thu, 14 Nov 2024 11:19:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241114111948epoutp024b3940948c8ac732b8b9740bba0c8293~H0bxtplmU0645406454epoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583189; bh=sPCiH7C8otAPeKBQxafGfpBc//4CVwTtOappMXTNYFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlgF5xNMuUcKjGML3C8N0JeFOiViW/LjLn8h1w2J5Ner2dpbM8OsTrSdsPltPYyRF ySzGDdFHoPydzXNg4Sak7Ui9py+kMu2QkfuVPBokmXAESKmIsAnfx7cxbZA3jqG4uF PoP4CZR0+xvujS26TWSvy3/0CEqzcg7+pr0NWGNI= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114111948epcas5p2425468228fccc7ba27fd405cfe538a0c~H0bxSRZWr0097800978epcas5p2U; Thu, 14 Nov 2024 11:19:48 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XpyNf5Dy7z4x9QG; Thu, 14 Nov 2024 11:19:46 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AB.DA.09420.A4CD5376; Thu, 14 Nov 2024 20:17:30 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241114105400epcas5p270b8062a0c4f26833a5b497f057d65a7~H0FPJmqK_1555815558epcas5p2d; Thu, 14 Nov 2024 10:54:00 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241114105400epsmtrp2eedbb581c1c9a80d1800cf73f9b7ce21~H0FPIWilp1919519195epsmtrp2J; Thu, 14 Nov 2024 10:54:00 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-ec-6735dc4a6900 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.5A.07371.7C6D5376; Thu, 14 Nov 2024 19:53:59 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105357epsmtip2bec5fd7f0d47e4a70ee8b15f3b18d6fa~H0FMtVSO_1421814218epsmtip2I; Thu, 14 Nov 2024 10:53: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 , Kanchan Joshi Subject: [PATCH v9 04/11] fs, iov_iter: define meta io descriptor Date: Thu, 14 Nov 2024 16:15:10 +0530 Message-Id: <20241114104517.51726-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02TfVRTZRzHfe693F3gzHPDl57oxXlNUHRzw23dEaiEB2/p6XBO51jZH7TD boPY29lLllhRNBEUxmYvOF6UGhlbCiFwkAHHeAnFQoQOhrVK40U0IOE07QDaxh3lf5/f7/n+ Xp/nIdAoHx5NZOnMrFGn1FB4BNbUuTFO2P+LTC2utUXTd/6ew+gPSxZQutzdBGiPz4bTtztn AD18/hxC13i6EXrK2ofRZZ/lIXT3g0mcdnQMAbrt2ia6te0iRp/4cpRHH7najNOneu4j9OWF njD6srOctyOKOef08ZjBHyxMvbsAZ8663me8w7k4c2f0GsYUN7gB8/3JLh4zW/8UUz8yiaRF 7MtOzGSVKtYoYHUZelWWTp1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izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSyO/n/LZjHp0DVGi723tC32 7D3JYjF/2VN2i+7rO9gslh//x2Rx/u9xVovzs+awOwh57Jx1l93j8tlSj02rOtk8Ni+p99h9 s4HN4+PTWywefVtWMXqcWXCE3ePzJjmPTU/eMgVwRXHZpKTmZJalFunbJXBlLJmmW3CFt2Lx tYVsDYyzubsYOTkkBEwkbh5tZQSxhQR2M0r8fc4EEZeQOPVyGSOELSyx8t9zdoiaj4wSG2eD 2WwC6hJHnkP0igicYJSYP9Gti5GLg1lgBpNEz68VbCAJYQFHiUPbPoMNZRFQlXi65BsziM0r YCkxcfMeZogF8hIzL30HG8opYCWxomErUJwDaJmlxPf1IhDlghInZz5hAbGZgcqbt85mnsAo MAtJahaS1AJGplWMkqkFxbnpucmGBYZ5qeV6xYm5xaV56XrJ+bmbGMGxpqWxg/He/H96hxiZ OBgPMUpwMCuJ8J5yNk4X4k1JrKxKLcqPLyrNSS0+xCjNwaIkzms4Y3aKkEB6YklqdmpqQWoR TJaJg1OqgYlNVpdh4cIjtpO11N6c4A1Z+34Zh/z8S8GLdp6eyFR1dY+bZuRa/vppiovvKC+z a9q5n8MsyChFwvfGYbHZ01pPVOxzX3sk9f37U94zJs9rWVXE9CtsWu4zs9K3Vo/v2rpeV9+e fYTj8CeNnrce05b2y0au2vZm6f8XOrY2FX84+T5rs5i0f7r9qqltt3OqqFYed+r9+1GvPVl1 sjV4b3ySt90o+M1Fp/bdtGMT+DyucXJsWLq3pmJGROjjwDWn418aXdshvPXhQs+QZb8PHHnA rlpzbW9gjUHUIrvTal9rJ4YJtsTZzXtmumDni3/qIg8rdK6xTBf9wulen7FLR9P9wKn2sHsa Wb8/hDjPn1OjxFKckWioxVxUnAgARuYorSQDAAA= X-CMS-MailID: 20241114105400epcas5p270b8062a0c4f26833a5b497f057d65a7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105400epcas5p270b8062a0c4f26833a5b497f057d65a7 References: <20241114104517.51726-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: 13875001 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 89DBE192D9D for ; Thu, 14 Nov 2024 11:20:09 +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=1731583211; cv=none; b=W9QfE7MfqgIiOBXqJp02CjtOVcfEp6wZ5Hi3QsK05ADheX+iVjsYlbwIYOhEZEcc6jiO299cADQa6dlT4x8+rs6Ptjbot/vXzipfoRC/NVD2FadBhCH3KhYr6p/iIka9ke7fsQgUWAfAtH6hHapY9esMT3lOI75L67QhmKym/Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583211; c=relaxed/simple; bh=PPDNMGOuEvkJDIU7LllEytV2427zo9AzbP3ebXn9pJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KB2Z97miuPxncT+3R7qQODAO1tkgiw7LMMZeo93auqrFcFYv8V2hwihurBOFEsQS2f6PaNGC+qhH/P07u49cSJSfhADF3YllU7A3j6Y1CdY7aZqqzE/dLSs6fYUa2BxE/aRvQBE1FiSBZY3gYvSFAWvHs6FfjnXDE2lLQbjUTzk= 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=YHSThZ5o; 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="YHSThZ5o" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241114112007epoutp0458d522ee802d38f3ada966aed10b96e7~H0cDYIXlg1893018930epoutp04k for ; Thu, 14 Nov 2024 11:20:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241114112007epoutp0458d522ee802d38f3ada966aed10b96e7~H0cDYIXlg1893018930epoutp04k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583207; bh=0Qev84oB/WNNKAORKgHjGWYS6Jca41BG3ZIzsvdmNNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHSThZ5o1xsaqVz750hiIlC852GqUiM1IQXXw1DR/beIhr5836ZE3Wt+YIIXkUj9N qfRNaeZarEv1+hoFwMNJExVHZa0hqsNqhliNPS25Xm22LMZlJJJoYFSMoAjS18dDAW rkJsGqf8ZgnQONuG8cr2FwWIsT5l8FerIGXJfbvw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114112007epcas5p2c0c280818e38dd3044fa0b8aeec9bbd2~H0cC4FZ8L1060210602epcas5p2B; Thu, 14 Nov 2024 11:20:07 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XpyP05d2Tz4x9Q3; Thu, 14 Nov 2024 11:20:04 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 1C.DA.09420.F4CD5376; Thu, 14 Nov 2024 20:17:35 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241114105402epcas5p41b1f6054a557f1bda2cfddfdfb9a9477~H0FRiATPP2479024790epcas5p47; Thu, 14 Nov 2024 10:54:02 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241114105402epsmtrp219b5de0bea165464a14f74580ee83897~H0FRg6MAH2100721007epsmtrp2G; Thu, 14 Nov 2024 10:54:02 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-f6-6735dc4f96cf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 77.B3.08227.AC6D5376; Thu, 14 Nov 2024 19:54:02 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105400epsmtip2f563123d90e413f262c86ef493005d03~H0FPOEslx1406514065epsmtip2V; Thu, 14 Nov 2024 10:53: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 Subject: [PATCH v9 05/11] fs: introduce IOCB_HAS_METADATA for metadata Date: Thu, 14 Nov 2024 16:15:11 +0530 Message-Id: <20241114104517.51726-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJJsWRmVeSWpSXmKPExsWy7bCmuu7jO6bpBmeeG1t8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSwmHbrGaLH3lrbFnr0nWSzm L3vKbtF9fQebxfLj/5gszv89zmpxftYcdgdBj52z7rJ7XD5b6rFpVSebx+Yl9R67bzaweXx8 eovFo2/LKkaPMwuOsHt83iTnsenJW6YArqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwND XUNLC3MlhbzE3FRbJRefAF23zBygd5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqpBSk5 BSYFesWJucWleel6eaklVoYGBkamQIUJ2RlrT69hLLjCWrH+VgtjA+M1li5GTg4JAROJE7de MYPYQgK7GSUe9Zp0MXIB2Z8YJXYtWMcG4XxjlJg67TcbTMe22avZIRJ7GSXuNNxlhXA+M0o0 vbzDBFLFJqAuceR5KyNIQkRgD6NE78LTLCAOs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4+ vcXi0bdlFaPHmQVH2D0+b5Lz2PTkLVMAVxSXTUpqTmZZapG+XQJXxtrTaxgLrrBWrL/VwtjA eI2li5GTQ0LARGLb7NXsXYxcHEICuxklHsx+ygSRkJA49XIZI4QtLLHy33N2EFtI4COjRMdL XRCbTUBd4sjzVrAaEYETjBLzJ7qBDGIGqZnwZTbYBmEBN4nvfbOYQWwWAVWJZ0fnsILYvAKW Eou6T7NCLJCXmHnpO9gCTgEriRUNW4HqOYCWWUp8Xy8CUS4ocXLmE7CRzEDlzVtnM09gFJiF JDULSWoBI9MqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95PzcTYzgKNPS2sG4Z9UHvUOMTByM hxglOJiVRHhPORunC/GmJFZWpRblxxeV5qQWH2KU5mBREuf99ro3RUggPbEkNTs1tSC1CCbL xMEp1cDE1Z2RucxjOvt8eemNnyYvvXzpko19wtrGLxcSXF84Cv87UxwxW1bqyIbft58Jxe1f sONtk7vFzZDqequYm34pwoa8cs2zVV/lXZnUHLd546+rn/RMZRjjZkbd01oaeOdUS1Nv4cHZ pa9sWY9Hbv2SuGuK7aSYbMOUFrZdCneS30/bPGNS7LHiaQuO7zKLXlRpsyavIMqmjE3yoSrj NIdZeaav+g7OMrYKFzus8vDmWrYrft77n+kXXj0n4xPxMf5BEEOfdRq3XfLxkMsRFRmpSyz+ lJQ5b+yb+7pybv30Zt9jvPxflx/mVzdepm+4QPzppYt3tYULquQfSl9nKVeZEBOzSrNmimKV e9zGtS+VWIozEg21mIuKEwGqv5BkIQMAAA== X-CMS-MailID: 20241114105402epcas5p41b1f6054a557f1bda2cfddfdfb9a9477 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105402epcas5p41b1f6054a557f1bda2cfddfdfb9a9477 References: <20241114104517.51726-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 4b5cad44a126..7f14675b02df 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -346,6 +346,7 @@ struct readahead_control; #define IOCB_DIO_CALLER_COMP (1 << 22) /* kiocb is a read or write operation submitted by fs/aio.c. */ #define IOCB_AIO_RW (1 << 23) +#define IOCB_HAS_METADATA (1 << 24) /* for use in trace events */ #define TRACE_IOCB_STRINGS \ From patchwork Thu Nov 14 10:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13874974 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 6D5DA1F8F1A for ; Thu, 14 Nov 2024 11:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583075; cv=none; b=aysyy942Jo+livOydAKBETmsV69f+yHgCXyMp7XMtSMSGps+kPTxikF5Nga8e2Imx56NkmF4CYBO7fRPUB6ADQQPL91L5PoqSPhVOaa+9sqd/AgoRkcOlta+GQ7AQh/qLPRnGSudnDyqFVmIM31SONlMX6UEWIaZzZPayDh7pwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583075; c=relaxed/simple; bh=PyfcMAMGeZJg51IyMSZk4QQAUN0KrHf8jzVl+O0XVOM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=M/Cv9lDp7qkPNwqVRcn381+QIXnQ6GqDL3iS7KEs/7xl34v1qD2LjZqYRe+AlPzJBUYgMrdMItA4IMnZah3GxrrT1mjEwEXQ/Vtfi2cTT2IGoF9ppAinYEZx8kbvGhe5ftKrYRetBgPE2kKzoGh1ZZXV9PLu6cGi0ZEhypGcyTE= 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=c9bj50yI; 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="c9bj50yI" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241114111745epoutp01a54992e2d123a8358b10a5fbc4733121~H0Z_ub11R2262522625epoutp01c for ; Thu, 14 Nov 2024 11:17:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241114111745epoutp01a54992e2d123a8358b10a5fbc4733121~H0Z_ub11R2262522625epoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583065; bh=tZZIY0MH0UpA8H3aJms9Q19PBOI9eFg3Maw9wcJIZ5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9bj50yIOUcxgXm68TaemLMasL3FIrV5PsGsN2noJy7MKDWUKtGnfg+of9DsDPxpr u4SEpnzPL/xe7kchrdYAZWAc9h4MP4nzgcPZErHAJVeC6YOxA6dMxqvpgh43XDqMex 25NXAnUaxGylC/XmdwLc2xzhJZ1esmFOS54tqRpY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241114111744epcas5p38ca87425dbc104df262cec71a0585b04~H0Z_D16aB2860228602epcas5p3A; Thu, 14 Nov 2024 11:17:44 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XpyLH0Klsz4x9Pw; Thu, 14 Nov 2024 11:17:43 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 93.A9.09770.65CD5376; Thu, 14 Nov 2024 20:17:42 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241114105405epcas5p24ca2fb9017276ff8a50ef447638fd739~H0FUG_oPd1716917169epcas5p2L; Thu, 14 Nov 2024 10:54:05 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241114105405epsmtrp2a9b6c23a8130ecc72bb42f54c9d522c2~H0FUGE-Zn2090520905epsmtrp2X; Thu, 14 Nov 2024 10:54:05 +0000 (GMT) X-AuditID: b6c32a4a-e25fa7000000262a-ed-6735dc566311 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 25.C6.18937.DC6D5376; Thu, 14 Nov 2024 19:54:05 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105402epsmtip25f2a68912a8179078ecbb54411c30476~H0FRnf2GX1403514035epsmtip2b; Thu, 14 Nov 2024 10:54: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 v9 06/11] io_uring: introduce attributes for read/write and PI support Date: Thu, 14 Nov 2024 16:15:12 +0530 Message-Id: <20241114104517.51726-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Tf0wTZxjOd3e7FrLCgaCfTZzdZSqiFCptORygCWSeboksLsawGHbSSyGU a+21m5ORNSDBwRBUHFIQ0LApuLiBivzqhvUHoUy6itmkEaYEnFhp5IfBiMBKW5z/Pc/7Pc/7 5nm/7xOiof/gYmEWZ2D1HKMh8UCs9cbGiKi9DxTqmJfPYqnJF3MYlV8+j1I1Ta2AujhUhlOu G1OAGuxuR6jGi7cQyl3Yj1HVlQUIdWtxAqdOWP8ClMW5ieqy9GJU3U9jAqrk7zacOt+zgFD2 +Z53KLu5RrA9lG43DwnogTtGuqXpO5y+3PAt3TlowunJMSdGH7vSBOg/6m8K6OmW9+iW0Qkk NTAtOyGTZVSsXsJyGVpVFqdOJD/ek56crlDGyKJk8VQcKeGYHDaRTPkkNeqjLI0nEyn5ktEY PaVUhufJ6KQEvdZoYCWZWt6QSLI6lUYn10l5Joc3cmopxxq2ymJitig8wi+yMy1nHZjuxc5D zVVlmAl0fVgMAoSQkMPWQTNaDAKFoUQngK8cDsRHpgCssJ/E35Dumcdg2WLtqfSr2gEcnmsF PjINoP1hg1eFExvgzX8LvQdhRBeApWf7sCWCEuUILDpeI1hSrSD2wTOvz+FLGCPWQdNTp9ct IuJhn60D9c1bC6vuznr1AcRWeMF0FfVpQmBv1Si2hFGPpuBqtTcGJO4J4axtxGMQekgKfLyI +fqsgE97rgh8WAyn3Rbch9Xw5cAY4sM6WHD7N3/ObbDQ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BKYkXDVqA4B9A2S4nv60UgygUlTs58wgJiMwOVN2+d zTyBUWAWktQsJKkFjEyrGEVTC4pz03OTCwz1ihNzi0vz0vWS83M3MYIjTStoB+Oy9X/1DjEy cTAeYpTgYFYS4T3lbJwuxJuSWFmVWpQfX1Sak1p8iFGag0VJnFc5pzNFSCA9sSQ1OzW1ILUI JsvEwSnVwNR1tdvU9LWKmN+XtNxdRVwnfpa9CeY18qjQNpu4qrvq+tRDf9iNV0b4ZP7z+H3c /Hji/sDQo0aT/2/bvbHG+btWyXLLXY1hIjmmwvs5a6q/MLqaTH7cwt+m4enodDF/4f52g1CZ bzMmSk96HF62LdY7weHQqhUn9Zad0d5m1Jv3ceLfw235P7UspsmuddjJc3zDS5HNr5lvfHov dKw8KM1ZQtyEsc3gguQzW1mZnTc/efkeWFX031HP6pRBSuxqk6AZ+mqPedqSXls/jfd/m9fY 1ff07k/zWS6fNU3EWN/NYVbhiVa555x0dnKWstFh7aRVrfkvKk8sbD5Tv0h6z3XfiseKiv+O C71KODTphBJLcUaioRZzUXEiAARm4AcjAwAA X-CMS-MailID: 20241114105405epcas5p24ca2fb9017276ff8a50ef447638fd739 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105405epcas5p24ca2fb9017276ff8a50ef447638fd739 References: <20241114104517.51726-1-anuj20.g@samsung.com> Add the ability to pass additional attributes along with read/write. Application can populate an array of 'struct io_uring_attr_vec' and pass its address using the SQE field: __u64 attr_vec_addr; Along with number of attributes using: __u8 nr_attr_indirect; Overall 16 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. Also, vectored read/write operations are not supported with PI currently. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/uapi/linux/io_uring.h | 29 ++++++++ io_uring/io_uring.c | 1 + io_uring/rw.c | 128 +++++++++++++++++++++++++++++++++- io_uring/rw.h | 14 +++- 4 files changed, 169 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 5d08435b95a8..2e6808f6ba28 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -92,12 +92,18 @@ struct io_uring_sqe { __u16 addr_len; __u16 __pad3[1]; }; + struct { + /* number of elements in the attribute vector */ + __u8 nr_attr_indirect; + __u8 __pad4[3]; + }; }; union { struct { __u64 addr3; __u64 __pad2[1]; }; + __u64 attr_vec_addr; __u64 optval; /* * If the ring is initialized with IORING_SETUP_SQE128, then @@ -107,6 +113,29 @@ 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 = 16, +}; + +struct io_uring_attr_vec { + enum io_uring_attr_type type; + __u64 addr; +}; + +/* PI attribute information */ +struct io_uring_attr_pi { + __u16 flags; + __u16 app_tag; + __u32 len; + __u64 addr; + __u64 seed; + __u64 rsvd; +}; + /* * If sqe->file_index is set to this for opcodes that instantiate a new * direct descriptor (like openat/openat2/accept), then io_uring will allocate diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index bd71782057de..e32dd118d7c8 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3867,6 +3867,7 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(44, __u32, file_index); BUILD_BUG_SQE_ELEM(44, __u16, addr_len); BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); + BUILD_BUG_SQE_ELEM(44, __u8, nr_attr_indirect); BUILD_BUG_SQE_ELEM(48, __u64, addr3); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); diff --git a/io_uring/rw.c b/io_uring/rw.c index cce8bc2ecd3f..93d7451b9370 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -257,11 +257,98 @@ 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, + const struct io_uring_attr_pi *pi_attr) +{ + const struct io_issue_def *def; + struct io_async_rw *io; + int ret; + + if (READ_ONCE(pi_attr->rsvd)) + return -EINVAL; + + def = &io_issue_defs[req->opcode]; + if (def->vectored) + return -EOPNOTSUPP; + + io = req->async_data; + io->meta.flags = READ_ONCE(pi_attr->flags); + io->meta.app_tag = READ_ONCE(pi_attr->app_tag); + io->meta.seed = READ_ONCE(pi_attr->seed); + ret = import_ubuf(ddir, u64_to_user_ptr(READ_ONCE(pi_attr->addr)), + READ_ONCE(pi_attr->len), &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + rw->kiocb.ki_flags |= IOCB_HAS_METADATA; + io_meta_save_state(io); + return ret; +} + + +static inline int io_prep_pi_indirect(struct io_kiocb *req, struct io_rw *rw, + int ddir, u64 pi_attr_addr) +{ + struct io_uring_attr_pi pi_attr; + + if (copy_from_user(&pi_attr, (void __user *)pi_attr_addr, sizeof(pi_attr))) + return -EFAULT; + return io_prep_rw_pi(req, rw, ddir, &pi_attr); +} + +static int io_prep_attr_vec(struct io_kiocb *req, struct io_rw *rw, int ddir, + u64 attr_addr, u8 nr_attr) +{ + struct io_uring_attr_vec attr_vec[ATTR_TYPE_LAST]; + size_t attr_vec_size = sizeof(struct io_uring_attr_vec) * nr_attr; + u8 dup[ATTR_TYPE_LAST] = {0}; + enum io_uring_attr_type t; + int i, ret; + + if (nr_attr > ATTR_TYPE_LAST) + return -EINVAL; + if (copy_from_user(attr_vec, (void __user *)attr_addr, attr_vec_size)) + return -EFAULT; + + for (i = 0; i < nr_attr; i++) { + t = attr_vec[i].type; + if (t >= ATTR_TYPE_LAST) + return -EINVAL; + /* allow each attribute only once */ + if (dup[ATTR_TYPE_PI]) + return -EBUSY; + dup[ATTR_TYPE_PI] = 1; + + switch (t) { + case ATTR_TYPE_PI: + ret = io_prep_pi_indirect(req, rw, ddir, attr_vec[i].addr); + break; + default: + ret = -EOPNOTSUPP; + } + if (unlikely(ret)) + return ret; + } + return 0; +} + 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; + u8 nr_attr_indirect; int ret; rw->kiocb.ki_pos = READ_ONCE(sqe->off); @@ -279,11 +366,29 @@ 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; + + nr_attr_indirect = READ_ONCE(sqe->nr_attr_indirect); + if (nr_attr_indirect) { + u64 attr_vec_usr_addr = READ_ONCE(sqe->attr_vec_addr); + + if (READ_ONCE(sqe->__pad4[0]) || READ_ONCE(sqe->__pad4[1]) || + READ_ONCE(sqe->__pad4[2])) + return -EINVAL; + + ret = io_prep_attr_vec(req, rw, ddir, attr_vec_usr_addr, + nr_attr_indirect); + } + + return ret; } int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe) @@ -409,7 +514,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 +902,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 +936,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 +1022,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 +1247,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 Thu Nov 14 10:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13874999 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 60CB9187FFE for ; Thu, 14 Nov 2024 11:19:38 +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=1731583180; cv=none; b=ihU9j7FgW2p6eHicvns11Q846ZZtJtXOuv6+NmA0p4jXsl67/7ZnUwS4boDMzFPU3GQpy9fZVODKWIRgJDVANu2IfCXgIIC16m+KNIpHAlCXyeA8eEa/EcdNrM1CFyIka/AVKscpVLja5wr//75Rb0mQTkUucFd/reZOw4wzSoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583180; c=relaxed/simple; bh=2kIvGSsCSHjizaCaOq0s4apCtzvVdfMgd90goROBPp0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=EcG19p5OfShH/QxNsyzShBlmBogzPvjzMne/6o7LoSTHI4USaE6BhKqoqyWms3bQL1n1Dco7oy1tNQrVLHocpUC5F5OCOEODvkz90aUIf/nryjF3Nngi+6J73yIY4tBfx5MogEPndI+7SZuWMk4QX5GOOw9Wso0d/pTnaZmNX9k= 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=ig+phc+d; 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="ig+phc+d" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241114111936epoutp0324630c8395dea240b602bb16f8efb372~H0bl_L7PY0104601046epoutp03S for ; Thu, 14 Nov 2024 11:19:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241114111936epoutp0324630c8395dea240b602bb16f8efb372~H0bl_L7PY0104601046epoutp03S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583176; bh=ib9AJGQhu+ajB/AguVXUCgWXWEskadPzJ1mb3EBw6vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ig+phc+dpYAHfx/m2ZXI0wwlGapB17T9cvMJuqeHKPb6XpL6o7E1jti4jPCc7Zk2p kVwXahoZniHUnJCWqzsE/4fEFL+6TgLMb3kon9og1F94k+II2qqNvzpVLfQfEFsfl+ gUrnX5oOoLrAfQICHHr6Vil2QXWzBPyiS//rUSjw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241114111935epcas5p17e85db56c4b17db0b346ec3563cc1247~H0blZ-ko62218022180epcas5p1x; Thu, 14 Nov 2024 11:19:35 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XpyNQ0rfWz4x9Pw; Thu, 14 Nov 2024 11:19:34 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FC.DA.09420.A5CD5376; Thu, 14 Nov 2024 20:17:46 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241114105408epcas5p3c77cda2faf7ccb37abbfd8e95b4ad1f5~H0FWspZez2837828378epcas5p3d; Thu, 14 Nov 2024 10:54:08 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241114105408epsmtrp2198d5ad524349923cd606f526fb13590~H0FWrul5g2100721007epsmtrp2i; Thu, 14 Nov 2024 10:54:08 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-0c-6735dc5afa28 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 49.C6.18937.FC6D5376; Thu, 14 Nov 2024 19:54:07 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105405epsmtip2083515c687749b8fae452db789bcba2c~H0FUNCF9p1327613276epsmtip23; Thu, 14 Nov 2024 10:54: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, Anuj Gupta , Kanchan Joshi Subject: [PATCH v9 07/11] io_uring: inline read/write attributes and PI Date: Thu, 14 Nov 2024 16:15:13 +0530 Message-Id: <20241114104517.51726-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLJsWRmVeSWpSXmKPExsWy7bCmlu7RO6bpBk/b5C0+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZzy/dIKpoEWz4mL3b5YGxo2KXYycHBIC JhIXz11h6WLk4hAS2M0o8fjjayYI5xOjxL7fhxGcn5OfssO0HP/+B6plJ6PE95brrBDOZ0aJ J2eXsYFUsQmoSxx53soIkhAR2MMo0bvwNFgLs8AEJon2iXPAZgkLuEtsu9MD1MHOwSKgKjEx HCTKK2Ap8XrNUSaIbfISMy99B6vmFLCSWNGwlRmiRlDi5MwnLCA2M1BN89bZzBD1Nzgkdi+U hLBdJPYvb2GEsIUlXh3fAvWBlMTnd3vZIOx0iR+Xn0LtKpBoPrYPqt5eovVUP9BMDqD5mhLr d+lDhGUlpp5axwSxlk+i9/cTqFZeiR3zYGwlifaVc6BsCYm95xqgbA+Jiw/fMkPCqpdR4vfJ HvYJjAqzkLwzC8k7sxBWL2BkXsUomVpQnJueWmxaYJiXWg6P5eT83E2M4HSu5bmD8e6DD3qH GJk4GA8xSnAwK4nwnnI2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ev/6h1i ZOJgPMQowcGsJMJ7ytk4XYg3JbGyKrUoP76oNCe1+BCjNAeLkjivck5nipBAemJJanZqakFq EUyWiYNTqoFp2v3I6GX9b6/bzirQyg5Y1SKqWvvQZn+aKVvSW76d9ztvTS7/Z540eUdJrcPs XPaTlXHHTLXKF1w7PeF/w/ofXjrrLmzi89VbP7u5ZfXjr267dc5f2fvuNd+HDwsPzikpNzzw m8933SNFYcarGw6d3Sp/wDNFKvG+w1YP1c8955s+Ks3kf1hufMG5pymgYNO63L7TvPc4uK9f MTrztWBrbdOlXZtjgo4x5y56y9Gldk2Krfyvntlfs0cNC5cw1vP8DXzPfH3xjk1hVi3vBfrk DK9/ihbvzVKtfbxxVfi3A3fkZqw9t0sjR3LxXEuVw8z341Q8dG7kOOVJBD2MPp6516F11761 my+ovHR1/V7nosRSnJFoqMVcVJwIAGd/bsEhAwAA X-CMS-MailID: 20241114105408epcas5p3c77cda2faf7ccb37abbfd8e95b4ad1f5 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105408epcas5p3c77cda2faf7ccb37abbfd8e95b4ad1f5 References: <20241114104517.51726-1-anuj20.g@samsung.com> Add the ability to place attributes inline within SQE. Carve a new field that can accommodate 16 attribute flags: __u16 attr_inline_flags; Currently ATTR_FLAG_PI is defined, and future flags can be or-ed to specify the attributes that are placed inline. When ATTR_FLAG_PI is passed, application should also setup SQE128 ring and place PI information (i.e., struct io_uring_attr_pi) in the first 32b of second SQE. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/uapi/linux/io_uring.h | 13 +++++++++++- io_uring/io_uring.c | 6 +++++- io_uring/rw.c | 38 ++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 2e6808f6ba28..9c290c16e543 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -93,9 +93,11 @@ struct io_uring_sqe { __u16 __pad3[1]; }; struct { + /* used when extra attribute is passed inline SQE/SQE128 */ + __u16 attr_inline_flags; /* number of elements in the attribute vector */ __u8 nr_attr_indirect; - __u8 __pad4[3]; + __u8 __pad4[1]; }; }; union { @@ -126,6 +128,8 @@ struct io_uring_attr_vec { __u64 addr; }; +/* sqe->attr_inline_flags */ +#define ATTR_FLAG_PI (1U << ATTR_TYPE_PI) /* PI attribute information */ struct io_uring_attr_pi { __u16 flags; @@ -136,6 +140,13 @@ struct io_uring_attr_pi { __u64 rsvd; }; +/* Second half of SQE128 for IORING_OP_READ/WRITE */ +struct io_uring_sqe_ext { + /* if sqe->attr_inline_flags has ATTR_PI, first 32 bytes are for PI */ + struct io_uring_attr_pi rw_pi; + __u64 rsvd1[4]; +}; + /* * 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 e32dd118d7c8..3f975befe82e 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3866,8 +3866,9 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(44, __s32, splice_fd_in); BUILD_BUG_SQE_ELEM(44, __u32, file_index); BUILD_BUG_SQE_ELEM(44, __u16, addr_len); + BUILD_BUG_SQE_ELEM(44, __u16, attr_inline_flags); BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); - BUILD_BUG_SQE_ELEM(44, __u8, nr_attr_indirect); + BUILD_BUG_SQE_ELEM(46, __u8, nr_attr_indirect); BUILD_BUG_SQE_ELEM(48, __u64, addr3); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); @@ -3894,6 +3895,9 @@ static int __init io_uring_init(void) /* top 8bits are for internal use */ BUILD_BUG_ON((IORING_URING_CMD_MASK & 0xff000000) != 0); + BUILD_BUG_ON(sizeof(struct io_uring_sqe_ext) != + sizeof(struct io_uring_sqe)); + io_uring_optable_init(); /* diff --git a/io_uring/rw.c b/io_uring/rw.c index 93d7451b9370..d2d403ca6eb3 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -269,6 +269,11 @@ static inline void io_meta_restore(struct io_async_rw *io) iov_iter_restore(&io->meta.iter, &io->meta_state.iter_meta); } +static inline const void *io_uring_sqe_ext(const struct io_uring_sqe *sqe) +{ + return (sqe + 1); +} + static int io_prep_rw_pi(struct io_kiocb *req, struct io_rw *rw, int ddir, const struct io_uring_attr_pi *pi_attr) { @@ -343,11 +348,34 @@ static int io_prep_attr_vec(struct io_kiocb *req, struct io_rw *rw, int ddir, return 0; } +static int io_prep_inline_attr(struct io_kiocb *req, struct io_rw *rw, + const struct io_uring_sqe *sqe, int ddir, + u16 attr_flags) +{ + const struct io_uring_sqe_ext *sqe_ext; + const struct io_uring_attr_pi *pi_attr; + + if (!(attr_flags & ATTR_FLAG_PI)) + return -EINVAL; + + if (!(req->ctx->flags & IORING_SETUP_SQE128)) + return -EINVAL; + + sqe_ext = io_uring_sqe_ext(sqe); + if (READ_ONCE(sqe_ext->rsvd1[0]) || READ_ONCE(sqe_ext->rsvd1[1]) + || READ_ONCE(sqe_ext->rsvd1[2]) || READ_ONCE(sqe_ext->rsvd1[3])) + return -EINVAL; + + pi_attr = &sqe_ext->rw_pi; + return io_prep_rw_pi(req, rw, ddir, pi_attr); +} + 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; + u16 attr_flags; u8 nr_attr_indirect; int ret; @@ -376,12 +404,16 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, if (unlikely(ret)) return ret; + attr_flags = READ_ONCE(sqe->attr_inline_flags); nr_attr_indirect = READ_ONCE(sqe->nr_attr_indirect); - if (nr_attr_indirect) { + if (attr_flags) { + if (READ_ONCE(sqe->__pad4[0]) || nr_attr_indirect) + return -EINVAL; + ret = io_prep_inline_attr(req, rw, sqe, ddir, attr_flags); + } else if (nr_attr_indirect) { u64 attr_vec_usr_addr = READ_ONCE(sqe->attr_vec_addr); - if (READ_ONCE(sqe->__pad4[0]) || READ_ONCE(sqe->__pad4[1]) || - READ_ONCE(sqe->__pad4[2])) + if (READ_ONCE(sqe->__pad4[0])) return -EINVAL; ret = io_prep_attr_vec(req, rw, ddir, attr_vec_usr_addr, From patchwork Thu Nov 14 10:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13874975 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 D73171F942E for ; Thu, 14 Nov 2024 11:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583075; cv=none; b=mi8AL+sV2WKn1YdKxYDFTxd2MLi04d+xBGw58rr0HczPKRKGz4rhE9fafzd6k3CTo8mIMQcSQ20vtZugNactmuqx5PC2Zl1q0ZPLDOTwNbGd6W3Com+2m9UiarTBcT66B4RAerYO27zUAOfU+qX396ueasrqBq0GuvRE8XENEnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583075; c=relaxed/simple; bh=zLKmPBKgE330gUiBEDdBE5IP6I7cKVfh+yfAPfTxqIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KH9VYT+ED6HgZfLFAwnErvhnZl19NPxQD1fhFCii9pQ50hMsHUpv7QGyHb6h0Lc+oCa3DoixoTBizuSkvedcdCc5YD6eeX6eh3B41ZuLtc6khFBxrplCHDLiFsnUb7qfV4rCgdknHFlimusLaDu4l7xVYVm/eGV74MsW+ZIglnI= 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=hsBKorR6; 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="hsBKorR6" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241114111751epoutp01d508e23ebc300c255426412ee39e17e9~H0aElhbsr2250322503epoutp01f for ; Thu, 14 Nov 2024 11:17:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241114111751epoutp01d508e23ebc300c255426412ee39e17e9~H0aElhbsr2250322503epoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583071; bh=TJPyl3aTvIkg4YnLvrh/pR51inkyCmkLsiviu+/e0sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hsBKorR6jyfdErYB0lW8JWzOiZx1mm8zDewkdyQYAJQVGpDAtu3O9bHtaW/ukMRvI 7F9EGufPvrYPXkItzGv8n4TpoR4K8rtPH3EX9c0Z6warSI+Shc8ijBjP1fz5N6UM5M 5aHVThDlGxnlWry1ScKl25Zpg89GBlqlq6bA6diw= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241114111751epcas5p11e7c22b6048020ddb2eaacbf0efd7d2c~H0aED2WZv2611726117epcas5p1o; Thu, 14 Nov 2024 11:17:51 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XpyLP3mlyz4x9Pr; Thu, 14 Nov 2024 11:17:49 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E9.10.08574.D5CD5376; Thu, 14 Nov 2024 20:17:49 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241114105410epcas5p1c6a4e6141b073ccfd6277288f7d5e28b~H0FZJykea0117201172epcas5p1O; Thu, 14 Nov 2024 10:54:10 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105410epsmtrp1acbac2af6818b8a83ac2243422cde220~H0FZI1YMj1676716767epsmtrp1W; Thu, 14 Nov 2024 10:54:10 +0000 (GMT) X-AuditID: b6c32a44-93ffa7000000217e-7d-6735dc5d4c1b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 38.6A.07371.2D6D5376; Thu, 14 Nov 2024 19:54:10 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105408epsmtip2ae6cc286ea2163093baedf6328059fe2~H0FWvO-JM1327613276epsmtip24; Thu, 14 Nov 2024 10:54:08 +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 v9 08/11] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Thu, 14 Nov 2024 16:15:14 +0530 Message-Id: <20241114104517.51726-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLJsWRmVeSWpSXmKPExsWy7bCmlm7sHdN0g3NrZSw+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZzzdPIW54Jlkxctnzg2My0W7GDk5JARM JGZNP83UxcjFISSwm1GiaWc3C4TziVFi2aJdbBDON0aJ/0ueMsG0dP78DGYLCexllNg0Sxmi 6DOjxKQbu1lAEmwC6hJHnrcygiREBPYwSvQuPA02l1lgApNE+8Q57CBVwgIhEhv2XmADsVkE VCW2fV8IZvMKWEosWtTMCrFOXmLmpe9g9ZwCVhIrGrYyQ9QISpyc+QRsGzNQTfPW2cwgCyQE HnBIPFs6jxGi2UXicOc0KFtY4tXxLewQtpTEy/42KDtd4sdlmN8KJJqP7YOqt5doPdUPNJQD aIGmxPpd+hBhWYmpp9YxQezlk+j9/QSqlVdixzwYW0mifeUcKFtCYu+5BijbQ+L+t3eMkKDr ZZToP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KnJz5hAXEZgYqb946 m3kCo8AsJKlZSFILGJlWMUqmFhTnpucmGxYY5qWW6xUn5haX5qXrJefnbmIER5uWxg7Ge/P/ 6R1iZOJgPMQowcGsJMJ7ytk4XYg3JbGyKrUoP76oNCe1+BCjNAeLkjiv4YzZKUIC6Yklqdmp qQWpRTBZJg5OqQYmfZ7E49ys1vuSF5oa3TLbuS/vQMlkvmmdv//9KF3DtmH3dfHzoS7z1Zbv +6l7/fi1Yw5fEv790Ys0t+H4dDRhBsvmZ407/y3R2N0pOUkqLNQ1l/nDrWUn7rlMWdHvf5bJ K7j4QVinqHkG+8+dy85NObWrrE1NLijxY39VyaeZXwK27Lus5bZyjcYJuScKPGe2yS5+avHL zSzm0uSIF8v28z1/l7A5XUKIf/uv/Xze+1jZ/I643q1/sel25aPGDTYnGO8vjYpR0ru+N9VK 4tum6J19h5MY/2Z3nOrzXblqz/PW76vy3uqyrl9cYXhm9QFOE8VVNaH7lRyTOvKdeI4tf2y/ x72imdf9xTLb6W1zriqxFGckGmoxFxUnAgDVqB4dJQMAAA== X-CMS-MailID: 20241114105410epcas5p1c6a4e6141b073ccfd6277288f7d5e28b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105410epcas5p1c6a4e6141b073ccfd6277288f7d5e28b References: <20241114104517.51726-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 1a8d32a4a5c3..bd309e98ffac 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1017,18 +1017,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_PRINFO_PRACT; } - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: + if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD)) control |= NVME_RW_PRINFO_PRCHK_GUARD; - break; - case NVME_NS_DPS_PI_TYPE1: - case NVME_NS_DPS_PI_TYPE2: - control |= NVME_RW_PRINFO_PRCHK_GUARD | - NVME_RW_PRINFO_PRCHK_REF; + if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) { + control |= NVME_RW_PRINFO_PRCHK_REF; if (op == nvme_cmd_zone_append) control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); - break; } } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 58ff9988433a..fe2bfe122db2 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -11,6 +11,9 @@ enum bip_flags { BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 6, /* guard check */ + BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ }; struct bio_integrity_payload { @@ -31,7 +34,8 @@ struct bio_integrity_payload { }; #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Thu Nov 14 10:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13874998 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 8599A1F8920 for ; Thu, 14 Nov 2024 11:18:41 +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=1731583124; cv=none; b=CK2xVNBv4iqtvmnTyVtYlWgMoRu2X6LSlD2M8Mt4eIUijrn+7iOLBtkBjAdFXDqqA7ezPe+7TQsFrW1Wqqh3QTSByC2MLJFt9BPCiRuxkKAdZWaTT3hdEyl/wdI3EDFDZWMVTaYVOPk2uuYdorJg8wXUoQ5PsTpob3mSEr3hmkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583124; c=relaxed/simple; bh=BcTaUWXGiJ0MutknrUQXrJQN90XnKpmBvR8c/ClXdO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=LxE41Ic2sAAa+rOztYyIm32iVjS75aQuok5/VuP+O84SSfS5/wFdXCz/LMIjmFG8h2VLMMDMzag+JHEaFAryDwfOZbW86+MaHsPJS4JAy3Lydd2ZJF/L31Cvv1GuucoyRxumLaB2DafRt/uBHUI6t1TK2TbcSYua+3opRHruoeo= 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=juDvAN+E; 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="juDvAN+E" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241114111839epoutp02dea89403e3d693dcea8781bd439f5940~H0axL5QGd0203302033epoutp02U for ; Thu, 14 Nov 2024 11:18:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241114111839epoutp02dea89403e3d693dcea8781bd439f5940~H0axL5QGd0203302033epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583119; bh=XTd04aHy4nxYr+d1HX0L3NEK4IL9MMGxFYcE73udmyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=juDvAN+EQNBt4Bw7EB7uze/RZgwjZr8wrlPCTfkvcqsNvYVkG+GFQyFuUCFJcZdX/ 49N18UkZzlJIcCwA/+6eBlOIc2R3OguPU0BfjijFfZwSYEh5yWAQWzQzErHdSpAkA4 uL9VWiBmX3I7t9+2/122CyF/C1eciWkEcwqTd+Co= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241114111839epcas5p10637657526c1f3bf9f0c9c9d080c73d5~H0awl2q4z2217622176epcas5p1G; Thu, 14 Nov 2024 11:18:39 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XpyMK28NGz4x9Pr; Thu, 14 Nov 2024 11:18:37 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 12.B9.09770.D8CD5376; Thu, 14 Nov 2024 20:18:37 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241114105413epcas5p2d7da8675df2de0d1efba3057144e691d~H0FbrSgBA1555815558epcas5p2A; Thu, 14 Nov 2024 10:54:13 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105413epsmtrp19009de600359d144e1a2500fb3290860~H0Fbqa_3J1676616766epsmtrp1c; Thu, 14 Nov 2024 10:54:13 +0000 (GMT) X-AuditID: b6c32a4a-e25fa7000000262a-59-6735dc8d17bd Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 99.6A.07371.5D6D5376; Thu, 14 Nov 2024 19:54:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105410epsmtip21979d9e042f8488f9e5c82fe85dbe60d~H0FZRGEOU1406514065epsmtip2a; Thu, 14 Nov 2024 10:54: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 v9 09/11] nvme: add support for passing on the application tag Date: Thu, 14 Nov 2024 16:15:15 +0530 Message-Id: <20241114104517.51726-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmpm7vHdN0g3MLeCw+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZ5w+e4u9YAt3RevJY4wNjEc5uxg5OSQE TCRm9T9n7GLk4hAS2M0ocehTCyuE84lR4srvJSwQzjdGiY7eU2wwLdcfP4Wq2sso8eH4Haj+ z4wSFw9eZAKpYhNQlzjyvBUsISKwh1Gid+FpsFnMAhOYJBZM38IMUiUsECDxomMdK4jNIqAq 8eTmWiCbg4NXwEpiy84SiHXyEjMvfWcHsTmBwisatoK18goISpyc+YQFxGYGqmneOpsZZL6E wAMOiRsLVkPd6iKx/MAPZghb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eHKPrI KNH5ZhkTSIJNQF3iyPNWsCIRgROMEvMnuoEUMQvMYJL4/WcB2CRhAT+JOXsPs4LYLAKqEk9u rgWyOTh4BawktuwsgVggLzHz0nd2EJsTKLyiYSszSImQgKXE9/UiIGFeAUGJkzOfgE1kBipv 3jqbeQKjwCwkqVlIUgsYmVYxSqYWFOem5yYbFhjmpZbrFSfmFpfmpesl5+duYgTHm5bGDsZ7 8//pHWJk4mA8xCjBwawkwnvK2ThdiDclsbIqtSg/vqg0J7X4EKM0B4uSOK/hjNkpQgLpiSWp 2ampBalFMFkmDk6pBqZDB+Z94Zx3pLX1Q+NJbacb+ktPqv2svpd7S3Ohp2WI/LYkMYPba+dY ehy89+Gheb1IR3FJ5vRU078Pr7iIOftFN1jyzf25o2rb+oYEru/680T/rWXVnT9Nes3E0Ajx 4k0J0x5cXN3RuVXn7nLmx7P82v/8zGb6VVubF3ulRyoo6Nzxqe86ot9HrzggdixkorP/nSpv jvbddtt4GAvTAldJW/aUiE/1fWby7/Cign/72iQO7+mtkfyxUn7dvd/CMyY9PSz85RMne8X6 FM3sb8ZWxXfc7gXn/rsXu2uKrtyn03dmXrXscyvpnqy5jVtV31XnjP/W3zHFz+5rL4vhyV9V mzJpxoz3jwNkOhNVDLcrsRRnJBpqMRcVJwIAgX1xNCYDAAA= X-CMS-MailID: 20241114105413epcas5p2d7da8675df2de0d1efba3057144e691d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105413epcas5p2d7da8675df2de0d1efba3057144e691d References: <20241114104517.51726-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 bd309e98ffac..4a6ed8f38b77 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -885,6 +885,12 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct request *req, struct nvme_command *cmnd) +{ + cmnd->rw.lbat = cpu_to_le16(bio_integrity(req->bio)->app_tag); + cmnd->rw.lbatm = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -1025,6 +1031,10 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); } + if (bio_integrity_flagged(req->bio, BIP_CHECK_APPTAG)) { + control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(req, cmnd); + } } cmnd->rw.control = cpu_to_le16(control); From patchwork Thu Nov 14 10:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875004 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 13A531F9AA0 for ; Thu, 14 Nov 2024 11:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583229; cv=none; b=ovLY4tBaXvLBP8iOHSjKsPrm4M4yO1UdT3kLFp5mM7+v1NWwtrdAHTPxiwKf966ALp237LxIzo6DakPxqzaK+i/QJImbl0VAduPjPVbIQNPHU3kFSPXZvMLXKVF+J7dhytsoUXjPkh1rdc9E6r6FdLAiNf2lIS+HMlPBRwCEvq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583229; c=relaxed/simple; bh=wf16SXbPE7IKcuRRSTK3G6OqCzknXrmBf1Mn0Cr7weM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=IkhaixshnJmPwRpMZehXnJ3iaQ1Dy7rvguX/e5c2099cp9u5PcPCBHn/dI4/NIrb5KNs+L3TFPITKm1pIsqssN8QsKUnKbY2Fb7knMwb5X2MTQ/2358+ySVHRuxa2X2dRYzP7b/iVHWZ4LZB4ZljHcG9KQPR18srnm0NCLum/Xs= 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=Mraw92l0; 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="Mraw92l0" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241114112025epoutp01b0e10ba3d67a37a03a15c2b1f475b049~H0cTkL3Ow2456824568epoutp01f for ; Thu, 14 Nov 2024 11:20:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241114112025epoutp01b0e10ba3d67a37a03a15c2b1f475b049~H0cTkL3Ow2456824568epoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583225; bh=DV5DBIpEJMoashvJk+4uhGWWufd3TPgC6b7DXtx2rfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mraw92l0VTxVNPIgrxdp4KDv/btGJpKItYoy2wNip5+pDtJyfjELuqn9c4/CsrY3z 8r4z48j0YgLp+W1h4N/tZHzMPQfe3ruTZf4HQwmq4efDV0uHPLO7oXJKe4/McMGyFX qRviu6s0/LALVMSmFuFGFvnUxbQ22k6qEvKw0wN0= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241114112024epcas5p48d9c06b1bc34a8bbfb319ae30a8394c3~H0cTD0v7c0985309853epcas5p4Z; Thu, 14 Nov 2024 11:20:24 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XpyPL2Ttjz4x9Q2; Thu, 14 Nov 2024 11:20:22 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id DB.4F.37975.36CD5376; Thu, 14 Nov 2024 20:17:55 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241114105416epcas5p3a7aa552775cfe50f60ef89f7d982ea12~H0FeHIZif2916029160epcas5p3E; Thu, 14 Nov 2024 10:54:16 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105416epsmtrp1ba676ae188c5ea171608ff0bdbbdb333~H0FeGSpZv1676716767epsmtrp1d; Thu, 14 Nov 2024 10:54:16 +0000 (GMT) X-AuditID: b6c32a50-085ff70000049457-e5-6735dc632dbb Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 4C.B3.08227.7D6D5376; Thu, 14 Nov 2024 19:54:15 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105413epsmtip2b05a4c14310035d341e7ef6031e99ca4~H0Fbx4AkK1420714207epsmtip2W; Thu, 14 Nov 2024 10:54:13 +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 v9 10/11] scsi: add support for user-meta interface Date: Thu, 14 Nov 2024 16:15:16 +0530 Message-Id: <20241114104517.51726-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNJsWRmVeSWpSXmKPExsWy7bCmlu6XO6bpBru3cVh8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSwmHbrGaLH3lrbFnr0nWSzm L3vKbtF9fQebxfLj/5gszv89zmpxftYcdgdBj52z7rJ7XD5b6rFpVSebx+Yl9R67bzaweXx8 eovFo2/LKkaPMwuOsHt83iTnsenJW6YArqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwND XUNLC3MlhbzE3FRbJRefAF23zBygd5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqpBSk5 BSYFesWJucWleel6eaklVoYGBkamQIUJ2RlPD95kLTgvWvH2/CfGBsYrgl2MnBwSAiYSpy6d Yuti5OIQEtjDKHFv/j1GCOcTo8SZ7cugMt8YJY4uPM0K03Jh6nd2iMReRokXU58yQzifGSWO tU5nBqliE1CXOPK8FWyWCMjg3oWnWUAcZoGXjBJLVy1iA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PTkLVMAVxSXTUpqTmZZapG+XQJXxtODN1kLzotWvD3/ibGB 8YpgFyMnh4SAicSFqd/ZQWwhgd2MEq392RBxCYlTL5cxQtjCEiv/PQeq4QKq+cgosffzI2aQ BJuAusSR561gRSICJxgl5k90AyliBima8GU2C0hCWMBZYumSZrAGFgFViXlLv7OC2LwCVhK3 txxhg9ggLzHzEsQVnEDxFQ1bgeo5gLZZSnxfLwJRLihxcuYTsJHMQOXNW2czT2AUmIUkNQtJ agEj0ypGydSC4tz03GLDAqO81HK94sTc4tK8dL3k/NxNjOAo09Lawbhn1Qe9Q4xMHIyHGCU4 mJVEeE85G6cL8aYkVlalFuXHF5XmpBYfYpTmYFES5/32ujdFSCA9sSQ1OzW1ILUIJsvEwSnV wNQULBquKmor8Pb5gYClllbxdydMveB9bMF9YVv3ot7Zp9eaNBlGz12+XPWmpdKkCuaU7S2l Wx9OO6N+L1RZ7IJ5zUpLPrXeoH8pOwVqPrTNejclsf1i6XF9k9ffrlfrKCzOXpMkx+69WHHr zwWbTd7V2vFwp21d2Hw3Svye8pt3FjOcnK5/PGqtpHp5QZDF450l8vPYJRxi9tZHbJi2+P51 8//Gaf6bfb+dzZof7ZFZ2Wq44KFUZjj3BYGipgqP31GfDXsZlr6Y53VrqshM/abOZO2/Xvc7 xObfbdkfvHVPziy32jXlSSv9/DRDI8pv5Mn+fKj6+fIFm4Wr17q8t6yU/yyfL/Fxon3Lm4mV U5RYijMSDbWYi4oTAT5DThchAwAA X-CMS-MailID: 20241114105416epcas5p3a7aa552775cfe50f60ef89f7d982ea12 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105416epcas5p3a7aa552775cfe50f60ef89f7d982ea12 References: <20241114104517.51726-1-anuj20.g@samsung.com> Add support for sending user-meta buffer. Set tags to be checked using flags specified by user/block-layer. With this change, BIP_CTRL_NOCHECK becomes unused. Remove it. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 4 ++-- include/linux/bio-integrity.h | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8947dab132d7..cb7ac8736b91 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -814,14 +814,14 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, if (bio_integrity_flagged(bio, BIP_IP_CHECKSUM)) scmd->prot_flags |= SCSI_PROT_IP_CHECKSUM; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_GUARD)) scmd->prot_flags |= SCSI_PROT_GUARD_CHECK; } if (dif != T10_PI_TYPE3_PROTECTION) { /* DIX/DIF Type 0, 1, 2 */ scmd->prot_flags |= SCSI_PROT_REF_INCREMENT; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_REFTAG)) scmd->prot_flags |= SCSI_PROT_REF_CHECK; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index fe2bfe122db2..2195bc06dcde 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -7,13 +7,12 @@ enum bip_flags { BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */ BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */ - BIP_CTRL_NOCHECK = 1 << 2, /* disable HBA integrity checking */ - BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ - BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ - BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ - BIP_CHECK_GUARD = 1 << 6, /* guard check */ - BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ - BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ + BIP_DISK_NOCHECK = 1 << 2, /* disable disk integrity checking */ + BIP_IP_CHECKSUM = 1 << 3, /* IP checksum */ + BIP_COPY_USER = 1 << 4, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 5, /* guard check */ + BIP_CHECK_REFTAG = 1 << 6, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 7, /* apptag check */ }; struct bio_integrity_payload { @@ -33,8 +32,7 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; -#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_IP_CHECKSUM | \ BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Thu Nov 14 10:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13874976 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 6FA5E1F942F for ; Thu, 14 Nov 2024 11:18:03 +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=1731583085; cv=none; b=BjNVonND1CWhuRMPqfySrn9lru2AuXaRAPrIkgEnrptTh+pC3+8/h1w8H5Pzw/ZNKVAFkYJ+n3WCdZk+j2rr8suAxh2wiw1Qi+LnloyjFSQacF1Ud2uRwPhmKjz5qYHrEmbXP0FgrDszn8eeehmmwjAw23qb8oV+6ZiPwZKWwxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583085; c=relaxed/simple; bh=3+EpeSIcCbF/6ZjkqBAtW4O9T46NdqwVVHXXGudPBqs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=VfnTi36NtbNXbd1BtiZPF9k18xM5nnuOLEBa43fmGSNysC8e5kz+4DoAhAzy3PAkJRevxSrU0Dc2QWSweVMPFlkViAFS3bIMgN3uHPe0/CXhaZ1tslj/LjhvVcYttpn43F3h1LXxuNrLKRVD/ffQSjbQL4qtTUjLlUf3Wog2bE4= 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=Cp9skm5P; 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="Cp9skm5P" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241114111801epoutp0452df39394ef4afab233f84ad66c18c2c~H0aN1OsQ_1849618496epoutp04g for ; Thu, 14 Nov 2024 11:18:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241114111801epoutp0452df39394ef4afab233f84ad66c18c2c~H0aN1OsQ_1849618496epoutp04g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583081; bh=wQsh5MEv2xvuMdMfRC5hx+1fVZ+6hqXmEyHQLubiY3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cp9skm5Pax253NR5CfYcDYeLeXtgUcijYAsQ4cTUwDr4VYzr4yuXpkRUQOrVOPxo0 bb03SDf6TFKebgsST6dtCFDTLe+kZ9kDgepRVjkdME2MgCIvyMzfwKSp/IwOyb+QHi N8heK0QYlVB/0QeLA/Ms2eNKrHNCNavOFqyxWe1M= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114111800epcas5p24f2a38b47cb535e73434a76cb543107f~H0aM1lEAO1772717727epcas5p2_; Thu, 14 Nov 2024 11:18:00 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.175]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4XpyLZ6bWsz4x9Pr; Thu, 14 Nov 2024 11:17:58 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 49.B0.09800.66CD5376; Thu, 14 Nov 2024 20:17:58 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241114105418epcas5p1537d72b9016d10670cf97751704e2cc8~H0Fgsu3Hq2293722937epcas5p1c; Thu, 14 Nov 2024 10:54:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105418epsmtrp14c7709d8112021db81643c021868707b~H0FgrzgDS1676716767epsmtrp1k; Thu, 14 Nov 2024 10:54:18 +0000 (GMT) X-AuditID: b6c32a4b-4a7fa70000002648-db-6735dc66072e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 14.B0.35203.AD6D5376; Thu, 14 Nov 2024 19:54:18 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105416epsmtip2a5420b9a1220b737b69105d53c9cce6e~H0FeLEzHm1110111101epsmtip24; Thu, 14 Nov 2024 10:54:16 +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 v9 11/11] block: add support to pass user meta buffer Date: Thu, 14 Nov 2024 16:15:17 +0530 Message-Id: <20241114104517.51726-12-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmhm7aHdN0g02njCw+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBZH/79ls5h06Bqjxd5b2hZ7 9p5ksZi/7Cm7Rff1HWwWy4//Y7I4//c4q8X5WXPYHYQ8ds66y+5x+Wypx6ZVnWwem5fUe+y+ 2cDm8fHpLRaPvi2rGD3OLDjC7vF5k5zHpidvmQK4orJtMlITU1KLFFLzkvNTMvPSbZW8g+Od 403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4B+UlIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fY KqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZxzbep+xoNuy4vrllYwNjBf0uhg5OSQE TCT6Z25n6mLk4hAS2M0ocfLHThYI5xOjxOEnT6Ay3xglJrZdYIRp+bVhERtEYi+jxL1H3VBV nxkleq+uZQGpYhNQlzjyvJURJCEisAcosfA02GBmgQlMEgumb2EGqRIWcJX41vqbvYuRg4NF QFVi39sokDCvgJXEkhvzmSDWyU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Nt6n7Gg27Li +uWVjA2MF/S6GDk5JARMJH5tWMQGYgsJ7GaUmNvtCxGXkDj1chkjhC0ssfLfc3aImo+MEnuf CoHYbALqEkeet4LViAicYJSYP9Gti5GLg1lgBpPE7z8LWEASwgKuEt9afwM1c3CwCKhK7Hsb BRLmFbCSWHJjPhPEfHmJmZe+g83nBIqvaNjKDFIuJGAp8X29CES5oMTJmU/AJjIDlTdvnc08 gVFgFpLULCSpBYxMqxglUwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLzczcxgmNNS3MH4/ZVH/QO MTJxMB5ilOBgVhLhPeVsnC7Em5JYWZValB9fVJqTWnyIUZqDRUmcV/xFb4qQQHpiSWp2ampB ahFMlomDU6qBKfH/1mi+4sP35ZLmzCrkOMRZt3ND85f6vSxVH6bUpFWd+pNoqcvfwLFKPGjd o/sXxeeZz9Zq9Ks5vvljecbnC7NYtYJrP6Rs0d3F1h/bnN+49ZENh53Bs6BszzdGU1qDGO/L TvAu5L3aFnBllU74j8PT0yVeTKzk3MLSdnKOTdw1o2P9QU7vHGMvLrFLCpnKeZtj+69TKdFb s6frnV7w4XHwak8l3folS1czJkddWKq53NHg874Ned7TeZuPHZBnWq7ncS3yS3Tkmczs+YcE zu3W9Z7HcDPnbWao5FTd+1cvXE+flrLimfnUN+/vzAw5uN4kN7morbDY/nj5rHkzy2Wfzcu7 Eaksk6jDUGhVp8RSnJFoqMVcVJwIACYv8LYkAwAA X-CMS-MailID: 20241114105418epcas5p1537d72b9016d10670cf97751704e2cc8 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105418epcas5p1537d72b9016d10670cf97751704e2cc8 References: <20241114104517.51726-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) { }