From patchwork Mon Nov 4 14:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 841310 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 C17AC1C07F7 for ; Mon, 4 Nov 2024 15:55:58 +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=1730735761; cv=none; b=BrD3+Nh7vy1Yj+4E4izQxqhMGX5WddOtL84PlTr3AoBj0BLllTjnRDU4ENlcLmkHQUYl3bkoKMxBQVW+p/K7kwYFSOaYtsHDs3G5kzCgKuUtcnp5/oEF9AlIFlW3OHCVWlEkxDRJ5qAvnmowT0BuyAK+Ng3rbcWadgJw+imR4j8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735761; c=relaxed/simple; bh=z3oZCEUpNWP6ssVVNnvaEMGwTgZ5HxAO2xsIC7OVOu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=ePr/7GNKwr9IXhG5+Y+YkjoFVwFswCPA1iUc7EwbuV565HNCkdQha2uKUGW76xz6t/QGMuWZJ1xuUuQa41aekm4H0VIBwlcvarw9yMIB+e2qhQhHdjt9ftp3+f7dWETNheHSuBr6h6ACcvMA80V1laZPlzgNbksBEw99GMmZ6vk= 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=snOvUU0P; 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="snOvUU0P" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241104155556epoutp0436b483cf073629d1f6a12bb2826574fd~EzwA8Qpm_1250312503epoutp04w for ; Mon, 4 Nov 2024 15:55:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241104155556epoutp0436b483cf073629d1f6a12bb2826574fd~EzwA8Qpm_1250312503epoutp04w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735756; bh=n6LNHR2UxOEOGCqUSfrJ4D/dcAXYHqklNM5hsVN/lLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snOvUU0PhjyxpXJ0ImpouSfoOsbjXA5lfd5QXcVj6VGLtDO59E/InvIWbbbJyc+Av SPWXO1sM5Yb/uZVuvLMw861feTr1e53fmIlurIyEitDLE8XVQ3waNdnx2KTUseNgF0 4Ig3m+PNXU7+DtPdtkurEgaFWpkXwGAdS/DlYt1c= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241104155555epcas5p31d8e2563298b091b0ce53f3e20fdb636~EzwAO_2lC0957809578epcas5p3W; Mon, 4 Nov 2024 15:55:55 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.180]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xhwzt30BLz4x9Pq; Mon, 4 Nov 2024 15:55:54 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 8B.8A.09770.A8EE8276; Tue, 5 Nov 2024 00:55:54 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241104141445epcas5p3fa11a5bebe88ac2bb3541850369591f7~EyXq4_IES2421324213epcas5p35; Mon, 4 Nov 2024 14:14:45 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141445epsmtrp2e82a212506f18b40914879ef41c4ab29~EyXq1QKGv1987019870epsmtrp2t; Mon, 4 Nov 2024 14:14:45 +0000 (GMT) X-AuditID: b6c32a4a-e25fa7000000262a-bc-6728ee8af0d3 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id C6.DC.18937.5D6D8276; Mon, 4 Nov 2024 23:14:45 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141443epsmtip200aef7f4c224e5aa2969207f662dc83d~EyXoYPB9E3011030110epsmtip28; Mon, 4 Nov 2024 14:14:42 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v7 01/10] block: define set of integrity flags to be inherited by cloned bip Date: Mon, 4 Nov 2024 19:35:52 +0530 Message-Id: <20241104140601.12239-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4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O9Z/fyTn3OnPDev fvjw5S6mIKfC3wv9/S86KX4TNni67AEX+92ZNuvkvz9O0MzM36Jg7Ls8sfpKXNRP8WdFMmkX NzqK581NtLhtFrpjXs+ihSsC/a4HbhYrPzV/m+uUeRvOWV8Q23g0fG/CufdvdQ/meuqXvtqx eD63QQjfEQ/91QUrrf5vuazfYjJD9nqCiIy6ZG+p84zDsfXxP304H6ddfmLjPnH+qRgJ4fcN R5RYijMSDbWYi4oTAUT3tAgeAwAA X-CMS-MailID: 20241104141445epcas5p3fa11a5bebe88ac2bb3541850369591f7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141445epcas5p3fa11a5bebe88ac2bb3541850369591f7 References: <20241104140601.12239-1-anuj20.g@samsung.com> Introduce BIP_CLONE_FLAGS describing integrity flags that should be inherited in the cloned bip from the parent. Suggested-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Keith Busch --- block/bio-integrity.c | 2 +- include/linux/bio-integrity.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 2a4bd6611692..a448a25d13de 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -559,7 +559,7 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vec = bip_src->bip_vec; bip->bip_iter = bip_src->bip_iter; - bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY; + bip->bip_flags = bip_src->bip_flags & BIP_CLONE_FLAGS; return 0; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index dbf0f74c1529..0f0cf10222e8 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -30,6 +30,9 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + #ifdef CONFIG_BLK_DEV_INTEGRITY #define bip_for_each_vec(bvl, bip, iter) \ From patchwork Mon Nov 4 14:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 840722 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 5C5EB1C07DA for ; Mon, 4 Nov 2024 15:56:03 +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=1730735765; cv=none; b=NNpKSUB7+KDlxM4oOFr+alFpxvaQH9luuMk3cl3zH+4MFzDsx2QFgWE5wjs3sWXYM1Uwpn9oFCCug5tHpij6qUAeqFsb5wjMKRESU33zPuV9gDA3e7MbzcFIQ0K0UBuK9cmV+Wzcr+r9w7MfoTiKp0577Btlta7nyosyMZYqWGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735765; c=relaxed/simple; bh=u4sUcEX/k+wez75P184+zcG/4LIpxzsuKCd9h01C0oc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=amzWyNSQZfUTmXH0RN/cEnDqlHeloIz5l3nC8HNj5bsgC3x1rl+WXj04b4ROGL1burm+hfQUPUilEF77f3qUaah08kL6CE3qSm6o84DbFVGLpudmr3cepO6a6HgizsOoSG5PPqaUytZEBFp2guHF+raYlUoIcOGmaXADSc5A4xk= 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=UBHZQ9U5; 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="UBHZQ9U5" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241104155601epoutp03537a8e146b36d4951dfc3ecc14545d5a~EzwFs0mG51886218862epoutp03G for ; Mon, 4 Nov 2024 15:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241104155601epoutp03537a8e146b36d4951dfc3ecc14545d5a~EzwFs0mG51886218862epoutp03G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735761; bh=1yEesIXP8hqj3mWCayZYKotAS9KxK7WmVJifezfxMwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBHZQ9U5ROZQk2h6x+IS3FL3DA92d3s76S5CkIiagVxlxyyQYvdII0YfoJE2f/kVm ze2kzkroHhz6sXv30Q+cN+4FyCx37BmWuPIkDcxUCF6BKzjMldzT2abgTSKXKWMnzQ jau2Udr8i45yNTELevZD/XEpf9svO44clDO6wEaw= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241104155601epcas5p192070f7df15f18991addc70bb2dc39c2~EzwFCvMs11118411184epcas5p1B; Mon, 4 Nov 2024 15:56:01 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Xhwzz2bHgz4x9Pr; Mon, 4 Nov 2024 15:55:59 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 14.A7.09420.F8EE8276; Tue, 5 Nov 2024 00:55:59 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241104141448epcas5p4179505e12f9cf45fd792dc6da6afce8e~EyXtYfRMJ3055130551epcas5p4S; Mon, 4 Nov 2024 14:14:48 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141448epsmtrp24edf578e5cd5bc2c3557be95e558f742~EyXtSpHQ21987019870epsmtrp2u; Mon, 4 Nov 2024 14:14:48 +0000 (GMT) X-AuditID: b6c32a49-33dfa700000024cc-f5-6728ee8f6110 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 57.68.35203.8D6D8276; Mon, 4 Nov 2024 23:14:48 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141445epsmtip2fe62a3d3e82bbb4099a5873d2b216399~EyXq5CkzQ3023030230epsmtip2s; Mon, 4 Nov 2024 14:14:45 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v7 02/10] block: copy back bounce buffer to user-space correctly in case of split Date: Mon, 4 Nov 2024 19:35:53 +0530 Message-Id: <20241104140601.12239-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJJsWRmVeSWpSXmKPExsWy7bCmpm7/O410g8fL+Sw+fv3NYtE04S+z xZxV2xgtVt/tZ7N4ffgTo8XNAzuZLFauPspk8a71HIvF7OnNTBaTDl1jtNh7S9tiz96TLBbz lz1lt+i+voPNYvnxf0wW5/8eZ7U4P2sOu4Ogx85Zd9k9Lp8t9di0qpPNY/OSeo/dNxvYPD4+ vcXi0bdlFaPHmQVH2D0+b5Lz2PTkLVMAV1S2TUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGh rqGlhbmSQl5ibqqtkotPgK5bZg7QO0oKZYk5pUChgMTiYiV9O5ui/NKSVIWM/OISW6XUgpSc ApMCveLE3OLSvHS9vNQSK0MDAyNToMKE7IxHd9ayF5zjq5i25TZLA+N6ni5GDg4JAROJ9//c uxi5OIQEdjNK3Pk0g6WLkRPI+cQosbQ3ECLxjVGitW02O0gCpOHx5E3sEIm9jBJf//9mg3A+ M0oc7/rADFLFJqAuceR5KyNIQkRgD6NE78LTLCAOs8BLoLmrFoEtERZIlvg3ZypYB4uAqsSG Xw/BdvAKWEr8vXKXCWKfvMTMS9/B4pwCVhJz/t5lgagRlDg58wmYzQxU07x1NjPIAgmBCxwS d5Z/YYFodpG4+3011CBhiVfHt0A9ISXx+d1eNgg7XeLH5adQNQUSzcf2MULY9hKtp/qZQaHE LKApsX6XPkRYVmLqqXVMEHv5JHp/P4Fq5ZXYMQ/GVpJoXzkHypaQ2HuuAcr2kNg27QIzJLh6 GSX+TjvJMoFRYRaSf2Yh+WcWwuoFjMyrGCVTC4pz01OLTQsM81LL4dGcnJ+7iRGcxrU8dzDe ffBB7xAjEwfjIUYJDmYlEd55qerpQrwpiZVVqUX58UWlOanFhxhNgQE+kVlKNDkfmE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VJnFf8RW+KkEB6YklqdmpqQWoRTJaJg1Oq gYm9/8fns/6W0/9LW+82/l33+sCEbyfvNJ+dzZfwUik0MfgPf87va3ekjPYnzVvZPUkiwyhW Wbn/zTkl/QsTE96wW4isUX+ZqmPff+yUlcilEz5f9no7Sl/5MtXd7Kn4da9DgVmts7inSeU0 TC6q6zwrZhz2N+ZsZ6Cp4RsP6d7OW+7HX//JYmeYOO3kw575O69O6DCde0PovFT5mnef2ULz a8K/2D5cyHHCOP2KYoo451cZJbuT9/OOrP6z4rrOHW+1Bkl2gWsuN+qtjCPb1j1l3XtLM1P+ +oRLniYuypOCml3yuBcuszz5vtY6MF/yi6zGM9XLEb82/hKv1Kg9JCU+/fTe4JkzZ0a77wnZ Xa3EUpyRaKjFXFScCAD3IHOYIgMAAA== X-CMS-MailID: 20241104141448epcas5p4179505e12f9cf45fd792dc6da6afce8e X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141448epcas5p4179505e12f9cf45fd792dc6da6afce8e References: <20241104140601.12239-1-anuj20.g@samsung.com> From: Christoph Hellwig Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers") Signed-off-by: Anuj Gupta [hch: better names for variables] Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index a448a25d13de..4341b0d4efa1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { - unsigned short nr_vecs = bip->bip_max_vcnt - 1; - struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; - struct iov_iter iter; + unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1; + struct bio_vec *orig_bvecs = &bip->bip_vec[1]; + struct bio_vec *bounce_bvec = &bip->bip_vec[0]; + size_t bytes = bounce_bvec->bv_len; + struct iov_iter orig_iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true); } /** From patchwork Mon Nov 4 14:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 841309 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 BE03D1C07EC for ; Mon, 4 Nov 2024 15:56:07 +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=1730735769; cv=none; b=qdhZmlbEVxUbs1MWEwP0weIwjtxm7h7eHdyeviQBp/t2sIGPzFUuJSZzGZim1bQB7/8yLkf2/r2QVjewHTmIH9OvlzmssdAGUb7SjlqR+tngsBGBQx2ZdZzoXkVHipugxsWFC+BjfkJnakV16//TTUCxozE+kaJdG7z/A5CJivY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735769; c=relaxed/simple; bh=ZIkdyJlOm3c2bE0cQ6pelSYB5Gra8HNzZg1GmGSloUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=MUSCLVRZJiqHMon6DJEdx9FNnINH/UC+N45xDPV8gACLVQc1R/Pp6ooGSbEU02noAcmqgOqD9dY26F25C1A+TawxW16jaA93trJE+KTWr1H65it+93dC4x4+u5ly6h+d43wBAYtc/RDk0D4NC1NECo5QV3gZcinQGqNiF8utBMQ= 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=JMQR6Nio; 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="JMQR6Nio" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241104155605epoutp02873708d8558675f2b8d090a9b0be547d~EzwJh63IP1506815068epoutp02H for ; Mon, 4 Nov 2024 15:56:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241104155605epoutp02873708d8558675f2b8d090a9b0be547d~EzwJh63IP1506815068epoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735765; bh=r23oSTZl50mKsH838ytL5lDlNxkmkMYy4oR7U1Ruz2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMQR6NiojxRKjU4cHSEF43DqQbKpeqgxotRVXXYJ3NaNcFzdfLtSTM/w3ldX3TvDz qkYUzI8PNI6mT+giNsvpW7YAYBS9+q+5XYOqW0oZ2qXGku0CFj8Zi66Jb//tpjcmqV U0Q5ipOREB/8eiSiWHTNbHlAQEFJB7G4+K573W9g= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241104155604epcas5p4c21eaecfaa8f69190416b3fb19f1d91f~EzwIQoJap2760427604epcas5p48; Mon, 4 Nov 2024 15:56:04 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.179]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xhx026HR4z4x9Pq; Mon, 4 Nov 2024 15:56:02 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id CF.00.37975.29EE8276; Tue, 5 Nov 2024 00:56:02 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241104141451epcas5p2aef1f93e905c27e34b3e16d89ff39245~EyXv5ExsS3053330533epcas5p2u; Mon, 4 Nov 2024 14:14:51 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141451epsmtrp25c9b792302190365df06d7cec0992b5f~EyXv3ptok1987019870epsmtrp21; Mon, 4 Nov 2024 14:14:51 +0000 (GMT) X-AuditID: b6c32a50-085ff70000049457-b3-6728ee92a152 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id B8.DC.18937.AD6D8276; Mon, 4 Nov 2024 23:14:50 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141448epsmtip2dd27c5d88448694207610d66d3844aea~EyXtZsX3L3011330113epsmtip2j; Mon, 4 Nov 2024 14:14:48 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v7 03/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Mon, 4 Nov 2024 19:35:54 +0530 Message-Id: <20241104140601.12239-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHJsWRmVeSWpSXmKPExsWy7bCmuu6kdxrpBrMO6Vh8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSyO/n/LZjHp0DVGi723tC32 7D3JYjF/2VN2i+7rO9gslh//x2Rx/u9xVovzs+awOwh57Jx1l93j8tlSj02rOtk8Ni+p99h9 s4HN4+PTWywefVtWMXqcWXCE3ePzJjmPTU/eMgVwRWXbZKQmpqQWKaTmJeenZOal2yp5B8c7 x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gD9pKRQlphTChQKSCwuVtK3synKLy1JVcjILy6x VUotSMkpMCnQK07MLS7NS9fLSy2xMjQwMDIFKkzIznj64jNTwR65it2XPRoYt0l2MXJySAiY SPxY3sHexcjFISSwh1Gi+dZWFgjnE6PEvtbDTHDOiX2TGWFaNty+wQRiCwnsZJSYdy4Gougz o0TvvcUsIAk2AXWJI89bGUESIiBzexeeBpvLLDCBSaJ94hx2kCphgXiJtiVTwcayCKhKXPnd BmRzcPAKWEp8PBMCsU1eYual72DlnAJWEnP+3gVbwCsgKHFy5hMwmxmopnnrbGaQ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pi5OIQEtjOKHHv+gsWiISExKmXyxghbGGJlf+es0MUfWSU WLL7BFiCTUBd4sjzVjBbROAEo8T8iW4gRcwCM5gken6tYANJCAvESlz5+hOsiEVAVeLK7zYg m4ODV8BS4uOZEIgF8hIzL31nB7E5Bawk5vy9C3aEEFDJpqZLYDavgKDEyZlPwGxmoPrmrbOZ JzAKzEKSmoUktYCRaRWjaGpBcW56bnKBoV5xYm5xaV66XnJ+7iZGcJxpBe1gXLb+r94hRiYO xkOMEhzMSiK881LV04V4UxIrq1KL8uOLSnNSiw8xSnOwKInzKud0pggJpCeWpGanphakFsFk mTg4pRqYKj9sufAl1nF2pvSMbRPOCMnm9rn+VEz0fXuweqWf1/tH4j8DVqfM2SHarDrt+G2t tokmPH6PVTea7N7780bdvuZNDTKmQTOmKuyZ8cRe9aqYYeI7Fq4PWRGtXcZcIdzbTNQXrH2a /573wt1zX+/YbxVfus7IqfCfRNzEb9GpG5ynOZkenad3OvzzOaOGnGjmm/qyO2+4zktf75Rz sDzMfdfj+A8VN+z1rniWVjCeFLj3IqY015XJQFL/neT1/VwmCv/KyuXXvtnoc+yzwWavyJXt n59KKTzmbJnINfHGVlGOw/XzgpQ3TEie+GHWJ7XL/XXKYTfllwtxHZy5dhKvzYvdvxzl09+d +J3s8uH8TSWW4oxEQy3mouJEABdlUiQiAwAA X-CMS-MailID: 20241104141451epcas5p2aef1f93e905c27e34b3e16d89ff39245 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141451epcas5p2aef1f93e905c27e34b3e16d89ff39245 References: <20241104140601.12239-1-anuj20.g@samsung.com> This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 12 +++++------- block/blk-integrity.c | 10 +++++++++- include/linux/bio-integrity.h | 5 ++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 4341b0d4efa1..f56d01cec689 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -302,16 +302,15 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = blk_lim_dma_alignment_and_pad(&q->limits); struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages; struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec; + size_t offset, bytes = iter->count; unsigned int direction, nr_bvecs; - struct iov_iter iter; int ret, nr_vecs; - size_t offset; bool copy; if (bio_integrity(bio)) @@ -324,8 +323,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) else direction = ITER_SOURCE; - iov_iter_ubuf(&iter, direction, ubuf, bytes); - nr_vecs = iov_iter_npages(&iter, BIO_MAX_VECS + 1); + nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS + 1); if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { @@ -335,8 +333,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes) pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/block/blk-integrity.c b/block/blk-integrity.c index b180cac61a9d..4a29754f1bc2 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -115,8 +115,16 @@ EXPORT_SYMBOL(blk_rq_map_integrity_sg); int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, ssize_t bytes) { - int ret = bio_integrity_map_user(rq->bio, ubuf, bytes); + int ret; + struct iov_iter iter; + unsigned int direction; + if (op_is_write(req_op(rq))) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, ubuf, bytes); + ret = bio_integrity_map_user(rq->bio, &iter); if (ret) return ret; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 0f0cf10222e8..58ff9988433a 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -75,7 +75,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr); int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -101,8 +101,7 @@ static inline void bioset_integrity_free(struct bio_set *bs) { } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len) +static int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) { return -EINVAL; } From patchwork Mon Nov 4 14:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 840721 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 9E3261C3026 for ; Mon, 4 Nov 2024 15:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735772; cv=none; b=kwQu8iGQCj5pQKvCrHJDQLFsFueh8Xcq+80urbEKlgauTab+ZhTllA49/VfA66tKeK74rfZppcK1MfTzETQQb20vHiXeyfz10HksOvGBj7HxiqjREPHhQAObzqX8p+pkTT4KTe3adodhRbmcrNMIRcPeaLToIcheZ4cn0KbMhag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735772; c=relaxed/simple; bh=UFY5MN9pbhnVXin5x3CaTOeVR6EWJ0aWiPTyVYFaoBM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=eZaRRiO/qJHbTHITXu87oO98xGx0B2C0iy6erdFbdVqPIZU/Atwkr8xdhnCtqeTPeU0+sdfmfSBa5wYewJXUKNGE0tXrnIfPEB3h5GS9CtnpRXp1fXsgI0fD/7nGoSrVCppjC6i9scVskEhfdBi9FUIJpUX0upKzDjfr53NNm9Q= 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=p0X/MXIr; 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="p0X/MXIr" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241104155608epoutp0400196e233885f710bad21c616d1dad5e~EzwMU2Pgb1250212502epoutp04E for ; Mon, 4 Nov 2024 15:56:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241104155608epoutp0400196e233885f710bad21c616d1dad5e~EzwMU2Pgb1250212502epoutp04E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735768; bh=xceWim7FbQmDU7VlpPk+fRyrGFM+8wFLGLVO0uYGafc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0X/MXIrS0WbqrNP9OszIJ6evitb34D3K4te4Z+CpLnkMrQHEr7M2x6zJEmHXe3gZ mRQA5aDlRbkgniB2gbv6jIa4FlG3IVl/StKEGWr3jlQ5ImEXlgfOn0urR4dNffjw0x CIe+ezfBqBHrTOg3rThJVU0s1O2diFx2iPhSvI/o= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241104155608epcas5p2d0e7c7a247415b4d41800dd08e115c0a~EzwLwsJYX2426624266epcas5p2P; Mon, 4 Nov 2024 15:56:08 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Xhx064bjFz4x9Pv; Mon, 4 Nov 2024 15:56:06 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 40.DA.09800.69EE8276; Tue, 5 Nov 2024 00:56:06 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241104141453epcas5p201e4aabfa7aa1f4af1cdf07228f8d4e7~EyXyb-HAs3052330523epcas5p2o; Mon, 4 Nov 2024 14:14:53 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141453epsmtrp2550a6ccf6797c4f03750e856f4b9404b~EyXybFHiE1987119871epsmtrp2z; Mon, 4 Nov 2024 14:14:53 +0000 (GMT) X-AuditID: b6c32a4b-23fff70000002648-34-6728ee965683 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 99.68.35203.DD6D8276; Mon, 4 Nov 2024 23:14:53 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141451epsmtip207668ca33be3d64f9fcd6ac19ddc4f3a~EyXv8Sdo23097430974epsmtip2m; Mon, 4 Nov 2024 14:14:51 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v7 04/10] fs, iov_iter: define meta io descriptor Date: Mon, 4 Nov 2024 19:35:55 +0530 Message-Id: <20241104140601.12239-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPJsWRmVeSWpSXmKPExsWy7bCmuu60dxrpBre+K1p8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSyO/n/LZjHp0DVGi723tC32 7D3JYjF/2VN2i+7rO9gslh//x2Rx/u9xVovzs+awOwh57Jx1l93j8tlSj02rOtk8Ni+p99h9 s4HN4+PTWywefVtWMXqcWXCE3ePzJjmPTU/eMgVwRWXbZKQmpqQWKaTmJeenZOal2yp5B8c7 x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gD9pKRQlphTChQKSCwuVtK3synKLy1JVcjILy6x VUotSMkpMCnQK07MLS7NS9fLSy2xMjQwMDIFKkzIzti1+z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+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSyO/n/LZjHp0DVGi723tC32 7D3JYjF/2VN2i+7rO9gslh//x2Rx/u9xVovzs+awOwh57Jx1l93j8tlSj02rOtk8Ni+p99h9 s4HN4+PTWywefVtWMXqcWXCE3ePzJjmPTU/eMgVwRXHZpKTmZJalFunbJXBl7Np9mq1gOW/F ud1fmBoYP3N1MXJySAiYSDycspmxi5GLQ0hgN6PE1k39zBAJCYlTL5cxQtjCEiv/PWeHKPrI KLGnfSdYgk1AXeLI81YwW0TgBKPE/IluIEXMAjOYJHp+rWADSQgLOEocunyIFcRmEVCV+Nk2 GSzOK2ApcbOtA2qDvMTMS9/ZQWxOASuJOX/vsoDYQkA1m5ousUDUC0qcnPkEzGYGqm/eOpt5 AqPALCSpWUhSCxiZVjFKphYU56bnFhsWGOallusVJ+YWl+al6yXn525iBMecluYOxu2rPugd YmTiYDzEKMHBrCTCOy9VPV2INyWxsiq1KD++qDQntfgQozQHi5I4r/iL3hQhgfTEktTs1NSC 1CKYLBMHp1QD05W+is0RX6VnNFv1XK2P4w21SLvKzfAl+trWnVf6DovGNCh+rehWeuBycd6c /LfFF6ffNWk48PzDvhuNuv9NprIz+D9VjRJfz2eXmP9ZaOWml1teeF5ZnaXn9P6ynsK2tZHH NWdYi3S6/rmkIKXBVBHwO2/pr36OBX1LP+flzKyIYxc+kuOasGmO/eVrb/hWz7NtThUzWbH8 w9b//lbHmdOv/XDdG3B7j8EfyRWbatRuO7zaY/2Jbd67t+tlXTJMYj+7FO/YevlPZH1z4ss5 q1qzP56abVQgMVe6ONP/rlj6c8ndFilXNxleOXqP13ed3cK/x3a/1HllqSspoCC3omRP19G3 gcJGOlUR/MEH1yqxFGckGmoxFxUnAgB4/XaMKAMAAA== X-CMS-MailID: 20241104141453epcas5p201e4aabfa7aa1f4af1cdf07228f8d4e7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141453epcas5p201e4aabfa7aa1f4af1cdf07228f8d4e7 References: <20241104140601.12239-1-anuj20.g@samsung.com> Add flags to describe checks for integrity meta buffer. Also, introduce a new 'uio_meta' structure that upper layer can use to pass the meta/integrity information. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- include/linux/uio.h | 9 +++++++++ include/uapi/linux/fs.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/uio.h b/include/linux/uio.h index 853f9de5aa05..8ada84e85447 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -82,6 +82,15 @@ struct iov_iter { }; }; +typedef __u16 uio_meta_flags_t; + +struct uio_meta { + uio_meta_flags_t flags; + u16 app_tag; + u64 seed; + struct iov_iter iter; +}; + static inline const struct iovec *iter_iov(const struct iov_iter *iter) { if (iter->iter_type == ITER_UBUF) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..9070ef19f0a3 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -40,6 +40,15 @@ #define BLOCK_SIZE_BITS 10 #define BLOCK_SIZE (1< X-Patchwork-Id: 841308 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 68B2D1C07F5 for ; Mon, 4 Nov 2024 15:56:14 +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=1730735776; cv=none; b=scbyKa+mu7X7VlqVEbvCAE3qKzRAbKfeGL+gB/sLReCce/DtYfLxvNt35GFPxu+Rdyfkn0oSCi8dt/IPmnMiw2QjMKenMRSD+GbOKs9OvZjW9w14B+Y0ueC6K1xZsHu6hGJTN1JX+eLkxWQs30K2/YbRc7/ulcvCpyg3EDlaVBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735776; c=relaxed/simple; bh=PPDNMGOuEvkJDIU7LllEytV2427zo9AzbP3ebXn9pJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jRxaTcpPnuBsH2aAjPQgjfSGSOZhbxPSjlGf47nOglvcJFswUB+FcpDz1xdp2TQF2P5j4kILcYBcbZEGoR7qp/ocwVkFAT0cqnbA6bM3NG5IriM0msuoYr+LpZssEIUDY6BApq5ETnFIBtLLYufviYm6VYakIRPsvmMHUQ0Scbg= 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=ur0EzeqZ; 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="ur0EzeqZ" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241104155612epoutp039aa3cab835c1c742da54c33f42ea9ca8~EzwP3oups2125721257epoutp03K for ; Mon, 4 Nov 2024 15:56:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241104155612epoutp039aa3cab835c1c742da54c33f42ea9ca8~EzwP3oups2125721257epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735772; bh=0Qev84oB/WNNKAORKgHjGWYS6Jca41BG3ZIzsvdmNNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ur0EzeqZ8s10zEmgkjwF3CDxrhCnmJ0jz/kQkGPt9Lp8TfTsPl4wUXgPrpV/BOzaE vcyySZbnBodIOV90iFE7F/QprkNvZ9Ui8rmxQwLd15NxOu1xqx+Nl5jXa2iHw9jm8u otXyxbYgmC8GolzyIrfAxcbJDEohimFP9q1+k6NY= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241104155611epcas5p4f6ca1d9f35d73c18873bfb1b7cccfaec~EzwPDTMVt1901719017epcas5p4O; Mon, 4 Nov 2024 15:56:11 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xhx0B1y3hz4x9Pq; Mon, 4 Nov 2024 15:56:10 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 22.DA.09800.A9EE8276; Tue, 5 Nov 2024 00:56:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241104141456epcas5p38fef2ccde087de84ffc6f479f50e8071~EyX0xLPPN2420824208epcas5p3A; Mon, 4 Nov 2024 14:14:56 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241104141456epsmtrp1f8075e736025a0e20cc83f1ed67e0f9d~EyX0wYXRY1340613406epsmtrp1K; Mon, 4 Nov 2024 14:14:56 +0000 (GMT) X-AuditID: b6c32a4b-4a7fa70000002648-39-6728ee9a70d8 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0B.68.35203.0E6D8276; Mon, 4 Nov 2024 23:14:56 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141453epsmtip2bc39da8da09bf780b329cc179e0ae39e~EyXydls4O3023030230epsmtip2v; Mon, 4 Nov 2024 14:14:53 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v7 05/10] fs: introduce IOCB_HAS_METADATA for metadata Date: Mon, 4 Nov 2024 19:35:56 +0530 Message-Id: <20241104140601.12239-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFJsWRmVeSWpSXmKPExsWy7bCmuu6sdxrpBvN+clh8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSwmHbrGaLH3lrbFnr0nWSzm L3vKbtF9fQebxfLj/5gszv89zmpxftYcdgdBj52z7rJ7XD5b6rFpVSebx+Yl9R67bzaweXx8 eovFo2/LKkaPMwuOsHt83iTnsenJW6YArqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwND XUNLC3MlhbzE3FRbJRefAF23zBygd5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqpBSk5 BSYFesWJucWleel6eaklVoYGBkamQIUJ2RlrT69hLLjCWrH+VgtjA+M1li5GTg4JAROJLUsX sHcxcnEICexmlGj8+pYJwvnEKDHlwhsmkCohgW+MEp8+SMF0vOr6BdWxl1Fi5dS5UM5nRomN F1+zg1SxCahLHHneygiSEBHYwyj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+b5Lz2PTkLVMAVxSXTUpqTmZZapG+XQJXxtrTaxgLrrBWrL/VwtjA eI2li5GTQ0LAROJV1y92EFtIYDejxJ75UhBxCYlTL5cxQtjCEiv/PQeq4QKq+cgosevUNCaQ BJuAusSR561gRSICJxgl5k90AyliBima8GU22AZhATeJmTNOg9ksAqoS16ZvYQaxeQUsJa5s bWSC2CAvMfPSd7ArOAWsJOb8vcsCcZGlxKamSywQ9YISJ2c+AbOZgeqbt85mnsAoMAtJahaS 1AJGplWMkqkFxbnpucWGBYZ5qeV6xYm5xaV56XrJ+bmbGMFxpqW5g3H7qg96hxiZOBgPMUpw MCuJ8M5LVU8X4k1JrKxKLcqPLyrNSS0+xCjNwaIkziv+ojdFSCA9sSQ1OzW1ILUIJsvEwSnV wMRU69RmeOdYzsbnt7yq+SP/TNiybNLqWzOcTPf9KNBKFXhwab/mqS/PP/2LOC+76ReLxuZw rrSZ9vvWsVif/PM04eBvplvOJ7g+FMS2v1xvwXNurl1p7nLl60stNq9/qC35L1nI9d/VSZ1q 89YeV1n80+r0p2vu/Jdjl/ZNXtB43J2Z073rreLd3eJfpnaevOjYssmJc17H+0y/aXHRASyt U+ILruZd4JZ91Cag1Plv2/zbja+FPacs+p7Ul7bo1c4+NmW5/3O2uzw9dKfMm7N8aXTLt+LV 7GXaqwWtfxQpLW+f8XzhDO3D0yQ+erj0VAt5HBBMmbCgrOPv1XMy11e0bXd2qTxjJj8rJW3m ulolJZbijERDLeai4kQA1JajCSIDAAA= X-CMS-MailID: 20241104141456epcas5p38fef2ccde087de84ffc6f479f50e8071 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141456epcas5p38fef2ccde087de84ffc6f479f50e8071 References: <20241104140601.12239-1-anuj20.g@samsung.com> Introduce an IOCB_HAS_METADATA flag for the kiocb struct, for handling requests containing meta payload. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- include/linux/fs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 4b5cad44a126..7f14675b02df 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -346,6 +346,7 @@ struct readahead_control; #define IOCB_DIO_CALLER_COMP (1 << 22) /* kiocb is a read or write operation submitted by fs/aio.c. */ #define IOCB_AIO_RW (1 << 23) +#define IOCB_HAS_METADATA (1 << 24) /* for use in trace events */ #define TRACE_IOCB_STRINGS \ From patchwork Mon Nov 4 14:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 840720 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 F2BBE1C4A05 for ; Mon, 4 Nov 2024 15:56:17 +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=1730735781; cv=none; b=WJObCBi91+wmFT5A7KhkeVhV9BX34AHzFQNVhJRdcrjdugBNEic5hxmNo9Aw8ql2VdxRwvwvffX9MmtfVOaqTs6rYFU+KWmrpUI4Y3RYDPbJCPbE+Bk88s97hE5aNGndKWBV4aCnQ4y/2dQ+qb26r58Z8A8zID7gz+Jk6OYpqIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735781; c=relaxed/simple; bh=kiDECaI0AWHYPH5JLwOA24dofwPFZLB6krkqJmB3MJE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=R79QTPrZXPn1RZ4HqlKW3DRquXXgK8Q0N/06wUDMLomKNYMfChfMNSN7Q7o4BSw+3TrKstI6W1dI66PKkRi9Nj8IlJN5fRduQ3cGwmmlyxgsZXCfqP9s7gQATdM7nk8JMlFrqFk5dYvLtHkLHfK/C0bAXyiTP4w4g48AjIZaKkY= 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=cgOYAyw0; 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="cgOYAyw0" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241104155616epoutp02d586c295cd2416b9dedb34996346030c~EzwTTi4nf1479614796epoutp02U for ; Mon, 4 Nov 2024 15:56:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241104155616epoutp02d586c295cd2416b9dedb34996346030c~EzwTTi4nf1479614796epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735776; bh=vOQQVCfmsj6BRfW+8n256TUsH7a5gLQ8OtUonlD8T9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgOYAyw0D7uhDt2m4aKRossOZP1YsF08LnFOJy0N6PyYBYzayuKbQD1Y0VVH1en0X BmGAMsQ0Pa7BeEJYsGoZ1nHzCrJZXBraifPxvlZRudOiaI0PrJjgioA04EhBn2KxwH yH6rD5QRO02Q504ZYuqhc2xd6uBmvVgsHpsRsO1k= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241104155615epcas5p166d626bcfc632b5db6e3428cfeac4372~EzwSdgayn1118411184epcas5p1S; Mon, 4 Nov 2024 15:56:15 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xhx0F6hjwz4x9Pq; Mon, 4 Nov 2024 15:56:13 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id EE.8A.09770.D9EE8276; Tue, 5 Nov 2024 00:56:13 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241104141459epcas5p27991e140158b1e7294b4d6c4e767373c~EyX3cRTse3053330533epcas5p27; Mon, 4 Nov 2024 14:14:59 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241104141459epsmtrp1ba012467fb5cb68db8d2e8e658d49a01~EyX3bTU9T1329813298epsmtrp1g; Mon, 4 Nov 2024 14:14:59 +0000 (GMT) X-AuditID: b6c32a4a-bbfff7000000262a-d7-6728ee9dad00 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 55.8D.07371.2E6D8276; Mon, 4 Nov 2024 23:14:58 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141456epsmtip2d25f1b8da45b93c34906c48e6afea0cb~EyX02Qfgj3121331213epsmtip2G; Mon, 4 Nov 2024 14:14:56 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v7 06/10] io_uring/rw: add support to send metadata along with read/write Date: Mon, 4 Nov 2024 19:35:57 +0530 Message-Id: <20241104140601.12239-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHJsWRmVeSWpSXmKPExsWy7bCmlu7cdxrpBg9fGFl8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSyO/n/LZjHp0DVGi723tC32 7D3JYjF/2VN2i+7rO9gslh//x2Rx/u9xVovzs+awOwh57Jx1l93j8tlSj02rOtk8Ni+p99h9 s4HN4+PTWywefVtWMXqcWXCE3ePzJjmPTU/eMgVwRWXbZKQmpqQWKaTmJeenZOal2yp5B8c7 x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gD9pKRQlphTChQKSCwuVtK3synKLy1JVcjILy6x VUotSMkpMCnQK07MLS7NS9fLSy2xMjQwMDIFKkzIzjjZPp+x4J9rxfZZR1gbGO9YdDFyckgI mEg87X/FCmILCexmlDj9S72LkQvI/sQocWh3LxuE841RYs32e0AOB1jHyvYqiPheRon5H48z QjifGSXurz7FDDKKTUBd4sjzVrCEiMAeRonehadZQBxmgQlMEu0T57CDVAkLREu827ocrINF QFXieMc/FhCbV8BSouf+TCaIA+UlZl76DlbPKWAlMefvXagaQYmTM5+A2cxANc1bZzODLJAQ uMEhsXzKHnaIZheJadcfsUHYwhKvjm+BiktJvOxvg7LTJX5cfgq1rECi+dg+RgjbXqL1VD8z yM/MApoS63fpQ4RlJaaeWscEsZdPovf3E6hWXokd82BsJYn2lXOgbAmJvecaoGwPiZUblkLD tJdR4uTJZsYJjAqzkPwzC8k/sxBWL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AKzkKRmIUktYGRaxSiZWlCcm56bbFhgmJdarlecmFtcmpeul5yfu4kRHG1aGjsY783/p3eI kYmD8RCjBAezkgjvvFT1dCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8hjNmpwgJpCeWpGanphak FsFkmTg4pRqYrgtJcBSV+hhvCrhZEsaTrnD1hMd/AdXJzdsPX5/gLPGI2++hdG/n6nv/Kk2b 50kK688XaLq0TWzl9Yr0Mz2LD/Pnfz/TJbT05HmjVo/mlxxBT5VuOCtM2/PQMEneqir7yYvi tYkOZkcy3W7/1fS5uiyk5+27yCVWM8KeLk26qHB+w2/FI0r2HmFzl10PTwwXt74kptIz427h 5ll3uEIyrZ/y8scsZkub3r/boWfh+ZNmcVtXBlr9X2T1Yqoj/wxH0crlExkFoqatj5x5+2LM jN6r7hvXFUyQyP1yyl5r1y4uDv9tc3kDeZ9OS/LwY4/aV8f81aN61ZpfXIw7OmZkXVx91c9x imOkZaws325ZJZbijERDLeai4kQAuEwAbCUDAAA= X-CMS-MailID: 20241104141459epcas5p27991e140158b1e7294b4d6c4e767373c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141459epcas5p27991e140158b1e7294b4d6c4e767373c References: <20241104140601.12239-1-anuj20.g@samsung.com> This patch adds the capability of passing integrity metadata along with read/write. A new meta_type field is introduced in SQE which indicates the type of metadata being passed. A new 'struct io_uring_sqe_ext' represents the secondary SQE space for read/write. The last 32 bytes of secondary SQE is used to pass following PI related information: - flags: integrity check flags namely IO_INTEGRITY_CHK_{GUARD/APPTAG/REFTAG} - len: length of the pi/metadata buffer - buf: address of the metadata buffer - seed: seed value for reftag remapping - app_tag: application defined 16b value Application sets up a SQE128 ring, prepares PI information within the second SQE. The patch processes this 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/uapi/linux/io_uring.h | 30 ++++++++++++ io_uring/io_uring.c | 8 ++++ io_uring/rw.c | 88 ++++++++++++++++++++++++++++++++++- io_uring/rw.h | 14 +++++- 4 files changed, 137 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 024745283783..7f01124bedd5 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -92,6 +92,10 @@ struct io_uring_sqe { __u16 addr_len; __u16 __pad3[1]; }; + struct { + __u16 meta_type; + __u16 __pad4[1]; + }; }; union { struct { @@ -107,6 +111,32 @@ struct io_uring_sqe { }; }; +enum io_uring_sqe_meta_type_bits { + META_TYPE_PI_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_PI (1U << META_TYPE_PI_BIT) + +/* Second half of SQE128 for IORING_OP_READ/WRITE */ +struct io_uring_sqe_ext { + __u64 rsvd0[4]; + /* if sqe->meta_type is META_TYPE_PI, last 32 bytes are for PI */ + union { + __u64 rsvd1[4]; + struct { + __u16 flags; + __u16 app_tag; + __u32 len; + __u64 addr; + __u64 seed; + __u64 rsvd; + } rw_pi; + }; +}; + /* * If sqe->file_index is set to this for opcodes that instantiate a new * direct descriptor (like openat/openat2/accept), then io_uring will allocate diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 44a772013c09..116c93022985 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3875,7 +3875,9 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(44, __s32, splice_fd_in); BUILD_BUG_SQE_ELEM(44, __u32, file_index); BUILD_BUG_SQE_ELEM(44, __u16, addr_len); + BUILD_BUG_SQE_ELEM(44, __u16, meta_type); BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); + BUILD_BUG_SQE_ELEM(46, __u16, __pad4[0]); BUILD_BUG_SQE_ELEM(48, __u64, addr3); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); @@ -3902,6 +3904,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_sqe_ext) != + sizeof(struct io_uring_sqe)); + + BUILD_BUG_ON(META_TYPE_LAST_BIT > + 8 * sizeof_field(struct io_uring_sqe, meta_type)); + io_uring_optable_init(); /* diff --git a/io_uring/rw.c b/io_uring/rw.c index 30448f343c7f..eb19b033df24 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -257,11 +257,64 @@ static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) return 0; } +static inline void io_meta_save_state(struct io_async_rw *io) +{ + io->meta_state.seed = io->meta.seed; + iov_iter_save_state(&io->meta.iter, &io->meta_state.iter_meta); +} + +static inline void io_meta_restore(struct io_async_rw *io) +{ + io->meta.seed = io->meta_state.seed; + iov_iter_restore(&io->meta.iter, &io->meta_state.iter_meta); +} + +static inline const void *io_uring_sqe_ext(const struct io_uring_sqe *sqe) +{ + return (sqe + 1); +} + +static int io_prep_rw_pi(struct io_kiocb *req, const struct io_uring_sqe *sqe, + struct io_rw *rw, int ddir) +{ + const struct io_uring_sqe_ext *sqe_ext; + const struct io_issue_def *def; + struct io_async_rw *io; + int ret; + + if (!(req->ctx->flags & IORING_SETUP_SQE128)) + return -EINVAL; + + sqe_ext = io_uring_sqe_ext(sqe); + if (READ_ONCE(sqe_ext->rsvd0[0]) || READ_ONCE(sqe_ext->rsvd0[1]) + || READ_ONCE(sqe_ext->rsvd0[2]) || READ_ONCE(sqe_ext->rsvd0[3])) + return -EINVAL; + if (READ_ONCE(sqe_ext->rw_pi.rsvd)) + return -EINVAL; + + def = &io_issue_defs[req->opcode]; + if (def->vectored) + return -EOPNOTSUPP; + + io = req->async_data; + io->meta.flags = READ_ONCE(sqe_ext->rw_pi.flags); + io->meta.app_tag = READ_ONCE(sqe_ext->rw_pi.app_tag); + io->meta.seed = READ_ONCE(sqe_ext->rw_pi.seed); + ret = import_ubuf(ddir, u64_to_user_ptr(READ_ONCE(sqe_ext->rw_pi.addr)), + READ_ONCE(sqe_ext->rw_pi.len), &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + rw->kiocb.ki_flags |= IOCB_HAS_METADATA; + io_meta_save_state(io); + return ret; +} + static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, int ddir, bool do_import) { struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); unsigned ioprio; + u16 meta_type; int ret; rw->kiocb.ki_pos = READ_ONCE(sqe->off); @@ -279,11 +332,23 @@ 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; + + meta_type = READ_ONCE(sqe->meta_type); + if (meta_type) { + if (READ_ONCE(sqe->__pad4[0]) || !(meta_type & META_TYPE_PI)) + return -EINVAL; + ret = io_prep_rw_pi(req, sqe, rw, ddir); + } + return ret; } int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe) @@ -409,7 +474,10 @@ static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req) static void io_resubmit_prep(struct io_kiocb *req) { struct io_async_rw *io = req->async_data; + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + if (rw->kiocb.ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); iov_iter_restore(&io->iter, &io->iter_state); } @@ -794,7 +862,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; @@ -823,6 +891,18 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type) kiocb->ki_complete = io_complete_rw; } + if (kiocb->ki_flags & IOCB_HAS_METADATA) { + struct io_async_rw *io = req->async_data; + + /* + * We have a union of meta fields with wpq used for buffered-io + * in io_async_rw, so fail it here. + */ + if (!(req->file->f_flags & O_DIRECT)) + return -EOPNOTSUPP; + kiocb->private = &io->meta; + } + return 0; } @@ -897,6 +977,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) * manually if we need to. */ iov_iter_restore(&io->iter, &io->iter_state); + if (kiocb->ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); do { /* @@ -1101,6 +1183,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + if (kiocb->ki_flags & IOCB_HAS_METADATA) + io_meta_restore(io); if (kiocb->ki_flags & IOCB_WRITE) io_req_end_write(req); return -EAGAIN; diff --git a/io_uring/rw.h b/io_uring/rw.h index 3f432dc75441..2d7656bd268d 100644 --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -2,6 +2,11 @@ #include +struct io_meta_state { + u32 seed; + struct iov_iter_state iter_meta; +}; + struct io_async_rw { size_t bytes_done; struct iov_iter iter; @@ -9,7 +14,14 @@ struct io_async_rw { struct iovec fast_iov; struct iovec *free_iovec; int free_iov_nr; - struct wait_page_queue wpq; + /* wpq is for buffered io, while meta fields are used with direct io */ + union { + struct wait_page_queue wpq; + struct { + struct uio_meta meta; + struct io_meta_state meta_state; + }; + }; }; int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); From patchwork Mon Nov 4 14:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 841307 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 4867E1C1AC7 for ; Mon, 4 Nov 2024 15:56:21 +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=1730735783; cv=none; b=WiwFiH96essVL7Xj8licKOmW+ck6a9PutZQQFPDgnsuEu8A56Q2WR9codIjQz6/MeufcRjH+9CR95ythIU3uFbz/L3g5VrV6nYZ+szyeoOHuslro5zQjgCu5HacuYxirOAyxcBV+ljLpdsF+dTihe9JXzNKY9bVWAjPTnFJnLCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735783; c=relaxed/simple; bh=5SWlWgE0v/ZgsGIR4YjIdGynPoaBkFM3l3dgZp1M8u0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=fI48OhVbAwH+mM28ivR0xWYGKvkIb+e9n9pDXcU4hZZiA3DUlSdDZ0xqoIeZ87iRWn+nXdVHJAbCr1o4SVwJMJ2vaQxqz759Zw80Jh1nxfp/Dut7OnhwtAlWlSXWdvhYuyPm2Xfkog3cyufKQ494rrK2T3pMvbQw7aJP26imLJw= 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=vHJBO04X; 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="vHJBO04X" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241104155619epoutp03efc76ac55be8299625f8284845ccb88a~EzwWSyPgt1828618286epoutp03W for ; Mon, 4 Nov 2024 15:56:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241104155619epoutp03efc76ac55be8299625f8284845ccb88a~EzwWSyPgt1828618286epoutp03W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735779; bh=/SlWjlwmF9Rr5zYWclsqVal/XEMs0tmP/ImOW56sBng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHJBO04X174IB6PiydOMnBuPtpTUeF+aevCHG62zCIKn/hUsSOnuPGBGcYCih6G33 aURk5r4ae4iaguVP/Mlfs7flnUB0NLUv/UzgocWsy0rIwVqT7wFerYsVGp8qYskzln 2HlgNZ/GHD2yXXIEzOSHPnhAMCutv8QWOcy7T9CY= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241104155618epcas5p45010de634170053529509503662c01e4~EzwVb-WQ32760427604epcas5p4V; Mon, 4 Nov 2024 15:56:18 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Xhx0K148Qz4x9Pp; Mon, 4 Nov 2024 15:56:17 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C3.75.08574.0AEE8276; Tue, 5 Nov 2024 00:56:17 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef~EyX56xglX2420824208epcas5p3F; Mon, 4 Nov 2024 14:15:01 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241104141501epsmtrp12fbb65828dc52d86d498ccbefe8fda83~EyX55sgYH1340613406epsmtrp1V; Mon, 4 Nov 2024 14:15:01 +0000 (GMT) X-AuditID: b6c32a44-93ffa7000000217e-e9-6728eea0fcff Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.8D.07371.5E6D8276; Mon, 4 Nov 2024 23:15:01 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141459epsmtip2fec098a032b17ccd6841ce6d71d440c0~EyX3bKxX03097430974epsmtip2n; Mon, 4 Nov 2024 14:14:59 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v7 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Mon, 4 Nov 2024 19:35:58 +0530 Message-Id: <20241104140601.12239-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xbdRTH87v3cltI2lwLuB/Ebc1NFmAbrMVSb8mQBYi5iziY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xd/SIs4kPeo8nSi6jqD51v3J/2qZN3dv4CnWYl/ovuys15z j11+q9qZdtnG43rT6ZSq3/Hrq6KfT16xxIrj7hJeUWXNvuO3ThnF2d2TrDz/Zd8S5h17fp5v StywgP1Q11tt927utS/nTUs9UWYS8/COxQntQwctRK9Ie785sTLhwFK/JrHKPb7ZBz1PrmLS 9akLmrDD40anev7DiUosxRmJhlrMRcWJADMW6O0mAwAA X-CMS-MailID: 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef References: <20241104140601.12239-1-anuj20.g@samsung.com> This patch introduces BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags which indicate how the hardware should check the integrity payload. BIP_CHECK_GUARD/REFTAG are conversion of existing semantics, while BIP_CHECK_APPTAG is a new flag. The driver can now just rely on block layer flags, and doesn't need to know the integrity source. Submitter of PI decides which tags to check. This would also give us a unified interface for user and kernel generated integrity. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 11 +++-------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index f56d01cec689..3bee43b87001 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -434,6 +434,11 @@ bool bio_integrity_prep(struct bio *bio) if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) bip->bip_flags |= BIP_IP_CHECKSUM; + /* describe what tags to check in payload */ + if (bi->csum_type) + bip->bip_flags |= BIP_CHECK_GUARD; + if (bi->flags & BLK_INTEGRITY_REF_TAG) + bip->bip_flags |= BIP_CHECK_REFTAG; if (bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)) < len) { printk(KERN_ERR "could not attach integrity payload\n"); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3de7555a7de7..79bd6b22e88d 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1004,18 +1004,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_PRINFO_PRACT; } - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: + if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD)) control |= NVME_RW_PRINFO_PRCHK_GUARD; - break; - case NVME_NS_DPS_PI_TYPE1: - case NVME_NS_DPS_PI_TYPE2: - control |= NVME_RW_PRINFO_PRCHK_GUARD | - NVME_RW_PRINFO_PRCHK_REF; + if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) { + control |= NVME_RW_PRINFO_PRCHK_REF; if (op == nvme_cmd_zone_append) control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); - break; } } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 58ff9988433a..fe2bfe122db2 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -11,6 +11,9 @@ enum bip_flags { BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 6, /* guard check */ + BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ }; struct bio_integrity_payload { @@ -31,7 +34,8 @@ struct bio_integrity_payload { }; #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Mon Nov 4 14:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 840719 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 040221C1AB1 for ; Mon, 4 Nov 2024 15:56: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=1730735787; cv=none; b=Fz8kszDbyMrCWEMYAGI95bGCzyxla849PlGt3P//+h7/VTA7UxqTLyI1TqoJ7F5csZbhCOndMBwSktW4Hfp7Pxa/nIRbyfMGNGmYnrzNX/P+olMfukpBeW8nmF19oSFBj9SJi2ooo2Y6+jPUPoNmazlaMPGZCUgnNHRVhdoh1ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735787; c=relaxed/simple; bh=Ti2AMmSbrMFScqU9q3xm9tPPI9IzzdHtGuAbg5J+KzE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=VRGvuNSdQNM2alV2C9jOcEYoww7rhtEPinK0v6lA1IUBl115IUNY/r+GCoaL7zwglQ9aU7EB/N1wrZgvVcoGFXGLB7jWdNKyxB8Ew3Jldm1BbHRSAMejO0+KXg+u+NG9kVm9Llt+gOxCPn2zX3TpZZ+ZlMqaKt3i80uXV4StE00= 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=eyaKIkyq; 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="eyaKIkyq" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241104155623epoutp024e230d2c2a1d5de3886eb67703e25ffd~EzwZu4lOk1517415174epoutp02C for ; Mon, 4 Nov 2024 15:56:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241104155623epoutp024e230d2c2a1d5de3886eb67703e25ffd~EzwZu4lOk1517415174epoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735783; bh=TdzGTMHoJr7DsmAYK7dZF3Jk+VkM+gVW6lv3bLW8Di0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eyaKIkyqn9+MnsrBSN0W0u8PaG0t+Gu2GHegB+s4I7RQ0u6hq4Rw0lzJX5BwgRHJC wtvi8fFvwmOZMY4PPE8sqzixZMUXNzqlUI5J/MRfR74xvOiC6qxA2US40rUseyGgFL 1p2o6sB96XWNnje8rpeYm76VUiZWq0W/mgS68/Ys= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241104155622epcas5p37fc4250e11a34029e910dfcdce649715~EzwY9sY380268302683epcas5p3C; Mon, 4 Nov 2024 15:56:22 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Xhx0N59wzz4x9Pp; Mon, 4 Nov 2024 15:56:20 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E8.A7.09420.4AEE8276; Tue, 5 Nov 2024 00:56:20 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241104141504epcas5p47e46a75f9248a37c9a4180de8e72b54c~EyX8jQoAX3055130551epcas5p4j; Mon, 4 Nov 2024 14:15:04 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241104141504epsmtrp185b3edd7ba835d76c7ea980221a18c8e~EyX8cS1Vl1329813298epsmtrp14; Mon, 4 Nov 2024 14:15:04 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-16-6728eea4e0f6 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5A.8D.07371.8E6D8276; Mon, 4 Nov 2024 23:15:04 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141501epsmtip273173b25c2459b8858b68de6692b678e~EyX6AFrz83074930749epsmtip2w; Mon, 4 Nov 2024 14:15:01 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v7 08/10] nvme: add support for passing on the application tag Date: Mon, 4 Nov 2024 19:35:59 +0530 Message-Id: <20241104140601.12239-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.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YvOmy5GurYIL jae7PVl8Y8bmpZdWcm8RfcwcJ6c7K/bX+k2vPn/YffVQRKtCguuXJcK3lt2OyDg40cfg52Sb 1f0R0x3OdDJK8Pt7mVampt9b2Lf7x6TGRtXkpevW7umwS3u2e/HqiqMX2ZwXicad++q99u4a uZbNR6eFbNfpTpLQ2bfpT9ae1jjpNsFHgcqlypPnP9h5VPvUXavi9c4SzG9+SM1yvzWncI2W sF1t0JkZl+65bT/+8PCfMNdw3zV6f794TI/r3Xkp0bx5+5G3vrpG/FLpte5MX7sMn1RGMbyv 6TTVvvzWacEpEcsEJZbijERDLeai4kQAWokeuScDAAA= X-CMS-MailID: 20241104141504epcas5p47e46a75f9248a37c9a4180de8e72b54c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141504epcas5p47e46a75f9248a37c9a4180de8e72b54c References: <20241104140601.12239-1-anuj20.g@samsung.com> From: Kanchan Joshi With user integrity buffer, there is a way to specify the app_tag. Set the corresponding protocol specific flags and send the app_tag down. Reviewed-by: Christoph Hellwig Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Keith Busch --- drivers/nvme/host/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 79bd6b22e88d..3b329e036d33 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -872,6 +872,12 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct request *req, struct nvme_command *cmnd) +{ + cmnd->rw.lbat = cpu_to_le16(bio_integrity(req->bio)->app_tag); + cmnd->rw.lbatm = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -1012,6 +1018,10 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); } + if (bio_integrity_flagged(req->bio, BIP_CHECK_APPTAG)) { + control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(req, cmnd); + } } cmnd->rw.control = cpu_to_le16(control); From patchwork Mon Nov 4 14:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 841306 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 5501A1C4A37 for ; Mon, 4 Nov 2024 15:56:28 +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=1730735790; cv=none; b=erKDiaJak1Iz3Da7DXSLz9iq7MNH53TMwKf1HuASDR275jvtPE2A2MCKZL/qHU5J+JLpjOlIOoGzY/FrpCtWuAlJYjybfWWALXXpu64ypVHdfLPUBpLd9b5AecnL0bCZrp0SsW2FE5TxJMHOQhY0IokKfnDbJ7OAeLhH3yT9P38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735790; c=relaxed/simple; bh=jraNWLaKHsTQe0pu2Jm0KWwiaQvYjmTAMdus/DUn6fU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=di46BHSJqfNkUmQW/1laDgITDky8cKkGKkQojeu99j2/GuiXObFqGQjjC0COYK5luj3Aila3OT79pu5UTxFUMmiJZ4yUGq0VwyaSyAypn8bB3X77eu0GXuAzr4uMW0+Ooxpd2DgbSSPoT896NTLFkeIHHN3Axb3QCPmbYGy9U64= 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=rhYiLOLf; 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="rhYiLOLf" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241104155626epoutp01e2fff87a32023c0da44d517ed0bf3bea~Ezwc3tYlp2173721737epoutp01N for ; Mon, 4 Nov 2024 15:56:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241104155626epoutp01e2fff87a32023c0da44d517ed0bf3bea~Ezwc3tYlp2173721737epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735786; bh=og22ywRlDp0pEXMrdTg3MkhTF5pEsbsojrZbbFE+yGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rhYiLOLfEXaNFT6lEgIy2XX6KLnbjK+5MumuDnORZ4Eea3yY+XVBySHDtUdBPf3Nh fcQTmvrdkdIej2wZDZzmzBig1iuC05323EBKEub/9+miOjCIkbcw4mlravqKMLeyb9 WXUWhHjGNVx879JtrrGp4aBsnIcADWjmukN4DlkM= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241104155626epcas5p10383c972697100e6e05280210168dfa5~EzwcaolWj1113211132epcas5p1r; Mon, 4 Nov 2024 15:56:26 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Xhx0S3nxWz4x9Pv; Mon, 4 Nov 2024 15:56:24 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id EA.A7.09420.8AEE8276; Tue, 5 Nov 2024 00:56:24 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241104141507epcas5p161e39cef85f8fa5f5ad59e959e070d0b~EyX_4hxKZ2157721577epcas5p10; Mon, 4 Nov 2024 14:15:07 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141507epsmtrp267492ec32aa1e84b08c069a0c6fa19d5~EyX_3soeQ1987119871epsmtrp2R; Mon, 4 Nov 2024 14:15:07 +0000 (GMT) X-AuditID: b6c32a49-33dfa700000024cc-1d-6728eea8dd62 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A6.78.35203.AE6D8276; Mon, 4 Nov 2024 23:15:07 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141504epsmtip29fc75f4f83ca57006c5c9a63d7dd3b1f~EyX8hKVv-3128131281epsmtip24; Mon, 4 Nov 2024 14:15:04 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v7 09/10] scsi: add support for user-meta interface Date: Mon, 4 Nov 2024 19:36:00 +0530 Message-Id: <20241104140601.12239-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFJsWRmVeSWpSXmKPExsWy7bCmpu6KdxrpBicOSFp8/PqbxaJpwl9m izmrtjFarL7bz2bx+vAnRoubB3YyWaxcfZTJ4l3rORaL2dObmSwmHbrGaLH3lrbFnr0nWSzm L3vKbtF9fQebxfLj/5gszv89zmpxftYcdgdBj52z7rJ7XD5b6rFpVSebx+Yl9R67bzaweXx8 eovFo2/LKkaPMwuOsHt83iTnsenJW6YArqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwND XUNLC3MlhbzE3FRbJRefAF23zBygd5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqpBSk5 BSYFesWJucWleel6eaklVoYGBkamQIUJ2RlTv/WwF5wXrWh43cvewHhFsIuRk0NCwERi6qqJ jF2MXBxCArsZJdpXL2AGSQgJfGKU+DvRASLxjVFi+oJFTDAdc19/herYyyjx/sRBVgjnM6PE xf1fWUCq2ATUJY48bwWrEhHYwyjRu/A0C4jDLPCSUWLpqkVgVcICzhIvzu4Em8sioCqx9PBd NhCbV8BK4tbxy8wQ++QlZl76zg5icwLF5/y9ywJRIyhxcuYTMJsZqKZ562xmkAUSAlc4JC70 foE61kWi/2UPI4QtLPHq+BZ2CFtK4vO7vWwQdrrEj8tPoeoLJJqP7YOqt5doPdUPNJQDaIGm xPpd+hBhWYmpp9YxQezlk+j9/QSqlVdixzwYW0mifeUcKFtCYu+5BijbQ+LK4pXQsOtllDjy Yx7zBEaFWUj+mYXkn1kIqxcwMq9ilEwtKM5NTy02LTDMSy2Hx3Nyfu4mRnAi1/LcwXj3wQe9 Q4xMHIyHGCU4mJVEeOelqqcL8aYkVlalFuXHF5XmpBYfYjQFBvhEZinR5HxgLskriTc0s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gtQimCwT B6dUA1M269Klq3aa3ZusK+a26Jdt2ub3u/8YHGTny/70PGfZ9twreR9EJ2RZLE5PmHXW5rDX llsaRwweSAb9YLO+cH5G9mm5XKWuhvkP/sp5x9m2fpi8dXLJzWg/4dBlOxwcdzXzvTJWXVQi OvU34xoNVrfaK80HZ/258E5BPmdjdolaoRB3t/azyf3bGbtC1vI2hddvjdohOetQNvMs50/1 Np2fJpgdO5Sz5dIUyVtXSo+YbTj4T4BjA3fNrleb03/lJm/PZWLYVD1fbge74EXxp6qJSd0S 6R8Lj7/7w7k+7f2KkrAH7m4Ja7lebdJ/JXbh8l+5xf+f2LkLVz1hM3NLmtGt778vX6VKMZXT pujnZWElluKMREMt5qLiRAC0JXdRIwMAAA== X-CMS-MailID: 20241104141507epcas5p161e39cef85f8fa5f5ad59e959e070d0b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141507epcas5p161e39cef85f8fa5f5ad59e959e070d0b References: <20241104140601.12239-1-anuj20.g@samsung.com> Add support for sending user-meta buffer. Set tags to be checked using flags specified by user/block-layer. With this change, BIP_CTRL_NOCHECK becomes unused. Remove it. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 4 ++-- include/linux/bio-integrity.h | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ca4bc0ac76ad..d1a2ae0d4c29 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -814,14 +814,14 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, if (bio_integrity_flagged(bio, BIP_IP_CHECKSUM)) scmd->prot_flags |= SCSI_PROT_IP_CHECKSUM; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_GUARD)) scmd->prot_flags |= SCSI_PROT_GUARD_CHECK; } if (dif != T10_PI_TYPE3_PROTECTION) { /* DIX/DIF Type 0, 1, 2 */ scmd->prot_flags |= SCSI_PROT_REF_INCREMENT; - if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) + if (bio_integrity_flagged(bio, BIP_CHECK_REFTAG)) scmd->prot_flags |= SCSI_PROT_REF_CHECK; } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index fe2bfe122db2..2195bc06dcde 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -7,13 +7,12 @@ enum bip_flags { BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */ BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */ - BIP_CTRL_NOCHECK = 1 << 2, /* disable HBA integrity checking */ - BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ - BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ - BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ - BIP_CHECK_GUARD = 1 << 6, /* guard check */ - BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ - BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ + BIP_DISK_NOCHECK = 1 << 2, /* disable disk integrity checking */ + BIP_IP_CHECKSUM = 1 << 3, /* IP checksum */ + BIP_COPY_USER = 1 << 4, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 5, /* guard check */ + BIP_CHECK_REFTAG = 1 << 6, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 7, /* apptag check */ }; struct bio_integrity_payload { @@ -33,8 +32,7 @@ struct bio_integrity_payload { struct bio_vec bip_inline_vecs[];/* embedded bvec array */ }; -#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ +#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_IP_CHECKSUM | \ BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY From patchwork Mon Nov 4 14:06: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: 840718 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 A1D881C7B75 for ; Mon, 4 Nov 2024 15:56:32 +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=1730735794; cv=none; b=XRbVMWWuRHGghCGPIdwjlEe1+hNmIkjWL8JdQ8jL8ctTPJZfH1ViRTIt0aA8cA+cn1uRSJb0mdiY/mK9Onuyp4wTDGy5W29bBjuoYNDg9upXPZvI0OwGu/XW9WKX355JYEgm3oPtwKcDuBbHRhhp3+lRNiJdLCkfcml/VUZw26k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735794; c=relaxed/simple; bh=WHvZy6Y5oID0mO4AofIk2VjNJ7NxK6UpWbYIbVVX3wY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=W4ux4PkJp5vC8kLBbqFN+r26tGSCmtJ+woZrHszp40WagYn/mb2kkmlYRCWPihPH4o88q9HGXWoUDGlKKejSRSNZ5FpujU+KK6KVLkVMkQarjRYfbvWJyApA8c3o6ReAKRk7cSJ0JD5uCi8Fa7IqzLz7gdGJAaOhTrs5EqUojkw= 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=uPGG2+CM; 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="uPGG2+CM" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241104155631epoutp012bcb99736acf6873e1f2f2c2e8273e46~Ezwg9zGAb2173421734epoutp01M for ; Mon, 4 Nov 2024 15:56:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241104155631epoutp012bcb99736acf6873e1f2f2c2e8273e46~Ezwg9zGAb2173421734epoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735791; bh=lzO5Gr/GJg/Q14qdgiZppE3+0qzFmF96RxNwH21zcLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPGG2+CMoAwP8J5jk53nW5Fr2Bo2xk7EfwJPTpBdJkpJL894PaZmwwniXUYyD2zSP ycf1WwIJ/uU3vBYQIuLP2tcU/NLFCFqQAUqD5aJSoxa3rTfiZVr1RnDRGy7zHJ7Cn+ ZDsUSTl3gMEdyQoDygIimGRVadNgRqXkwHv3ozzQ= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241104155629epcas5p317f76a2999cf2e5ac26083e0783d255e~EzwfohX8t2593425934epcas5p3w; Mon, 4 Nov 2024 15:56:29 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Xhx0W6nywz4x9Pq; Mon, 4 Nov 2024 15:56:27 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 43.DA.09800.BAEE8276; Tue, 5 Nov 2024 00:56:27 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241104141509epcas5p4ed0c68c42ccad27f9a38dc0c0ef7628d~EyYBZ6W0B3055030550epcas5p4t; Mon, 4 Nov 2024 14:15:09 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241104141509epsmtrp2a117a3377c18571a105712e5fe9b9b65~EyYBY3dlZ1987019870epsmtrp2W; Mon, 4 Nov 2024 14:15:09 +0000 (GMT) X-AuditID: b6c32a4b-23fff70000002648-4c-6728eeabda1b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 16.C9.08227.DE6D8276; Mon, 4 Nov 2024 23:15:09 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141507epsmtip22fcbe2494b12d261f60cf1d1a84d975a~EyX_6_yCt3097330973epsmtip2j; Mon, 4 Nov 2024 14:15:07 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH v7 10/10] block: add support to pass user meta buffer Date: Mon, 4 Nov 2024 19:36:01 +0530 Message-Id: <20241104140601.12239-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Tf0wTZxjH894dbenWeRZ0r5gNchsBJGA7CxxG5rIxcomEdLiNRZPhhd5a Qnvteu10sGyEpjN2Iuh0SGVQdWpoRSYwUpAygyAUHSSSiRBLZMIgYyX8krnwY2t7uPnf53ne 5/t83+f9IUKlY4IoUSFrYowsrSUEYqz1VkJCkms2Xi1bt6aQ809WMLKscg0la5ytgHT5KgTk zK0FQI7cbEPIelcPQs5aBzDyXJUFIXv+8QvIU133AekZTSQ7PF6MrLs8KSS/GXYLyCu96wg5 uNYbRg7aa4RvSak2u09IDf1ippqcxwRU8w9fUTdGSgXU/OQoRp1ocQLqrqNbSC02vUo1TfgR pfhA0R4NQ6sYYwzDFuhVhaw6g9i3P/+d/JRUmTxJnk6mETEsrWMyiMxsZVJWoTYwExHzGa01 B1JKmuOInW/uMerNJiZGo+dMGQRjUGkNCkMyR+s4M6tOZhnTbrlM9kZKoPBQkeaB62fM0JZ2 5PryUlgpuJZkAyIRxBXwxwbSBsQiKX4DQN9AFeCDBQA7h2wIHywD6Gy8hNlAeEhxsmFayC94 ALw3txzGB4sAXvBahcEqAR4Hu6esoV6ReAeA5efvYMEAxSsR6KhqQYPuEfi7cMzzQVCA4bHw 4pIFDbIE3w2b/bYNu2hYfe+vUNPwQL5mzYfxNZuht3oixGigxvLTOTTYH+IPRdA7Nwh4cSac q10I4zkC/tHbIuQ5Ci7OegQ8q+HToUmEZwO03O7c0O6F1v6K0D5RPAE2tu/k06/AM/3XEN73 JVi+MrEhlUB37TMm4NH6mg2G0DNQusEUnLb0YPxplQPY92gAqwQx9ufmsT83j/1/awdAnWAb Y+B0aoZLMeximcP/XXOBXtcEQg99xz43+O3RXHIXQESgC0ARSkRKapk4tVSioj8vZoz6fKNZ y3BdICVw4CfRqC0F+sBPYU35ckW6TJGamqpI35UqJ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WvifDYcefMw5uvGpym9N+rq9p4QfL5vReM9nvv7FvyVOmJzRfjOWeE WtfyX9myUOHTjNe1+b7/5NzDdzKFLZv8M//FgUu//6rmfd9Sf172+6uvGdM+fF/XuXnq2QiX g3I1jVkiN+STlR3y6+u/nrebdb3I58zZrDdln6VvOMXkcz95PmOX+++fLO1OQqemdivEJ17Y MO0071MBdpHC3BbZ0mZzbUNloStrxNQLpvBmW7uU1TIwn5ssM3G2G+/i1SYN7exfFJ29Fk8L WSp25N75h5pxR9aJ2rPKfmaJlL02abOH7YdHt8JOltXmV3y+MrU+517ztwOLjv99kfSN8UJD 5cZLBjH+Kcc52lfPVmIpzkg01GIuKk4EAIMmAwAnAwAA X-CMS-MailID: 20241104141509epcas5p4ed0c68c42ccad27f9a38dc0c0ef7628d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141509epcas5p4ed0c68c42ccad27f9a38dc0c0ef7628d References: <20241104140601.12239-1-anuj20.g@samsung.com> From: Kanchan Joshi If an iocb contains metadata, extract that and prepare the bip. Based on flags specified by the user, set corresponding guard/app/ref tags to be checked in bip. Reviewed-by: Christoph Hellwig Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Keith Busch --- block/bio-integrity.c | 50 +++++++++++++++++++++++++++++++++++ block/fops.c | 42 ++++++++++++++++++++++------- include/linux/bio-integrity.h | 7 +++++ 3 files changed, 90 insertions(+), 9 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 3bee43b87001..5d81ad9a3d20 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -364,6 +364,55 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) return ret; } +static void bio_uio_meta_to_bip(struct bio *bio, struct uio_meta *meta) +{ + struct bio_integrity_payload *bip = bio_integrity(bio); + + if (meta->flags & IO_INTEGRITY_CHK_GUARD) + bip->bip_flags |= BIP_CHECK_GUARD; + if (meta->flags & IO_INTEGRITY_CHK_APPTAG) + bip->bip_flags |= BIP_CHECK_APPTAG; + if (meta->flags & IO_INTEGRITY_CHK_REFTAG) + bip->bip_flags |= BIP_CHECK_REFTAG; + + bip->app_tag = meta->app_tag; +} + +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); + unsigned int integrity_bytes; + int ret; + struct iov_iter it; + + if (!bi) + return -EINVAL; + /* + * original meta iterator can be bigger. + * process integrity info corresponding to current data buffer only. + */ + it = meta->iter; + integrity_bytes = bio_integrity_bytes(bi, bio_sectors(bio)); + if (it.count < integrity_bytes) + return -EINVAL; + + /* should fit into two bytes */ + BUILD_BUG_ON(IO_INTEGRITY_VALID_FLAGS >= (1 << 16)); + + if (meta->flags && (meta->flags & ~IO_INTEGRITY_VALID_FLAGS)) + return -EINVAL; + + it.count = integrity_bytes; + ret = bio_integrity_map_user(bio, &it); + if (!ret) { + bio_uio_meta_to_bip(bio, meta); + bip_set_seed(bio_integrity(bio), meta->seed); + iov_iter_advance(&meta->iter, integrity_bytes); + meta->seed += bio_integrity_intervals(bi, bio_sectors(bio)); + } + return ret; +} + /** * bio_integrity_prep - Prepare bio for integrity I/O * @bio: bio to prepare @@ -564,6 +613,7 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_vec = bip_src->bip_vec; bip->bip_iter = bip_src->bip_iter; bip->bip_flags = bip_src->bip_flags & BIP_CLONE_FLAGS; + bip->app_tag = bip_src->app_tag; return 0; } diff --git a/block/fops.c b/block/fops.c index 2d01c9007681..3cf7e15eabbc 100644 --- a/block/fops.c +++ b/block/fops.c @@ -54,6 +54,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, struct bio bio; ssize_t ret; + WARN_ON_ONCE(iocb->ki_flags & IOCB_HAS_METADATA); if (nr_pages <= DIO_INLINE_BIO_VECS) vecs = inline_vecs; else { @@ -128,6 +129,9 @@ static void blkdev_bio_end_io(struct bio *bio) if (bio->bi_status && !dio->bio.bi_status) dio->bio.bi_status = bio->bi_status; + if (dio->iocb->ki_flags & IOCB_HAS_METADATA) + bio_integrity_unmap_user(bio); + if (atomic_dec_and_test(&dio->ref)) { if (!(dio->flags & DIO_IS_SYNC)) { struct kiocb *iocb = dio->iocb; @@ -221,14 +225,16 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, * a retry of this from blocking context. */ if (unlikely(iov_iter_count(iter))) { - bio_release_pages(bio, false); - bio_clear_flag(bio, BIO_REFFED); - bio_put(bio); - blk_finish_plug(&plug); - return -EAGAIN; + ret = -EAGAIN; + goto fail; } bio->bi_opf |= REQ_NOWAIT; } + if (!is_sync && (iocb->ki_flags & IOCB_HAS_METADATA)) { + ret = bio_integrity_map_iter(bio, iocb->private); + if (unlikely(ret)) + goto fail; + } if (is_read) { if (dio->flags & DIO_SHOULD_DIRTY) @@ -269,6 +275,12 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, bio_put(&dio->bio); return ret; +fail: + bio_release_pages(bio, false); + bio_clear_flag(bio, BIO_REFFED); + bio_put(bio); + blk_finish_plug(&plug); + return ret; } static void blkdev_bio_end_io_async(struct bio *bio) @@ -286,6 +298,9 @@ static void blkdev_bio_end_io_async(struct bio *bio) ret = blk_status_to_errno(bio->bi_status); } + if (iocb->ki_flags & IOCB_HAS_METADATA) + bio_integrity_unmap_user(bio); + iocb->ki_complete(iocb, ret); if (dio->flags & DIO_SHOULD_DIRTY) { @@ -330,10 +345,8 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, bio_iov_bvec_set(bio, iter); } else { ret = bio_iov_iter_get_pages(bio, iter); - if (unlikely(ret)) { - bio_put(bio); - return ret; - } + if (unlikely(ret)) + goto out_bio_put; } dio->size = bio->bi_iter.bi_size; @@ -346,6 +359,13 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, task_io_account_write(bio->bi_iter.bi_size); } + if (iocb->ki_flags & IOCB_HAS_METADATA) { + ret = bio_integrity_map_iter(bio, iocb->private); + WRITE_ONCE(iocb->private, NULL); + if (unlikely(ret)) + goto out_bio_put; + } + if (iocb->ki_flags & IOCB_ATOMIC) bio->bi_opf |= REQ_ATOMIC; @@ -360,6 +380,10 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, submit_bio(bio); } return -EIOCBQUEUED; + +out_bio_put: + bio_put(bio); + return ret; } static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 2195bc06dcde..de0a6c9de4d1 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -23,6 +23,7 @@ struct bio_integrity_payload { unsigned short bip_vcnt; /* # of integrity bio_vecs */ unsigned short bip_max_vcnt; /* integrity bio_vec slots */ unsigned short bip_flags; /* control flags */ + u16 app_tag; /* application tag value */ struct bvec_iter bio_iter; /* for rewinding parent bio */ @@ -78,6 +79,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter); +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -108,6 +110,11 @@ static int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) return -EINVAL; } +static inline int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + return -EINVAL; +} + static inline void bio_integrity_unmap_user(struct bio *bio) { }