From patchwork Tue Oct 29 16:23: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: 13855248 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 14E3B1DBB38 for ; Tue, 29 Oct 2024 17:23:45 +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=1730222628; cv=none; b=NosfIoX/LW/W+3VsEMvJYQ8z2XUs3nxy4TuRjzrxliwmpv8p6RWZbYOm2+BODNcb/F/p8uAOanYcu38HoxPHRRaB878y1AZkSakok1hGTg+DtXp89NSUdzjGAIazffEvW96cqMqXMWajo7ru2Zu3YOAh1gRWa84QhL6BWrWv+rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222628; c=relaxed/simple; bh=u0IdrfpF8vfRYrAsGoJ+C8qHOzARBVDbhDH4yIhjzQU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=pO8JteAcznstsGmbpit0TEjXs4rwtbWdSvlK2SUFdG6P+J1Mwfq86fjiACCryjolIwIIZHyx6022SJZZ/DH0qgTCIiCOadcwEAoIIjUbXY+6gcdrdYAq1ogFMwb06pFYKqE07tDzXs7rEtWgSMgoDSXRYZogPD+F3D/qIENZGWY= 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=plhiuL6x; 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="plhiuL6x" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241029172344epoutp027467d8e29a104a6ac3d7a4ed84dca300~C-E86vlVZ2217222172epoutp02R for ; Tue, 29 Oct 2024 17:23:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241029172344epoutp027467d8e29a104a6ac3d7a4ed84dca300~C-E86vlVZ2217222172epoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730222624; bh=+220GbndM91TZYcbQfyaQ2xjcCIjE+33z1HUaPt3Dds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plhiuL6xhBHzEhD/hK8fOUsXe6zwNxIQa4EVxNVDFpOdKzuJ2m2b7V5Y44SBOJaRw x663/w0Y/ZmJav8Ow5OqDuwnS07TREN8sXKSBp4664Nq1XSzkY0EkOmIGxsfUBRA96 TqgKy7VIT7rJUzzdzCVhV7vcb5qyhK0+viUdQKlc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241029172343epcas5p1cc4d4e88a21d0042c881a223a4344724~C-E8MSMcJ0899208992epcas5p1E; Tue, 29 Oct 2024 17:23:43 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XdHCx5MVVz4x9Pt; Tue, 29 Oct 2024 17:23:41 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 73.F9.09420.D1A11276; Wed, 30 Oct 2024 02:23:41 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241029163217epcas5p414d493b7a89c6bd092afd28c4eeea24c~C_YCON41I1629316293epcas5p4x; Tue, 29 Oct 2024 16:32:17 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241029163217epsmtrp14680812d561cbd9f9c6bf89fd9b026a5~C_YCNJO9g0723107231epsmtrp1j; Tue, 29 Oct 2024 16:32:17 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-5e-67211a1d41d8 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 09.4B.07371.11E01276; Wed, 30 Oct 2024 01:32:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241029163214epsmtip21df614ea02497a6fcd82039dc37de744~C_X-xd3zu0975909759epsmtip2W; Tue, 29 Oct 2024 16:32:14 +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 v5 03/10] block: modify bio_integrity_map_user to accept iov_iter as argument Date: Tue, 29 Oct 2024 21:53:55 +0530 Message-Id: <20241029162402.21400-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241029162402.21400-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-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d/EHVszcpo1JrX/TE1E0SYRMXSxx5VfUt9v5qmdfH2d03 7WB0bIx+fCmwpjz0l3v672WBGl7zF/H8qpyTcjV25cyWm7e80lW2Fs652vz8RYilUM58CYcG 3/bXd3OOi1w9J3Xwfkbe7fdcfy7KaOWkF5SLqSglG+9UV/F/N02Bt7kvZV+CjtWPcwtefeH7 untTq0iVW+PsCsUveTOdvyUqyOQvTuLQ76vlVfhelblxA8cZ/afXOTkYzR9a9GpuPqvY3280 uer3xKue2UosxRmJhlrMRcWJAPnP/wIlAwAA X-CMS-MailID: 20241029163217epcas5p414d493b7a89c6bd092afd28c4eeea24c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241029163217epcas5p414d493b7a89c6bd092afd28c4eeea24c References: <20241029162402.21400-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; }