From patchwork Tue Sep 6 06:27:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966929 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 2349EC38145 for ; Tue, 6 Sep 2022 06:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238230AbiIFGhg (ORCPT ); Tue, 6 Sep 2022 02:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238495AbiIFGhf (ORCPT ); Tue, 6 Sep 2022 02:37:35 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B7D6F260 for ; Mon, 5 Sep 2022 23:37:34 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220906063729epoutp04baf64ab804038fc6b4804ffe61608a1b~SMg4-qqnm1135211352epoutp04m for ; Tue, 6 Sep 2022 06:37:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220906063729epoutp04baf64ab804038fc6b4804ffe61608a1b~SMg4-qqnm1135211352epoutp04m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662446249; bh=cal95robFJLQGJ8+m5/E4SeEhAYnouWNx2DVQA94dKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IjCrnNAuaJ1wdFFJ2HMaWayjtYpy71qUTwiqICtbcCiWXxls4jfHDoIXbyFMzI22Y CdwzYbKhTfqljKoRqOu5Ykw65QKY/RL4l0asMLywSWym+l7wW0MXzmltqRuONSHacs 6FHEZaj22EzVZU/bm7A+oauHzmSK8fdnfwTPzeAA= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220906063728epcas5p21ce7253400629bf8bd19b61112328162~SMg4hoLWY0869908699epcas5p2I; Tue, 6 Sep 2022 06:37:28 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MMG041K02z4x9Py; Tue, 6 Sep 2022 06:37:24 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9D.20.53458.4AAE6136; Tue, 6 Sep 2022 15:37:24 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220906063723epcas5p23946fd33031aee591210af1c3cd2d574~SMgz-cMBQ0869908699epcas5p20; Tue, 6 Sep 2022 06:37:23 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906063723epsmtrp204c487db3d7785f5f41cba8c8d3998f1~SMgz_ifjL1360313603epsmtrp2D; Tue, 6 Sep 2022 06:37:23 +0000 (GMT) X-AuditID: b6c32a4a-a5bff7000000d0d2-69-6316eaa41b8f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B9.45.14392.3AAE6136; Tue, 6 Sep 2022 15:37:23 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906063722epsmtip2076ddaa86be9dd6173c3c3841b4c3def~SMgycrUnU2854328543epsmtip2w; Tue, 6 Sep 2022 06:37:22 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v5 1/4] io_uring: introduce io_uring_cmd_import_fixed Date: Tue, 6 Sep 2022 11:57:18 +0530 Message-Id: <20220906062721.62630-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906062721.62630-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOJsWRmVeSWpSXmKPExsWy7bCmhu6SV2LJBpf/sFo0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaLvbe0LeYve8ruwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPvi2rGD0+b5ILYI/KtslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw 1DW0tDBXUshLzE21VXLxCdB1y8wBOk5JoSwxpxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCS U2BSoFecmFtcmpeul5daYmVoYGBkClSYkJ3R176WvWCxUMWZy0+ZGxin83cxcnJICJhIbHx8 laWLkYtDSGA3o0TPnRusEM4nRonf92exQTjfGCU+vpnB2MXIAdby7r8zRHwvo8SfOd1Q7Z8Z Jc7MWcIGUsQmoClxYXIpyAoRAS+J+7ffg01lBlnx9kYjO0hCWCBA4uG+s+wg9SwCqhI9jUYg YV4BC4k9656xQpwnLzHz0newck4BS4kJJ7+wQdQISpyc+YQFxGYGqmneOpsZZL6EQC+HxMoJ b9khml0kjs7fzAJhC0u8Or4FKi4l8fndXjYIO1ni0sxzTBB2icTjPQehbHuJ1lP9zCC3MQP9 sn6XPsQuPone30+YIOHAK9HRJgRRrShxb9JTqJPFJR7OWMIKUeIh8a21ABI6PYwSf2/MZpvA KD8LyQezkHwwC2HZAkbmVYySqQXFuempxaYFRnmp5fBoTc7P3cQIT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UX58UWlOavEhRmkOFiVx3gtdJ+OFBNITS1KzU1MLUotg skwcnFINTOJJS66zz/+VzB0yr2p9/QQFOyaWPL+lW448/Sr6o+6J8+zzc1LnJ72KOc2RfDzc TLFWxNU3cMVajo/BeeEOFw9+W/JW6sO5+FiRvo6d94SsJ+vzSB2TivjIN+FWModPoXy/92kP 94T98ryL0v5l3g5J0zu896aj17xPXH5Ljz3Pk3l/6JjK1INPGJ+mOnRotmzeGqhu2jSfk7vs 0awD0Y5Jq8X3mP+YUMFy3G3i8inNi6t7y9q77SYoFr8/mHewf/mzr1K3X5TM3PHsdFBJVneo xm7hvuS56WUWzOvKr9xSOXrJ74qtwO2vD3puW6xLnNU33ZR1MZfC0hc39Rb9nVO8U+7n0s/3 0q1aHHfznVViKc5INNRiLipOBACLad1Q7gIAAA== X-CMS-MailID: 20220906063723epcas5p23946fd33031aee591210af1c3cd2d574 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220906063723epcas5p23946fd33031aee591210af1c3cd2d574 References: <20220906062721.62630-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Anuj Gupta 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..202d90bc2c88 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 +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 6f99dbd5d550..b8f4dc84c403 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -7,6 +7,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) @@ -124,3 +125,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 Tue Sep 6 06:27:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966932 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 2CF51C6FA83 for ; Tue, 6 Sep 2022 06:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238516AbiIFGho (ORCPT ); Tue, 6 Sep 2022 02:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238557AbiIFGhm (ORCPT ); Tue, 6 Sep 2022 02:37:42 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 969E07171B for ; Mon, 5 Sep 2022 23:37:40 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220906063736epoutp01d45369b0755748a2fcdc9721845f7502~SMg-j9Wc_0727007270epoutp01E for ; Tue, 6 Sep 2022 06:37:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220906063736epoutp01d45369b0755748a2fcdc9721845f7502~SMg-j9Wc_0727007270epoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662446256; bh=xYWDawx7wbel1WJGFM9Uma0BQ13A775WPFqjMQwRzQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7H7gigTYaO+dqw25Bt1CkRVfcipni5RIINB9mpPy6vXizr79lRvW8qLP5+NM2izp fpmPBZwWAXFjT995t6KuZntnkV5Aw0+J+NGidJa9fZdH0pwX/Qax+AZ+jBbBtZ5wGg zVKDV7xgi/yI2EmsfJLpwGyv66sDMeYv/mY86xyk= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220906063735epcas5p1544c2e9e38f619e77d0788936d586a38~SMg_4z6B-1555715557epcas5p1H; Tue, 6 Sep 2022 06:37:35 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MMG092VHWz4x9QJ; Tue, 6 Sep 2022 06:37:29 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 21.52.59633.6AAE6136; Tue, 6 Sep 2022 15:37:26 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220906063726epcas5p42f764b4c01b841dd1fc34abebcab02e6~SMg2ha3pd1147211472epcas5p4m; Tue, 6 Sep 2022 06:37:26 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906063726epsmtrp16a5aedf0cde5f829276a94698a138dab~SMg2gpLcr2538925389epsmtrp1K; Tue, 6 Sep 2022 06:37:26 +0000 (GMT) X-AuditID: b6c32a49-06ffe7000000e8f1-b1-6316eaa6a56e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 30.C7.18644.6AAE6136; Tue, 6 Sep 2022 15:37:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906063724epsmtip2784df2284d6835586dc5adf3a67c13c4~SMg1ASCNz2854328543epsmtip21; Tue, 6 Sep 2022 06:37:24 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v5 2/4] io_uring: introduce fixed buffer support for io_uring_cmd Date: Tue, 6 Sep 2022 11:57:19 +0530 Message-Id: <20220906062721.62630-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906062721.62630-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmhu6yV2L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dKV3nfzT7yZuDqdZXJ2jpH8wnT3VmvHZiWBtqPlVysi fROvL035qsRSnJFoqMVcVJwIAHlNCnrwAgAA X-CMS-MailID: 20220906063726epcas5p42f764b4c01b841dd1fc34abebcab02e6 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220906063726epcas5p42f764b4c01b841dd1fc34abebcab02e6 References: <20220906062721.62630-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Anuj Gupta 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 | 3 ++- include/uapi/linux/io_uring.h | 9 +++++++++ io_uring/uring_cmd.c | 18 +++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 202d90bc2c88..621b2c5469ed 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -16,6 +16,7 @@ enum io_uring_cmd_flags { IO_URING_F_SQE128 = 4, IO_URING_F_CQE32 = 8, IO_URING_F_IOPOLL = 16, + IO_URING_F_FIXEDBUFS = 32, }; struct io_uring_cmd { @@ -28,7 +29,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 48e5c70e0baf..34be8dd31f17 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 b8f4dc84c403..f9189885edec 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -76,8 +77,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; + + if (ioucmd->flags & IORING_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 index; + + ioucmd->flags = READ_ONCE(sqe->uring_cmd_flags); + 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; @@ -102,6 +116,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) req->iopoll_completed = 0; WRITE_ONCE(ioucmd->cookie, NULL); } + if (ioucmd->flags & IORING_URING_CMD_FIXED) + issue_flags |= IO_URING_F_FIXEDBUFS; if (req_has_async_data(req)) ioucmd->cmd = req->async_data; From patchwork Tue Sep 6 06:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966930 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 481D7ECAAA1 for ; Tue, 6 Sep 2022 06:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238523AbiIFGhj (ORCPT ); Tue, 6 Sep 2022 02:37:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238495AbiIFGhi (ORCPT ); Tue, 6 Sep 2022 02:37:38 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F7A6F260 for ; Mon, 5 Sep 2022 23:37:36 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220906063735epoutp04fdbe271ba7ed91a84fefe037c1059903~SMg_YIgsG1237012370epoutp04M for ; Tue, 6 Sep 2022 06:37:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220906063735epoutp04fdbe271ba7ed91a84fefe037c1059903~SMg_YIgsG1237012370epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662446255; bh=G67kfqT7ju2Wy37bOXw+s0IVht5UeVvdSkoq3vkdofw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lql+RvN+VdE5u2uB8dbtgBVhHHRVdurTeQHM53bWxRqH72ixLPTNUGvkwyuAofaCP L6bNGYQQiIGpZlzLpRodqUHSqmqx5OrIeXJGRsISi9F5qAHWr66v9/RyBeLK8XVoSL wRuteXYsJpz5WZ9c7kOV5QbNN1no7c+o3Dp0EQwM= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220906063734epcas5p374f2717a219d00fff50e928f644c2725~SMg9k4Mq32989229892epcas5p3S; Tue, 6 Sep 2022 06:37:34 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MMG0B6sf1z4x9Pr; Tue, 6 Sep 2022 06:37:30 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E5.52.59633.9AAE6136; Tue, 6 Sep 2022 15:37:29 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220906063729epcas5p1bf05e6873de0f7246234380d66c21fb9~SMg5IAD8j2227522275epcas5p1V; Tue, 6 Sep 2022 06:37:29 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906063729epsmtrp247de0d18917e22757c0db90c93905238~SMg5HJfbd1358713587epsmtrp2k; Tue, 6 Sep 2022 06:37:29 +0000 (GMT) X-AuditID: b6c32a49-dfdff7000000e8f1-c2-6316eaa9ddb4 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.45.14392.9AAE6136; Tue, 6 Sep 2022 15:37:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906063727epsmtip28c5de2a68bdf494c3bc79397d0fb1a28~SMg3n46h12854028540epsmtip21; Tue, 6 Sep 2022 06:37:27 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v5 3/4] block: add helper to map bvec iterator for passthrough Date: Tue, 6 Sep 2022 11:57:20 +0530 Message-Id: <20220906062721.62630-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906062721.62630-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmuu7KV2LJBl9uals0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaLvbe0LeYve8ruwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPvi2rGD0+b5ILYI/KtslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw 1DW0tDBXUshLzE21VXLxCdB1y8wBOk5JoSwxpxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCS U2BSoFecmFtcmpeul5daYmVoYGBkClSYkJ0x5w9rwX7limfbm9gbGBfLdDFyckgImEjMXDKT pYuRi0NIYDejxIX1q1khnE+MEscerIDKfGOU+H1kBStMy/afsxkhEnsZJa5dX84O4XxmlDj9 4DJQFQcHm4CmxIXJpSANIgJeEvdvvwcbywyyY/Xft2CThAUiJa6+XcAIYrMIqEr833ONCcTm FbCQ6Ny4DWqbvMTMS9/ZQWxOAUuJCSe/sEHUCEqcnPmEBcRmBqpp3jqbGaK+k0Ni2gwzCNtF Yt/Hr+wQtrDEq+NboGwpic/v9rJB2MkSl2aeY4KwSyQe7zkIZdtLtJ7qZwb5hRnol/W79CFW 8Un0/n7CBBKWEOCV6GgTgqhWlLg36SnUxeISD2csgbI9JGYfm8sECZ4eRon9xy6xTWCUn4Xk g1lIPpiFsG0BI/MqRsnUguLc9NRi0wLDvNRyeLwm5+duYgQnUS3PHYx3H3zQO8TIxMF4iFGC g1lJhDdlh0iyEG9KYmVValF+fFFpTmrxIUZTYBBPZJYSTc4HpvG8knhDE0sDEzMzMxNLYzND JXHeKdqMyUIC6YklqdmpqQWpRTB9TBycUg1Mq28t/Rd5auc/N+e2SQJfWM/Mj3Lw/FoomaWz /HRW6LJrl77MaC/m1+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+yNzeBcVsh35dSB/xt87MQs/GV6esYut5dJsW8cjR77VeF23DU04 rKq7qd39zt2pLw1vPbzms32Tys9NFwx0bz+xNE+y3MTOnftctLrc6efTGzZH5JeWv4248J/9 QFRm9cnjAYf+f9+t5f8uolm2KyvoQUhZqErCnsVZVRxbihv/7fx/V78rKjrmRczWe9e3Nqot XdJZ0ntyuhJLcUaioRZzUXEiAKmXUSTuAgAA X-CMS-MailID: 20220906063729epcas5p1bf05e6873de0f7246234380d66c21fb9 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220906063729epcas5p1bf05e6873de0f7246234380d66c21fb9 References: <20220906062721.62630-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add blk_rq_map_user_bvec which maps the bvec iterator into a bio and places that into the request. This helper will be used in nvme for uring-passthrough with fixed-buffer. While at it, create another helper bio_map_get to reduce the code duplication. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta --- block/blk-map.c | 94 +++++++++++++++++++++++++++++++++++++----- include/linux/blk-mq.h | 1 + 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index f3768876d618..e2f268167342 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -241,17 +241,10 @@ static void bio_map_put(struct bio *bio) } } -static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, +static struct bio *bio_map_get(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 = bio_map_get(rq, nr_vecs, gfp_mask); + if (bio == NULL) + return -ENOMEM; while (iov_iter_count(iter)) { struct page **pages, *stack_pages[UIO_FASTIOV]; @@ -612,6 +623,69 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, } EXPORT_SYMBOL(blk_rq_map_user); +/* Prepare bio for passthrough IO given an existing bvec iter */ +int blk_rq_map_user_bvec(struct request *rq, struct iov_iter *iter) +{ + struct request_queue *q = rq->q; + size_t iter_count, nr_segs; + struct bio *bio; + struct bio_vec *bv, *bvec_arr, *bvprvp = NULL; + struct queue_limits *lim = &q->limits; + unsigned int nsegs = 0, bytes = 0; + int ret, i; + + iter_count = iov_iter_count(iter); + nr_segs = iter->nr_segs; + + if (!iter_count || (iter_count >> 9) > 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 = bio_map_get(rq, 0, GFP_KERNEL); + if (bio == NULL) + return -ENOMEM; + + bio_iov_bvec_set(bio, iter); + blk_rq_bio_prep(rq, bio, nr_segs); + + /* loop to perform a bunch of sanity checks */ + bvec_arr = (struct bio_vec *)iter->bvec; + for (i = 0; i < nr_segs; i++) { + bv = &bvec_arr[i]; + /* + * If the queue doesn't support SG gaps and adding this + * offset would create a gap, disallow it. + */ + if (bvprvp && bvec_gap_to_prev(lim, bvprvp, bv->bv_offset)) { + ret = -EINVAL; + goto out_free; + } + + /* check full condition */ + if (nsegs >= nr_segs || bytes > UINT_MAX - bv->bv_len) { + ret = -EINVAL; + goto out_free; + } + + if (bytes + bv->bv_len <= iter_count && + bv->bv_offset + bv->bv_len <= PAGE_SIZE) { + nsegs++; + bytes += bv->bv_len; + } else { + ret = -EINVAL; + goto out_free; + } + bvprvp = bv; + } + return 0; +out_free: + bio_map_put(bio); + return ret; +} +EXPORT_SYMBOL(blk_rq_map_user_bvec); + /** * 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 b43c81d91892..83bef362f0f9 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -970,6 +970,7 @@ struct rq_map_data { bool from_user; }; +int blk_rq_map_user_bvec(struct request *rq, struct iov_iter *iter); 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_iov(struct request_queue *, struct request *, From patchwork Tue Sep 6 06:27:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966931 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 C5ECFECAAA1 for ; Tue, 6 Sep 2022 06:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238555AbiIFGhn (ORCPT ); Tue, 6 Sep 2022 02:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238553AbiIFGhl (ORCPT ); Tue, 6 Sep 2022 02:37:41 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99ABC70E63 for ; Mon, 5 Sep 2022 23:37:39 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220906063738epoutp0325f32e07446753b70735996b1d08cf0c~SMhBPGyO41359113591epoutp03B for ; Tue, 6 Sep 2022 06:37:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220906063738epoutp0325f32e07446753b70735996b1d08cf0c~SMhBPGyO41359113591epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662446258; bh=XgeeoulHQJxbtOhPCDaOvhvAzjNttpjnHeL7vwNSTU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NhxRwS1K/YCyB1bwXITEDRTPVxmis+I+c0YZ++VVAnWhiYJDBaSEj4QC7ca5+UCNE 8Ho21m2takU/Sr4q8UVF9YcEv/QnzuOf3iPRY8gWR096VNi401meVNACV/cXOnb7FE /n6UCa2C440UQ++B2Me3qoi/2iRIiL2LACykYkqc= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220906063737epcas5p25f2087b6bd8677f33422d7c2d1b8a0d2~SMhAxdepi0869508695epcas5p2c; Tue, 6 Sep 2022 06:37:37 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MMG0G5jXQz4x9QB; Tue, 6 Sep 2022 06:37:34 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id DB.30.53458.EAAE6136; Tue, 6 Sep 2022 15:37:34 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220906063733epcas5p22984174bd6dbb2571152fea18af90924~SMg9IoAv21760117601epcas5p2E; Tue, 6 Sep 2022 06:37:33 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906063733epsmtrp1bfd849e42b5ce385a4fc7216879aded6~SMg9H1Umn2539325393epsmtrp1Q; Tue, 6 Sep 2022 06:37:33 +0000 (GMT) X-AuditID: b6c32a4a-a5bff7000000d0d2-99-6316eaae51ae Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 50.55.14392.DAAE6136; Tue, 6 Sep 2022 15:37:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906063732epsmtip238a7154bf5d5095aaf2b196c833b6cf1~SMg7nFxSy2854328543epsmtip23; Tue, 6 Sep 2022 06:37:31 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v5 4/4] nvme: wire up fixed buffer support for nvme passthrough Date: Tue, 6 Sep 2022 11:57:21 +0530 Message-Id: <20220906062721.62630-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906062721.62630-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKJsWRmVeSWpSXmKPExsWy7bCmuu66V2LJBv9usVs0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaLvbe0LeYve8ruwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPvi2rGD0+b5ILYI/KtslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw 1DW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tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsWy7bCSvO7aV2LJBhv/ylk0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8tmMenQNUaLvbe0LeYve8ruwOWxc9Zddo/LZ0s9 Nq3qZPPYvKTeY/fNBjaPvi2rGD0+b5ILYI/isklJzcksSy3St0vgyviy+gpjwV/liverW1gb GBfKdjFyckgImEgcalvHCmILCexmlHi4PAwiLi7RfO0HO4QtLLHy33Mgmwuo5iOjxJ/D09i6 GDk42AQ0JS5MLgWpEREIkDjYeBmshlngIKPE+aZvLCAJYYEIiRtrzoANYhFQlbjf84IRxOYV sJBYdbaNFWKBvMTMS9/BajgFLCUmnPzCBnGQhcSdFXeZIOoFJU7OfAI2kxmovnnrbOYJjAKz kKRmIUktYGRaxSiZWlCcm55bbFhgmJdarlecmFtcmpeul5yfu4kRHAFamjsYt6/6oHeIkYmD 8RCjBAezkghvyg6RZCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8F7pOxgsJpCeWpGanphakFsFk mTg4pRqYVjTu+VJaZ9j8edtRh3u1LFGFrMv8Yw7oRis2H2svXXa6+NTnryp6wi0cCbJ3w9yy tk61UKm/O6v+fV7m1OLV78J6fVc7tdxefKVmwsNWDaNQqYC8uVkV0a/Vdou94wqRyfC4qJ5+ dX2N9AzVk8ZX7du3n+CwLl62nvkHz80N4Tl7vzz9EOt6aCLPSbX1zJoLnF5Nk3iX6japkTE7 XUlJ8nX0p4KTX3mTOf1nXq1c83OL+KTfpWJqanUy1yedW7vj94GOOV81lps+shI54Jw54ZJS sPwu0dNJc1mkImZecUoyzcq8fGPBDpUZ8c+2HrH7qGH168DUtQs4NR8zfXZsnLS5M/lwMROf 7UTz5Zd3K7EUZyQaajEXFScCAE55i7zvAgAA X-CMS-MailID: 20220906063733epcas5p22984174bd6dbb2571152fea18af90924 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220906063733epcas5p22984174bd6dbb2571152fea18af90924 References: <20220906062721.62630-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org if io_uring sends passthrough command with IO_URING_F_FIXEDBUFS flag, use the pre-registered buffer to form the bio. While at it modify nvme_submit_user_cmd 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 --- drivers/nvme/host/ioctl.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 548aca8b5b9f..4341d758d6b9 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -65,10 +65,11 @@ 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, + struct nvme_command *cmd, u64 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) + blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags, + struct io_uring_cmd *ioucmd, bool fixedbufs) { bool write = nvme_is_write(cmd); struct nvme_ns *ns = q->queuedata; @@ -89,14 +90,27 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, if (ubuffer && bufflen) { if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - GFP_KERNEL); + if (fixedbufs) { + struct iov_iter iter; + + ret = io_uring_cmd_import_fixed(ubuffer, + bufflen, rq_data_dir(req), + &iter, ioucmd); + if (ret < 0) + goto out; + ret = blk_rq_map_user_bvec(req, &iter); + } else { + ret = blk_rq_map_user(q, req, NULL, + nvme_to_user_ptr(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, + ret = import_iovec(rq_data_dir(req), + nvme_to_user_ptr(ubuffer), bufflen, UIO_FASTIOV, &iov, &iter); if (ret < 0) goto out; @@ -132,7 +146,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, } 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) { @@ -142,7 +156,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, int ret; req = nvme_alloc_user_request(q, cmd, ubuffer, bufflen, meta_buffer, - meta_len, meta_seed, &meta, timeout, vec, 0, 0); + meta_len, meta_seed, &meta, timeout, vec, 0, 0, NULL, 0); if (IS_ERR(req)) return PTR_ERR(req); @@ -220,7 +234,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); } @@ -274,7 +288,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); @@ -320,7 +334,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); @@ -457,11 +471,11 @@ 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), + req = nvme_alloc_user_request(q, &c, 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); + blk_flags, ioucmd, issue_flags & IO_URING_F_FIXEDBUFS); if (IS_ERR(req)) return PTR_ERR(req); req->end_io = nvme_uring_cmd_end_io;