From patchwork Thu Apr 25 18:39:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643659 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 1083F14F9F5 for ; Thu, 25 Apr 2024 18:47:06 +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=1714070828; cv=none; b=WAjxydHTb1uIDeZPKVTjJ1KJrPbJQX+5OhU3HOjMLxRTIktJqEWZV/hzi+pKlTCd3Dlm6aq8Utv5Vn9KJ6jOUdrbjW18mY60RPUYTDf7pHmnIiRuKAVPPrU6KK1T+y/fdlGf766UJc6mHZ2680YNpdJsrGV6nvDLK3aog1pOWhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070828; c=relaxed/simple; bh=EELVs2/K7r6/yt7yfKYJWd3E3c40DRgqJAJx6QNgmF8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=rkshvdIainrpiAJ1com30TOkVeo+RQ5mE5B5Qe/2wetAoq/S1BakkSLknF2HXlrZNgU9qsu+b5Zew5I70PP8meyCR6cMwHVtNxL/v9osvVQKTM5AaJp69wdrGRMqBFmW0kVad1B021+JftGV/AreV5B+/SxwwbjuDfXQDUjoZUE= 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=ieemyNF+; 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="ieemyNF+" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184705epoutp02f01d41cbbbf84340bac14f320a674dd5~JmlV41Ezg2855928559epoutp02g for ; Thu, 25 Apr 2024 18:47:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184705epoutp02f01d41cbbbf84340bac14f320a674dd5~JmlV41Ezg2855928559epoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070825; bh=OxaxYUv6kXArTeVw0WCBnIgHVnHyAM8bZTyh57XJclA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieemyNF+qwNgiF5ZKTEJtJSDMhMEsCir90HlzFn8b6N/jX5iUBpUNWLFHS3TYQ6hI qVdmxSi2lYAWc2QgfWxT2xgeyaWtgViHtbSkTfO8hu4AIkTKP1vZLf5h4CU3GvTF2/ JBfcIw+hmTHteIVisvsB4/9tsdSrJNAXUqJQHKcE= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240425184704epcas5p449c454a93cee3cd90db570bdcd3525e4~JmlVUZQq11507515075epcas5p4f; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4VQPwQ5N6Fz4x9Pp; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.E6.19431.625AA266; Fri, 26 Apr 2024 03:47:02 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa~JmlTM_5Ai1330613306epcas5p1M; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184702epsmtrp18037949dd8671c2b47ec3374d07e8cf3~JmlTMODXx0085000850epsmtrp1f; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) X-AuditID: b6c32a50-f57ff70000004be7-cd-662aa526028b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2B.F0.07541.625AA266; Fri, 26 Apr 2024 03:47:02 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184700epsmtip12c9a5239317da24686f8384443bb40e6~JmlRXCNYr0041000410epsmtip1N; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 06/10] block: modify bio_integrity_map_user argument Date: Fri, 26 Apr 2024 00:09:39 +0530 Message-Id: <20240425183943.6319-7-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMJsWRmVeSWpSXmKPExsWy7bCmuq7aUq00g4bt6hZNE/4yW8xZtY3R YvXdfja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0lDv58/sir/k7GJtbP7nWSqc+PnKQ9533i5thh5IdaidnSKrmJUb9 UXQxXtKhctDH0ICfTfJj0ZNGe5Opa68IPgmertu7oNmuUYmlOCPRUIu5qDgRAHhULSgJAwAA X-CMS-MailID: 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta 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 --- block/bio-integrity.c | 14 ++++++-------- drivers/nvme/host/ioctl.c | 11 +++++++++-- include/linux/bio.h | 7 ++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index b698eb77515d..1085cf45f51e 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -318,17 +318,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, - u32 seed) +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 = q->dma_pad_mask | queue_dma_alignment(q); 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)) @@ -341,8 +340,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) { @@ -352,8 +350,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 499a8bb7cac7..4ed389edb3b6 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -145,8 +145,15 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, if (bdev) { bio_set_dev(bio, bdev); if (meta_buffer && meta_len) { - ret = bio_integrity_map_user(bio, meta_buffer, meta_len, - meta_seed); + struct iov_iter iter; + unsigned int direction; + + if (bio_data_dir(bio) == READ) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, meta_buffer, meta_len); + ret = bio_integrity_map_user(bio, &iter, meta_seed); if (ret) goto out_unmap; req->cmd_flags |= REQ_INTEGRITY; diff --git a/include/linux/bio.h b/include/linux/bio.h index 875d792bffff..20cf47fc851f 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -723,7 +723,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) -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); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); extern bool bio_integrity_prep(struct bio *); @@ -795,8 +795,9 @@ static inline int bio_integrity_add_page(struct bio *bio, struct page *page, return 0; } -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; }