From patchwork Fri Aug 23 10:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774950 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 CA4B7187345 for ; Fri, 23 Aug 2024 10:48:11 +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=1724410093; cv=none; b=ffUNhSLZkAaPHNelKu+USP+7MJQPp1A3eJYd/vn5boysilWTv74XLDKF9SibMxxzViM4w9adA3b1HBfgyuRBHT/PCdM3HSQOnUoyG9LP7UkL5T0Q/SQMgRb79/Tuwbh6YVRmxBrM+yKsiuC4jReqoUqIK2oNooEe5B55AOmzto8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410093; c=relaxed/simple; bh=d7rXebeSEm18bCB7MKc526gnn9BA+iKBq0twd4J7e+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=TP8KmFw0HusfhAKsrzidovJtbyd3zBQrvEOTdwyJVCvXQof4FDQCE4mUxpDKVOa7etkCY2HOmBcZ///EgFovGdEV6+hTdxyGS230nI0pd4GZJPAmkDNF9cl+/325248e6Z/pcB25wGWx7bUDi9DurjnKs/EVtxfAobCjaJR1XC8= 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=TxRIAD/l; 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="TxRIAD/l" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240823104809epoutp04169ae235cc62f325cb3f0bcc9fab86eb~uVdcqNG7b1876118761epoutp04F for ; Fri, 23 Aug 2024 10:48:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240823104809epoutp04169ae235cc62f325cb3f0bcc9fab86eb~uVdcqNG7b1876118761epoutp04F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410089; bh=jMx8UpUspdytnu+Xq0U/x/8sHusVPIVYMik9VsbX5dM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxRIAD/l5b0q3HPoQ7KkF0/uffuQBLB8U/l7r0MenTiTr2snbit/wVL/gMcMAzTWc LmlMq52YSbelFEa5g0yBDwa2zb3QnqHLyyfNHF7FzS62K9CtKS8PJxnruU+IwoCEar RtlZYqrNHx+1NOpnKEnHBbGhGd+/B8sYX+P3i+vM= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240823104806epcas5p365b10ec701f48979e49694b199d5fb7e~uVdZhIeMo0529105291epcas5p3Y; Fri, 23 Aug 2024 10:48:06 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.178]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WqxcN5H75z4x9Q1; Fri, 23 Aug 2024 10:48:04 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 3F.7A.19863.4E868C66; Fri, 23 Aug 2024 19:48:04 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240823104616epcas5p4bd315bd116ea7e32b1abf7e174af64a1~uVbyr-QcC3268132681epcas5p4l; Fri, 23 Aug 2024 10:46:16 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240823104616epsmtrp19e122e7c3e3f792d82b6528df3ed01d6~uVbyrIHkr0200002000epsmtrp1i; Fri, 23 Aug 2024 10:46:16 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-de-66c868e41339 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7C.1B.08964.87868C66; Fri, 23 Aug 2024 19:46:16 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104614epsmtip227daa07025f3459d97df93b29cdc2537~uVbw0JSpS1442714427epsmtip2Y; Fri, 23 Aug 2024 10:46:14 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta Subject: [PATCH v3 01/10] block: define set of integrity flags to be inherited by cloned bip Date: Fri, 23 Aug 2024 16:08:01 +0530 Message-Id: <20240823103811.2421-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJJsWRmVeSWpSXmKPExsWy7bCmuu6TjBNpBs3b1C2aJvxltpizahuj xeq7/WwWNw/sZLJYufook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mfFMT+2VUZd+LvU9M+K4/numZQ9KH3/9 edDOL5XB8iK/XNZm7a50uTNHnwd/S7+y5pj8EyWW4oxEQy3mouJEALYkjOYFAwAA X-CMS-MailID: 20240823104616epcas5p4bd315bd116ea7e32b1abf7e174af64a1 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104616epcas5p4bd315bd116ea7e32b1abf7e174af64a1 References: <20240823103811.2421-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 --- 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 8d1fb38f745f..0b69f2b003c3 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -567,7 +567,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 dd831c269e99..485d8a43017a 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 Fri Aug 23 10:38:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774951 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 EEA76187339 for ; Fri, 23 Aug 2024 10:48:15 +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=1724410098; cv=none; b=GIAsTLGmZdZoqz+EC1gITbS9lTrQmUoFB/c1CWu89UqyVssxl3JhFC0ilmvf1w6BILQ1JNGPwkpAR+Nhs4RXv+ngPP3SZ1X6vCulmI4NE9IP2nFWF3DZH3AqW+gNy6BEwlFmL2JS9I/q0btaxPO8tp7Y6UZG8Wa59BTTeNwLZU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410098; c=relaxed/simple; bh=8xrCboqKX1/hsaIOvnjsh52EnC8Lbd1VxbhU5M3E8Tc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KpkB7nLsvaEaSPRWX7jxS3DQMRxb2BMAHuDt810Nk0IG6OxhWDIbRWYEiVvTmIRux3cY+WOkmoddujBm4qFAICiFwKxJta8XNs4yVycYY4AmKl26vlxKcRvocNITZP9lyjWNZ4em69bh6rAsp9st61LWHhLFjhVTlvfsG0UaIxU= 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=Bfbd4dcq; 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="Bfbd4dcq" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240823104813epoutp04a5198a5b52c4e139982afef48903e4d8~uVdgWvkPP1659716597epoutp04W for ; Fri, 23 Aug 2024 10:48:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240823104813epoutp04a5198a5b52c4e139982afef48903e4d8~uVdgWvkPP1659716597epoutp04W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410093; bh=8jA6l5tMs++plw+N26Lk0rdh9tUDLvjEvpwEPgRSsMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bfbd4dcquQvzRBXt3rFZ1lPrq6fWhWV/tyaUVPFGI0iZsO6QkHYs9EX9tV+e9YxUc ERGwPe2g3ZDgR3BA2f3OaNcyzwACiB5VflafQGfbTHgqu/lBU7WBW7qm5C2mh7Mbfl PN/6o+8j1850HQaV2/qecUBPdrt23zrSmsiX89YU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240823104813epcas5p31e498e0c26224c6efcfc9b2222bc5a6b~uVdfzMXFK1288512885epcas5p3C; Fri, 23 Aug 2024 10:48:13 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WqxcW44ZWz4x9Pw; Fri, 23 Aug 2024 10:48:11 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 60.F3.09640.BE868C66; Fri, 23 Aug 2024 19:48:11 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240823104618epcas5p4b9983678886dceed75edd9cbec9341b2~uVb0vhpeM1988919889epcas5p46; Fri, 23 Aug 2024 10:46:18 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104618epsmtrp2daca9994ff06c5d5736525680aef473b~uVb0uxG2Z0122301223epsmtrp2A; Fri, 23 Aug 2024 10:46:18 +0000 (GMT) X-AuditID: b6c32a49-a57ff700000025a8-34-66c868eb61d2 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 21.6F.07567.A7868C66; Fri, 23 Aug 2024 19:46:18 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104616epsmtip206aa9085094eaa85cbf4914c5ff3b2b4~uVby08i-N1244412444epsmtip2j; Fri, 23 Aug 2024 10:46:16 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta Subject: [PATCH v3 02/10] block: introduce a helper to determine metadata bytes from data iter Date: Fri, 23 Aug 2024 16:08:02 +0530 Message-Id: <20240823103811.2421-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJJsWRmVeSWpSXmKPExsWy7bCmuu7rjBNpBk/+yVo0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLCYdusZosf3MUmaLv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zatSLCa7LJw stHeGOuUu66pmqYL/UpDrktfqLAVStyXHXVHiaU4I9FQi7moOBEARZhMZAQDAAA= X-CMS-MailID: 20240823104618epcas5p4b9983678886dceed75edd9cbec9341b2 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104618epcas5p4b9983678886dceed75edd9cbec9341b2 References: <20240823103811.2421-1-anuj20.g@samsung.com> Introduce a new helper bio_iter_integrity_bytes to determine the number of metadata bytes corresponding to data iter. Suggested-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- include/linux/blk-integrity.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index de98049b7ded..2ff65c933c50 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -76,6 +76,15 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, return bio_integrity_intervals(bi, sectors) * bi->tuple_size; } +/* + * Return the integrity bytes corresponding to data iter + */ +static inline unsigned int bio_iter_integrity_bytes(struct blk_integrity *bi, + struct bvec_iter iter) +{ + return bio_integrity_bytes(bi, bvec_iter_sectors(iter)); +} + static inline bool blk_integrity_rq(struct request *rq) { return rq->cmd_flags & REQ_INTEGRITY; @@ -132,6 +141,13 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, { return 0; } + +static inline unsigned int bio_iter_integrity_bytes(struct blk_integrity *bi, + struct bvec_iter iter) +{ + return 0; +} + static inline int blk_integrity_rq(struct request *rq) { return 0; From patchwork Fri Aug 23 10:38:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774952 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 EF1ED187338 for ; Fri, 23 Aug 2024 10:48:22 +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=1724410104; cv=none; b=rSS5+YuV3ZeOT+UtL1yRden/a/QPE7OGXVgVKNOJRvC4Y9Xo2Ak06IUIfAuO2cKB8KlFdxlKclHeAxmGHDX82cbSW+6eKoXufJS+iNmsXCJxakqiilLGR8VBCJtw/uhlHU2/d24tRfhboWFOqvhRTent0bEq1SyzbnKavpgCMd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410104; c=relaxed/simple; bh=LhdbcZF4B80zbfPoh5Hu/R0x2p7V4nerfBZjYBB2iX8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=Ibdciwsivv4/nOLyxo+t1sXi5xTOvmgfhdSG0TvdQVDe4H0irTgjPps1OgqxdEbDTMzBE0tHMtD7G6JJzsijV2F3FJWAGUEWlbXiOF6NaC0sGpv5u38NXtzhidvicKuKka1CSchcsNcHKki6SCp4gvVqfdBvMnGgqv6QV6JZPWk= 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=iOfxQroK; 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="iOfxQroK" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240823104820epoutp01c9a3701931e028a17c1c592777e6cbac~uVdm10LV60367903679epoutp01m for ; Fri, 23 Aug 2024 10:48:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240823104820epoutp01c9a3701931e028a17c1c592777e6cbac~uVdm10LV60367903679epoutp01m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410100; bh=1SgBe/bIw4UZFTnEY47DrIroMxr4nIL6WJSjqlhA05Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iOfxQroKP3cP5X8swgFEV1N0e9RWXp5rW5SFApUA4rFQlbn+p4XifMieQbqlEikvA dWlXtp5E8GWTnF1XKN+2KiR79WN2dUmbrI3v+RG5S2NVpcp4MLX84Mzy+URVGLqapX LVwTpqliO+TE2UhgLztAdmlesf3uk0b27Wh7cUrA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240823104820epcas5p12a938076eb9c62c64199a28fa498e5c3~uVdmIpwER2850228502epcas5p1c; Fri, 23 Aug 2024 10:48:20 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Wqxcf39bdz4x9Q0; Fri, 23 Aug 2024 10:48:18 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id A6.8F.09743.1F868C66; Fri, 23 Aug 2024 19:48:17 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240823104620epcas5p2118c152963d6cadfbc9968790ac0e536~uVb2uOBWF1853818538epcas5p29; Fri, 23 Aug 2024 10:46:20 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104620epsmtrp29c081cebc9c898dfb876eb8922773530~uVb2thqK50114601146epsmtrp2W; Fri, 23 Aug 2024 10:46:20 +0000 (GMT) X-AuditID: b6c32a4a-3b1fa7000000260f-76-66c868f1a27a Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.1B.08964.C7868C66; Fri, 23 Aug 2024 19:46:20 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104618epsmtip2230219aa34e06babef4aa6c9b4175d9b~uVb00PXRD1410214102epsmtip2l; Fri, 23 Aug 2024 10:46:18 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta Subject: [PATCH v3 03/10] block: handle split correctly for user meta bounce buffer Date: Fri, 23 Aug 2024 16:08:03 +0530 Message-Id: <20240823103811.2421-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBJsWRmVeSWpSXmKPExsWy7bCmhu7HjBNpBq+eCVg0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLCYdusZosf3MUmaLvbe0LeYve8pu0X19B5vF8uP/mBx4 PHbOusvucflsqcemVZ1sHpuX1HvsvtnA5vHx6S0Wj74tqxg9Np+u9vi8SS6AMyrbJiM1MSW1 SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ19DSwlxJIS8xN9VWycUnQNctMwfoX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mVeSWpSXmKPExsWy7bCSvG5Nxok0gwnbxC2aJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFpMOXWO02H5mKbPF3lvaFvOXPWW36L6+g81i+fF/TA48 Hjtn3WX3uHy21GPTqk42j81L6j1232xg8/j49BaLR9+WVYwem09Xe3zeJBfAGcVlk5Kak1mW WqRvl8CV8WzePsaCzZwVze17GBsY37N3MXJwSAiYSLxq0e5i5OIQEtjNKNE/8TpbFyMnUFxC 4tTLZYwQtrDEyn/P2SGKPjJKzJ0wCyzBJqAuceR5KyNIQkSgkVFiS/MXFhCHWWAHo8S6Z4vB qoQFgiXePV/MBGKzCKhKnN/1hh3E5hWwkPi3aB3UCnmJmZe+g8U5BSwlmmY3sIDYQkA1y5af YYSoF5Q4OfMJWJwZqL5562zmCYwCs5CkZiFJLWBkWsUomVpQnJueW2xYYJiXWq5XnJhbXJqX rpecn7uJERwrWpo7GLev+qB3iJGJg/EQowQHs5IIb9K9o2lCvCmJlVWpRfnxRaU5qcWHGKU5 WJTEecVf9KYICaQnlqRmp6YWpBbBZJk4OKUamJhaN5++09W37fIHvtuxf8WPzbfKn3D+5W4r mbflsXP3yT67elBnq8ujN3cmuCu/NGYtv/5IXV5248WDXa0vHZckukv4nDz4rybWO2CLsaP2 nob6Z+sTvZcvX7Hlyuuyy52nr//1nPM8niv2+AnNkvT2LwZCDXtPWHPUKB38VLaeVWmlZUqv 0vkVrM+eBXIsmy+sKdep1/bMbufSTbYFn0578a5dpKL/+I9bwoeIy5t0OvytF7H6lrnn2z5b /cJttrjkbne7mC2+R6Z+lDM78/5ziWDWRNE53X+WsAV6S0ycf1nLp8NBYof3X82I/T2Xrzan VkpLrU29r3zy//rDLUkmW6/6aISfyHU7rl8RxqHEUpyRaKjFXFScCAA/CGPHBAMAAA== X-CMS-MailID: 20240823104620epcas5p2118c152963d6cadfbc9968790ac0e536 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104620epcas5p2118c152963d6cadfbc9968790ac0e536 References: <20240823103811.2421-1-anuj20.g@samsung.com> Copy back the bounce buffer to user-space in entirety when the parent bio completes. Signed-off-by: Anuj Gupta --- block/bio-integrity.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 0b69f2b003c3..d8b810a2b4bf 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,9 +118,11 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { + struct bio *bio = bip->bip_bio; + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); unsigned short nr_vecs = bip->bip_max_vcnt - 1; struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; + size_t bytes = bio_iter_integrity_bytes(bi, bip->bio_iter); struct iov_iter iter; int ret; @@ -253,6 +255,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_COPY_USER; bip->bip_iter.bi_sector = seed; bip->bip_vcnt = nr_vecs; + bip->bio_iter = bio->bi_iter; return 0; free_bip: bio_integrity_free(bio); From patchwork Fri Aug 23 10:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774953 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 E93A2187563 for ; Fri, 23 Aug 2024 10:48: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=1724410106; cv=none; b=WZ0cJfjmDaCOWxhvKUMmnqvoXuS/NCE9GczXxl6/Lz6zbU3+mJGvNtmw/vhMUO/RJjRXBCXTBGKsPimorSJsKW2cCsvhmSQ5i4jsMf5DDyxOIdmjtHi9Sn6zz49156I83A/w57DUpKnsxCFsywpICbSg1tIwRdhtZ7QpT2YdqDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410106; c=relaxed/simple; bh=sZkPdHu9h1cr9eLtTsn2Hs6X8Mcx1oFFuOWH/X/o+Tg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=sJx9RPll8JTttul5lWTnFBegnbHK2L7DCPjmCor7bntSMEXZqgjyW3QiigFVZvTMCReG5CrcWq51TBUDA3CzPs/CCutqSLMFzAGUxUpZaLA4D4vJbOpOwsi8K+98XTnhox9Bs0ko2Wzy7HbH/ruu2jCM7EN6RZp4sIyJCfqaAbw= 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=GsyhN/HM; 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="GsyhN/HM" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240823104823epoutp0254c6cae296d59b9d6f8c4aa4f796162b~uVdo9Lspg0969809698epoutp02a for ; Fri, 23 Aug 2024 10:48:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240823104823epoutp0254c6cae296d59b9d6f8c4aa4f796162b~uVdo9Lspg0969809698epoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410103; bh=90CNtiP/2tt+h1YZtONu5flbGM3VvoqfTKHbF+jJYgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GsyhN/HM1//gxXmRqb23bC+dYSqQoLO85lk6DFbBuhEYGiuZNAtKjhKMuMETelPiF sHf6pHzbzLZc6N4xXpjIXsuAAdaZcoTwu4gF6qS6dRGglhMBhv1p3RpDPpwD3JKk5L 5EJfm2Gjw6HfWA6CKGWHVWM4k7gB8abCF0ecn9iU= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240823104822epcas5p1262f2e00ced25e2a84c26e18f1596f68~uVdodsH0s2850128501epcas5p1a; Fri, 23 Aug 2024 10:48:22 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Wqxch6lndz4x9Q0; Fri, 23 Aug 2024 10:48:20 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.8F.09743.4F868C66; Fri, 23 Aug 2024 19:48:20 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240823104622epcas5p2e3b29f793eff9857c5712b3d6d327ed5~uVb44JoMx1288512885epcas5p2n; Fri, 23 Aug 2024 10:46:22 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104622epsmtrp2e09c20224f926e6655aeccf9907e12da~uVb42v-es0122301223epsmtrp2E; Fri, 23 Aug 2024 10:46:22 +0000 (GMT) X-AuditID: b6c32a4a-14fff7000000260f-7d-66c868f4185f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 26.50.19367.E7868C66; Fri, 23 Aug 2024 19:46:22 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104620epsmtip288908594f49a4e4a562d9e488ce2b8d2~uVb213WlK1442714427epsmtip2a; Fri, 23 Aug 2024 10:46:20 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta , Kanchan Joshi Subject: [PATCH v3 04/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Fri, 23 Aug 2024 16:08:04 +0530 Message-Id: <20240823103811.2421-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLJsWRmVeSWpSXmKPExsWy7bCmlu6XjBNpBktn61k0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaL7WeWMlvsvaVtMX/ZU3aL7us72CyW H//H5MDrsXPWXXaPy2dLPTat6mTz2Lyk3mP3zQY2j49Pb7F49G1Zxeix+XS1x+dNcgGcUdk2 GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBHKymUJeaU AoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyMzad esFUcEq+YsPlFywNjL1SXYycHBICJhIz+qeydzFycQgJ7GaUWLJ6CROE84lRYs27BWwgVWDO jauOMB0//7SzQBTtZJS4Pm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8+rasYvTYfLra4/MmuQDOKC6b lNSczLLUIn27BK6MTadeMBWckq/YcPkFSwNjr1QXIyeHhICJxM8/7SxdjFwcQgLbGSUebupg gUhISJx6uYwRwhaWWPnvOTtE0UdGiRud59lAEmwC6hJHnrcygiREBBoZJbY0fwHrZha4zyix oDsExBYWiJX40tgE1sAioCox8fJ2sBpeAQuJrQ872SA2yEvMvPSdHcTmFLCUaJrdAFYjBFSz bPkZRoh6QYmTM59AzZeXaN46m3kCo8AsJKlZSFILGJlWMYqmFhTnpucmFxjqFSfmFpfmpesl 5+duYgRHi1bQDsZl6//qHWJk4mA8xCjBwawkwpt072iaEG9KYmVValF+fFFpTmrxIUZpDhYl cV7lnM4UIYH0xJLU7NTUgtQimCwTB6dUA9M0I/66B5oq26w79mceEJGwXFpX80HfxG1D/5LT Ti9XiE+ztA/v7nhw+45Sg/X8fTMkd+z7xG3j3Cqq8PXYx6tP3F88mRwU79Gu48XIniC5jNfv nPLjR9KVaYcnzdE/Fhv2ofSy1MN+Xc4FjhnNIZtjuxfIvFwxl7HHZVl33elM/9kN6wPOvkr6 XGc2SeVU3X2Zc6rlC9Jzt8gueXq+2zn+/Zr+WQfXspev2sDEtPjXSvcY3pOPVdbqvmQ9c2jn nG13YywqDzJyfF8nPIlHj/3VNaXCrMIX7k18F51O/e7adtXb4li6sGxIXS/n/cRz7dF3PpRz u5vxMVXvmdO0dFnEjU3SVXW7cpjOi0s7+CmxFGckGmoxFxUnAgC0jE+0BQMAAA== X-CMS-MailID: 20240823104622epcas5p2e3b29f793eff9857c5712b3d6d327ed5 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104622epcas5p2e3b29f793eff9857c5712b3d6d327ed5 References: <20240823103811.2421-1-anuj20.g@samsung.com> This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 12 +++++------- drivers/nvme/host/ioctl.c | 11 +++++++++-- include/linux/bio-integrity.h | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index d8b810a2b4bf..aaf67eb427ab 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -310,17 +310,16 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = 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)) @@ -333,8 +332,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) { @@ -344,8 +342,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index f1d58e70933f..d8628e7071cb 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -146,8 +146,15 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, if (bdev) { bio_set_dev(bio, bdev); if (meta_buffer && meta_len) { - ret = bio_integrity_map_user(bio, meta_buffer, meta_len, - meta_seed); + struct iov_iter iter; + unsigned int direction; + + if (bio_data_dir(bio) == READ) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, meta_buffer, meta_len); + ret = bio_integrity_map_user(bio, &iter, meta_seed); if (ret) goto out_unmap; req->cmd_flags |= REQ_INTEGRITY; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 485d8a43017a..5313811dc1ce 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, u32 seed); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); 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,8 @@ 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, u32 seed) +static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, + u32 seed) { return -EINVAL; } From patchwork Fri Aug 23 10:38:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774954 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 D7202187874 for ; Fri, 23 Aug 2024 10:48:27 +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=1724410109; cv=none; b=kdqCb1a+eRGAT9g3VeiBPXZJrLcK++DsQpTQ4gBgdAv7y1Ge3Q5HWwZV1+umwGbSs5Ys6Z/AyA0+SdaJGEpObUCkonKwryEJcHT8FGZS7S+yEwNQmLeGUXRMg+1urJruJOhIetmcifXjmMl5+Rvi7CreRjRA04MsoliR8HjzDVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410109; c=relaxed/simple; bh=Q7UzLGf8MKdCLyKP3dqKL//JTDm9JhtgAu8TQCvTKUM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=O116omAHo2YcXWS88UXxR0EbipX3YErAu/WQu6Rx/YurNTACISM5jZNb42mUGCx5mbMmLc9ex3i1UaS1CW9ofpOtuyTQIcaJ9J2hxtkmZP5DPmP/Fid/0q8jP1TuvRvhiJp3ocOItLSFocuJwfA+jO3F2M+Q7Jc0pyVWqiIStT8= 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=EO/QF1wU; 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="EO/QF1wU" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240823104825epoutp03bd02adabef4d83652e7f053a8cdd7560~uVdrbqVML1015510155epoutp033 for ; Fri, 23 Aug 2024 10:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240823104825epoutp03bd02adabef4d83652e7f053a8cdd7560~uVdrbqVML1015510155epoutp033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410105; bh=dHflLZxFjxBERw9P6UhrJ3VAQJqBtBlBCjawxtTo9Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EO/QF1wUbe3umRcH6D9vxbbBpds0lw041Uy/4QpzTwA37577rcMc8ZUDXsPIWT7qJ SW5vBOmJT9IAg8baGgLDLpHTNp20FicX0rQNEclHPrUHN9uTdoXUip0eDSaNyGI2zI auwSa3Pn1ak3uypEUSyiC8IIsSI8I1Qaju2Gj3dE= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240823104825epcas5p2e2c56889cac00a48fd239e910c09a317~uVdq70haN1947219472epcas5p2F; Fri, 23 Aug 2024 10:48:25 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Wqxcl20Gcz4x9Pr; Fri, 23 Aug 2024 10:48:23 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 59.8A.19863.7F868C66; Fri, 23 Aug 2024 19:48:23 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240823104624epcas5p40c1b0f3516100f69cbd31d45867cd289~uVb60yNDG1989019890epcas5p4R; Fri, 23 Aug 2024 10:46:24 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104624epsmtrp22e6120f2aec0add88e82ca28503226a9~uVb60Jd690122301223epsmtrp2J; Fri, 23 Aug 2024 10:46:24 +0000 (GMT) X-AuditID: b6c32a50-c73ff70000004d97-0f-66c868f7ae1b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 08.50.19367.08868C66; Fri, 23 Aug 2024 19:46:24 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104622epsmtip28ea9f66138f2e61ca934e1bd02c34d4c~uVb4_dOD31442714427epsmtip2b; Fri, 23 Aug 2024 10:46:22 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Kanchan Joshi Subject: [PATCH v3 05/10] block: define meta io descriptor Date: Fri, 23 Aug 2024 16:08:05 +0530 Message-Id: <20240823103811.2421-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDJsWRmVeSWpSXmKPExsWy7bCmhu73jBNpBqs+8ljMWbWN0WL13X42 i5sHdjJZrFx9lMniXes5Fouj/9+yWUw6dI3RYvuZpcwWe29pW8xf9pTdovv6DjaL5cf/MTnw eOycdZfd4/LZUo9NqzrZPDYvqffYfbOBzePj01ssHn1bVjF6bD5d7fF5k1wAZ1S2TUZqYkpq kUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QvUoKZYk5pUChgMTi YiV9O5ui/NKSVIWM/OISW6XUgpScAp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CSvG5Dxok0g9Z9hhZzVm1jtFh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02H5mKbPF3lvaFvOXPWW36L6+g81i+fF/TA48 Hjtn3WX3uHy21GPTqk42j81L6j1232xg8/j49BaLR9+WVYwem09Xe3zeJBfAGcVlk5Kak1mW WqRvl8CVcXT2bZaCTvaK52d3sjcwfmDtYuTkkBAwkTj2+BdLFyMXh5DAdkaJ1vaHLBAJCYlT L5cxQtjCEiv/PWeHKPrIKDHrUx8TSIJNQF3iyPNWRpCEiEAjo8SW5i9go5gFdjFKzN36jRmk SljASuLT/4fsIDaLgKrEtjM/wOK8AhYSH+c2MEOskJeYeek7WA2ngKVE0+wGsDOEgGqWLT/D CFEvKHFy5hOwODNQffPW2cwTGAVmIUnNQpJawMi0ilE0taA4Nz03ucBQrzgxt7g0L10vOT93 EyM4SrSCdjAuW/9X7xAjEwfjIUYJDmYlEd6ke0fThHhTEiurUovy44tKc1KLDzFKc7AoifMq 53SmCAmkJ5akZqemFqQWwWSZODilGpjqpC4nXjULMdz95LPOpAcfJFdsWPkvUtaOR4D77BLF djmWL4wLFL5ayoey1OjatDBNdKjer8696W/58ut1LImG7UvLqycEnPsWFLKGpem20RMZtpN3 6ubpsPrWv0nP4QxR9MpSfq/gKe6fs/9K7v7X/2fyHqnZ1Nzyucpm+3bVQ+Gn1h3v4/x8Y8my KP8f340vuOSFiHclrTLQO71n17W/zs2PDW8ma1TV608PKmFwCFSsjTT7q+cTGHlmSYq4fivn 0y1Z+o6miw62VZs0CZb98J81VerjzKs2M24dcK/WdDy5TPrPL7t9Yirdq10vaVk4SbjctJzn L1BfKmosaBY0Z51wtGMrK39PtqqcEktxRqKhFnNRcSIAvJ82tAEDAAA= X-CMS-MailID: 20240823104624epcas5p40c1b0f3516100f69cbd31d45867cd289 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104624epcas5p40c1b0f3516100f69cbd31d45867cd289 References: <20240823103811.2421-1-anuj20.g@samsung.com> From: Kanchan Joshi Introduces a new 'uio_meta' structure that upper layer can use to pass the meta/integrity information. Signed-off-by: Kanchan Joshi --- include/linux/bio-integrity.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 5313811dc1ce..a1a9031a5985 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -30,6 +30,15 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; +/* flags for integrity meta */ +typedef __u16 __bitwise meta_flags_t; + +struct uio_meta { + meta_flags_t flags; + u16 app_tag; + struct iov_iter iter; +}; + #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) From patchwork Fri Aug 23 10:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774955 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 C4F4F18787D for ; Fri, 23 Aug 2024 10:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410111; cv=none; b=HBAq33zQGCLuA208RR+aYLUsW8KX93bhHWoI5IQRguRDQf1iU5naSVDl3ecbCKoDcYoQ3aBV28xCHhcyyvdxIWuBGAQfa8Laur+Xcj6Bqxksl/xiTYFbJIgYMr7BDLKTejktKEsORNJeNLl5sSBjD7Z5jojB0vbJ5hXEefZrniA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410111; c=relaxed/simple; bh=Hymx3xj0OF6Ct6HDNu4MIPToW/smUveCIpQzAHntiLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=nAuFYWSlF/j9jcg8PEOK/8RldlRjWZprhnq2eC9vSmBMTfSF7SElbJfpqhfN50X47fK3t86i1yo/t5Z/dMFtEIQ5eoJ46oteKPFtH5f44l2sZifO//ewiC3AdZYnFeebtbGzBdHlWIQmTmQxVST5jA6LTxG7zlhm148XXboLAFw= 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=QahR06O/; 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="QahR06O/" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240823104828epoutp025b7a9891b4973bf9b9338cb84c125835~uVdtnwBej0951809518epoutp02b for ; Fri, 23 Aug 2024 10:48:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240823104828epoutp025b7a9891b4973bf9b9338cb84c125835~uVdtnwBej0951809518epoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410108; bh=/S/IL8F0kHSzv8YcpPPzosRpcJVevp1vPtYpcSap8Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QahR06O/N7ZGRJ3TASy6z6f+7uNZD+Z2hEcArlx29qLzxc6QdU53dMiloCA9LeXR6 t8Nv8izM5EOeA/bG0HH7TqtoqdewNoJWqR6moX0P1Aekw6V9Bzj89ButRZDHDPFxYm jmXqkaAaAy3rh5byKlhEPHZCnUPuIJu7/oIOW0FU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240823104827epcas5p20f7de225a7e03763b30067136044adff~uVdtX2nbW0721607216epcas5p2w; Fri, 23 Aug 2024 10:48:27 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Wqxcp21T8z4x9Px; Fri, 23 Aug 2024 10:48:26 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id EA.8A.19863.AF868C66; Fri, 23 Aug 2024 19:48:26 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240823104627epcas5p2abcd2283f6fb3301e1a8e828e3c270ae~uVb9DF6XS1853818538epcas5p2I; Fri, 23 Aug 2024 10:46:27 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240823104627epsmtrp158812ea9fe28ab7f6179f5339307bbdf~uVb9CV9RK0257302573epsmtrp1G; Fri, 23 Aug 2024 10:46:27 +0000 (GMT) X-AuditID: b6c32a50-c73ff70000004d97-15-66c868fa3dc9 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 34.0B.08456.38868C66; Fri, 23 Aug 2024 19:46:27 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104625epsmtip29a9701ab44fd472934b7b30010847784~uVb69w52b1442714427epsmtip2c; Fri, 23 Aug 2024 10:46:24 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta , Kanchan Joshi Subject: [PATCH v3 06/10] io_uring/rw: add support to send meta along with read/write Date: Fri, 23 Aug 2024 16:08:06 +0530 Message-Id: <20240823103811.2421-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAJsWRmVeSWpSXmKPExsWy7bCmuu6vjBNpBseb2CyaJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF9jNLmS323tK2mL/sKbtF9/UdbBbL j/9jcuD12DnrLrvH5bOlHptWdbJ5bF5S77H7ZgObx8ent1g8+rasYvTYfLra4/MmuQDOqGyb jNTElNQihdS85PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKCjlRTKEnNK gUIBicXFSvp2NkX5pSWpChn5xSW2SqkFKTkFJgV6xYm5xaV56Xp5qSVWhgYGRqZAhQnZGRf3 fWUt2O5aMX3/KpYGxh0WXYycHBICJhIf3nWydDFycQgJ7GGUmDbrNSOE84lRYtGid2wQzjdG iWNnnrDAtNxZNpkZIrGXUeLxkQVMEM5nRonVX6ayg1SxCahLHHneyghiiwhUSjzf9QNsCbPA TUaJQ3ufMYMkhAXCJZ5/OMsKYrMIqEps7ZvMBGLzClhIfJt2jRVinbzEzEvfwYZyClhKNM1u YIGoEZQ4ORPiJGagmuats8FOkhBYyyFx4vR7RohmF4l7DfuZIWxhiVfHt7BD2FISL/vboOx0 iR+XnzJB2AUSzcf2QfXaS7Se6gfq5Q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Q2+QlZl76zg5icwpYSjTNbgCbIwRU s2z5GUaIekGJkzOfQM2Xl2jeOpt5AqPALCSpWUhSCxiZVjFKphYU56bnFhsWGOWllusVJ+YW l+al6yXn525iBEeNltYOxj2rPugdYmTiYDzEKMHBrCTCm3TvaJoQb0piZVVqUX58UWlOavEh RmkOFiVx3m+ve1OEBNITS1KzU1MLUotgskwcnFINTLlbb01fftj0Q6T3G+UDVTvm+NbIKSVM mm6VsrPf+ee/6fzPOFYZ/XFJ+9r1Qul/pPqMv2ttUgqmu319d0/qX48Fl82fr1smGclPW3Eh OPHbUjM5xpXsMpJJUjL/pv69Z1X63FGqwDNawfRUDNf2Z7UmV4+tuGzze/LC6wXL9h4y+6ml tv3EhUb71+bzl5kf9uosk74ct0HVmKdedN785P2fOJV6T/vJl3hfcF7ydCLrHaG5u3U3pemm GX3cVlJdV9s/Yf+EtvzCiScNX4WIfl+79lmN8EzrxvYrB3I/Hk2tXHC5aK7tipPz/2zcYsHq dMg3slvq3tTjO57+v8k37f+NldtS7auXO9zqPrIhWrRHiaU4I9FQi7moOBEAohtJBQkDAAA= X-CMS-MailID: 20240823104627epcas5p2abcd2283f6fb3301e1a8e828e3c270ae X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104627epcas5p2abcd2283f6fb3301e1a8e828e3c270ae References: <20240823103811.2421-1-anuj20.g@samsung.com> This patch adds the capability of sending meta along with read/write. This meta is represented by a newly introduced 'struct io_uring_meta' which specifies information such as meta type/flags/buffer/length and apptag. Application sets up a SQE128 ring, prepares io_uring_meta within the second SQE. The patch processes the user-passed information to prepare uio_meta descriptor and passes it down using kiocb->private. Meta exchange is supported only for direct IO. Also vectored read/write operations with meta are not supported currently. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 32 ++++++++++++++++ io_uring/io_uring.c | 6 +++ io_uring/rw.c | 70 +++++++++++++++++++++++++++++++++-- io_uring/rw.h | 10 ++++- 5 files changed, 115 insertions(+), 4 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index fb0426f349fc..aec78bf3040c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -330,6 +330,7 @@ struct readahead_control; #define IOCB_NOIO (1 << 20) /* can use bio alloc cache */ #define IOCB_ALLOC_CACHE (1 << 21) +#define IOCB_HAS_META (1 << 22) /* * IOCB_DIO_CALLER_COMP can be set by the iocb owner, to indicate that the * iocb completion can be passed back to the owner for execution from a safe diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 042eab793e26..09e6cc022669 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -105,8 +105,40 @@ struct io_uring_sqe { */ __u8 cmd[0]; }; + /* + * If the ring is initialized with IORING_SETUP_SQE128, then + * this field is starting offset for 64 bytes of data. For meta io + * this contains 'struct io_uring_meta' + */ + __u8 big_sqe_cmd[0]; }; +enum io_uring_sqe_meta_type_bits { + META_TYPE_INTEGRITY_BIT, + /* not a real meta type; just to make sure that we don't overflow */ + META_TYPE_LAST_BIT, +}; + +/* meta type flags */ +#define META_TYPE_INTEGRITY (1U << META_TYPE_INTEGRITY_BIT) + +/* this goes to SQE128 */ +struct io_uring_meta { + __u16 meta_type; + __u16 meta_flags; + __u32 meta_len; + __u64 meta_addr; + __u16 app_tag; + __u8 pad[46]; +}; + +/* + * flags for integrity meta + */ +#define INTEGRITY_CHK_GUARD (1U << 0) /* enforce guard check */ +#define INTEGRITY_CHK_APPTAG (1U << 1) /* enforce app tag check */ +#define INTEGRITY_CHK_REFTAG (1U << 2) /* enforce ref tag check */ + /* * If sqe->file_index is set to this for opcodes that instantiate a new * direct descriptor (like openat/openat2/accept), then io_uring will allocate diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index a53f2f25a80b..743201d37611 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3814,6 +3814,12 @@ static int __init io_uring_init(void) /* top 8bits are for internal use */ BUILD_BUG_ON((IORING_URING_CMD_MASK & 0xff000000) != 0); + BUILD_BUG_ON(sizeof(struct io_uring_meta) > + sizeof(struct io_uring_sqe)); + + BUILD_BUG_ON(META_TYPE_LAST_BIT > + 8 * sizeof_field(struct io_uring_meta, meta_type)); + io_uring_optable_init(); /* diff --git a/io_uring/rw.c b/io_uring/rw.c index c004d21e2f12..fadc17813f76 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -23,6 +23,8 @@ #include "poll.h" #include "rw.h" +#define INTEGRITY_VALID_FLAGS (INTEGRITY_CHK_GUARD | INTEGRITY_CHK_APPTAG | \ + INTEGRITY_CHK_REFTAG) struct io_rw { /* NOTE: kiocb has the file as the first member, so don't do it here */ struct kiocb kiocb; @@ -247,6 +249,42 @@ static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) return 0; } +static int io_prep_rw_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe, + struct io_rw *rw, int ddir) +{ + const struct io_uring_meta *md = (struct io_uring_meta *)sqe->big_sqe_cmd; + u16 meta_type = READ_ONCE(md->meta_type); + const struct io_issue_def *def; + struct io_async_rw *io; + int ret; + + if (!meta_type) + return 0; + if (!(meta_type & META_TYPE_INTEGRITY)) + return -EINVAL; + + /* should fit into two bytes */ + BUILD_BUG_ON(INTEGRITY_VALID_FLAGS >= (1 << 16)); + + def = &io_issue_defs[req->opcode]; + if (def->vectored) + return -EOPNOTSUPP; + + io = req->async_data; + io->meta.flags = READ_ONCE(md->meta_flags); + if (io->meta.flags && (io->meta.flags & ~INTEGRITY_VALID_FLAGS)) + return -EINVAL; + + io->meta.app_tag = READ_ONCE(md->app_tag); + ret = import_ubuf(ddir, u64_to_user_ptr(READ_ONCE(md->meta_addr)), + READ_ONCE(md->meta_len), &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + rw->kiocb.ki_flags |= IOCB_HAS_META; + iov_iter_save_state(&io->meta.iter, &io->iter_meta_state); + return ret; +} + static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, int ddir, bool do_import) { @@ -269,11 +307,18 @@ 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; + if (unlikely(req->ctx->flags & IORING_SETUP_SQE128)) + ret = io_prep_rw_meta(req, sqe, rw, ddir); + return ret; } int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe) @@ -400,7 +445,10 @@ static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req) static void io_resubmit_prep(struct io_kiocb *req) { struct io_async_rw *io = req->async_data; + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + if (unlikely(rw->kiocb.ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); iov_iter_restore(&io->iter, &io->iter_state); } @@ -768,8 +816,12 @@ static inline int io_iter_do_read(struct io_rw *rw, struct iov_iter *iter) static bool need_complete_io(struct io_kiocb *req) { + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + + /* Exclude meta IO as we don't support partial completion for that */ return req->flags & REQ_F_ISREG || - S_ISBLK(file_inode(req->file)->i_mode); + S_ISBLK(file_inode(req->file)->i_mode) || + !(rw->kiocb.ki_flags & IOCB_HAS_META); } static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) @@ -786,7 +838,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) if (!(req->flags & REQ_F_FIXED_FILE)) req->flags |= io_file_get_flags(file); - kiocb->ki_flags = file->f_iocb_flags; + kiocb->ki_flags |= file->f_iocb_flags; ret = kiocb_set_rw_flags(kiocb, rw->flags, rw_type); if (unlikely(ret)) return ret; @@ -815,6 +867,14 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) kiocb->ki_complete = io_complete_rw; } + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) { + struct io_async_rw *io = req->async_data; + + if (!(req->file->f_flags & O_DIRECT)) + return -EOPNOTSUPP; + kiocb->private = &io->meta; + } + return 0; } @@ -881,6 +941,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) * manually if we need to. */ iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); do { /* @@ -1091,6 +1153,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_HAS_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); if (kiocb->ki_flags & IOCB_WRITE) io_req_end_write(req); return -EAGAIN; diff --git a/io_uring/rw.h b/io_uring/rw.h index 3f432dc75441..ce7a865fac95 100644 --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include struct io_async_rw { size_t bytes_done; @@ -9,7 +10,14 @@ struct io_async_rw { struct iovec fast_iov; struct iovec *free_iovec; int free_iov_nr; - struct wait_page_queue wpq; + /* wpq is for buffered io, while meta fields are used with direct io*/ + union { + struct wait_page_queue wpq; + struct { + struct uio_meta meta; + struct iov_iter_state iter_meta_state; + }; + }; }; int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); From patchwork Fri Aug 23 10:38: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: 13774956 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 2FA89187877 for ; Fri, 23 Aug 2024 10:48:32 +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=1724410113; cv=none; b=oSoattB3sAkMHrQ0rGKxuZQUkXWfMrCWBXluOrvZQ1m0QyE/AyOepHwGyl4TwWYVgdc0VKibmXJGTZWVdIBKJXq5hQsPibRndWuFiTejdrjJ8sD/qmNjRmikI3/2FqjiT+oAG4l/De2LShFcDqwzqxbME3OM3J2eykMZEz9saj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410113; c=relaxed/simple; bh=kmTSdUT+bP9tsddpB6eT+RYHgy7lddAPgpddvcZdAGA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=HA+NAkzZRq8DAfOiuaLcFzH+vj2PL2bAkMghwTa2GvHet+L69Ixq/A/k8lDRchJMHsXlFeIzLkePly6wkDV8+J17v+CsNdcOITIdtbR3ja5UWdjlFb91XyjK4Z4V7IyjHWCm1889bYfWGORK7Yt+bg9EC8HDi3rpGQsbZJZKsTs= 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=IaH3U1m0; 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="IaH3U1m0" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240823104830epoutp02a65b88ebfe30fb6b832dbd23f1c13ff5~uVdv4Lzvu1185511855epoutp02U for ; Fri, 23 Aug 2024 10:48:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240823104830epoutp02a65b88ebfe30fb6b832dbd23f1c13ff5~uVdv4Lzvu1185511855epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410110; bh=fdfNA1BhNobCcdbbPzAPNJ/9rXGRREf8RhQ25IpYD8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IaH3U1m05Yq56Z7hn3yIih+AQk+KehLWxeJp1gGJ34wrKxTb3vFMnkr0+e2m27HBj sNQtTIKYVa9CbCR7Y7hboZXtiQMihPnR/YNn3mpOB5Ht2DQeht+oyseuZ5P/e9uL6Y bD1nFR16J2gRb4QsvXxhFL25Jx69fLczp8zbXdWo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240823104830epcas5p4826c24b394f3cb5b21217d069f39561b~uVdvg2IsV1745317453epcas5p4t; Fri, 23 Aug 2024 10:48:30 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Wqxcr3YY8z4x9Q1; Fri, 23 Aug 2024 10:48:28 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 5D.8A.19863.CF868C66; Fri, 23 Aug 2024 19:48:28 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8~uVb-MALz22095320953epcas5p3W; Fri, 23 Aug 2024 10:46:29 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240823104629epsmtrp132972e540270c63d4dfd7abdd7d847fe~uVb-LNNz00257302573epsmtrp1N; Fri, 23 Aug 2024 10:46:29 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-1e-66c868fc3e24 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 03.6F.07567.58868C66; Fri, 23 Aug 2024 19:46:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104627epsmtip2ec3a72087ba73c78ad139cde0b1e31dc~uVb9G5eM91384313843epsmtip2T; Fri, 23 Aug 2024 10:46:27 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta , Kanchan Joshi Subject: [PATCH v3 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Fri, 23 Aug 2024 16:08:07 +0530 Message-Id: <20240823103811.2421-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPJsWRmVeSWpSXmKPExsWy7bCmpu6fjBNpBj/XiVs0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaL7WeWMlvsvaVtMX/ZU3aL7us72CyW H//H5MDrsXPWXXaPy2dLPTat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IAQo2TTwgDAAA= X-CMS-MailID: 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8 References: <20240823103811.2421-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. 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 --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 12 +++--------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index aaf67eb427ab..7fbf8c307a36 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -444,6 +444,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 33fa01c599ad..d4c366df8f12 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1002,19 +1002,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, return BLK_STS_NOTSUPP; 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 a1a9031a5985..c7c0121689e1 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, + BIP_CHECK_REFTAG = 1 << 7, + BIP_CHECK_APPTAG = 1 << 8, }; struct bio_integrity_payload { @@ -40,7 +43,8 @@ struct uio_meta { }; #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 Fri Aug 23 10:38: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: 13774958 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 98A3B13D521 for ; Fri, 23 Aug 2024 10:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410128; cv=none; b=Om467GepJXzgYxo/WJGv6snW7cBR93FnReB6cJszm8b/aIk+NiI3O+zSXluJgNt53ooZKGfijpVyx/252qYUUGQCVv7vigD9B4m+TlOwy9KgT2x7U5e1di2F+xnERDb35Z9OJutjul5eUTi/+4jy3YWnL4ysqB4Wzi5s1Z4auQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410128; c=relaxed/simple; bh=ZFRQD9h8z7hSXpmmJj4mQnOOQRJC2IiHlwUXp6iT0Tk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=KlVlh7uPiE4ggudgN2Dhn26+SszB15on7/Toy7cRw7/8bJLEa1R5vdW9/D+cd7r8r92MdemFkCJQDf0AXfwPIpCF9oV8O5wsGwDkPNjJoEurpDJCWZUh2G016lgeWa2wxEkVm4+YCtAFZ/slTZs62mhT3jTlm3aHo+vhLp4GGFs= 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=hw/QDHs8; 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="hw/QDHs8" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240823104844epoutp034f2d53fc012c563609c67d56ea07bd1f~uVd9Tquxr0963909639epoutp03D for ; Fri, 23 Aug 2024 10:48:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240823104844epoutp034f2d53fc012c563609c67d56ea07bd1f~uVd9Tquxr0963909639epoutp03D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410125; bh=xx/xKoOUcbojb9soBs/yl0B6zu+0BvFN6VqSS3y8yOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hw/QDHs8Re082khBLEc8/iC6F9jo5/uHixtlDFIRoub/7gLN4Z+VD7eLkqgd1GEvF c/fhJeLLnIm/Dn654/QxhJ4DbvOaysAlM2GmBbv0o81kHNB4hxay46TbPxVcILD1fU 8SZcbrAbkfGTs2GEFGXQALxhH+uOPLGNGomOHA4Q= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240823104844epcas5p321b62e0822626f1b28485f8e22f10cd4~uVd8payEw1524515245epcas5p3z; Fri, 23 Aug 2024 10:48:44 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Wqxd63xs1z4x9Q0; Fri, 23 Aug 2024 10:48:42 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D8.30.08855.A0968C66; Fri, 23 Aug 2024 19:48:42 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240823104634epcas5p4ef1af26cc7146b4e8b7a4a1844ffe476~uVcDkn7Qc3268132681epcas5p4j; Fri, 23 Aug 2024 10:46:34 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240823104634epsmtrp14411ac4782d6495c00ecee9d728005d2~uVcDj2E7d0262002620epsmtrp1B; Fri, 23 Aug 2024 10:46:34 +0000 (GMT) X-AuditID: b6c32a44-107ff70000002297-c7-66c8690a6ada Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 86.6F.07567.A8868C66; Fri, 23 Aug 2024 19:46:34 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104632epsmtip2938765aea09c7de01353c72ad9e196c4~uVcBcYfOP1453814538epsmtip2C; Fri, 23 Aug 2024 10:46:31 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Kanchan Joshi , Anuj Gupta Subject: [PATCH v3 08/10] block: add support to pass user meta buffer Date: Fri, 23 Aug 2024 16:08:09 +0530 Message-Id: <20240823103811.2421-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHJsWRmVeSWpSXmKPExsWy7bCmui5X5ok0gwPThC2aJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF9jNLmS323tK2mL/sKbtF9/UdbBbL j/9jcuD12DnrLrvH5bOlHptWdbJ5bF5S77H7ZgObx8ent1g8+rasYvTYfLra4/MmuQDOqGyb jNTElNQihdS85PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKCjlRTKEnNK gUIBicXFSvp2NkX5pSWpChn5xSW2SqkFKTkFJgV6xYm5xaV56Xp5qSVWhgYGR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j xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF9jNLmS323tK2mL/sKbtF9/UdbBbL j/9jcuD12DnrLrvH5bOlHptWdbJ5bF5S77H7ZgObx8ent1g8+rasYvTYfLra4/MmuQDOKC6b lNSczLLUIn27BK6Mtq8zmQs+W1d0Lt7E1MB4yKCLkZNDQsBEYuf098xdjFwcQgK7GSWe9E5l g0hISJx6uYwRwhaWWPnvOTtE0UdGiZ4fl8ASbALqEkeetzKCJEQEGhkltjR/YQFxmAXuM0q8 bd7NAlIlLOAqcfHnQmYQm0VAVeLpnO+sIDavgKXE/n8nWCBWyEvMvPSdHcTmBIo3zW4AiwsJ WEgsW36GEaJeUOLkzCdgcWag+uats5knMArMQpKahSS1gJFpFaNkakFxbnpusmGBYV5quV5x Ym5xaV66XnJ+7iZGcNxoaexgvDf/n94hRiYOxkOMEhzMSiK8SfeOpgnxpiRWVqUW5ccXleak Fh9ilOZgURLnNZwxO0VIID2xJDU7NbUgtQgmy8TBKdXAtKQwsWX/i6f16aYZ/K1yeVVnbgd1 S+3QOnjGS23OihX3F/U16wvuqbylInptpeWKP6Uhgi9+nl6g9kN0XgarY3XBR0u52EbGeYyz 3TTf8+TYX8hXTlsrOj2m8nnuq3eKRvrLs8q+ZjmECzatuaXgKRCR/tn1SOqhU99O7C1hkW6W 2GW1K2PfB67iSDXzhUv0PzeIc6bJJktXWls1B1vzu6yYumdmgF6Q2xuDd2LrGWc8kckoOrFH KWXC5K7iq3v6Mq92ztooYfC8v3nJ6QvrptonFvU0JnmcWt0t023s1rxi6hJ+aYfNfJ5SPwst mlM6ZxtY8V7LTtnx/oUjv8p27QdtyYdUY/+pesp7nVJiKc5INNRiLipOBADkltLoCgMAAA== X-CMS-MailID: 20240823104634epcas5p4ef1af26cc7146b4e8b7a4a1844ffe476 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104634epcas5p4ef1af26cc7146b4e8b7a4a1844ffe476 References: <20240823103811.2421-1-anuj20.g@samsung.com> From: Kanchan Joshi If iocb contains the meta, extract that and prepare the bip. Based on flags specified by the user, set corresponding guard/app/ref tags to be checked in bip. Introduce BIP_INTEGRITY_USER flag to indicate integrity payload is user address. Make sure that ->prepare_fn and ->complete_fn are skipped for user-owned meta buffer. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 45 ++++++++++++++++++++++++++++++++++- block/fops.c | 25 +++++++++++++++++++ block/t10-pi.c | 6 +++++ include/linux/bio-integrity.h | 13 +++++++++- 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 7fbf8c307a36..02b766c2e57d 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "blk.h" static struct kmem_cache *bip_slab; @@ -252,7 +253,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, goto free_bip; } - bip->bip_flags |= BIP_COPY_USER; + bip->bip_flags |= BIP_INTEGRITY_USER | BIP_COPY_USER; bip->bip_iter.bi_sector = seed; bip->bip_vcnt = nr_vecs; bip->bio_iter = bio->bi_iter; @@ -274,6 +275,7 @@ static int bio_integrity_init_user(struct bio *bio, struct bio_vec *bvec, return PTR_ERR(bip); memcpy(bip->bip_vec, bvec, nr_vecs * sizeof(*bvec)); + bip->bip_flags |= BIP_INTEGRITY_USER; bip->bip_iter.bi_sector = seed; bip->bip_iter.bi_size = len; bip->bip_vcnt = nr_vecs; @@ -310,6 +312,47 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } +static void bio_uio_meta_to_bip(struct bio *bio, struct uio_meta *meta) +{ + struct bio_integrity_payload *bip = bio_integrity(bio); + + if (meta->flags & INTEGRITY_CHK_GUARD) + bip->bip_flags |= BIP_CHECK_GUARD; + if (meta->flags & INTEGRITY_CHK_APPTAG) + bip->bip_flags |= BIP_CHECK_APPTAG; + if (meta->flags & 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; + + it.count = integrity_bytes; + ret = bio_integrity_map_user(bio, &it, 0); + if (!ret) { + bio_uio_meta_to_bip(bio, meta); + iov_iter_advance(&meta->iter, integrity_bytes); + } + return ret; +} + int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { diff --git a/block/fops.c b/block/fops.c index 9825c1713a49..5c18676c17ab 100644 --- a/block/fops.c +++ b/block/fops.c @@ -154,6 +154,9 @@ static void blkdev_bio_end_io(struct bio *bio) } } + if (bio_integrity(bio) && (dio->iocb->ki_flags & IOCB_HAS_META)) + bio_integrity_unmap_user(bio); + if (should_dirty) { bio_check_pages_dirty(bio); } else { @@ -231,6 +234,16 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, } bio->bi_opf |= REQ_NOWAIT; } + if (!is_sync && unlikely(iocb->ki_flags & IOCB_HAS_META)) { + ret = bio_integrity_map_iter(bio, iocb->private); + if (unlikely(ret)) { + bio_release_pages(bio, false); + bio_clear_flag(bio, BIO_REFFED); + bio_put(bio); + blk_finish_plug(&plug); + return ret; + } + } if (is_read) { if (dio->flags & DIO_SHOULD_DIRTY) @@ -288,6 +301,9 @@ static void blkdev_bio_end_io_async(struct bio *bio) ret = blk_status_to_errno(bio->bi_status); } + if (bio_integrity(bio) && (iocb->ki_flags & IOCB_HAS_META)) + bio_integrity_unmap_user(bio); + iocb->ki_complete(iocb, ret); if (dio->flags & DIO_SHOULD_DIRTY) { @@ -348,6 +364,15 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, task_io_account_write(bio->bi_iter.bi_size); } + if (unlikely(iocb->ki_flags & IOCB_HAS_META)) { + ret = bio_integrity_map_iter(bio, iocb->private); + WRITE_ONCE(iocb->private, NULL); + if (unlikely(ret)) { + bio_put(bio); + return ret; + } + } + if (iocb->ki_flags & IOCB_ATOMIC) bio->bi_opf |= REQ_ATOMIC; diff --git a/block/t10-pi.c b/block/t10-pi.c index e7052a728966..cb7bc4a88380 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -139,6 +139,8 @@ static void t10_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; @@ -188,6 +190,8 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) struct bio_vec iv; struct bvec_iter iter; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; void *p; @@ -313,6 +317,8 @@ static void ext_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index c7c0121689e1..22ff2ae16444 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -14,6 +14,9 @@ enum bip_flags { BIP_CHECK_GUARD = 1 << 6, BIP_CHECK_REFTAG = 1 << 7, BIP_CHECK_APPTAG = 1 << 8, + BIP_INTEGRITY_USER = 1 << 9, /* Integrity payload is user + * address + */ }; struct bio_integrity_payload { @@ -24,6 +27,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; struct bvec_iter bio_iter; /* for rewinding parent bio */ @@ -44,7 +48,8 @@ struct uio_meta { #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ - BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | \ + BIP_CHECK_APPTAG | BIP_INTEGRITY_USER) #ifdef CONFIG_BLK_DEV_INTEGRITY @@ -89,6 +94,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, u32 seed); +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); @@ -120,6 +126,11 @@ static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, return -EINVAL; } +static inline int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + return -EINVAL; +} + static inline void bio_integrity_unmap_user(struct bio *bio) { } From patchwork Fri Aug 23 10:38: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: 13774959 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 116401862B2 for ; Fri, 23 Aug 2024 10:48:49 +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=1724410131; cv=none; b=U4NcHsMSHFT5XwUv0v8JDlFw9r5mRLUYO9jtTGATo+jsjwLQ18AKCdSXNDDjWqHhxhBTliTbv0hkrhjdpOqNdagoPZjF8Xb0New4UahABhh0t7/TDIiBXwUo5zBSbjjnFTmPpn2WNCf6vUvoN241MSopm4J+mxfP00pDOUVOfU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410131; c=relaxed/simple; bh=CUU00BYF/vTzR78Gh+My/x3Wzz9L9q/Wf/JJa0RPp6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=kEq99HxxpvS724SNcihCfTHpohEcQrqC6d429p6pt0sJJaf/d9wpLzv23Xcr0BHCFmM4Pc7QagIaaQWo8Bjdb4P94QW0KoaAHQSvHUOCzuiPqE1sVrR5p4OTe695MOjvvqng472DsIWm+eyWH3Wm9+y+HAqllGqmig/q0ejVxV8= 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=fNd+sOs/; 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="fNd+sOs/" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240823104848epoutp028eec0c31b9dd81ac33192801ee52d23b~uVeAdvZhW0950009500epoutp02j for ; Fri, 23 Aug 2024 10:48:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240823104848epoutp028eec0c31b9dd81ac33192801ee52d23b~uVeAdvZhW0950009500epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410128; bh=gXHtlknFE9nvxeqNKkR2iIn97pKvOQEYOliJebKXNkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNd+sOs/aZ6FYPx6i/ZvLjCvRhnZgWWvEEm3FJZR8YvSWsJd263P6D5WiG8JF6vkK XdKArXpeaD8BEklmU6v++tx/TyIsUpMU9yD8FPXZoXTJBHY8m05cvPyWO4VnVu7qzu 13Z+1OlCOlIZXRafX2yL4O0yN85fcOOib+emJy2Y= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240823104847epcas5p16806045158f31a0435af199a300942a0~uVd-793x92850228502epcas5p1H; Fri, 23 Aug 2024 10:48:47 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WqxdB189bz4x9Pq; Fri, 23 Aug 2024 10:48:46 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CA.30.08855.E0968C66; Fri, 23 Aug 2024 19:48:46 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240823104636epcas5p4825a6d2dd9e45cfbcc97895264662d30~uVcFscXsf1394713947epcas5p4Q; Fri, 23 Aug 2024 10:46:36 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104636epsmtrp23a2d147a0fe123c333c0fe910e8f9b7b~uVcFnczlI0163301633epsmtrp2W; Fri, 23 Aug 2024 10:46:36 +0000 (GMT) X-AuditID: b6c32a44-15fb870000002297-d0-66c8690e4604 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 29.0B.08456.C8868C66; Fri, 23 Aug 2024 19:46:36 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104634epsmtip2046c9f44c5cbd54c2a0c28b10004bbb0~uVcDpDd3N1442714427epsmtip2x; Fri, 23 Aug 2024 10:46:34 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Kanchan Joshi , Anuj Gupta Subject: [PATCH v3 09/10] nvme: add handling for app_tag Date: Fri, 23 Aug 2024 16:08:10 +0530 Message-Id: <20240823103811.2421-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLJsWRmVeSWpSXmKPExsWy7bCmli5f5ok0g8adLBZNE/4yW8xZtY3R YvXdfjaLmwd2MlmsXH2UyeJd6zkWi6P/37JZTDp0jdFi+5mlzBZ7b2lbzF/2lN2i+/oONovl x/8xOfB67Jx1l93j8tlSj02rOtk8Ni+p99h9s4HN4+PTWywefVtWMXpsPl3t8XmTXABnVLZN RmpiSmqRQmpecn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtDRSgpliTml QKGAxOJiJX07m6L80pJUhYz84hJbpdSClJwCkwK94sTc4tK8dL281BIrQwMDI1OgwoTsjEXH 2pkL5nNXbPjp38C4lLOLkZNDQsBEovHxJEYQW0hgN6PEkW0FXYxcQPYnRokzL5awQD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93j8tlSj02rOtk8Ni+p99h9s4HN4+PTWywefVtWMXpsPl3t8XmTXABnFJdN SmpOZllqkb5dAlfGomPtzAXzuSs2/PRvYFzK2cXIySEhYCJxuOUmSxcjF4eQwG5GiTdPZjBB JCQkTr1cxghhC0us/PecHaLoI6PElOuH2UESbALqEkeetzKCJEQEGhkltjR/ARvFLHCfUeJt 824gh4NDWMBC4k2fIUgDi4CqxKrz81hAbF4BS4ljLWegtslLzLz0HWwoJ1C8aXYDWI0QUOuy 5WcYIeoFJU7OfAIWZwaqb946m3kCo8AsJKlZSFILGJlWMUqmFhTnpucWGxYY5aWW6xUn5haX 5qXrJefnbmIEx4yW1g7GPas+6B1iZOJgPMQowcGsJMKbdO9omhBvSmJlVWpRfnxRaU5q8SFG aQ4WJXHeb697U4QE0hNLUrNTUwtSi2CyTBycUg1MXPuWaE//+MMw1udO4oUGRucZO8t27H3K t1vduo7V2S1omeb11gt7lETMBVbtYr2VXmWqLavp5M+0v3JP8vxbYZHmKXqzLHxdWNkPnLc7 HXX0D5tO7MkV0Xvs2i0PxxT9+7plbW+d+iHd5M6W1UtVX//c8XPjlGlvJi2ezhLIOM109SZ+ 01BbP/kPOwQv+czI7z6ituC7vDOTPiP/Vp5XDAw9T7/8Vp9Y9Vmg9bvt9gSXybqFeY6P7+0P LRK1rWl+Xvz4CE/+jIKiKa5SBlXuCyK4Tu/eKjBtvkPKS52yt2G3TJNn3Gjdudbt3rvbwfza 065bxdzS4lstE/Pkw04uiYsaLce79ZmF2RJYZZmVWIozEg21mIuKEwFmrOzyCAMAAA== X-CMS-MailID: 20240823104636epcas5p4825a6d2dd9e45cfbcc97895264662d30 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104636epcas5p4825a6d2dd9e45cfbcc97895264662d30 References: <20240823103811.2421-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. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- drivers/nvme/host/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d4c366df8f12..af6940ec6e3c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -871,6 +871,13 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct nvme_command *cmnd, u16 apptag) +{ + cmnd->rw.apptag = cpu_to_le16(apptag); + /* use 0xfff as mask so that apptag is used in entirety */ + cmnd->rw.appmask = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -1010,6 +1017,11 @@ 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(cmnd, + bio_integrity(req->bio)->app_tag); + } } cmnd->rw.control = cpu_to_le16(control); From patchwork Fri Aug 23 10:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13774960 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 5C52E187872 for ; Fri, 23 Aug 2024 10:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410136; cv=none; b=UbkcJYx8QogaVt4Nh6+q+0lvAdIJZt/DBtLg8Y1+GpCsprDdcpMGwBGX+DbmiLJFodejxpK3axXA/axRnbEAZwKFLH3o9Cr5488HhxcW7jCniRSJ8DbIf0xfqS5jmyJMKpXSqGy1F5vDyem2sJeYUAjZ5EpNz3o4dcwQWB1+ts8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410136; c=relaxed/simple; bh=d8uLLwSdbzE5G1fR2VMdUPEYeU0UD3cRDnuIOnqv5P4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=A4y9XFMopzOA5EzW2Cbkh+AsYFjmATjSnIqcdIOErH+QfUYk5lUlsbAzGhf7zIlgpkdIFRVXJUkMz0k/+f1J5GUj0zaaXoe8ZnX2OclOGjpE6WOnmDks0Ai6K0RsEZeY2qpHWlh8kfQBLS5xAsrWNAfoR1IvfgsE7ywKGfjlFWA= 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=Zi/TY8EA; 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="Zi/TY8EA" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240823104852epoutp037deb05962356b93498202f1b83a528ae~uVeEgSHeV1192211922epoutp03V for ; Fri, 23 Aug 2024 10:48:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240823104852epoutp037deb05962356b93498202f1b83a528ae~uVeEgSHeV1192211922epoutp03V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410132; bh=YAT9f3XY8IKgq4WGMiK0V4o2WovD1lxpk8P5rBhzxR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zi/TY8EA4txsjwhM/vQbcI663nD8acr+pVTsqZg9o4LAx+BMurmS8TPsWrc2qvn3f AZix6GMsf784zmL6M3zfzBCbhu5kdll2tZAacIuMY3iNeUio9A19pItbqVZe0zPhkB M9fDUgfbZNeW+Vs0jwEBlvLJWucYPvPm/9m1j1VA= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240823104852epcas5p424c5a420f83babade5eb18c7b817db39~uVeEBmsGG1746017460epcas5p4S; Fri, 23 Aug 2024 10:48:52 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.180]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WqxdG4j1Yz4x9Pv; Fri, 23 Aug 2024 10:48:50 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 7F.28.09642.21968C66; Fri, 23 Aug 2024 19:48:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240823104639epcas5p11dbab393122841419368a86b4bd5c04b~uVcIMnAqt0371903719epcas5p1h; Fri, 23 Aug 2024 10:46:39 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240823104639epsmtrp2a5af888759a8b81fe7731ecd1c213759~uVcILd2ID0163301633epsmtrp2m; Fri, 23 Aug 2024 10:46:39 +0000 (GMT) X-AuditID: b6c32a4b-613ff700000025aa-8d-66c86912ad23 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 5D.50.19367.F8868C66; Fri, 23 Aug 2024 19:46:39 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104636epsmtip20ab42e1096e1e413e32f65d84bf4f0bb~uVcFxtx0q1442714427epsmtip2y; Fri, 23 Aug 2024 10:46:36 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de 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, Anuj Gupta Subject: [PATCH v3 10/10] scsi: add support for user-meta interface Date: Fri, 23 Aug 2024 16:08:11 +0530 Message-Id: <20240823103811.2421-12-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJJsWRmVeSWpSXmKPExsWy7bCmpq5Q5ok0g2sn5S2aJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFpMOXWO02H5mKbPF3lvaFvOXPWW36L6+g81i+fF/TA48 Hjtn3WX3uHy21GPTqk42j81L6j1232xg8/j49BaLR9+WVYwem09Xe3zeJBfAGZVtk5GamJJa pJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0r5JCWWJOKVAoILG4 WEnfzqYov7QkVSEjv7jEVim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO+PJu8tMBS0K FZvaVjE2MF6V6mLk5JAQMJFo2LmesYuRi0NIYDejxJ7fy9kgnE+MEr0fLzHDOR2dj5lgWjZO nMMCkdjJKLFo21mols+MEkvefGMEqWITUJc48rwVzBYRqJR4vusHWAezwCZGiV/Xj4GNEhZw lrjW+hyom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AiYSGycOIeli5GLQ0hgO6PE+k3XWSASEhKn Xi5jhLCFJVb+e84OUfSRUeL4pbfsIAk2AXWJI89bGUESIgKNjBJbmr+AjWIW2MEose7ZYrB2 YQFniWutz9m6GDk4WARUJc4dzwEJ8wpYSjy9/YINYoO8xMxL38GGcgLFm2Y3gF0hJGAhsWz5 GUaIekGJkzOfgMWZgeqbt85mnsAoMAtJahaS1AJGplWMoqkFxbnpuckFhnrFibnFpXnpesn5 uZsYwTGiFbSDcdn6v3qHGJk4GA8xSnAwK4nwJt07mibEm5JYWZValB9fVJqTWnyIUZqDRUmc VzmnM0VIID2xJDU7NbUgtQgmy8TBKdXAVHnw3Kx58kwVyaVBhqX/OxqsgkISGQvlv/aern1V pxhYfWvrrP4XGef7JFSCMqbmf1ojoR9aduD1TVGFXecXhN5iai+8ym3XPbO5edvP/1wF77c5 eAkcbTStYErufGHitWpHb8xkJmW/GpEPQR8ZrGVPPa696349/JjR/rR4UUUGsxaBpN1ezEaz /9XGOGlo58yqvJ6y/vqTnatnWmc9eHZ8vipr1VGJQzO8/LrcV5ROasy/GqD58tYUoTu65e0T Tglv/s7I9j663CTeJsz34tPblwTMLtn/ltYV2N0jOGnnl23Gx6Ieb5Gv7BcweXb5433F1Obz f/uXXLR+y8Uh+vbx/l/sQfesD1+b9vi8EktxRqKhFnNRcSIAVsx/6QADAAA= X-CMS-MailID: 20240823104639epcas5p11dbab393122841419368a86b4bd5c04b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104639epcas5p11dbab393122841419368a86b4bd5c04b References: <20240823103811.2421-1-anuj20.g@samsung.com> Add support for sending user-meta buffer. Set tags to be checked using flags specified by user/block-layer user and underlying DIF/DIX configuration. Introduce BLK_INTEGRITY_APP_TAG to specify apptag. This provides a way for upper layers to specify apptag checking. Signed-off-by: Anuj Gupta --- block/bio-integrity.c | 2 ++ drivers/scsi/sd.c | 25 +++++++++++++++++++++++-- drivers/scsi/sd_dif.c | 2 +- include/linux/blk-integrity.h | 1 + 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 02b766c2e57d..ff7de4fe74c4 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -492,6 +492,8 @@ bool bio_integrity_prep(struct bio *bio) bip->bip_flags |= BIP_CHECK_GUARD; if (bi->flags & BLK_INTEGRITY_REF_TAG) bip->bip_flags |= BIP_CHECK_REFTAG; + if (bi->flags & BLK_INTEGRITY_APP_TAG) + bip->bip_flags |= BIP_CHECK_APPTAG; 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/scsi/sd.c b/drivers/scsi/sd.c index 699f4f9674d9..6ebef140cec2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -803,6 +803,23 @@ static unsigned int sd_prot_flag_mask(unsigned int prot_op) return flag_mask[prot_op]; } +/* + * Can't check reftag alone or apptag alone + */ +static bool sd_prot_flags_valid(struct scsi_cmnd *scmd) +{ + struct request *rq = scsi_cmd_to_rq(scmd); + struct bio *bio = rq->bio; + + if (bio_integrity_flagged(bio, BIP_CHECK_REFTAG) && + !bio_integrity_flagged(bio, BIP_CHECK_APPTAG)) + return false; + if (!bio_integrity_flagged(bio, BIP_CHECK_REFTAG) && + bio_integrity_flagged(bio, BIP_CHECK_APPTAG)) + return false; + return true; +} + static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, unsigned int dix, unsigned int dif) { @@ -815,14 +832,16 @@ 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_CTRL_NOCHECK) == false && + (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_CTRL_NOCHECK) == false) && + (!dix || bio_integrity_flagged(bio, BIP_CHECK_REFTAG))) scmd->prot_flags |= SCSI_PROT_REF_CHECK; } @@ -1374,6 +1393,8 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) dif = scsi_host_dif_capable(cmd->device->host, sdkp->protection_type); dld = sd_cdl_dld(sdkp, cmd); + if (!sd_prot_flags_valid(cmd)) + goto fail; if (dif || dix) protect = sd_setup_protect_cmnd(cmd, dix, dif); else diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c index ae6ce6f5d622..6c53e3b9d7d7 100644 --- a/drivers/scsi/sd_dif.c +++ b/drivers/scsi/sd_dif.c @@ -50,7 +50,7 @@ void sd_dif_config_host(struct scsi_disk *sdkp, struct queue_limits *lim) bi->csum_type = BLK_INTEGRITY_CSUM_CRC; if (type != T10_PI_TYPE3_PROTECTION) - bi->flags |= BLK_INTEGRITY_REF_TAG; + bi->flags |= BLK_INTEGRITY_REF_TAG | BLK_INTEGRITY_APP_TAG; bi->tuple_size = sizeof(struct t10_pi_tuple); diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 2ff65c933c50..865e0c4a7255 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -13,6 +13,7 @@ enum blk_integrity_flags { BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2, BLK_INTEGRITY_REF_TAG = 1 << 3, BLK_INTEGRITY_STACKED = 1 << 4, + BLK_INTEGRITY_APP_TAG = 1 << 5, }; const char *blk_integrity_profile_name(struct blk_integrity *bi);