From patchwork Thu Sep 29 12:06:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12993990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DBA3C433F5 for ; Thu, 29 Sep 2022 12:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235079AbiI2MVU (ORCPT ); Thu, 29 Sep 2022 08:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbiI2MVP (ORCPT ); Thu, 29 Sep 2022 08:21:15 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9B3D01DE for ; Thu, 29 Sep 2022 05:21:13 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220929122112epoutp0456365b3b826bc08d01cc014ef0273bc1~ZVCj7t_sc0840708407epoutp04q for ; Thu, 29 Sep 2022 12:21:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220929122112epoutp0456365b3b826bc08d01cc014ef0273bc1~ZVCj7t_sc0840708407epoutp04q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454072; bh=iirM43BcaFmNufDrlcC4cnJ4qMGLT6ODyYNtDEbayfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3oKm9cq1tUy3NrwH0U1jcmy8H7gEedTS96jugFPHaSXcpMSt1GwMTb7JGg6aUg7O yG1+L0JuVsst3gNKTF4EM6NQnRsiuP0ODVOsRkWwUYXSqzS/yVfdRZlmnVWR3OGLBf yFJqhsksF1cDgHW9T3wB0EoaYiXoYnVe3jrmpZtc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220929122111epcas5p15f7ec8ef37540964c64e874780abc6db~ZVCjWrVwW2617526175epcas5p18; Thu, 29 Sep 2022 12:21:11 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXX56R2Nz4x9Pt; Thu, 29 Sep 2022 12:21:09 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F0.82.26992.5BD85336; Thu, 29 Sep 2022 21:21:09 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220929121634epcas5p27400b84f8a8b43a91c4199ec39d50b51~ZU_gxZxSi2579425794epcas5p2v; Thu, 29 Sep 2022 12:16:34 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220929121633epsmtrp1bae654eccfe047e51fac2532f8850756~ZU_gwZMW11820918209epsmtrp1O; Thu, 29 Sep 2022 12:16:33 +0000 (GMT) X-AuditID: b6c32a49-0c7ff70000016970-56-63358db506e8 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 1D.2C.18644.1AC85336; Thu, 29 Sep 2022 21:16:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121632epsmtip13e97ea335b162e573e81cdf2ab02f7d9~ZU_fTwVzD2856128561epsmtip1R; Thu, 29 Sep 2022 12:16:32 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v11 01/13] io_uring: add io_uring_cmd_import_fixed Date: Thu, 29 Sep 2022 17:36:20 +0530 Message-Id: <20220929120632.64749-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAJsWRmVeSWpSXmKPExsWy7bCmhu7WXtNkg+sT9CyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnAKTAr3i xNzi0rx0vbzUEitDAwMjU6DChOyMJ8cnsRT8F6zYPfkyYwPjT74uRk4OCQETiRnNz9i6GLk4 hAR2M0osntfNBJIQEvjEKLGmoQAi8ZlRorPjFTtMx9NZs5kgErsYJVp3bGKB6ACqOtYmDWKz CahLHHneyghiiwgYSez/dJIVpIFZ4CajxKG9z5hBEsIC3hInuj6BTWURUJXYvWwjUAMHB6+A pcSxf34Qy+QlZl76DlbCKWAlsfjaHFYQm1dAUOLkzCdge5mBapq3zmYGmS8h0Mgh8burjQWi 2UViUUsnlC0s8er4FqgPpCRe9rdB2ekSPy4/ZYKwCySaj+1jhLDtJVpP9TOD3MMsoCmxfpc+ RFhWYuqpdUwQe/kken8/gWrlldgxD8ZWkmhfOQfKlpDYe64ByvaQmNS+mRUScL2MEk96H7NN YFSYheSfWUj+mYWwegEj8ypGydSC4tz01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8uOLSnNSiw8xSnOwKInzXug6GS8kkJ5YkpqdmlqQWgSTZeLglGpg 2pYX6H36hOwxzgc3+Y9tPqqarVRUdGW/RPlHk5nLpphKG5kayKRqtWm31W/JuF+dK/KmuDmr WCpN6/Lxl1c3M13j4o6fWdQfVaZ/afXtwk6dnMty2laivey3dor49pjf/OmhO/EF8+yy+Vxu Gtc2GMy+seTnnDX/dXmX/RHyWxmz7LiK35nHH5R/pbcu2rd4/ce/G39dCPnk7R1efuLM6gsh nY//2H3j3bCyX+dE5V2ztWt2zPu7Q+GrbADnkrBFL/0UZ03N2G22wvYMx2SxoAmG5/ed7n9T IvM0kzPhwra8qu43qx/+tfodkalzwZdbwZZX5FDSohP8F/2f+IiVfv7Dq2zg0+Ltwz7fQ/uz txJLcUaioRZzUXEiAKnmJzzpAgAA X-CMS-MailID: 20220929121634epcas5p27400b84f8a8b43a91c4199ec39d50b51 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121634epcas5p27400b84f8a8b43a91c4199ec39d50b51 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This is a new helper that callers can use to obtain a bvec iterator for the previously mapped buffer. This is preparatory work to enable fixed-buffer support for io_uring_cmd. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/io_uring.h | 8 ++++++++ io_uring/uring_cmd.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 58676c0a398f..1dbf51115c30 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -4,6 +4,7 @@ #include #include +#include enum io_uring_cmd_flags { IO_URING_F_COMPLETE_DEFER = 1, @@ -32,6 +33,8 @@ struct io_uring_cmd { }; #if defined(CONFIG_IO_URING) +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd); void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2); void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd, void (*task_work_cb)(struct io_uring_cmd *)); @@ -59,6 +62,11 @@ static inline void io_uring_free(struct task_struct *tsk) __io_uring_free(tsk); } #else +static int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd) +{ + return -EOPNOTSUPP; +} static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t ret2) { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index f3ed61e9bd0f..6a6d69523d75 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -8,6 +8,7 @@ #include #include "io_uring.h" +#include "rsrc.h" #include "uring_cmd.h" static void io_uring_cmd_work(struct io_kiocb *req, bool *locked) @@ -129,3 +130,12 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) return IOU_ISSUE_SKIP_COMPLETE; } + +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd) +{ + struct io_kiocb *req = cmd_to_io_kiocb(ioucmd); + + return io_import_fixed(rw, iter, req->imu, ubuf, len); +} +EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); From patchwork Thu Sep 29 12:06:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12993991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE445C433F5 for ; Thu, 29 Sep 2022 12:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbiI2MVu (ORCPT ); Thu, 29 Sep 2022 08:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235229AbiI2MVc (ORCPT ); Thu, 29 Sep 2022 08:21:32 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADED4149D30 for ; Thu, 29 Sep 2022 05:21:29 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220929122127epoutp04c9211b38ea6f7d17eb6c2720d0949e5b~ZVCxpc13y0840708407epoutp04s for ; Thu, 29 Sep 2022 12:21:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220929122127epoutp04c9211b38ea6f7d17eb6c2720d0949e5b~ZVCxpc13y0840708407epoutp04s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454087; bh=xMmj22Fm1UKQdbN5q3tCCFoK6cDTkB7H5tHv92rgbKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUwB86AqJwt8CZSu2AgvFFiAQvfBnvQMBRNHCAThU2HBJskBZPqduwEnnWH/ncidD VJRNuk7GbDdEhVPhZl/+F4AWkuV9z2sX9IJXbSfhWpbDgSL6LFE68fzTiuP4eQzxS9 yvgnQPpOoTsIpGlUvaPdJ+897azy9TTM1skUxs7g= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220929122126epcas5p4762a6d38976025c2534e41da35321155~ZVCwwMgIx3003630036epcas5p4T; Thu, 29 Sep 2022 12:21:26 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXXN34KSz4x9Pt; Thu, 29 Sep 2022 12:21:24 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CB.82.26992.4CD85336; Thu, 29 Sep 2022 21:21:24 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220929121637epcas5p2ff344c7951037f79d117d000e405dd45~ZU_kVncoA2731427314epcas5p22; Thu, 29 Sep 2022 12:16:37 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121637epsmtrp2af0f316a39759668bd5bf5b9cfb1042a~ZU_kU2dZI1794617946epsmtrp2N; Thu, 29 Sep 2022 12:16:37 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-83-63358dc4c423 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B1.43.14392.5AC85336; Thu, 29 Sep 2022 21:16:37 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121636epsmtip16ea7bb99dca714e76c33e617af52b8e1~ZU_i6fvKb2848328483epsmtip1X; Thu, 29 Sep 2022 12:16:36 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v11 02/13] io_uring: introduce fixed buffer support for io_uring_cmd Date: Thu, 29 Sep 2022 17:36:21 +0530 Message-Id: <20220929120632.64749-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlr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tRqh8zIq+M5pWL6xFLTiPHfpewLUfcmx86dbrD/N/uOabdW FCuxFGckGmoxFxUnAgB+Q3To6gIAAA== X-CMS-MailID: 20220929121637epcas5p2ff344c7951037f79d117d000e405dd45 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121637epcas5p2ff344c7951037f79d117d000e405dd45 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add IORING_URING_CMD_FIXED flag that is to be used for sending io_uring command with previously registered buffers. User-space passes the buffer index in sqe->buf_index, same as done in read/write variants that uses fixed buffers. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/io_uring.h | 2 +- include/uapi/linux/io_uring.h | 9 +++++++++ io_uring/uring_cmd.c | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 1dbf51115c30..e10c5cc81082 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -28,7 +28,7 @@ struct io_uring_cmd { void *cookie; }; u32 cmd_op; - u32 pad; + u32 flags; u8 pdu[32]; /* available inline for free use */ }; diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 92f29d9505a6..ab7458033ee3 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -56,6 +56,7 @@ struct io_uring_sqe { __u32 hardlink_flags; __u32 xattr_flags; __u32 msg_ring_flags; + __u32 uring_cmd_flags; }; __u64 user_data; /* data to be passed back at completion time */ /* pack this to avoid bogus arm OABI complaints */ @@ -219,6 +220,14 @@ enum io_uring_op { IORING_OP_LAST, }; +/* + * sqe->uring_cmd_flags + * IORING_URING_CMD_FIXED use registered buffer; pass thig flag + * along with setting sqe->buf_index. + */ +#define IORING_URING_CMD_FIXED (1U << 0) + + /* * sqe->fsync_flags */ diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 6a6d69523d75..faefa9f6f259 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -77,8 +78,21 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); - if (sqe->rw_flags || sqe->__pad1) + if (sqe->__pad1) return -EINVAL; + + ioucmd->flags = READ_ONCE(sqe->uring_cmd_flags); + if (ioucmd->flags & IORING_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 index; + + req->buf_index = READ_ONCE(sqe->buf_index); + if (unlikely(req->buf_index >= ctx->nr_user_bufs)) + return -EFAULT; + index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); + req->imu = ctx->user_bufs[index]; + io_req_set_rsrc_node(req, ctx, 0); + } ioucmd->cmd = sqe->cmd; ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); return 0; From patchwork Thu Sep 29 12:06:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8826CC433F5 for ; Thu, 29 Sep 2022 12:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235055AbiI2MV5 (ORCPT ); Thu, 29 Sep 2022 08:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234896AbiI2MVo (ORCPT ); Thu, 29 Sep 2022 08:21:44 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FBAC14F2BF for ; Thu, 29 Sep 2022 05:21:42 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220929122140epoutp03d442f3ac83cb0f40461a09df603d1caa~ZVC_pDHVZ1883118831epoutp03c for ; Thu, 29 Sep 2022 12:21:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220929122140epoutp03d442f3ac83cb0f40461a09df603d1caa~ZVC_pDHVZ1883118831epoutp03c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454101; bh=dVPpGsZIImAW+BdashB8ATM4WSqR1Zww/QHHIFBBUjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TTBbtDY8VkDfHEAul9pIWd4aCPtYGuWn2mHpayLVj2Uw1az8EdlTxw+OrGINC1wcO MtznAE45S1P4pDwLVt04mjPPqqXJGwB2jE25S6D2Q98QrwLhIDjuj/6TpYEKsDuffA iOoYotRNmpqM9gReDFI+uBKKfPiICewm8QVzfWo0= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122140epcas5p3ec76a5862d7faed98da3d6dfedf11cb8~ZVC98H_gP2720827208epcas5p3Z; Thu, 29 Sep 2022 12:21:40 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXXf2tCQz4x9Px; Thu, 29 Sep 2022 12:21:38 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F7.B2.26992.2DD85336; Thu, 29 Sep 2022 21:21:38 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220929121640epcas5p400a71aa51f374f016e2143d0228879bc~ZU_nLF2mP3132331323epcas5p4Y; Thu, 29 Sep 2022 12:16:40 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220929121640epsmtrp165631add7717ec14317e5cef9a082c98~ZU_nKXg2H1820918209epsmtrp1R; Thu, 29 Sep 2022 12:16:40 +0000 (GMT) X-AuditID: b6c32a49-0c7ff70000016970-a0-63358dd2ea2a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C2.43.14392.8AC85336; Thu, 29 Sep 2022 21:16:40 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121639epsmtip1adae630e3d96567c44ab37114f666959~ZU_lzWpes3028630286epsmtip14; Thu, 29 Sep 2022 12:16:39 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v11 03/13] nvme: refactor nvme_add_user_metadata Date: Thu, 29 Sep 2022 17:36:22 +0530 Message-Id: <20220929120632.64749-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLJsWRmVeSWpSXmKPExsWy7bCmuu6lXtNkgzevhCxW3+1ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpu0X39R1sDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWlW2TkZqYklqkkJqXnJ+SmZduq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lOCPRUIu5qDgRAMfNWUEwBAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsWy7bCSnO6KHtNkg8Uz9CxW3+1ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpu0X39R1sDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJWx4c5aloLpIhX/rkxhbWCcJdDFyMEhIWAi ceFyThcjF4eQwG5Giaevr7J3MXICxSUkTr1cxghhC0us/PecHaLoI6PEyufT2UASbALqEkee t4IViQiYSSw9vIYFpIhZYBejxNyt35hBEsICnhIPPuwCa2ARUJWY/+gzK4jNK2ApMevLN6ht 8hIzL30HszkFrCQWX5vDCnKdEFDN9psKEOWCEidnPmEBsZmBypu3zmaewCgwC0lqFpLUAkam VYySqQXFuem5xYYFhnmp5XrFibnFpXnpesn5uZsYwcGupbmDcfuqD3qHGJk4GA8xSnAwK4nw iheYJgvxpiRWVqUW5ccXleakFh9ilOZgURLnvdB1Ml5IID2xJDU7NbUgtQgmy8TBKdXAVL6h /d++7utpTWeENW/KPjtrJXVTd85BE5Wz96aHuP/aGRopHrRUZMdRjZLHh5klTYz9DkklcefF T9I+uNjtbHLvtYzMs5MkpBR03zzh5csITvOS+BS8i6u5Qdx/4p7VAu8al2rFy8bc/avhO7Xm Wt9Gvf85WSWbvgmyzr+yJLHYNyufb+fsI0YzVyx4xTK1v3bjxNqTjx9bzmHc9SP42JQb5nLq Mk94V56KncquINLI0Hvize8ndZPf7u2z1vqbZNKok/rdNqP/3ZXLPxcESpTM3vLUUGSFA7/M N8XQlK2GC69Hb3aofX5T6NSfyVc/H/6q3CTsdDhk7lQvy71ph5z2qq3J3tKpl+jzY9qiWiWW 4oxEQy3mouJEAM/6FhPlAgAA X-CMS-MailID: 20220929121640epcas5p400a71aa51f374f016e2143d0228879bc X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121640epcas5p400a71aa51f374f016e2143d0228879bc References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi Pass struct request rather than bio. It helps to kill a parameter, and some processing clean-up too. Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 914b142b6f2b..749f588a1228 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -20,19 +20,20 @@ static void __user *nvme_to_user_ptr(uintptr_t ptrval) return (void __user *)ptrval; } -static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf, - unsigned len, u32 seed, bool write) +static void *nvme_add_user_metadata(struct request *req, void __user *ubuf, + unsigned len, u32 seed) { struct bio_integrity_payload *bip; int ret = -ENOMEM; void *buf; + struct bio *bio = req->bio; buf = kmalloc(len, GFP_KERNEL); if (!buf) goto out; ret = -EFAULT; - if (write && copy_from_user(buf, ubuf, len)) + if ((req_op(req) == REQ_OP_DRV_OUT) && copy_from_user(buf, ubuf, len)) goto out_free_meta; bip = bio_integrity_alloc(bio, GFP_KERNEL, 1); @@ -45,9 +46,13 @@ static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf, bip->bip_iter.bi_sector = seed; ret = bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)); - if (ret == len) - return buf; - ret = -ENOMEM; + if (ret != len) { + ret = -ENOMEM; + goto out_free_meta; + } + + req->cmd_flags |= REQ_INTEGRITY; + return buf; out_free_meta: kfree(buf); out: @@ -70,7 +75,6 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, u32 meta_seed, void **metap, unsigned timeout, bool vec, blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags) { - bool write = nvme_is_write(cmd); struct nvme_ns *ns = q->queuedata; struct block_device *bdev = ns ? ns->disk->part0 : NULL; struct request *req; @@ -110,13 +114,12 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, if (bdev) bio_set_dev(bio, bdev); if (bdev && meta_buffer && meta_len) { - meta = nvme_add_user_metadata(bio, meta_buffer, meta_len, - meta_seed, write); + meta = nvme_add_user_metadata(req, meta_buffer, + meta_len, meta_seed); if (IS_ERR(meta)) { ret = PTR_ERR(meta); goto out_unmap; } - req->cmd_flags |= REQ_INTEGRITY; *metap = meta; } } From patchwork Thu Sep 29 12:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F1FEC4332F for ; Thu, 29 Sep 2022 12:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235201AbiI2MWQ (ORCPT ); Thu, 29 Sep 2022 08:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbiI2MWH (ORCPT ); Thu, 29 Sep 2022 08:22:07 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466D7148A2C for ; Thu, 29 Sep 2022 05:22:05 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220929122204epoutp04d5c38e5dff405a2fc70f3222df15df33~ZVDUZDnRJ0937409374epoutp04g for ; Thu, 29 Sep 2022 12:22:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220929122204epoutp04d5c38e5dff405a2fc70f3222df15df33~ZVDUZDnRJ0937409374epoutp04g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454124; bh=LeLI2qR2gM2LLy5jVtD0IFNvJ8xQj6lBm3zf0UZZ7bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XO9e7ZpdQuo/xeUP2pyYS38PynWmDybABUI17s9ILWYzcSNjDO5dwbwFL5p8BwQyw hWWdB57hlgVASltqoDczZXv0p5dgZEJpZzTfDJVyVv8awBCp3/Va565HGyYpvVRVxs 9XLbz5n527O635upkw2nmiej7I7Nf4dbpajHrqdA= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122203epcas5p3d75fbd3d68a5eb6e028b339c3a7c9d81~ZVDT2FENW2488324883epcas5p3G; Thu, 29 Sep 2022 12:22:03 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MdXY52xZVz4x9Q1; Thu, 29 Sep 2022 12:22:01 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id DE.28.39477.9ED85336; Thu, 29 Sep 2022 21:22:01 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220929121643epcas5p4c58f6ebb794bde58981272cd33c69f9f~ZU_phy-vt3132331323epcas5p4a; Thu, 29 Sep 2022 12:16:43 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121643epsmtrp259370ba348f3564bda783d724a2a1489~ZU_phBCWQ1794617946epsmtrp2Q; Thu, 29 Sep 2022 12:16:43 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-66-63358de97895 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4F.2C.18644.BAC85336; Thu, 29 Sep 2022 21:16:43 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121641epsmtip1bb82e7a15dd69eb79f0619061d566220~ZU_oFPM8s3141431414epsmtip1q; Thu, 29 Sep 2022 12:16:41 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v11 04/13] nvme: refactor nvme_alloc_request Date: Thu, 29 Sep 2022 17:36:23 +0530 Message-Id: <20220929120632.64749-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmuu7LXtNkgyl/hSyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnAKTAr3i xNzi0rx0vbzUEitDAwMjU6DChOyM/XfTCqbqVTy7OYelgfGxShcjJ4eEgInExwm9LF2MXBxC ArsZJdo/HGaEcD4xSvz99hXK+cwo8b3rLhNMy9KPl6BadjFKTL7/igmu6vy9J8wgVWwC6hJH nrcygtgiAkYS+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Q0LARGLpx0ssXYxcHEICOxgldpzezgSRkJA49XIZI4QtLLHy33N2iKKPjBKvjhxkAUmwCahL HHneClYkImAmsfTwGrBJzAL3GSXeNu8GKxIWcJW4v+U6UDcHB4uAqsT8HVUgYV4BS4mVH45A LZCXmHnpOzuIzSlgJbH42hxWkHIhoJrtNxUgygUlTs58AjaRGai8eets5gmMArOQpGYhSS1g ZFrFKJlaUJybnltsWGCUl1quV5yYW1yal66XnJ+7iREc9FpaOxj3rPqgd4iRiYPxEKMEB7OS CK94gWmyEG9KYmVValF+fFFpTmrxIUZpDhYlcd4LXSfjhQTSE0tSs1NTC1KLYLJMHJxSDUxM mutF1mlo7dOptpZ7usKxbFfz1EC+bcrl3gt/Gc5Oc7BaOanu5AaGaDumm4991paqs885qHZX dcO1zcZ1UZ3n36/8plh1NPpZj0b1pMRbzD8PCldM0eOoqK75Mmn/8r1vrtVt8D8R/27b+Qm/ 6qeJLHdpluR8sFnfStyby7/h8vZL7zdxs58+ETBjQvpmv3/FXT8O6VlMn7VYZOoFNTGPl/qP n/9b+FBNI+vnn9MCP1cu9AqznuUWYMt2fXe3NQ9fOuN1rzTxxKZX30P/W6r3VjYwXji/rOLj 8yq+RccmmCz5fcbVLHrLfrVNHo8l97IcDzXeYXQlRujAF+v4d8b8dSd9U2ftWpLs8Zdvt+IP JZbijERDLeai4kQArbdxIukCAAA= X-CMS-MailID: 20220929121643epcas5p4c58f6ebb794bde58981272cd33c69f9f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121643epcas5p4c58f6ebb794bde58981272cd33c69f9f References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi nvme_alloc_request expects a large number of parameters. Split this out into two functions to reduce number of parameters. First one retains the name nvme_alloc_request, while second one is named nvme_map_user_request. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 120 ++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 51 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 749f588a1228..0143f62b27c2 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -70,68 +70,69 @@ static int nvme_finish_user_metadata(struct request *req, void __user *ubuf, } static struct request *nvme_alloc_user_request(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, - unsigned bufflen, void __user *meta_buffer, unsigned meta_len, - u32 meta_seed, void **metap, unsigned timeout, bool vec, - blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags) + struct nvme_command *cmd, blk_opf_t rq_flags, + blk_mq_req_flags_t blk_flags) { - struct nvme_ns *ns = q->queuedata; - struct block_device *bdev = ns ? ns->disk->part0 : NULL; struct request *req; - struct bio *bio = NULL; - void *meta = NULL; - int ret; req = blk_mq_alloc_request(q, nvme_req_op(cmd) | rq_flags, blk_flags); if (IS_ERR(req)) return req; nvme_init_request(req, cmd); - - if (timeout) - req->timeout = timeout; nvme_req(req)->flags |= NVME_REQ_USERCMD; + return req; +} - if (ubuffer && bufflen) { - if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - GFP_KERNEL); - else { - struct iovec fast_iov[UIO_FASTIOV]; - struct iovec *iov = fast_iov; - struct iov_iter iter; - - ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, - UIO_FASTIOV, &iov, &iter); - if (ret < 0) - goto out; - ret = blk_rq_map_user_iov(q, req, NULL, &iter, - GFP_KERNEL); - kfree(iov); - } - if (ret) +static int nvme_map_user_request(struct request *req, void __user *ubuffer, + unsigned bufflen, void __user *meta_buffer, unsigned meta_len, + u32 meta_seed, void **metap, bool vec) +{ + struct request_queue *q = req->q; + struct nvme_ns *ns = q->queuedata; + struct block_device *bdev = ns ? ns->disk->part0 : NULL; + struct bio *bio = NULL; + void *meta = NULL; + int ret; + + if (!vec) + ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, + GFP_KERNEL); + else { + struct iovec fast_iov[UIO_FASTIOV]; + struct iovec *iov = fast_iov; + struct iov_iter iter; + + ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, + UIO_FASTIOV, &iov, &iter); + if (ret < 0) goto out; - bio = req->bio; - if (bdev) - bio_set_dev(bio, bdev); - if (bdev && meta_buffer && meta_len) { - meta = nvme_add_user_metadata(req, meta_buffer, - meta_len, meta_seed); - if (IS_ERR(meta)) { - ret = PTR_ERR(meta); - goto out_unmap; - } - *metap = meta; + + ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); + kfree(iov); + } + if (ret) + goto out; + bio = req->bio; + if (bdev) + bio_set_dev(bio, bdev); + + if (bdev && meta_buffer && meta_len) { + meta = nvme_add_user_metadata(req, meta_buffer, meta_len, + meta_seed); + if (IS_ERR(meta)) { + ret = PTR_ERR(meta); + goto out_unmap; } + *metap = meta; } - return req; + return ret; out_unmap: if (bio) blk_rq_unmap_user(bio); out: - blk_mq_free_request(req); - return ERR_PTR(ret); + return ret; } static int nvme_submit_user_cmd(struct request_queue *q, @@ -146,11 +147,18 @@ static int nvme_submit_user_cmd(struct request_queue *q, u32 effects; int ret; - req = nvme_alloc_user_request(q, cmd, ubuffer, bufflen, meta_buffer, - meta_len, meta_seed, &meta, timeout, vec, 0, 0); + req = nvme_alloc_user_request(q, cmd, 0, 0); if (IS_ERR(req)) return PTR_ERR(req); + req->timeout = timeout; + if (ubuffer && bufflen) { + ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer, + meta_len, meta_seed, &meta, vec); + if (ret) + goto out; + } + bio = req->bio; ctrl = nvme_req(req)->ctrl; @@ -163,6 +171,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, meta_len, ret); if (bio) blk_rq_unmap_user(bio); +out: blk_mq_free_request(req); if (effects) @@ -470,6 +479,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, blk_opf_t rq_flags = 0; blk_mq_req_flags_t blk_flags = 0; void *meta = NULL; + int ret; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -509,13 +519,18 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, rq_flags |= REQ_POLLED; retry: - req = nvme_alloc_user_request(q, &c, nvme_to_user_ptr(d.addr), - d.data_len, nvme_to_user_ptr(d.metadata), - d.metadata_len, 0, &meta, d.timeout_ms ? - msecs_to_jiffies(d.timeout_ms) : 0, vec, rq_flags, - blk_flags); + req = nvme_alloc_user_request(q, &c, rq_flags, blk_flags); if (IS_ERR(req)) return PTR_ERR(req); + req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0; + + if (d.addr && d.data_len) { + ret = nvme_map_user_request(req, nvme_to_user_ptr(d.addr), + d.data_len, nvme_to_user_ptr(d.metadata), + d.metadata_len, 0, &meta, vec); + if (ret) + goto out_err; + } if (issue_flags & IO_URING_F_IOPOLL && rq_flags & REQ_POLLED) { if (unlikely(!req->bio)) { @@ -541,6 +556,9 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, } blk_execute_rq_nowait(req, false); return -EIOCBQUEUED; +out_err: + blk_mq_free_request(req); + return ret; } static bool is_ctrl_ioctl(unsigned int cmd) From patchwork Thu Sep 29 12:06:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 572CDC43217 for ; Thu, 29 Sep 2022 12:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235226AbiI2MWl (ORCPT ); Thu, 29 Sep 2022 08:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235106AbiI2MWa (ORCPT ); Thu, 29 Sep 2022 08:22:30 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A1F151DF6 for ; Thu, 29 Sep 2022 05:22:27 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220929122225epoutp048087310e3c22e4000a5dc9fd2760fbd7~ZVDoUX4qU0839708397epoutp04z for ; Thu, 29 Sep 2022 12:22:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220929122225epoutp048087310e3c22e4000a5dc9fd2760fbd7~ZVDoUX4qU0839708397epoutp04z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454145; bh=59MWC7YKVdzgmkE5Wy/YUKyd6wK6AegrnshKeeB/mZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyTLJ5m7GGnjIHSRrKIzjETaPdBWaCWqwzewQ6bqZgO+Qth1AdLWg9RqZ20eLniiR Ehbi0yNZjpnWckcoXd/IEDKKzYIGJGDQHfiIOr/nSU728BKTKr1/Ysavxog9ZjA2Jq J4Njd48Wa2w1WmQsgB5l9motfiJptrOVAFonEOxY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220929122225epcas5p1e8b3a0589c411fefac09641f5004345b~ZVDoA8c2m2788827888epcas5p1b; Thu, 29 Sep 2022 12:22:25 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXYV5438z4x9Pt; Thu, 29 Sep 2022 12:22:22 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C5.D2.26992.EFD85336; Thu, 29 Sep 2022 21:22:22 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220929121647epcas5p2d4ca8ae0b83a1fce230914f586ee3cc0~ZU_s4RNeD2579425794epcas5p2B; Thu, 29 Sep 2022 12:16:47 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121647epsmtrp2a837379cd2f37959172aa4103b7d7299~ZU_s3mBYr1794617946epsmtrp2S; Thu, 29 Sep 2022 12:16:47 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-1c-63358dfe8c16 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 70.3C.18644.EAC85336; Thu, 29 Sep 2022 21:16:46 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121645epsmtip10ef31f1711717eaeaf118834a0438953~ZU_rhjGXU2848328483epsmtip1Y; Thu, 29 Sep 2022 12:16:45 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v11 05/13] block: rename bio_map_put to blk_mq_map_bio_put Date: Thu, 29 Sep 2022 17:36:24 +0530 Message-Id: <20220929120632.64749-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sI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rO7f9FkbRG3t6VCavKPpGNsLmTHlgbOaf/6myX1xIyGxKQ6/bP/CpVWVDcfU2Ipzkg0 1GIuKk4EAAyJtZzkAgAA X-CMS-MailID: 20220929121647epcas5p2d4ca8ae0b83a1fce230914f586ee3cc0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121647epcas5p2d4ca8ae0b83a1fce230914f586ee3cc0 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch renames existing bio_map_put function to blk_mq_map_bio_put. Signed-off-by: Anuj Gupta Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- block/blk-map.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index 7693f8e3c454..d913ef92a9fe 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -231,7 +231,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, return ret; } -static void bio_map_put(struct bio *bio) +static void blk_mq_map_bio_put(struct bio *bio) { if (bio->bi_opf & REQ_ALLOC_CACHE) { bio_put(bio); @@ -331,7 +331,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, out_unmap: bio_release_pages(bio, false); - bio_map_put(bio); + blk_mq_map_bio_put(bio); return ret; } @@ -636,7 +636,7 @@ int blk_rq_unmap_user(struct bio *bio) next_bio = bio; bio = bio->bi_next; - bio_map_put(next_bio); + blk_mq_map_bio_put(next_bio); } return ret; From patchwork Thu Sep 29 12:06:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1D37C4332F for ; Thu, 29 Sep 2022 12:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235106AbiI2MWz (ORCPT ); Thu, 29 Sep 2022 08:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235337AbiI2MWo (ORCPT ); Thu, 29 Sep 2022 08:22:44 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C789149D30 for ; Thu, 29 Sep 2022 05:22:43 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122241epoutp02f4d68fc1155eef19d036e750554c937e~ZVD3eUY0V0536305363epoutp02Z for ; Thu, 29 Sep 2022 12:22:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122241epoutp02f4d68fc1155eef19d036e750554c937e~ZVD3eUY0V0536305363epoutp02Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454162; bh=W5zR9Q+5gEEdrOHdojR8p3L+nHGhst0iy432lBKcQAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMvw68ssrmKCqCH55/LEr672SkNRy7HQE2BMvC3TUnDChfcv6uiGXN3InsbeF06PY Udw6NFinM7gYl+7lJgpikHuVYFPL78IBdhdgB0hVmmcMZ9ZqxGTqmcDQyVa2y1SKo5 3UxCxAceXmy8Jb4oEt2p/Im0rohraxFQpFyEx2Jk= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220929122241epcas5p40b1b249b6595fc7d3b7686a82565f7a2~ZVD2olSB01885818858epcas5p45; Thu, 29 Sep 2022 12:22:41 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MdXYp35QCz4x9Pr; Thu, 29 Sep 2022 12:22:38 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 71.68.39477.E0E85336; Thu, 29 Sep 2022 21:22:38 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220929121650epcas5p424925af86ec6941bb53e5c102fd0ffc8~ZU_vrtSGV2903829038epcas5p44; Thu, 29 Sep 2022 12:16:50 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121650epsmtrp2f9ab656e80b5b3d92c29a895c1679244~ZU_vq_UDM1811218112epsmtrp2F; Thu, 29 Sep 2022 12:16:50 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-d7-63358e0ecd41 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 42.3C.18644.1BC85336; Thu, 29 Sep 2022 21:16:49 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121648epsmtip1869c87726d43726a5bd74fb439227216~ZU_uT09Kl2848328483epsmtip1Z; Thu, 29 Sep 2022 12:16:48 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v11 06/13] block: factor out blk_rq_map_bio_alloc helper Date: Thu, 29 Sep 2022 17:36:25 +0530 Message-Id: <20220929120632.64749-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmpi5fn2mywfw7ohar7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3aL7+g42B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqX rpeXWmJlaGBgZApUmJCdsWx1K3vBCoGKO6tnszUwzuXtYuTkkBAwkdj2tou1i5GLQ0hgN6PE rf99jBDOJ0aJ+WevMUE4nxklHnyaClTGAdbyY6MLSLeQwC5GiV9f1eBqtmxfzgqSYBNQlzjy vJURxBYRMJLY/+kk2ApmgS2MEs3rFrODJIQFgiUOd+xjAbFZBFQlpq++ygZi8wpYSizYM5EN 4j55iZmXvoPVcwpYSSy+NocVokZQ4uTMJ2C9zEA1zVtnM4MskBD4yy6x5ekrFohmF4klbz6z QtjCEq+Ob2GHsKUkPr/bC7UgXeLH5adMEHaBRPOxfYwQtr1E66l+ZpCPmQU0Jdbv0ocIy0pM PbWOCWIvn0Tv7ydQrbwSO+bB2EoS7SvnQNkSEnvPNTBBAs5D4t4sXUhg9TJKXH+8hWkCo8Is JO/MQvLOLITNCxiZVzFKphYU56anFpsWGOWllsMjOTk/dxMjOJVqee1gfPjgg94hRiYOxkOM EhzMSiK84gWmyUK8KYmVValF+fFFpTmpxYcYTYHhPZFZSjQ5H5jM80riDU0sDUzMzMxMLI3N DJXEeRfP0EoWEkhPLEnNTk0tSC2C6WPi4JRqYNJiSlq67Py2Ddv1Gj6Xx0e/tuO2Zuf/WaRg spOlizkvLchl9ZVDRcmX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nnjZwOlyvKs H5L8xuKOHNZv1B/9sf8QPyVGPdHyyEQTaxUrJX895WxV1YwjIvkfb3/bmPjss/7dvx1+/9ZM WGnb+J0xJGU1y8Pn5YczZ/2ynXw7bn3+8/7EtSXFav/MQtW7C/J2H17korNB63rB8R38L4sT HuxJ0674H+SftPyHSoRMp42LYnjA2tdT9A2zcrsXH6k8ODmpTqYu+tpyO/+ut4cnim/4ocRS nJFoqMVcVJwIANeXzsTlAgAA X-CMS-MailID: 20220929121650epcas5p424925af86ec6941bb53e5c102fd0ffc8 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121650epcas5p424925af86ec6941bb53e5c102fd0ffc8 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi Move bio allocation logic from bio_map_user_iov to a new helper blk_rq_map_bio_alloc. It is named so because functionality is opposite of what is done inside blk_mq_map_bio_put. This is a prep patch. Signed-off-by: Kanchan Joshi --- block/blk-map.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index d913ef92a9fe..9e37a03b8a21 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -241,17 +241,10 @@ static void blk_mq_map_bio_put(struct bio *bio) } } -static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, - gfp_t gfp_mask) +static struct bio *blk_rq_map_bio_alloc(struct request *rq, + unsigned int nr_vecs, gfp_t gfp_mask) { - unsigned int max_sectors = queue_max_hw_sectors(rq->q); - unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS); struct bio *bio; - int ret; - int j; - - if (!iov_iter_count(iter)) - return -EINVAL; if (rq->cmd_flags & REQ_POLLED) { blk_opf_t opf = rq->cmd_flags | REQ_ALLOC_CACHE; @@ -259,13 +252,31 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, bio = bio_alloc_bioset(NULL, nr_vecs, opf, gfp_mask, &fs_bio_set); if (!bio) - return -ENOMEM; + return NULL; } else { bio = bio_kmalloc(nr_vecs, gfp_mask); if (!bio) - return -ENOMEM; + return NULL; bio_init(bio, NULL, bio->bi_inline_vecs, nr_vecs, req_op(rq)); } + return bio; +} + +static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, + gfp_t gfp_mask) +{ + unsigned int max_sectors = queue_max_hw_sectors(rq->q); + unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS); + struct bio *bio; + int ret; + int j; + + if (!iov_iter_count(iter)) + return -EINVAL; + + bio = blk_rq_map_bio_alloc(rq, nr_vecs, gfp_mask); + if (bio == NULL) + return -ENOMEM; while (iov_iter_count(iter)) { struct page **pages, *stack_pages[UIO_FASTIOV]; From patchwork Thu Sep 29 12:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04963C4332F for ; Thu, 29 Sep 2022 12:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235399AbiI2MXI (ORCPT ); Thu, 29 Sep 2022 08:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235337AbiI2MXC (ORCPT ); Thu, 29 Sep 2022 08:23:02 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67F21514E3 for ; Thu, 29 Sep 2022 05:23:01 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220929122300epoutp014bf6aa4de4138b87c9f5b6f32c3a86f3~ZVEIbRYAe0295802958epoutp01T for ; Thu, 29 Sep 2022 12:23:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220929122300epoutp014bf6aa4de4138b87c9f5b6f32c3a86f3~ZVEIbRYAe0295802958epoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454180; bh=ab9DY8Ucw3isFXw+5koECtKHmSq1jktgfR1i7oX2zNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kIxsGOzk43hZ4FR6MdIQdNsfAV/c9pdYuYG7Zs2BsE3kg/gf1HE5TX3A3m7Xn2ncM RvkUCarzJZn2aiKxu5R3u+3Il3pd1k4jX8o2Ajb6EFluPaTAg7kF/pUabBzLSxz+MK Bualfrd+1Kb3TqmLMe/kjX2YDRFE3RXZisjkCe5M= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220929122259epcas5p2319827770a29f624a0c4b149ff9c3913~ZVEH8d-Z82677026770epcas5p2I; Thu, 29 Sep 2022 12:22:59 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MdXZ91kJMz4x9Px; Thu, 29 Sep 2022 12:22:57 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 2D.68.39477.12E85336; Thu, 29 Sep 2022 21:22:57 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220929121653epcas5p4ee82ef35b46d6686820dc4d870b6588e~ZU_zPDYV93131131311epcas5p4x; Thu, 29 Sep 2022 12:16:53 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220929121653epsmtrp146a3953021124a5b36115e448a9ac939~ZU_zN3BoZ1820918209epsmtrp1U; Thu, 29 Sep 2022 12:16:53 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-0e-63358e2188fd Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 03.3C.18644.5BC85336; Thu, 29 Sep 2022 21:16:53 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121652epsmtip1b55397e978a4316537867fb857c255af~ZU_xupW4Q2919929199epsmtip1C; Thu, 29 Sep 2022 12:16:52 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v11 07/13] block: add blk_rq_map_user_bvec Date: Thu, 29 Sep 2022 17:36:26 +0530 Message-Id: <20220929120632.64749-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHJsWRmVeSWpSXmKPExsWy7bCmpq5in2mywZdnHBZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2i+7rO9gcuDwuny312LSqk81j 85J6j903G9g8+rasYvT4vEkugC0q2yYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJc SSEvMTfVVsnFJ0DXLTMH6C4lhbLEnFKgUEBicbGSvp1NUX5pSapCRn5xia1SakFKToFJgV5x Ym5xaV66Xl5qiZW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5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFsUl01Kak5mWWqRvl0CV0b/pYOsBU0iFQe++DQwNgt0MXJy SAiYSLRPmsQCYgsJ7GCUODvdEiIuIXHq5TJGCFtYYuW/5+wQNR8ZJT5u8AGx2QTUJY48bwWr EREwk1h6eA3QHC4OZoH7jBJvm3eDDRUWcJbo+rOWDcRmEVCVmL5pFtAgDg5eAUuJD3NSIObL S8y89B1sPqeAlcTia3NYQUqEgEq231QACfMKCEqcnPkEbCIzUHnz1tnMExgFZiFJzUKSWsDI tIpRMrWgODc9t9iwwCgvtVyvODG3uDQvXS85P3cTIzjgtbR2MO5Z9UHvECMTB+MhRgkOZiUR XvEC02Qh3pTEyqrUovz4otKc1OJDjNIcLErivBe6TsYLCaQnlqRmp6YWpBbBZJk4OKUamDpv v17m0fjETqk0Wvl5I//txQqmNudU/rQr6OVX9ciVPMv5/+bX5hULQs4GnU277HjLhK0jYEqr yXuTb7Vq1vvdLudNOTB7YvkDGd6bK92v7ypqyl9ku7T/0JOS6zqd7wLuz5JYIF7g8/jm9b3J a1l6nR9eE+YKuFvH+fVMgse02q1fuZgPPry0d6fbqo8ph4Ua9oZfOibe9YdzjTpfeuXhi7Z7 mxbZF+dyvTls5eW7/I9iRMOhHXd/2AoVH3/b3TznanxrzJc/Uunr377MNH3iKr7DPv1hybGJ CZLlEisFI/JPrfrt0N1QGma1IWPiLMkPOouT3MQbHQ5sf/WwS93p/p6JdyJ7xHr+z1UrDlVi Kc5INNRiLipOBAAtRurN5wIAAA== X-CMS-MailID: 20220929121653epcas5p4ee82ef35b46d6686820dc4d870b6588e X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121653epcas5p4ee82ef35b46d6686820dc4d870b6588e References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi This is a prep patch. This function maps the pages from bvec iterator into a bio and place the bio into request. This helper will be used by nvme for uring-passthrough path when IO is done using pre-mapped buffers. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta Suggested-by: Christoph Hellwig --- block/blk-map.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index 9e37a03b8a21..023b63ad06d8 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -548,6 +548,62 @@ int blk_rq_append_bio(struct request *rq, struct bio *bio) } EXPORT_SYMBOL(blk_rq_append_bio); +/* Prepare bio for passthrough IO given ITER_BVEC iter */ +static int blk_rq_map_user_bvec(struct request *rq, const struct iov_iter *iter) +{ + struct request_queue *q = rq->q; + size_t nr_iter = iov_iter_count(iter); + size_t nr_segs = iter->nr_segs; + struct bio_vec *bvecs, *bvprvp = NULL; + struct queue_limits *lim = &q->limits; + unsigned int nsegs = 0, bytes = 0; + struct bio *bio; + size_t i; + + if (!nr_iter || (nr_iter >> SECTOR_SHIFT) > queue_max_hw_sectors(q)) + return -EINVAL; + if (nr_segs > queue_max_segments(q)) + return -EINVAL; + + /* no iovecs to alloc, as we already have a BVEC iterator */ + bio = blk_rq_map_bio_alloc(rq, 0, GFP_KERNEL); + if (bio == NULL) + return -ENOMEM; + + bio_iov_bvec_set(bio, (struct iov_iter *)iter); + blk_rq_bio_prep(rq, bio, nr_segs); + + /* loop to perform a bunch of sanity checks */ + bvecs = (struct bio_vec *)iter->bvec; + for (i = 0; i < nr_segs; i++) { + struct bio_vec *bv = &bvecs[i]; + + /* + * If the queue doesn't support SG gaps and adding this + * offset would create a gap, fallback to copy. + */ + if (bvprvp && bvec_gap_to_prev(lim, bvprvp, bv->bv_offset)) { + blk_mq_map_bio_put(bio); + return -EREMOTEIO; + } + /* check full condition */ + if (nsegs >= nr_segs || bytes > UINT_MAX - bv->bv_len) + goto put_bio; + if (bytes + bv->bv_len > nr_iter) + goto put_bio; + if (bv->bv_offset + bv->bv_len > PAGE_SIZE) + goto put_bio; + + nsegs++; + bytes += bv->bv_len; + bvprvp = bv; + } + return 0; +put_bio: + blk_mq_map_bio_put(bio); + return -EINVAL; +} + /** * blk_rq_map_user_iov - map user data to a request, for passthrough requests * @q: request queue where request should be inserted From patchwork Thu Sep 29 12:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B465C433F5 for ; Thu, 29 Sep 2022 12:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbiI2MX3 (ORCPT ); Thu, 29 Sep 2022 08:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235307AbiI2MXP (ORCPT ); Thu, 29 Sep 2022 08:23:15 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 839AC149D0C for ; Thu, 29 Sep 2022 05:23:13 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122312epoutp02321b19f0b489876ce73f3f4ef2a88165~ZVETbgN-60549605496epoutp02c for ; Thu, 29 Sep 2022 12:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122312epoutp02321b19f0b489876ce73f3f4ef2a88165~ZVETbgN-60549605496epoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454192; bh=jJ27zbCLEceaklctu22+6qXhghsfenDH5+qFluqe48M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pcRsGUKlt8XdiDeibBEtqxznANL6buO635EIJBSt9Y3v2xIgTKabDFYlp+NduBk91 bxMgarJAO5AkxFACzagdXH53PJR8E94ahFIrPCuV8afmh8s1EpwAqWmCsJeio2QQgE 3U0vc+abIR6e5LAb4PH1Uf/xHPErJ0S8sthDnqLg= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122311epcas5p308d2641ec13b884de5460d42442fa9aa~ZVES-F8vR2720827208epcas5p3D; Thu, 29 Sep 2022 12:23:11 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.174]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXZN58T7z4x9Pw; Thu, 29 Sep 2022 12:23:08 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 5E.78.39477.C2E85336; Thu, 29 Sep 2022 21:23:08 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220929121657epcas5p213b7a187fd77b0783adb4b9389579b44~ZU_21iE6w2731427314epcas5p2Q; Thu, 29 Sep 2022 12:16:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121657epsmtrp2cdc61ec37973b43a2f5c47929c60e46d~ZU_20zlB81794617946epsmtrp2b; Thu, 29 Sep 2022 12:16:57 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-34-63358e2c03df Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 46.43.14392.9BC85336; Thu, 29 Sep 2022 21:16:57 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121656epsmtip18e8b2a9c803d0c673f2d5d6e3dbbb534~ZU_1aCYLx3141831418epsmtip1n; Thu, 29 Sep 2022 12:16:56 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v11 08/13] block: extend functionality to map bvec iterator Date: Thu, 29 Sep 2022 17:36:27 +0530 Message-Id: <20220929120632.64749-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEJsWRmVeSWpSXmKPExsWy7bCmpq5On2mywYJr6hZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2i+7rO9gcuDwuny312LSqk81j 85J6j903G9g8+rasYvT4vEkugC0q2yYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJc SSEvMTfVVsnFJ0DXLTMH6C4lhbLEnFKgUEBicbGSvp1NUX5pSapCRn5xia1SakFKToFJgV5x Ym5xaV66Xl5qiZWhgYGRKVBhQnbGgzmbGQuO81T0LH/N2sD4i7OLkZNDQsBEonX7cdYuRi4O IYHdjBKfD7xmgnA+MUpMeraQEcL5xihx7uQvVpiWdWf+s0Mk9jJKfFv7EqrlM6PEopV7WECq 2ATUJY48b2UEsUUEjCT2fzoJtoRZ4CajRPOxfUwgCWGBMIn3e+6CFbEIqEqc/nodyObg4BWw lHiyOR1im7zEzEvf2UFsTgEricXX5oBdwSsgKHFy5hOwXcxANc1b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GSXeNu9mAUkIC4RI7Li/H8xmEVCVOP31OlADBwevgKXEk83p EAvkJWZe+s4OYnMKWEksvjaHFaRECKhk+00FkDCvgKDEyZlPwKYwA5U3b53NPIFRYBaS1Cwk qQWMTKsYJVMLinPTc4sNCwzzUsv1ihNzi0vz0vWS83M3MYLDXktzB+P2VR/0DjEycTAeYpTg YFYS4RUvME0W4k1JrKxKLcqPLyrNSS0+xCjNwaIkznuh62S8kEB6YklqdmpqQWoRTJaJg1Oq gcmukzFpI9N8NbUFzbp8kmy3Td8xdD/VzXn5Vq1/i27EKp0cp/8WvF7ndHo7Hz2Y9dmcKyfz avr7ujXMhlV+z7S3cc1d2V4ldOGSf+GFh+L8zsLyPrEnP1R3nf8XdU9o9d1m212vSnIDf9Qs 4ym7NrVZhU887/ALo57zVb5tkZlLOA5Ou/e7W7dILeRMsmT+LON305oWLTcw/vri4udn23fl H5jZlHFH8vnklE9fpvQd+PcjL1OssnDfgvVMyaYr3SZpHz8oZMRz9bFKsb24lctEvSfWceoa 2q/nuVzie6Kmxplwf/Ill3NZD3ySP1x5Y7FQNeLsz12Td8eaPFT6oDZzp7RnTKXqkgvHNpr2 KSqxFGckGmoxFxUnAgAmrHG16gIAAA== X-CMS-MailID: 20220929121657epcas5p213b7a187fd77b0783adb4b9389579b44 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121657epcas5p213b7a187fd77b0783adb4b9389579b44 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi Extend blk_rq_map_user_iov so that it can handle bvec iterator, using the new blk_rq_map_user_bvec function. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Suggested-by: Christoph Hellwig --- block/blk-map.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index 023b63ad06d8..ffab5d2d8d6d 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -623,24 +623,35 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, struct rq_map_data *map_data, const struct iov_iter *iter, gfp_t gfp_mask) { - bool copy = false; + bool copy = false, map_bvec = false; unsigned long align = q->dma_pad_mask | queue_dma_alignment(q); struct bio *bio = NULL; struct iov_iter i; int ret = -EINVAL; - if (!iter_is_iovec(iter)) - goto fail; - if (map_data) copy = true; else if (blk_queue_may_bounce(q)) copy = true; else if (iov_iter_alignment(iter) & align) copy = true; + else if (iov_iter_is_bvec(iter)) + map_bvec = true; + else if (!iter_is_iovec(iter)) + copy = true; else if (queue_virt_boundary(q)) copy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter); + if (map_bvec) { + ret = blk_rq_map_user_bvec(rq, iter); + if (!ret) + return 0; + if (ret != -EREMOTEIO) + goto fail; + /* fall back to copying the data on limits mismatches */ + copy = true; + } + i = *iter; do { if (copy) From patchwork Thu Sep 29 12:06:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E734C4332F for ; Thu, 29 Sep 2022 12:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235597AbiI2MYB (ORCPT ); Thu, 29 Sep 2022 08:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbiI2MXx (ORCPT ); Thu, 29 Sep 2022 08:23:53 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D212148A12 for ; Thu, 29 Sep 2022 05:23:50 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122349epoutp027c4098d85282381b236288c2dbe218d7~ZVE16tmdl0892808928epoutp02B for ; Thu, 29 Sep 2022 12:23:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122349epoutp027c4098d85282381b236288c2dbe218d7~ZVE16tmdl0892808928epoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454229; bh=Z3PK6vAIkjNPzydQ/3AsMAslieosT5m/aEKA82hKphM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHKbEL1KxLa8P//t0vJPASre+DzaD8H0tP+CdK0+52mDetufmcUMXJEyQu+5+diwP olICtNZ6rymYC6CPVCwbhyfrijMaHD+CgXfmE8yS0gPQeksiFXcg+vYEIORxIOWjJZ osvDc6l5YAr3LdraBe9orVgHEjV9efXFKV+bLfXM= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122348epcas5p34e0fb4decac1005f3080c4ab016d5946~ZVE1XEd_10262002620epcas5p3X; Thu, 29 Sep 2022 12:23:48 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.178]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MdXb51Dhtz4x9Q1; Thu, 29 Sep 2022 12:23:45 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id FD.9F.56352.15E85336; Thu, 29 Sep 2022 21:23:45 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220929121701epcas5p287a6d3f851626a5c7580d9a534432e9b~ZU_6oC5ll2579425794epcas5p2S; Thu, 29 Sep 2022 12:17:01 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121701epsmtrp2a681b5bef377744050439db211fd039b~ZU_6mGWvn1794617946epsmtrp2f; Thu, 29 Sep 2022 12:17:01 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-42-63358e511047 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E7.43.14392.DBC85336; Thu, 29 Sep 2022 21:17:01 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121700epsmtip1034d1120294b80632ca910941a802a1f~ZU_5LcNVb3029530295epsmtip1A; Thu, 29 Sep 2022 12:17:00 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v11 09/13] nvme: pass ubuffer as an integer Date: Thu, 29 Sep 2022 17:36:28 +0530 Message-Id: <20220929120632.64749-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmlm5gn2mywdbXbBZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2i+7rO9gcuDwuny312LSqk81j 85J6j903G9g8+rasYvT4vEkugC0q2yYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJc SSEvMTfVVsnFJ0DXLTMH6C4lhbLEnFKgUEBicbGSv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SnO7eHtNkgzPfNC2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFsUl01Kak5mWWqRvl0CV8bRW3NZCh5KVVw7e5m5gbFbrIuR k0NCwETi9aNXTF2MXBxCArsZJa7eWskEkZCQOPVyGSOELSyx8t9zdoiij4wSE64fYwFJsAmo Sxx53gpWJCJgJrH08BoWkCJmgfuMEm+bd4MVCQu4SBzYv44NxGYRUJX49uo2O4jNK2AlsfXk CWaIDfISMy99B4tzAsUXX5vD2sXIAbTNUmL7TQWIckGJkzOfgI1kBipv3jqbeQKjwCwkqVlI UgsYmVYxSqYWFOem5xYbFhjmpZbrFSfmFpfmpesl5+duYgQHvpbmDsbtqz7oHWJk4mA8xCjB wawkwiteYJosxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dU A9OJmyZWqXqJ9u9VPJ92ih+bVNTO7iNXuOnd6m+6dmdWv5Gx7FuztOAsf+M1lxen2K86GXgz 2LqWFutadhW3zXu1aAE7T/7xvZ1aZt/0e3p+2GzkdmHNXBHCm7egeTv3qV0erm5tWQJ94tPf vZt+f4XmpY/7/9TPux/1S3zDFucGqf0OVfc26f3ZJZW/24nx66qcckWrB4zie8W0lhxzk/kj U/q6LGKO3ZoXGw5Gma4VWODLsO6JgvsvCSPFY9W/5yzribv/hbd8yrSu8vfdHumMcU7bfrXv Vikx+7v54QfGDO3w4M+xt6fJK86f1Oa3SvSF5KrCKVMaecTZNTaz1laev9fIp1hnw7ZIraLq mxJLcUaioRZzUXEiAJBoCtzrAgAA X-CMS-MailID: 20220929121701epcas5p287a6d3f851626a5c7580d9a534432e9b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121701epcas5p287a6d3f851626a5c7580d9a534432e9b References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi This is a prep patch. Modify nvme_submit_user_cmd and nvme_map_user_request to take ubuffer as plain integer argument, and do away with nvme_to_user_ptr conversion in callers. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 0143f62b27c2..4a7e45a263b6 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -83,9 +83,10 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, return req; } -static int nvme_map_user_request(struct request *req, void __user *ubuffer, +static int nvme_map_user_request(struct request *req, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, - u32 meta_seed, void **metap, bool vec) + u32 meta_seed, void **metap, struct io_uring_cmd *ioucmd, + bool vec) { struct request_queue *q = req->q; struct nvme_ns *ns = q->queuedata; @@ -136,7 +137,7 @@ static int nvme_map_user_request(struct request *req, void __user *ubuffer, } static int nvme_submit_user_cmd(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, + struct nvme_command *cmd, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, u64 *result, unsigned timeout, bool vec) { @@ -154,7 +155,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, req->timeout = timeout; if (ubuffer && bufflen) { ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer, - meta_len, meta_seed, &meta, vec); + meta_len, meta_seed, &meta, NULL, vec); if (ret) goto out; } @@ -239,7 +240,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) c.rw.appmask = cpu_to_le16(io.appmask); return nvme_submit_user_cmd(ns->queue, &c, - nvme_to_user_ptr(io.addr), length, + io.addr, length, metadata, meta_len, lower_32_bits(io.slba), NULL, 0, false); } @@ -293,7 +294,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &result, timeout, false); @@ -339,7 +340,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &cmd.result, timeout, vec); @@ -525,9 +526,9 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0; if (d.addr && d.data_len) { - ret = nvme_map_user_request(req, nvme_to_user_ptr(d.addr), + ret = nvme_map_user_request(req, d.addr, d.data_len, nvme_to_user_ptr(d.metadata), - d.metadata_len, 0, &meta, vec); + d.metadata_len, 0, &meta, ioucmd, vec); if (ret) goto out_err; } From patchwork Thu Sep 29 12:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC382C43217 for ; Thu, 29 Sep 2022 12:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235044AbiI2MYV (ORCPT ); Thu, 29 Sep 2022 08:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235623AbiI2MYF (ORCPT ); Thu, 29 Sep 2022 08:24:05 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F3A153A66 for ; Thu, 29 Sep 2022 05:24:03 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122401epoutp02f4be03968c48f70338c1ac6f62c9a254~ZVFBs2zH30890308903epoutp02I for ; Thu, 29 Sep 2022 12:24:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122401epoutp02f4be03968c48f70338c1ac6f62c9a254~ZVFBs2zH30890308903epoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454241; bh=Ed9XhutZ9yja1KBK7s/NhIde4D4RLW0LgjBzhdzQQuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AbeZZLbV7rjhuUgAGZYFSbJUzaZAYr0NDNhFvHdBwqyjjMuBErrQC/nXj4Tz33JDP 5Qv3DsOK/BmYKSS3hNZw585qqhhsgN/ZnTNq0gOqS53dbL3odVqthA2+YkE3U+njES ZtF1f8LaVcvOwRwi/KY+lWnLr2ASnvrIYkl96/rE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122400epcas5p39665fba01ab3370f40e476dd3bd9b128~ZVFA43Ipd1893018930epcas5p3K; Thu, 29 Sep 2022 12:24:00 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MdXbL71dVz4x9Pv; Thu, 29 Sep 2022 12:23:58 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id D3.AF.56352.E5E85336; Thu, 29 Sep 2022 21:23:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220929121704epcas5p3415fd4782cbcffa7b1e6ddf774bebb03~ZU_9bhHI91775017750epcas5p3N; Thu, 29 Sep 2022 12:17:04 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121704epsmtrp205ece237de06921f9d1411640ee76168~ZU_9ZoCzH1811218112epsmtrp2a; Thu, 29 Sep 2022 12:17:04 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-61-63358e5e3185 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id DA.43.14392.0CC85336; Thu, 29 Sep 2022 21:17:04 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121703epsmtip189c153b1e68dc628dac9008781c8f1ed~ZU_8CDj-x3141831418epsmtip1p; Thu, 29 Sep 2022 12:17:03 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v11 10/13] nvme: wire up fixed buffer support for nvme passthrough Date: Thu, 29 Sep 2022 17:36:29 +0530 Message-Id: <20220929120632.64749-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+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t3+Y2fYFVFm Z75+NYZpnqpuMms/9/X1ql9j4mav8rdMPbc7QtYsh/v3gpDW5nNPJnEZVq05OyPZsT5YZoUS S3FGoqEWc1FxIgBJBL7I5AIAAA== X-CMS-MailID: 20220929121704epcas5p3415fd4782cbcffa7b1e6ddf774bebb03 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121704epcas5p3415fd4782cbcffa7b1e6ddf774bebb03 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Kanchan Joshi if io_uring sends passthrough command with IORING_URING_CMD_FIXED flag, use the pre-registered buffer for IO (non-vectored variant). Pass the buffer/length to io_uring and get the bvec iterator for the range. Next, pass this bvec to block-layer and obtain a bio/request for subsequent processing. Signed-off-by: Kanchan Joshi Suggested-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 4a7e45a263b6..25a68e8c60db 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -95,21 +95,31 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, void *meta = NULL; int ret; - if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - GFP_KERNEL); - else { + if (ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED)) { + struct iov_iter iter; + + /* fixedbufs is only for non-vectored io */ + if (WARN_ON_ONCE(vec)) + return -EINVAL; + ret = io_uring_cmd_import_fixed(ubuffer, bufflen, + rq_data_dir(req), &iter, ioucmd); + if (ret < 0) + goto out; + ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); + } else if (vec) { struct iovec fast_iov[UIO_FASTIOV]; struct iovec *iov = fast_iov; struct iov_iter iter; - ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, - UIO_FASTIOV, &iov, &iter); + ret = import_iovec(rq_data_dir(req), nvme_to_user_ptr(ubuffer), + bufflen, UIO_FASTIOV, &iov, &iter); if (ret < 0) goto out; - ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); kfree(iov); + } else { + ret = blk_rq_map_user(q, req, NULL, + nvme_to_user_ptr(ubuffer), bufflen, GFP_KERNEL); } if (ret) goto out; From patchwork Thu Sep 29 12:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EA4BC4332F for ; Thu, 29 Sep 2022 12:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235489AbiI2MYi (ORCPT ); Thu, 29 Sep 2022 08:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235643AbiI2MYZ (ORCPT ); Thu, 29 Sep 2022 08:24:25 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF0A155670 for ; Thu, 29 Sep 2022 05:24:21 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220929122419epoutp0475425b5a30162baf769ecb6ff547289b~ZVFSXzKnK0839708397epoutp04c for ; Thu, 29 Sep 2022 12:24:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220929122419epoutp0475425b5a30162baf769ecb6ff547289b~ZVFSXzKnK0839708397epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454259; bh=DG6Zpqd4/2UP5P9wNBGWZp+XVTct8fbhkANYJQeAaWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkPxDG9X5ggsvQlXwhF84sAkM9npi+AjUglAjre3Rlti6aPu5JH6AYyjI+oauXkp4 ddOFQRYf7e2a+Agkf6PNI8kY9NITeR3UUKvT5GQ+ea1FbdfcNqNCIyLv/l60HzvWNh 4ho18VSqotQGwYpJ0mcf0BYrvN79z0jv4YEdO92g= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122419epcas5p3ab50085349aa2d4f199397ae8060aac2~ZVFR8zI0j1893118931epcas5p3n; Thu, 29 Sep 2022 12:24:19 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MdXbh5h5Tz4x9Pt; Thu, 29 Sep 2022 12:24:16 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F5.33.26992.E6E85336; Thu, 29 Sep 2022 21:24:14 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220929121709epcas5p325553d10a7ada7717c2f51ddb566a3e5~ZU-BsZpoH1999119991epcas5p3-; Thu, 29 Sep 2022 12:17:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121709epsmtrp270ba0d78c1d27006505094c47795e360~ZU-BriPFm1811218112epsmtrp2i; Thu, 29 Sep 2022 12:17:09 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-48-63358e6eda74 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4C.43.14392.5CC85336; Thu, 29 Sep 2022 21:17:09 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121707epsmtip127b90fef27a1a68fece6a7d250645b96~ZU-ATJ1Xi3029530295epsmtip1D; Thu, 29 Sep 2022 12:17:07 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v11 11/13] block: add blk_rq_map_user_io Date: Thu, 29 Sep 2022 17:36:30 +0530 Message-Id: <20220929120632.64749-12-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDJsWRmVeSWpSXmKPExsWy7bCmum5+n2mywUkBi6YJf5ktVt/tZ7O4 eWAnk8XK1UeZLN61nmOxmHToGqPF3lvaFvOXPWW36L6+g82B0+Py2VKPTas62Tw2L6n32H2z gc2jb8sqRo/Pm+QC2KKybTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwMdQ0tLcyVFPISc1Nt lVx8AnTdMnOALlJSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2CqlFqTkFJgU6BUn5haX5qXr 5aWWWBkaGBiZAhUmZGdsbf/HWHBZqOLIo4PsDYzt/F2MnBwSAiYSkzZsYe9i5OIQEtjNKPH6 8RFmCOcTo8TMji2MEM43IGdqLxNMy7y9d6Cq9jJKPJm1GqrqM6PEkW3PWECq2ATUJY48b2UE sUUEjCT2fzrJClLELLCJUeLX9WNgo4QFHCX23/wKZrMIqErsXDMLrJlXwEpi98qvrBDr5CVm XvrODmJzAsUXX5v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XsMCUsQssINRYt2zxWAJYQFHif03vzKB2CwCqhI718xiAbF5Bawkdq/8ygqxQV5i 5qXv7CA2J1B88bU5QHEOoG2WEttvKkCUC0qcnPkErJUZqLx562zmCYwCs5CkZiFJLWBkWsUo mVpQnJueW2xYYJiXWq5XnJhbXJqXrpecn7uJERzuWpo7GLev+qB3iJGJg/EQowQHs5IIr3iB abIQb0piZVVqUX58UWlOavEhRmkOFiVx3gtdJ+OFBNITS1KzU1MLUotgskwcnFINTJbtF889 Uj91Q1OaZyXbHZG/C+95Hti6J7PwSsvx5LS9rb4iDhuNneL4QiYbtx+r2tF3+rHJwpSQVLZv TP0m4d3La55qq2/e56qWGqrz9sfJnpKVnbaZx6/JHAq4+9TR0SPL/L3u9rLsb+Z3DmyZYr/C j2PXkt9r+t8Lr+zftdfWz1tJqdzTN+M+27+vf/IFNO8dTU6NUN6Y9OyG8erKled0K3bPEjQz ClQ7cudZkn5f1eN698tTqm9Jh733/6xT/3Dr+2fC7vyx7j2iL7Oe1emZtU/k4nnoeVj/kO3a UL/8N/w5jfM37Poq0D0//vnNn4L2v8/FTJTLcPhUwPJPjIE7d8Xjl5mHvWdcWrSpQImlOCPR UIu5qDgRACr5wZ/mAgAA X-CMS-MailID: 20220929121709epcas5p325553d10a7ada7717c2f51ddb566a3e5 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121709epcas5p325553d10a7ada7717c2f51ddb566a3e5 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Create a helper blk_rq_map_user_io for mapping of vectored as well as non-vectored requests. This will help in saving dupilcation of code at few places in scsi and nvme. Signed-off-by: Anuj Gupta Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- block/blk-map.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index ffab5d2d8d6d..74ee496c2d3a 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -689,6 +689,42 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, } EXPORT_SYMBOL(blk_rq_map_user); +int blk_rq_map_user_io(struct request *req, struct rq_map_data *map_data, + void __user *ubuf, unsigned long buf_len, gfp_t gfp_mask, + bool vec, int iov_count, bool check_iter_count, int rw) +{ + int ret; + + if (vec) { + struct iovec fast_iov[UIO_FASTIOV]; + struct iovec *iov = fast_iov; + struct iov_iter iter; + + ret = import_iovec(rw, ubuf, iov_count ? iov_count : buf_len, + UIO_FASTIOV, &iov, &iter); + if (ret < 0) + return ret; + + if (iov_count) { + /* SG_IO howto says that the shorter of the two wins */ + iov_iter_truncate(&iter, buf_len); + if (check_iter_count && !iov_iter_count(&iter)) { + kfree(iov); + return -EINVAL; + } + } + + ret = blk_rq_map_user_iov(req->q, req, map_data, &iter, + gfp_mask); + kfree(iov); + } else if (buf_len) { + ret = blk_rq_map_user(req->q, req, map_data, ubuf, buf_len, + gfp_mask); + } + return ret; +} +EXPORT_SYMBOL(blk_rq_map_user_io); + /** * blk_rq_unmap_user - unmap a request with user data * @bio: start of bio list diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 50811d0fb143..ba18e9bdb799 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -985,6 +985,8 @@ struct rq_map_data { int blk_rq_map_user(struct request_queue *, struct request *, struct rq_map_data *, void __user *, unsigned long, gfp_t); +int blk_rq_map_user_io(struct request *, struct rq_map_data *, + void __user *, unsigned long, gfp_t, bool, int, bool, int); int blk_rq_map_user_iov(struct request_queue *, struct request *, struct rq_map_data *, const struct iov_iter *, gfp_t); int blk_rq_unmap_user(struct bio *); From patchwork Thu Sep 29 12:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42EA5C433FE for ; Thu, 29 Sep 2022 12:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235571AbiI2MY4 (ORCPT ); Thu, 29 Sep 2022 08:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235584AbiI2MYs (ORCPT ); Thu, 29 Sep 2022 08:24:48 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BACB5FF7 for ; Thu, 29 Sep 2022 05:24:40 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122438epoutp029be279f32c106c7ddc396e5e16b9517f~ZVFkDRvH80891208912epoutp02S for ; Thu, 29 Sep 2022 12:24:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122438epoutp029be279f32c106c7ddc396e5e16b9517f~ZVFkDRvH80891208912epoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454278; bh=4MDUpwx2cUKu3o31e+4s7CnsnjvHszXB+w2SZxN5EHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L66dUsFa33zMXCDswdpFl1ZYboNr5wVc9KGajep4gf2M7462YYmbwZQ48ORropBMH ac2UBFijoDUjHE0iC/WHXfhHg6PFMwudcPR8G4g+X2XBIo43J48AP7eiRNv48MZ4xX 58P6cJB0VtEHcnG2xa9i6lnni2hHSx0RHG7awzwM= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220929122438epcas5p323a706d2e2e034d7d3b8a0ef3a7f83be~ZVFjjIG180990309903epcas5p3I; Thu, 29 Sep 2022 12:24:38 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MdXc36kJ6z4x9Pr; Thu, 29 Sep 2022 12:24:35 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E6.B8.39477.38E85336; Thu, 29 Sep 2022 21:24:35 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220929121713epcas5p1824ed0c48c9e9ceeb18954d9c23564ed~ZU-FJDhK41192111921epcas5p1o; Thu, 29 Sep 2022 12:17:13 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220929121713epsmtrp2a12d60bc0823694167ede69c347c2c74~ZU-FIT3MK1942419424epsmtrp2F; Thu, 29 Sep 2022 12:17:13 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-1a-63358e83c5db Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4E.43.14392.8CC85336; Thu, 29 Sep 2022 21:17:12 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121711epsmtip17062c4deb706c2bfbfcf817e4a18c8ea~ZU-D1tCru3028230282epsmtip10; Thu, 29 Sep 2022 12:17:11 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v11 12/13] scsi: Use blk_rq_map_user_io helper Date: Thu, 29 Sep 2022 17:36:31 +0530 Message-Id: <20220929120632.64749-13-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmpm5zn2mywaM2Y4umCX+ZLVbf7Wez uHlgJ5PFytVHmSzetZ5jsZh06Bqjxd5b2hbzlz1lt+i+voPNgdPj8tlSj02rOtk8Ni+p99h9 s4HNo2/LKkaPz5vkAtiism0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNT bZVcfAJ03TJzgE5SUihLzCkFCgUkFhcr6dvZFOWXlqQqZOQXl9gqpRak5BSYFOgVJ+YWl+al 6+WlllgZGhgYmQIVJmRnnLt8ja3gh2DFu01XGRsYV/F1MXJySAiYSNxd/4iti5GLQ0hgN6PE seMrmEASQgKfGCWuz9CBsL8xSnRvLYFp+NjxnhmiYS+jxJYFZ6C6PzNK/HrRzg5SxSagLnHk eSsjiC0iYCSx/9NJVpAiZoFNQEXXj4GtEBZwl1h54TlYEYuAqsSaiXOBmjk4eAWsJBYuV4PY Ji8x89J3sJmcQOHF1+awgti8AoISJ2c+YQGxmYFqmrfOBrtIQuAvu8TsZ3/YIJpdJKY92McE YQtLvDq+hR3ClpL4/G4vVE26xI/LT6FqCiSaj+1jhLDtJVpP9TOD3MMsoCmxfpc+RFhWYuqp dUwQe/kken8/gWrlldgxD8ZWkmhfOQfKlpDYe66BCWSMhICHROM5GUhY9TJKnJs5m3ECo8Is JO/MQvLOLITNCxiZVzFKphYU56anFpsWGOWllsPjODk/dxMjOJFqee1gfPjgg94hRiYOxkOM EhzMSiK84gWmyUK8KYmVValF+fFFpTmpxYcYTYHBPZFZSjQ5H5jK80riDU0sDUzMzMxMLI3N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71MYjSfdCP4Yru5nVvHd xrfH9vUu3+Yi+QJFyU18j57Ztguvf3Vb5ttvaeMUhV7OKSJZsyW/b1u68+6ETdOOS5yXnxu3 cuU19T/bv7ivMkvhYZx+tVorXf76NYUIWY3PgQZ/T1lq3HX2vhGhfPvrwQ179zOw/13O7iCk 7+C4luPhuWMMP23XHm7hd9WyL33FVan09dJNrnU1/NtWXGiQe7ZUYfeE0w069Tf5Bb+Zfrw8 4UnUnqSJjo8Yml4HiDks5q9YYZk9fbXuquw1q9ZE9Oy5Nk/T1SHmkHPWK+HruonBCxn9lFiK MxINtZiLihMBsjp7CuQCAAA= X-CMS-MailID: 20220929121713epcas5p1824ed0c48c9e9ceeb18954d9c23564ed X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121713epcas5p1824ed0c48c9e9ceeb18954d9c23564ed References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use the new blk_rq_map_user_io helper instead of duplicating code at various places. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_ioctl.c | 22 +++------------------- drivers/scsi/sg.c | 22 ++-------------------- 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 729e309e6034..2d20da55fb64 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -449,25 +449,9 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) if (ret < 0) goto out_put_request; - ret = 0; - if (hdr->iovec_count && hdr->dxfer_len) { - struct iov_iter i; - struct iovec *iov = NULL; - - ret = import_iovec(rq_data_dir(rq), hdr->dxferp, - hdr->iovec_count, 0, &iov, &i); - if (ret < 0) - goto out_put_request; - - /* SG_IO howto says that the shorter of the two wins */ - iov_iter_truncate(&i, hdr->dxfer_len); - - ret = blk_rq_map_user_iov(rq->q, rq, NULL, &i, GFP_KERNEL); - kfree(iov); - } else if (hdr->dxfer_len) - ret = blk_rq_map_user(rq->q, rq, NULL, hdr->dxferp, - hdr->dxfer_len, GFP_KERNEL); - + ret = blk_rq_map_user_io(rq, NULL, hdr->dxferp, hdr->dxfer_len, + GFP_KERNEL, hdr->iovec_count && hdr->dxfer_len, + hdr->iovec_count, 0, rq_data_dir(rq)); if (ret) goto out_put_request; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 94c5e9a9309c..ce34a8ad53b4 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1804,26 +1804,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) md->from_user = 0; } - if (iov_count) { - struct iovec *iov = NULL; - struct iov_iter i; - - res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i); - if (res < 0) - return res; - - iov_iter_truncate(&i, hp->dxfer_len); - if (!iov_iter_count(&i)) { - kfree(iov); - return -EINVAL; - } - - res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC); - kfree(iov); - } else - res = blk_rq_map_user(q, rq, md, hp->dxferp, - hp->dxfer_len, GFP_ATOMIC); - + res = blk_rq_map_user_io(rq, md, hp->dxferp, hp->dxfer_len, + GFP_ATOMIC, iov_count, iov_count, 1, rw); if (!res) { srp->bio = rq->bio; From patchwork Thu Sep 29 12:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 12994022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C53F0C4332F for ; Thu, 29 Sep 2022 12:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235374AbiI2MZJ (ORCPT ); Thu, 29 Sep 2022 08:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbiI2MYz (ORCPT ); Thu, 29 Sep 2022 08:24:55 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C2BBF0 for ; Thu, 29 Sep 2022 05:24:49 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220929122447epoutp0255ee560bf1d9e618962366ba2fed5245~ZVFsDrH-00892808928epoutp02T for ; Thu, 29 Sep 2022 12:24:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220929122447epoutp0255ee560bf1d9e618962366ba2fed5245~ZVFsDrH-00892808928epoutp02T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664454287; bh=kslegbVgJtIIf+TJbQuizRtJPWkwJq7sepMKs3FyoAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a6k9gGdBj2immi03/ArMkQnKrm0sMHHyoTTPR/5EIBMes3qy1RHroCRgjCo0/d/MP 6a5FQ5bpDM6z27FwZzyC1DIXpBtZaeGOqH2/B0Nl4MtcWoElOU53huwCuDhh1nZmBL SddZk+2cm/Rrv3SBJe01V4XCeFvWFzXKa139SFFo= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220929122446epcas5p2353f2f2284a5c794ab883c28b63ea082~ZVFrlMHKe2510225102epcas5p23; Thu, 29 Sep 2022 12:24:46 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MdXcD13mbz4x9Pp; Thu, 29 Sep 2022 12:24:44 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 27.43.26992.B8E85336; Thu, 29 Sep 2022 21:24:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220929121715epcas5p488759f34f6e55d940c6dca523e24f464~ZU-Hb9wl03132331323epcas5p4J; Thu, 29 Sep 2022 12:17:15 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220929121715epsmtrp1cae91d15790f2c4884ffe2d3ef5f48e6~ZU-HbMwLp1820918209epsmtrp1_; Thu, 29 Sep 2022 12:17:15 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-a4-63358e8b83e7 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B9.3C.18644.BCC85336; Thu, 29 Sep 2022 21:17:15 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220929121714epsmtip1513c033d52b1dce33f68bee347e1822d~ZU-GHrcqK3029230292epsmtip11; Thu, 29 Sep 2022 12:17:13 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v11 13/13] nvme: Use blk_rq_map_user_io helper Date: Thu, 29 Sep 2022 17:36:32 +0530 Message-Id: <20220929120632.64749-14-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929120632.64749-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAA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IBnqp+bmk4HcDR/fPrw4W/TaP+tizZmZDtdyxWIFGsvn39A8k/I/AlJvkosxRmJhlrM RcWJALotnFDlAgAA X-CMS-MailID: 20220929121715epcas5p488759f34f6e55d940c6dca523e24f464 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220929121715epcas5p488759f34f6e55d940c6dca523e24f464 References: <20220929120632.64749-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org User blk_rq_map_user_io instead of duplicating the same code at different places Signed-off-by: Anuj Gupta --- drivers/nvme/host/ioctl.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 25a68e8c60db..a3f22bbe511a 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -106,21 +106,12 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, if (ret < 0) goto out; ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); - } else if (vec) { - struct iovec fast_iov[UIO_FASTIOV]; - struct iovec *iov = fast_iov; - struct iov_iter iter; - - ret = import_iovec(rq_data_dir(req), nvme_to_user_ptr(ubuffer), - bufflen, UIO_FASTIOV, &iov, &iter); - if (ret < 0) - goto out; - ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); - kfree(iov); } else { - ret = blk_rq_map_user(q, req, NULL, - nvme_to_user_ptr(ubuffer), bufflen, GFP_KERNEL); + ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer), + bufflen, GFP_KERNEL, vec, 0, 0, + rq_data_dir(req)); } + if (ret) goto out; bio = req->bio;