From patchwork Wed Oct 16 11:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 836092 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 52B0E173357 for ; Wed, 16 Oct 2024 12:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729082190; cv=none; b=Uh2IPFCpu6byxeySl/iO+yY6P+JmRw+uxzha+itHg/tPtm97I6SiRsmZKmfaheqpQDI4WtKVufMdcO7+sTFO5+0nCjHZtG3BmV8IMufwTwjNuIohL3R66YwA+Eimkh9k0fiTUn/ZJ3/W7zAuoHJiu1KV7gh5DNXUktQZGX/41g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729082190; c=relaxed/simple; bh=he/RKtwB0BA6gZ5+5gIwr4rdDI2BtLEw7XicuZ0Kc5A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jjBcIds509d32KK0I4IP97g+8HTdCxWe6B67bbpiG3HbqUoyAMCcd4XzgfO9czi5XOY8jU6BghH6VSrTzZ6y/QlE78CQLyO7ox4jhmslzKy92ghfQL8ShbWI5Cpj9jfJKwiV39j05HYwrJOtyyNW4SBXBt55DWeCda8+/NgptZM= 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=i2H0uxzT; 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="i2H0uxzT" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20241016123625epoutp03fd84064317106b79240b9623ebdac9f8~_7xYRxlPH1120611206epoutp03z for ; Wed, 16 Oct 2024 12:36:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20241016123625epoutp03fd84064317106b79240b9623ebdac9f8~_7xYRxlPH1120611206epoutp03z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1729082185; bh=UVsxMR53W9XtECcTqAPzjCe5MFT++ZFTK0IoQGFyX50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2H0uxzTjQrTysPpdFAZ3k9U1AWyqYia/NdpqN5CW4mstpfp/b3OLSRDDnjQbgqEp 5qYkgTzu+nykMAzUBxll68UCVhlXFm0nS2jaGaMpCSP0ku8PGI6mE2z2qOYlpvyHGY HD0y+1hb6ZQPjL2o0IKdGsKtbPwgz++9pu9M59qc= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241016123624epcas5p2f0d8b35c2ea1b60bc616d926c088e95a~_7xXYp64r3112131121epcas5p2S; Wed, 16 Oct 2024 12:36:24 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XT9SQ3t5cz4x9Pr; Wed, 16 Oct 2024 12:36:22 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.43.18935.643BF076; Wed, 16 Oct 2024 21:36:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20241016113738epcas5p2d217b8d6efbf855f61c133f64deaa486~_6_EOP5tl3038230382epcas5p26; Wed, 16 Oct 2024 11:37:38 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241016113738epsmtrp16c8c84804246c27c5bbbec8778145815~_6_ENcN6u0254402544epsmtrp1o; Wed, 16 Oct 2024 11:37:38 +0000 (GMT) X-AuditID: b6c32a50-cb1f8700000049f7-14-670fb346808a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2D.9A.07371.285AF076; Wed, 16 Oct 2024 20:37:38 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241016113736epsmtip1c8a477b3eda0933f06fe491b78581761~_6_CJyia12875928759epsmtip1E; Wed, 16 Oct 2024 11:37:36 +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, krisman@suse.de Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH v4 03/11] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Wed, 16 Oct 2024 16:59:04 +0530 Message-Id: <20241016112912.63542-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016112912.63542-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+NgFjrOJsWRmVeSWpSXmKPExsWy7bCmhq7b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f7WrS8XrPHMc9d83jne5n7LjPymNuUdv2IQ HOwWarkk+fZaNXlp2yW635/tPx68hMPyk4SHonvE2xdrRCSePMncGNPcvkrW74LZqf5DE0NU 653zT539PY9pec4V9rZNWS+X95d8f6Xaf+nZodPKIfMjNh5kuOFw5Czn8uPn/QMrlFiKMxIN tZiLihMBt0Z1GRIDAAA= X-CMS-MailID: 20241016113738epcas5p2d217b8d6efbf855f61c133f64deaa486 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241016113738epcas5p2d217b8d6efbf855f61c133f64deaa486 References: <20241016112912.63542-1-anuj20.g@samsung.com> This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 12 +++++------- block/blk-integrity.c | 10 +++++++++- include/linux/bio-integrity.h | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 8948e635432d..341a0382befd 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -303,17 +303,16 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = blk_lim_dma_alignment_and_pad(&q->limits); struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages; struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec; + size_t offset, bytes = iter->count; unsigned int direction, nr_bvecs; - struct iov_iter iter; int ret, nr_vecs; - size_t offset; bool copy; if (bio_integrity(bio)) @@ -326,8 +325,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) { @@ -337,8 +335,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 83b696ba0cac..cb8f7260bdcf 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, u32 seed) { - int ret = bio_integrity_map_user(rq->bio, ubuf, bytes, seed); + 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, seed); if (ret) return ret; diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 485d8a43017a..90aab50a3e14 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -75,7 +75,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr); int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset); -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); void bio_integrity_unmap_user(struct bio *bio); bool bio_integrity_prep(struct bio *bio); void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); @@ -101,8 +101,8 @@ static inline void bioset_integrity_free(struct bio_set *bs) { } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len, u32 seed) +static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, + u32 seed) { return -EINVAL; }