From patchwork Mon Sep 5 13:48:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966168 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 E6E66C6FA8B for ; Mon, 5 Sep 2022 13:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbiIEN7B (ORCPT ); Mon, 5 Sep 2022 09:59:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237142AbiIEN67 (ORCPT ); Mon, 5 Sep 2022 09:58:59 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27DBB5A16F for ; Mon, 5 Sep 2022 06:58:54 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220905135850epoutp032ec8087b19dc0e1bc32c2e8bf8301b6e~R_49CeWQG2723127231epoutp03Q for ; Mon, 5 Sep 2022 13:58:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220905135850epoutp032ec8087b19dc0e1bc32c2e8bf8301b6e~R_49CeWQG2723127231epoutp03Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662386330; bh=A9eeh4RBJYaAco8jXNywjr3avubLO7fkkdnIseGNno0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fg2Qp9k0hp8Srs4dwQMd2wka4h2RGa/Qty/E5lOH2w5ZJkiEpNugwkD0cqT/Hv3FM vguVF1FddpGBfdi5ScrCBCKBxJ8hgacj62r03NBL74djPHin8NeLuSpvZdlXrPyWcF jXTy0R1QHLBuUHropAcLXghLe8JDFYZfdfa2mrBI= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220905135849epcas5p3abd70f080e747db49ae86e3e2918c664~R_48jO_Ix2215922159epcas5p3k; Mon, 5 Sep 2022 13:58:49 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MLqqq20kRz4x9Pp; Mon, 5 Sep 2022 13:58:47 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4F.7A.59633.79006136; Mon, 5 Sep 2022 22:58:47 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220905135846epcas5p4fde0fc96442adc3cf11319375ba2596b~R_45maAVN2801128011epcas5p4E; Mon, 5 Sep 2022 13:58:46 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220905135846epsmtrp29d91e5e8e56425c813975213f2e5fe0f~R_45lpA6k0557505575epsmtrp2j; Mon, 5 Sep 2022 13:58:46 +0000 (GMT) X-AuditID: b6c32a49-06ffe7000000e8f1-b8-631600973a15 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AC.39.14392.69006136; Mon, 5 Sep 2022 22:58:46 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220905135844epsmtip1dd3b2f2aa878ee1536f9a2b3798e33a6~R_44Iybrd1794817948epsmtip1R; Mon, 5 Sep 2022 13:58:44 +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 v4 1/4] io_uring: introduce io_uring_cmd_import_fixed Date: Mon, 5 Sep 2022 19:18:30 +0530 Message-Id: <20220905134833.6387-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905134833.6387-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmuu50BrFkg5+buCyaJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6hpaWpgrKeQl5qbaKrn4BOi6ZeYAHaekUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJ KTAp0CtOzC0uzUvXy0stsTI0MDAyBSpMyM7omjKHpWC1UMXWoz0sDYxr+bsYOTkkBEwkJu45 zdjFyMUhJLCbUeLMnsXsIAkhgU+MEpNOJ0AkvjFKvGyewgjTsWXlMXaIxF5GiefPzrJBOJ8Z Jdq+nGLtYuTgYBPQlLgwuRSkQUTAS+L+7fesIDXMICve3mgEWyEsECCxe8kMsKksAqoSV7c/ YwGxeQXMJe6c2MoMsU1eYual72D1nAIWEpO67rNB1AhKnJz5BKyeGaimeetsZpAFEgKtHBJb py5mhWh2kbi1+ycbhC0s8er4FnYIW0ri87u9UPFkiUszzzFB2CUSj/cchLLtJVpP9TODPMMM 9Mz6XfoQu/gken8/YQIJSwjwSnS0CUFUK0rcm/QUaqu4xMMZS6BsD4kfcz8wQ8Knm1Fi+fJ9 zBMY5WcheWEWkhdmIWxbwMi8ilEytaA4N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YlUR4U3aIJAvxpiRWVqUW5ccXleakFh9ilOZgURLnvdB1Ml5IID2xJDU7NbUgtQgmy8TB KdXAdLqHzav6/b32R2XLisLyrDwj15z982jalvMca1znsE8QzShfzT83dNqy50lzfewrA2av /viX9+nVk+849aP0NabZBGdbBt50cvvx0Kbri/t03dLrOmK+hf0LK7ffmad/wHiidQzLRt3/ YltuVHq1KavPepRzMdj2zq6vN6ducrq0L+a5ybaJswUsHupOrP9UGm5TJfKbaan78mcs1Y3P dO6YdZ7uVLx3VEzNeWFp7MvLR3wlT33lyv5yQpT17Ovum6ZGc/t7Nv08mlkW6mH2danMrXzR y4qH+JZXJft4XAph3P1vbePSJT7eZzZxNO8Qb4sPEWqTq968UIB5r82i+XPWHI6olmO68Plm 4rVTPkosxRmJhlrMRcWJANT3bt/wAgAA X-CMS-MailID: 20220905135846epcas5p4fde0fc96442adc3cf11319375ba2596b X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220905135846epcas5p4fde0fc96442adc3cf11319375ba2596b References: <20220905134833.6387-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 | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 58676c0a398f..dba6fb47aa6c 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 -1; +} 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..8cddd18ad10b 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,13 @@ 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); + struct io_mapped_ubuf *imu = req->imu; + + return io_import_fixed(rw, iter, imu, ubuf, len); +} +EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); From patchwork Mon Sep 5 13:48:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966170 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 78F32ECAAD5 for ; Mon, 5 Sep 2022 13:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237597AbiIEN7E (ORCPT ); Mon, 5 Sep 2022 09:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237726AbiIEN67 (ORCPT ); Mon, 5 Sep 2022 09:58:59 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC5AF5A177 for ; Mon, 5 Sep 2022 06:58:57 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220905135853epoutp0166e613536d11998a168f12f8c96332db~R_5AGB6GQ3021530215epoutp01k for ; Mon, 5 Sep 2022 13:58:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220905135853epoutp0166e613536d11998a168f12f8c96332db~R_5AGB6GQ3021530215epoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662386333; bh=BnlRTbNNqn7Th77tQTzZ10cK7Qt10nSdZnE6JtLTcEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jligVjV64hRZIhiHEfUiW/+rjiRykNeK/B5YKhZ5ISgpB70wXqMGr2B1GCFDotAAV d7R+vuRqzuJXtY6zs0xpMZPONSKgJ6K/Y/HYKf0ddrsujHupb0RxbjGUUQs5cQXy6Y UmPggbAcT7b3b3wBroKBTpMU5j77xMDxWiFYgV4E= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220905135852epcas5p3ac21c78f3a33be3347a2c1a614123ebf~R_4_-pEI62360423604epcas5p32; Mon, 5 Sep 2022 13:58:52 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MLqqs5dBWz4x9Pr; Mon, 5 Sep 2022 13:58:49 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 20.8A.59633.99006136; Mon, 5 Sep 2022 22:58:49 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220905135848epcas5p445275a3af56a26a036878fe8a8bcb55f~R_472k8-r0621806218epcas5p4l; Mon, 5 Sep 2022 13:58:48 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220905135848epsmtrp1d1cb1cf8dcc170b1da6514c4a74d4eef~R_470-mk91158011580epsmtrp1j; Mon, 5 Sep 2022 13:58:48 +0000 (GMT) X-AuditID: b6c32a49-06ffe7000000e8f1-bc-63160099ceee Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.39.14392.89006136; Mon, 5 Sep 2022 22:58:48 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220905135847epsmtip1085e513c5b90049fd34fda2f4a05529e~R_46V1pjE1139411394epsmtip1H; Mon, 5 Sep 2022 13:58:47 +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 v4 2/4] io_uring: introduce fixed buffer support for io_uring_cmd Date: Mon, 5 Sep 2022 19:18:31 +0530 Message-Id: <20220905134833.6387-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905134833.6387-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmK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j0v3zLr9jmUzq80KFrdb4ZtNBc9ffN7xlGEby4Qm+WCt+JiCkENK zlvZ4pRYijMSDbWYi4oTAT99on3uAgAA X-CMS-MailID: 20220905135848epcas5p445275a3af56a26a036878fe8a8bcb55f X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220905135848epcas5p445275a3af56a26a036878fe8a8bcb55f References: <20220905134833.6387-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 dba6fb47aa6c..6ca633b88816 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 8cddd18ad10b..ea989a348d98 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; + + ioucmd->flags = READ_ONCE(sqe->uring_cmd_flags); + req->buf_index = READ_ONCE(sqe->buf_index); + if (ioucmd->flags & IORING_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 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 Mon Sep 5 13:48:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966169 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 EFD95C54EE9 for ; Mon, 5 Sep 2022 13:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237987AbiIEN7C (ORCPT ); Mon, 5 Sep 2022 09:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237597AbiIEN67 (ORCPT ); Mon, 5 Sep 2022 09:58:59 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22DD5A2C0 for ; Mon, 5 Sep 2022 06:58:57 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220905135856epoutp01ffef54c4b172684cd57d390ac5372183~R_5C0gnsE3032130321epoutp01c for ; Mon, 5 Sep 2022 13:58:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220905135856epoutp01ffef54c4b172684cd57d390ac5372183~R_5C0gnsE3032130321epoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662386336; bh=G67kfqT7ju2Wy37bOXw+s0IVht5UeVvdSkoq3vkdofw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bp8wxTbZKacg+af/F6lpau9GdvKqhUF+Xoh84T22984Ajbm5OjIWweC+oWxLI9U/t sT/iBENyqKNZxdK/LpFDVvxuacHqHkCkoCsd+jj/iuPSBprTj4xmZrayL5a5o+7Gw0 bom7tpAqH+CQXZGmzSgJ4JYIOBaTqWHJ27E3OgCQ= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220905135855epcas5p1bdf1140ebaf3a912b7d14a20c1ae714c~R_5B9p9WH1346413464epcas5p1i; Mon, 5 Sep 2022 13:58:55 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MLqqw3CLbz4x9Px; Mon, 5 Sep 2022 13:58:52 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8B.E4.54060.C9006136; Mon, 5 Sep 2022 22:58:52 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220905135851epcas5p3d107b140fd6cba1feb338c1a31c4feb1~R_4_iyTRr2360423604epcas5p31; Mon, 5 Sep 2022 13:58:51 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220905135851epsmtrp15b2d28fe3e50751c375187b4e47ffe54~R_4_h5uK71158011580epsmtrp1k; Mon, 5 Sep 2022 13:58:51 +0000 (GMT) X-AuditID: b6c32a4b-e33fb7000000d32c-ad-6316009c301f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4E.39.14392.B9006136; Mon, 5 Sep 2022 22:58:51 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220905135850epsmtip1bc414ac091b3d460bb555c5f5fc1b9f4~R_49EWyB-1794417944epsmtip1N; Mon, 5 Sep 2022 13:58:50 +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 v4 3/4] block: add helper to map bvec iterator for passthrough Date: Mon, 5 Sep 2022 19:18:32 +0530 Message-Id: <20220905134833.6387-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905134833.6387-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmpu4cBrFkg0N3xSyaJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6hpaWpgrKeQl5qbaKrn4BOi6ZeYAHaekUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJ KTAp0CtOzC0uzUvXy0stsTI0MDAyBSpMyM6Y84e1YL9yxbPtTewNjItluhg5OSQETCTe/DrL 3MXIxSEksJtRYsPfqVDOJ0aJG7+WsoFUCQl8Y5T422kJ07FseQsbRNFeRomurj1MEM5nRokD 5z6wdDFycLAJaEpcmFwK0iAi4CVx//Z7VpAaZpAVq/++ZQVJCAtESmyZ+pARxGYRUJVY9f0/ O4jNK2Au0TxxGgvENnmJmZe+g8U5BSwkJnXdZ4OoEZQ4OfMJWA0zUE3z1tlgZ0sItHJILO+Z yQbR7CKx+PIVJghbWOLV8S3sELaUxMv+Nig7WeLSzHNQNSUSj/cchLLtJVpP9TODPMMM9Mz6 XfoQu/gken8/YQIJSwjwSnS0CUFUK0rcm/SUFcIWl3g4YwmU7SFxtmkDOyR8uhkleltWM05g lJ+F5IVZSF6YhbBtASPzKkbJ1ILi3PTUYtMC47zUcni8JufnbmIEJ1Et7x2Mjx580DvEyMTB eIhRgoNZSYQ3ZYdIshBvSmJlVWpRfnxRaU5q8SFGU2AYT2SWEk3OB6bxvJJ4QxNLAxMzMzMT S2MzQyVx3inajMlCAumJJanZqakFqUUwfUwcnFINTDX1C/e4Jk7o25HQ4elj4Mp7eJks68k7 +0+Eady+cy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bhtw3bthdzs/tmFs15s2lq2vq3TyWjBVjsogLkb2uZd+lYMZ9P8g90d9tzTV+ovOF9 yDx1wb9vbuypPhut+lH+sNa5n6vzDBZdr7B+V50k9ejXvV0rZeZcec+Xm2Oo8N76QFlWtP7O /U2+jNFTe/ptH3psnVf3+7/6yXMd77v2L5mSX2Ea1vYlyq35dAbnhJpdHE89fdsF2z9ctlvc 0arEUpyRaKjFXFScCADGjApr7gIAAA== X-CMS-MailID: 20220905135851epcas5p3d107b140fd6cba1feb338c1a31c4feb1 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220905135851epcas5p3d107b140fd6cba1feb338c1a31c4feb1 References: <20220905134833.6387-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 Mon Sep 5 13:48:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12966171 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 51B91C6FA83 for ; Mon, 5 Sep 2022 13:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237809AbiIEN7F (ORCPT ); Mon, 5 Sep 2022 09:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237142AbiIEN7C (ORCPT ); Mon, 5 Sep 2022 09:59:02 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B06C859256 for ; Mon, 5 Sep 2022 06:58:59 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220905135858epoutp0146663eba1dafb04bba06d4ba99fc4dca~R_5EixuR13018630186epoutp01m for ; Mon, 5 Sep 2022 13:58:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220905135858epoutp0146663eba1dafb04bba06d4ba99fc4dca~R_5EixuR13018630186epoutp01m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662386338; bh=XgeeoulHQJxbtOhPCDaOvhvAzjNttpjnHeL7vwNSTU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Us5Tb9x50K+7rT36ea0ImqMABDaRfyr5QxYfjXr802wA2Mn8WJY4Lb0lSmmUlTxZ0 pJ6xC9g8Fvf8466Yg2vWgck46OPvLW7mwXl/ckk6A8of+BZkF//D9DglRtL8MdrgGe YmnJSEyl+Q8iUdUwX+BsS5grHyU7QlVNtvEutS+8= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220905135857epcas5p1ebae4f92d0dd3946d9a71550fcbbd01a~R_5D__BiE0780107801epcas5p18; Mon, 5 Sep 2022 13:58:57 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MLqqz23BYz4x9Pr; Mon, 5 Sep 2022 13:58:55 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.E4.54060.F9006136; Mon, 5 Sep 2022 22:58:55 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220905135854epcas5p2256848a964afec41f46502b0114698e2~R_5BgLA2P1747417474epcas5p27; Mon, 5 Sep 2022 13:58:54 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220905135854epsmtrp260a934733ec706f1a719387c176229a2~R_5BfY6um0711507115epsmtrp2C; Mon, 5 Sep 2022 13:58:54 +0000 (GMT) X-AuditID: b6c32a4b-be1ff7000000d32c-b4-6316009f7c12 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 44.2C.18644.E9006136; Mon, 5 Sep 2022 22:58:54 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220905135853epsmtip10b02e02248af028724fb384963abb838~R_5ABMfeE1795917959epsmtip1U; Mon, 5 Sep 2022 13:58:53 +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 v4 4/4] nvme: wire up fixed buffer support for nvme passthrough Date: Mon, 5 Sep 2022 19:18:33 +0530 Message-Id: <20220905134833.6387-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905134833.6387-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmuu58BrFkg/XveS2aJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6h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Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsWy7bCSnO48BrFkg8c3jCyaJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdx2aSk5mSWpRbp2yVwZXxZfYWx4K9yxfvVLawN jAtluxg5OSQETCSW3nrA3sXIxSEksINR4smB+2wQCXGJ5ms/2CFsYYmV/55DFX1klPj1aiZr FyMHB5uApsSFyaUgNSICARIHGy+D1TALHGSUON/0jQUkISwQIXH39XMmEJtFQFVi2/PPYHFe AXOJmxfnsUAskJeYeek72DJOAQuJSV0QRwgB1eyZ8ZQRol5Q4uTMJ2D1zED1zVtnM09gFJiF JDULSWoBI9MqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95PzcTYzgGNDS2sG4Z9UHvUOMTByM hxglOJiVRHhTdogkC/GmJFZWpRblxxeV5qQWH2KU5mBREue90HUyXkggPbEkNTs1tSC1CCbL xMEp1cC0LbM4YdXvmx/TEpJbo9szqw9I/vh11qboy5OPVS75m2U45CXKApWezJzvV7xk4qR3 kq8q3S/KbFOa3xbxJqZmasiW2cffpXs+6bxzXsnttdq14pe777QpZnYbTQyZrLH00qP9anwu DsyaHlGRKSHT7K7J+TQFzXtweVOJ4Tw+TvFrMbFGh1Y//d767at6QufHSe8vLmrPvSaeJ2Eu GzTNRGSb0eO9e5R35LKnK8Z8Uqlqyrn7M3xLr993xpxTidukTh+Tct1itqL2nUQgX9Uzu0k1 Ir+WfJ9RkaWu1pvK+jWAzy2w4JWcsvXpGUs7IlXrTBbrLP6mcmO7c40m3+QrNidPNPWpOvJa pdraPFNiKc5INNRiLipOBAC4BqQ88AIAAA== X-CMS-MailID: 20220905135854epcas5p2256848a964afec41f46502b0114698e2 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220905135854epcas5p2256848a964afec41f46502b0114698e2 References: <20220905134833.6387-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;