From patchwork Sun Sep 25 20:22:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988106 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 C8CE1C04A95 for ; Sun, 25 Sep 2022 20:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbiIYUd3 (ORCPT ); Sun, 25 Sep 2022 16:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiIYUd2 (ORCPT ); Sun, 25 Sep 2022 16:33:28 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EEE52BE35 for ; Sun, 25 Sep 2022 13:33:26 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220925203324epoutp019e4a6f342893f0d4c963f19c6590e008~YNLLL1kZ_1134511345epoutp01Z for ; Sun, 25 Sep 2022 20:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220925203324epoutp019e4a6f342893f0d4c963f19c6590e008~YNLLL1kZ_1134511345epoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138004; bh=6HR7pDfEWCQApaFHaY1z8P5ClzoEBjIEJhDVePj5Z8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3II1XB6Mb7JpZKItp7rO3WCn/rEjf0oGX80oUnUDSFJjHTgZl/vqw9pzGgBF+MuH 6wHY9/4hxtUADBWmPMiKopI3THnk0O5dMz6QgknDEgj+nXTycRDtzH/WYH4R/E9K3A kWMOcryzoIY5ZH+jdjJ/2FPZN5rSv4qcY0tgiIq0= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220925203324epcas5p46e2107b0bbd681ebbfee7daaef224a26~YNLKeelDl2831828318epcas5p40; Sun, 25 Sep 2022 20:33:24 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MbHds6wTTz4x9Pr; Sun, 25 Sep 2022 20:33:21 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0B.9F.26992.11BB0336; Mon, 26 Sep 2022 05:33:21 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220925203320epcas5p28fcc3c9ff8669c56213547725ea71001~YNLHVM4Hy0635906359epcas5p2N; Sun, 25 Sep 2022 20:33:20 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220925203320epsmtrp1f4b4dce3b8bf644757873c2e902fcfcf~YNLHUcKFT1867318673epsmtrp1T; Sun, 25 Sep 2022 20:33:20 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-19-6330bb11bc5e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.01.14392.01BB0336; Mon, 26 Sep 2022 05:33:20 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203317epsmtip194879d7811d4001d91d4eab2979d16df~YNLEvpQMm0205602056epsmtip1K; Sun, 25 Sep 2022 20:33:17 +0000 (GMT) From: Kanchan Joshi 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, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v9 1/7] io_uring: add io_uring_cmd_import_fixed Date: Mon, 26 Sep 2022 01:52:58 +0530 Message-Id: <20220925202304.28097-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdlhTU1dwt0GyQcsyU4umCX+ZLVbf7Wez uHlgJ5PFytVHmSzetZ5jsTj6/y2bxaRD1xgt9t7Stpi/7Cm7A6fH5bOlHptWdbJ5bF5S77H7 ZgObR9+WVYwenzfJBbBFZdtkpCampBYppOYl56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam 2iq5+AToumXmAJ2kpFCWmFMKFApILC5W0rezKcovLUlVyMgvLrFVSi1IySkwKdArTswtLs1L 18tLLbEyNDAwMgUqTMjO+D9rJlPBKqGKl6+/MjUwzuXvYuTgkBAwkdj33a2LkZNDSGA3o8T+ 09FdjFxA9idGiU87dzBBON8YJdYdWscIUgXS0Ht4HzNEYi+jxPcHy1khnM+MEgf+HmUBGcsm oClxYXIpSIOIgJHE/k8nwWqYQVa8vdHIDpIQFvCQmNh+nQnEZhFQlTj2rIcVxOYVsJA4+uk9 E8Q2eYmZl76D1XMKWEo8mbuVGaJGUOLkzCcsIDYzUE3z1tlgF0kI/GWX2LLzMzNEs4vEk/7b 7BC2sMSr41ugbCmJl/1tUHayxKWZ56CWlUg83nMQyraXaD3VzwzyDDPQM+t36UPs4pPo/f2E CRJ0vBIdbUIQ1YoS9yY9ZYWwxSUezlgCZXtIHJk/hx0SPj2MEudmPGWbwCg/C8kLs5C8MAth 2wJG5lWMkqkFxbnpqcWmBYZ5qeXweE3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ZgURLnvdB1Ml5IID2xJDU7NbUgtQgmy8TBKdXA1Gn5 SOHt3rNLRM2MVC+Zsf89JWlwYtZnuUTh/uLfRd/DJskdFFazd77I85bpos3zv3d2BGY+WXV4 6q7GiamS/y4davJPX++TlSm+QmSP9NPTJRu91h56aF2rJNYZfksuyz2oYeG8zy4JK0zXV0k8 yupgiX0yJ8NZztXstNfE2tN++iZHdaayHzs492rZhN78knlPamVj/okJJyTeEe34sv/ebjlF wesvLU9cU1h9+fPBKQGbntx2Lg/+c/h4wYbbqqvEtu7iDGDTvx700XZ511+3Pb3zjXe9Ndlk Lbt6ZdFVi7UtlSxVD9QMucVS07dWmdzlSDO5vjn01sGQ++2LDSUyH92TXHGkkX9usxaTtRJL cUaioRZzUXEiALY3/5zlAgAA X-CMS-MailID: 20220925203320epcas5p28fcc3c9ff8669c56213547725ea71001 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203320epcas5p28fcc3c9ff8669c56213547725ea71001 References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@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..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 Sun Sep 25 20:22:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988108 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 ADB2CC54EE9 for ; Sun, 25 Sep 2022 20:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbiIYUdi (ORCPT ); Sun, 25 Sep 2022 16:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbiIYUdg (ORCPT ); Sun, 25 Sep 2022 16:33:36 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC872C13E for ; Sun, 25 Sep 2022 13:33:34 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220925203329epoutp029084333cf3773364a37041ca3b890aaf~YNLP8neUT0567205672epoutp02j for ; Sun, 25 Sep 2022 20:33:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220925203329epoutp029084333cf3773364a37041ca3b890aaf~YNLP8neUT0567205672epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138009; bh=2f95MMw1JaP2a2qx6h2pgrT8vnSnYyP4Ul8WVop1exo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxkcOJRPKdl4Hw5sowp5AwClo67EuzscUq+ivGfdxM25QL6X1ttvwzFUbF2W2nVHI 1uchF741E/NtYvivnzxbFe3t/M/jb8aNyrTEjVyWEY8y0Y9PP4BKY7BwdaafXW2C26 L8bEtg37qpeMQ16Ohd7crn62++Hc6OeLiQqVFsz4= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220925203328epcas5p272f03be1bd4a725a19d4a0447d21e384~YNLO7DXy02718327183epcas5p2F; Sun, 25 Sep 2022 20:33:28 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MbHdy1z8yz4x9Pt; Sun, 25 Sep 2022 20:33:26 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AB.9F.26992.61BB0336; Mon, 26 Sep 2022 05:33:26 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220925203325epcas5p1e4e89d414aa7a268a6e526d3c7c2261c~YNLL2KP0I3207732077epcas5p1l; Sun, 25 Sep 2022 20:33:25 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220925203325epsmtrp2abb15881af91734ea6cb3f05afb52c10~YNLLyqxom1586315863epsmtrp2H; Sun, 25 Sep 2022 20:33:25 +0000 (GMT) X-AuditID: b6c32a49-0c7ff70000016970-1e-6330bb16d009 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 00.11.14392.51BB0336; Mon, 26 Sep 2022 05:33:25 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203323epsmtip1bde5755fe210b4f0ce7d269315bdc744~YNLJ3O0fn0205902059epsmtip1H; Sun, 25 Sep 2022 20:33:23 +0000 (GMT) From: Kanchan Joshi 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, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v9 2/7] io_uring: introduce fixed buffer support for io_uring_cmd Date: Mon, 26 Sep 2022 01:52:59 +0530 Message-Id: <20220925202304.28097-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnk+LIzCtJLcpLzFFi42LZdlhTU1dst0GywZF+LoumCX+ZLVbf7Wez uHlgJ5PF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FxUnAgAKCEB35AIAAA== X-CMS-MailID: 20220925203325epcas5p1e4e89d414aa7a268a6e526d3c7c2261c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203325epcas5p1e4e89d414aa7a268a6e526d3c7c2261c References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@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 | 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 Sun Sep 25 20:23:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988107 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 96121C54EE9 for ; Sun, 25 Sep 2022 20:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbiIYUdh (ORCPT ); Sun, 25 Sep 2022 16:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiIYUdg (ORCPT ); Sun, 25 Sep 2022 16:33:36 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B56FF2C118 for ; Sun, 25 Sep 2022 13:33:34 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220925203332epoutp03e3de9b2b6a235b8511c0e2f2d6c0c7d4~YNLSvWRHf1368813688epoutp03J for ; Sun, 25 Sep 2022 20:33:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220925203332epoutp03e3de9b2b6a235b8511c0e2f2d6c0c7d4~YNLSvWRHf1368813688epoutp03J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138012; bh=YvisQxDCCiY/YZ3UCOZ2Bjwz4ZAQa8PRkCgpg4Fkog4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XPlogZbhuT7uerT2YDoKPEDMrEyfFRwauYPAKibVec8ajg76xi8QG56YOWd6HHify PzLHlBM9JX9hi8EL3rPnjPvGpXsOQm03hG7dghvc51UnTPxe+uIwAkWdicZzNkEOsz Up2n/Udh+UAGusEGslmzghDNiNF+ajBdoXS4oKGw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220925203331epcas5p21f5dc19cc6f58a8e49e773e4449e7091~YNLROT9ia0635906359epcas5p2T; Sun, 25 Sep 2022 20:33:31 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MbHf03gZXz4x9Pv; Sun, 25 Sep 2022 20:33:28 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CA.DF.56352.81BB0336; Mon, 26 Sep 2022 05:33:28 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220925203328epcas5p1872214ededaf3b75762dcb5af15199da~YNLOMXBtq0458804588epcas5p1D; Sun, 25 Sep 2022 20:33:28 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220925203328epsmtrp2d3c4637b5c4e6b4c4cc3a7edad3933a7~YNLOJDqs-1586315863epsmtrp2I; Sun, 25 Sep 2022 20:33:28 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-76-6330bb1897ca Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CA.1A.18644.71BB0336; Mon, 26 Sep 2022 05:33:27 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203326epsmtip1e21d4e04714bed193e77562734905d21~YNLM7Hh9q0205602056epsmtip1L; Sun, 25 Sep 2022 20:33:26 +0000 (GMT) From: Kanchan Joshi 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, Kanchan Joshi Subject: [PATCH for-next v9 3/7] nvme: refactor nvme_add_user_metadata Date: Mon, 26 Sep 2022 01:53:00 +0530 Message-Id: <20220925202304.28097-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTU1dit0GywdMp4har7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUW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ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpuwOHx+WzpR6bVnWyeWxeUu+x+2YDm0ff llWMHp83yQWwRXHZpKTmZJalFunbJXBl7Dw/ialgr3BFyxHLBsYz/F2MnBwSAiYSUyY2MXcx cnEICexglNjR1cAOkRCXaL72A8oWllj57zk7RNFHRok3fU0sXYwcHGwCmhIXJpeC1IgImEks PbyGBaSGWWAOo8Tly3vYQWqEBdwkdh3hBKlhEVCV+HziBQuIzStgIbH1zidGiPnyEjMvfQfb xSlgKfFk7lZmkFYhkJrzWhDlghInZz4Ba2UGKm/eOpt5AqPALCSpWUhSCxiZVjFKphYU56bn FhsWGOWllusVJ+YWl+al6yXn525iBIe3ltYOxj2rPugdYmTiYDzEKMHBrCTCm3JRN1mINyWx siq1KD++qDQntfgQozQHi5I474Wuk/FCAumJJanZqakFqUUwWSYOTqkGJt38uGUu21ud9x+a PHH2tyUnlk+XncGxNXfhj8uVoa5zH+bHbXJo37xYZfO8YE2eewEq1/aW26wv3rG8LF6+60a0 YMafXoYwOZ/bCp3r3JSaJopPFl+asub5fi3FS3P3qkquvGB7IjHW6uNUT5PEIyfzQy25aj69 ucYh+4WN/Z3ajjVWbDOjWz6/3NC7+qvqrH+qvQs6v8qXvdjfM9tzyg/x5WwzN3zZn99d2/nf MPqP8eMqD35Lm2civ97H6K7n2BIYVMS8Z2bctD3LWpiWrVh5Uszm4BxH5ddvmHc2OZmqT8lO 2XkrqCex6R2fpp/71KWScW1Tz4o97F81//+NP+9fyEmZS7nteiezvXbJ8UIlluKMREMt5qLi RADkQPBL3gIAAA== X-CMS-MailID: 20220925203328epcas5p1872214ededaf3b75762dcb5af15199da X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203328epcas5p1872214ededaf3b75762dcb5af15199da References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Pass struct request rather than bio. It helps to kill a parameter, and some processing clean-up too. Signed-off-by: Kanchan Joshi --- 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 548aca8b5b9f..8f8435b55b95 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 Sun Sep 25 20:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988109 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 D750CC54EE9 for ; Sun, 25 Sep 2022 20:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbiIYUdl (ORCPT ); Sun, 25 Sep 2022 16:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbiIYUdj (ORCPT ); Sun, 25 Sep 2022 16:33:39 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466E92C66A for ; Sun, 25 Sep 2022 13:33:38 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220925203334epoutp02f7ace2f3f86988b4fb0d797d7b05e5c4~YNLUB9OO02609626096epoutp02X for ; Sun, 25 Sep 2022 20:33:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220925203334epoutp02f7ace2f3f86988b4fb0d797d7b05e5c4~YNLUB9OO02609626096epoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138014; bh=OWfX54HqbvG9emkZ5yG9m2A9p0d53tVfjUM9ft+8e3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcuFPrU5+Q/ZG9hTbXYqaV5iM55MDndCDcOmCyrOmv0Ri2/EKCWiEbdoyWBMKNZz5 Qa1jCa/YCNkV3IH3tpJ+RrDZ9/fySS3eDS44QuChDixxZCHVrSNVqxs9TUecbzlADy 9HJ2Vni6wlJjieiSl9ECySsah0b+CQMrwdewKQ4Q= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220925203333epcas5p4b9eff4cf934ce5ba2c0725927f98a05c~YNLTVw1H92831828318epcas5p42; Sun, 25 Sep 2022 20:33:33 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MbHf33bWyz4x9Pp; Sun, 25 Sep 2022 20:33:31 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 6D.54.39477.B1BB0336; Mon, 26 Sep 2022 05:33:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220925203330epcas5p20c712fa919a4cc2a5ec3bbaa94bb72ca~YNLQS-OyI2718327183epcas5p2I; Sun, 25 Sep 2022 20:33:30 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220925203330epsmtrp287aa87128a20e7c5717c502cc881b6ad~YNLQSSKwD1586315863epsmtrp2K; Sun, 25 Sep 2022 20:33:30 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-8d-6330bb1b77cd Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.1A.18644.A1BB0336; Mon, 26 Sep 2022 05:33:30 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203329epsmtip13580b9ae4f15707ab0740f8442451752~YNLPFPyA20205902059epsmtip1I; Sun, 25 Sep 2022 20:33:28 +0000 (GMT) From: Kanchan Joshi 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, Kanchan Joshi Subject: [PATCH for-next v9 4/7] nvme: refactor nvme_alloc_request Date: Mon, 26 Sep 2022 01:53:01 +0530 Message-Id: <20220925202304.28097-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTQ1d6t0Gywco1Uhar7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZY GRoYGJkCFSZkZ6yde4W94KxuRcO59YwNjEtUuhg5OSQETCQudz9mAbGFBHYzSuzqsuli5AKy PzFKfH9+gx3C+cwoMeHgLaAqDrCOKQtdIeK7GCVOrX6BUPTwyFx2kCI2AU2JC5NLQaaKCBhJ 7P90khWkhllgBqPE6o7X7CAJYQEniVPLJoLZLAKqEu3d25lBbF4BC4nZd1exQ5wnLzHz0ncw m1PAUuLJ3K1QNYISJ2c+ATubGaimeetsZpAFEgJf2SW+/5nICNHsIvHgVRvUIGGJV8e3QNlS Ep/f7WWDsJMlLs08xwRhl0g83nMQyraXaD3VzwzyDDPQM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rGCVTC4pz 03OLDQuM8lLL9YoTc4tL89L1kvNzNzGCA1xLawfjnlUf9A4xMnEwHmKU4GBWEuFNuaibLMSb klhZlVqUH19UmpNafIhRmoNFSZz3QtfJeCGB9MSS1OzU1ILUIpgsEwenVAMTU+mNO575Rs3r Ph5dMfWP24HKCar+c5cYzpV+aXxXfH139X/TSs23hxdxLDl+T2vSGsbYayZZDVLbbrc/TxI5 8VD5y5ctGs0V9+ZqP93ZtS9sqtDZfZN5ZhRsumyp9aOqXCbPh22HmNc8CYYDy5a9Mp7cP41n k3hGo7dubc2jLeWdSQyZudpc+Tt6JfhXWXWmGX4SlZH68/crR1eed7r8I70lW48sVfz7evsO vnvVC40TNM8LKvRPMK9XvVZxJbP55t4LWVKJEiZ/r0peEOSQWnbEb9fOJmdd2TWPNe49VGbW tIkQ/P6jtKXDwMOgyqn3bkW3UvKty5cZUjdnr+H0rnXaFvLy8OGQCv/bvzKUWIozEg21mIuK EwEshiac3wIAAA== X-CMS-MailID: 20220925203330epcas5p20c712fa919a4cc2a5ec3bbaa94bb72ca X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203330epcas5p20c712fa919a4cc2a5ec3bbaa94bb72ca References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org nvme_alloc_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 --- drivers/nvme/host/ioctl.c | 121 ++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 52 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 8f8435b55b95..b9f17dc87de9 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, @@ -144,13 +145,19 @@ static int nvme_submit_user_cmd(struct request_queue *q, struct bio *bio; 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); - bio = req->bio; + 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; ret = nvme_execute_passthru_rq(req); if (result) @@ -160,6 +167,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); return ret; } @@ -421,6 +429,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; @@ -460,13 +469,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; + } req->end_io = nvme_uring_cmd_end_io; req->end_io_data = ioucmd; @@ -489,6 +503,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 Sun Sep 25 20:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988110 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 50A82C6FA82 for ; Sun, 25 Sep 2022 20:33:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232575AbiIYUdn (ORCPT ); Sun, 25 Sep 2022 16:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbiIYUdk (ORCPT ); Sun, 25 Sep 2022 16:33:40 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227F92C660 for ; Sun, 25 Sep 2022 13:33:39 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220925203337epoutp0499048d6a7f723507e074a651fb0d07fb~YNLXCBY2I0311903119epoutp04s for ; Sun, 25 Sep 2022 20:33:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220925203337epoutp0499048d6a7f723507e074a651fb0d07fb~YNLXCBY2I0311903119epoutp04s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138017; bh=xEHA1PhpFtWG0bamSbFFyJGRJOLAAuhGzUa6LLwM4SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E6oMkOl7TechJJ1mreFv1q+Rxz7F3/cwEucqvDnDMpqVLvUg9yOsBo9bDQ4SF8myo g4mRxkvuJJQ0Y1VXHGGKNcUBkb3dGGHmfIaRpIHhVlmrHr8oyx6XBRZTxPZCzEOKPW iZuMGlNGswcTCeqokFBNTTvOsmLWHAZ2TD3I0W1c= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220925203336epcas5p25e535716418fc2ee0cd5fdc3090ced4a~YNLWbSum92718327183epcas5p2P; Sun, 25 Sep 2022 20:33:36 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MbHf61bVYz4x9Pw; Sun, 25 Sep 2022 20:33:34 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 4C.DF.56352.E1BB0336; Mon, 26 Sep 2022 05:33:34 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220925203332epcas5p3b080cce759996dec4e081f03e9ecd2f9~YNLSva-p13065330653epcas5p3D; Sun, 25 Sep 2022 20:33:32 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220925203332epsmtrp1c69f3c038d7262904ee06decc3f2d561~YNLSr3JVi1867318673epsmtrp1U; Sun, 25 Sep 2022 20:33:32 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-7f-6330bb1ec6de Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 51.11.14392.C1BB0336; Mon, 26 Sep 2022 05:33:32 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203331epsmtip194fd1e2d401f96ffffb9bd9bca2b9696~YNLRhXsA82877328773epsmtip1l; Sun, 25 Sep 2022 20:33:31 +0000 (GMT) From: Kanchan Joshi 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, Kanchan Joshi Subject: [PATCH for-next v9 5/7] block: factor out bio_map_get helper Date: Mon, 26 Sep 2022 01:53:02 +0530 Message-Id: <20220925202304.28097-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTQ1dut0GywdK3LBar7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZY GRoYGJkCFSZkZx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uMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorhsUlJzMstSi/TtErgyDvUnFOzhr5jRc5K5gXEPTxcjJ4eEgInExyl9rF2M XBxCArsZJR7cWMQKkRCXaL72gx3CFpZY+e85O0TRR0aJ57P2AxVxcLAJaEpcmFwKUiMiYCax 9PAaFpAaZoE5jBKXL+8BaxYWcJV4tX0DmM0ioCrxruMyI4jNK2Ahsfj0UhaIBfISMy99B6vh FLCUeDJ3KzPIfCGgmq3ntSDKBSVOznwCVs4MVN68dTbzBEaBWUhSs5CkFjAyrWKUTC0ozk3P LTYsMMxLLdcrTswtLs1L10vOz93ECA5wLc0djNtXfdA7xMjEwXiIUYKDWUmEN+WibrIQb0pi ZVVqUX58UWlOavEhRmkOFiVx3gtdJ+OFBNITS1KzU1MLUotgskwcnFINTLET5E2m/FheyCiW 5XF1UVF9McOF6g8pRUzLWqOWzijg6TnGkdptra93Z0PqgksREXayd7782cgdsvyB4ZITX4Rm 5pyzftXgw27MGySm6qjdeK3G47m8vfWUH1KGt4x4epexLLewyl4v+7exuKF5zbVyp7R3j2Za uTbrp7P7JU9559j7ZYKSzC/TBtXTX0IKzubJZ2dcfTv3WZkeayFD8prNm4SmnVpmylkvPU3E U6tTRti0TGK6sVbLxv5yVek7ZifmP/H/sDTRUuNhvhMbj/fGDcp7lvAe0SzmPx/9YdJByYuP prkZ7locum2q9OynNs80xbdqWK3TeDt3zvxP2QtPaq/rvSUb9v3fvJ0MSizFGYmGWsxFxYkA 14Qevt8CAAA= X-CMS-MailID: 20220925203332epcas5p3b080cce759996dec4e081f03e9ecd2f9 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203332epcas5p3b080cce759996dec4e081f03e9ecd2f9 References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Move bio allocation logic from bio_map_user_iov to a new helper bio_map_get. It is named so because functionality is opposite of what is done inside bio_map_put. This is a prep patch. Signed-off-by: Kanchan Joshi --- block/blk-map.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index 7693f8e3c454..a7838879e28e 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]; From patchwork Sun Sep 25 20:23:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988111 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 4D52AC54EE9 for ; Sun, 25 Sep 2022 20:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232645AbiIYUdw (ORCPT ); Sun, 25 Sep 2022 16:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiIYUdp (ORCPT ); Sun, 25 Sep 2022 16:33:45 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBA5C2C675 for ; Sun, 25 Sep 2022 13:33:41 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220925203339epoutp02979cb006453fd2e9c0d9347e319a31fc~YNLZHIzPy2609626096epoutp02Y for ; Sun, 25 Sep 2022 20:33:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220925203339epoutp02979cb006453fd2e9c0d9347e319a31fc~YNLZHIzPy2609626096epoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138019; bh=1eUFXioQABTGlcCmvgZ3Nvy1qjkLXODANaisMexCU74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uxjDf2+VmwEm1YH0EzoyBvFqKiC4mEiAHB652oSbFx6R4ZFAJCUSk+fRbb2CK3QmB 4Pff4ujkXcDIxR0oFgr8JjPpqwnwA3HnALBBUxL54hRq4QYgVTX182XrwCs3xDdz6R OLPkXOXE816Swg//A9nexuZYodewDUvBRYalriOE= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220925203339epcas5p20a93b564c3e0bcf57c9702ff44dcfb96~YNLYkDV3K2718327183epcas5p2R; Sun, 25 Sep 2022 20:33:39 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MbHf90mxQz4x9Pq; Sun, 25 Sep 2022 20:33:37 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 1E.54.39477.02BB0336; Mon, 26 Sep 2022 05:33:37 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220925203336epcas5p39e910479f992d7d9e233210e0647a6bf~YNLV_xuIR2847928479epcas5p3S; Sun, 25 Sep 2022 20:33:36 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220925203336epsmtrp2b1458761586f35ff92632a3314f7e0d8~YNLV99BIi1586315863epsmtrp2L; Sun, 25 Sep 2022 20:33:36 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-95-6330bb20148a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id EB.1A.18644.02BB0336; Mon, 26 Sep 2022 05:33:36 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203334epsmtip108ffed27c7bf31c0b92b85dfedc42eb1~YNLTxn6SR2877328773epsmtip1m; Sun, 25 Sep 2022 20:33:33 +0000 (GMT) From: Kanchan Joshi 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, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v9 6/7] block: introduce helper to map bvec iterator Date: Mon, 26 Sep 2022 01:53:03 +0530 Message-Id: <20220925202304.28097-7-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdlhTS1dxt0GywfZSi6YJf5ktVt/tZ7O4 eWAnk8XK1UeZLN61nmOxOPr/LZvFpEPXGC323tK2mL/sKbsDp8fls6Uem1Z1snlsXlLvsftm A5tH35ZVjB6fN8kFsEVl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qba Krn4BOi6ZeYAXaSkUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJKTAp0CtOzC0uzUvX y0stsTI0MDAyBSpMyM7o+LueqWCBdMWjVS8ZGxgviXYxcnJICJhI9D2cz9zFyMUhJLCbUWLP jz1MEM4nRolPL5awQjifGSWOLnjODNOy6NwnqMQuRokPhycyw1W9n3kCyOHgYBPQlLgwuRSk QUTASGL/p5NgDcwgO1b/fcsKUiMs4C9x7FsRSA2LgKrE3/42dhCbV8BC4ueGq1DL5CVmXvoO FucUsJR4MncrM0SNoMTJmU9YQGxmoJrmrbPBbpAQ+MsuMfV0MyNEs4vE26dPWSFsYYlXx7ew Q9hSEp/f7WWDsJMlLs08xwRhl0g83nMQyraXaD3VD/YLM9Av63fpQ+zik+j9/YQJJCwhwCvR 0SYEUa0ocW8SzCZxiYczlkDZHhITH3+GhlUPo8SuNV0sExjlZyF5YRaSF2YhbFvAyLyKUTK1 oDg3PbXYtMAoL7UcHrHJ+bmbGMEJU8trB+PDBx/0DjEycTAeYpTgYFYS4U25qJssxJuSWFmV WpQfX1Sak1p8iNEUGMYTmaVEk/OBKTuvJN7QxNLAxMzMzMTS2MxQSZx38QytZCGB9MSS1OzU 1ILUIpg+Jg5OqQYm+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LqAZEa91buM9C3kFRyeF4lkXc1ImZl7J6/dbMXF8561ZuwZOfu+Sm TEl0Tfmcvtr8mdm+pPPCbb4sj6OiDL9snlL06vxOgUyPNO3dy1jn9Cjy/1lRc7FCcOoOn59b 5jx7Gmyb0jrjcWb4yScmH+tqA5Iyi404du8R2eTyMcmon88oedaFOW+iprZeWr9yZ5jtekWJ 9dwKaT8Ocs69Ztn9iT9p6dFj9bNf7fgiJ+8c/m7FpsqqozPZrjsvfs0Q80rLUnyKeFGGEktx RqKhFnNRcSIAU+MZMeUCAAA= X-CMS-MailID: 20220925203336epcas5p39e910479f992d7d9e233210e0647a6bf X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203336epcas5p39e910479f992d7d9e233210e0647a6bf References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add blk_rq_map_user_bvec which maps the pages from bvec iterator into a bio, and places the bio into the request. This helper will be used by nvme for uring-passthrough path with pre-mapped buffers. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta --- block/blk-map.c | 80 ++++++++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 81 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index a7838879e28e..d6265d49b15b 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -622,6 +622,86 @@ 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 nr_iter, nr_segs, i; + struct bio *bio = NULL; + struct bio_vec *bv, *bvecs, *bvprvp = NULL; + struct queue_limits *lim = &q->limits; + unsigned int nsegs = 0, bytes = 0; + bool copy = false; + int ret; + unsigned long align = q->dma_pad_mask | queue_dma_alignment(q); + + /* see if we need to copy pages due to any weird situation */ + if (blk_queue_may_bounce(q)) + copy = true; + else if (iov_iter_alignment(iter) & align) + copy = true; + + if (copy) { + do { + ret = bio_copy_user_iov(rq, NULL, iter, GFP_KERNEL); + if (ret) { + blk_rq_unmap_user(bio); + rq->bio = NULL; + break; + } + if (!bio) + bio = rq->bio; + } while (iov_iter_count(iter)); + + return ret; + } + /* common (non-copy) case handling */ + nr_iter = iov_iter_count(iter); + nr_segs = iter->nr_segs; + + 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 = 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 */ + bvecs = (struct bio_vec *)iter->bvec; + for (i = 0; i < nr_segs; i++) { + bv = &bvecs[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)) + goto put_bio; + + /* 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: + bio_map_put(bio); + return -EINVAL; +} +EXPORT_SYMBOL_GPL(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 00a15808c137..1a9ae17e49be 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -977,6 +977,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 Sun Sep 25 20:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12988112 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 D9DBCC04A95 for ; Sun, 25 Sep 2022 20:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232798AbiIYUd6 (ORCPT ); Sun, 25 Sep 2022 16:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232924AbiIYUdv (ORCPT ); Sun, 25 Sep 2022 16:33:51 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBAD2C66A for ; Sun, 25 Sep 2022 13:33:46 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220925203344epoutp0276851c72a4a6edf998537fad4c3dbb95~YNLdclxAz0567005670epoutp02r for ; Sun, 25 Sep 2022 20:33:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220925203344epoutp0276851c72a4a6edf998537fad4c3dbb95~YNLdclxAz0567005670epoutp02r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664138024; bh=3A/lgcvkDGVjeLIHZ4//Y527GGsAiDQHEVnPedJDOak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTO6wvIjGoc/6gToX9oFuSDO/RwibMHGuoR1HD9IrM2PtDcpUyWHIUxqIzMTnzn/x ZkqWzfSI7ALRKQyz/1GmIW7ua9jAmf3//0FvbTiQoeHIY/18WBpGTijYuklLsssRps 4rq5WYz0dZB9MphJ4F5tBq2/KJTYjHxj4dKjbYow= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220925203343epcas5p43cb2a8a5a1be684719c3999ac01d90e0~YNLcXUpGs2832328323epcas5p4C; Sun, 25 Sep 2022 20:33:43 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MbHfF1NmBz4x9Pq; Sun, 25 Sep 2022 20:33:41 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 52.AF.26992.42BB0336; Mon, 26 Sep 2022 05:33:41 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220925203340epcas5p21bd73962a73c36c7bd56841299c0d229~YNLZy-Zs10635906359epcas5p2b; Sun, 25 Sep 2022 20:33:40 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220925203340epsmtrp21c70fa682ece6af7df1b29015edba3b1~YNLZyUb9Q1586315863epsmtrp2N; Sun, 25 Sep 2022 20:33:40 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-33-6330bb245163 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.1A.18644.42BB0336; Mon, 26 Sep 2022 05:33:40 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220925203338epsmtip1f20161add80368655d19994a5028e4c0~YNLXi3WkZ3161131611epsmtip1X; Sun, 25 Sep 2022 20:33:37 +0000 (GMT) From: Kanchan Joshi 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, Kanchan Joshi Subject: [PATCH for-next v9 7/7] nvme: wire up fixed buffer support for nvme passthrough Date: Mon, 26 Sep 2022 01:53:04 +0530 Message-Id: <20220925202304.28097-8-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925202304.28097-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgk+LIzCtJLcpLzFFi42LZdlhTQ1d1t0Gywdt9zBar7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZY GRoYGJkCFSZkZ7y/2s5e8EO14vSXFSwNjG/luhg5OSQETCS2zdzL0sXIxSEksJtRYtuS+UwQ zidGiR+r1jJCOJ8ZJb6ensUK03Jj7gpmEFtIYBejxJ2HqXBF1443s3UxcnCwCWhKXJhcClIj ImAksf/TSVaQGmaBGYwSqztes4PUCAtESaz7XQFSwyKgKrHs3VcWEJtXwEJi6bRpTBC75CVm XvrODmJzClhKPJm7lRmiRlDi5MwnYPXMQDXNW2czg8yXEPjILvH8aRfYDRICLhILdplBzBGW eHV8CzuELSXx+d1eNgg7WeLSzHNQu0okHu85CGXbS7Se6mcGGcMM9Mr6XfoQq/gken8/YYKY zivR0SYEUa0ocW/SU2joiEs8nLEEyvaQ2NfVxA4JnR5GibVTH7FNYJSfheSDWUg+mIWwbQ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iZVVqUX58UWlOanFhxilOViUxHkvdJ2MFxJITyxJzU5NLUgtgskycXBKNTBJ8Pc/82H/9q9j 3VPdl/+iNy09xMbVMVM5Nv7N8e2yN0U+vlLR6edlSTh7+KEES9er6G/SLQuaYvwivY8xfQty u18m9n7XLP2d/+TnTXRuV1dXda87tXbXXp7A7k7ljYHC9Zqtb/fxxhUZXKlsuCY6abFHzhIO gzaRZ2xrl82rK/zHts6zotBi0o/OU89v8VSuWNaaJbTCKfkY6wWmp9f/LGO6KBPIbcN2dGLz 9r7UsEqJk9O0ZNuLNQxeidjN4Gy+E1LynzvNWc99QZMmZ526y5P50vrRLP6KCwWy9XpW2U1b 3qY28wRXZPeZBMHoSS0s83fwu3Kd/cejVpN1IeexSN7xKAXFeoXjvo5rlViKMxINtZiLihMB yUEp0eACAAA= X-CMS-MailID: 20220925203340epcas5p21bd73962a73c36c7bd56841299c0d229 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220925203340epcas5p21bd73962a73c36c7bd56841299c0d229 References: <20220925202304.28097-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org 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 helper and obtain a bio/request for subsequent processing. 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: Kanchan Joshi --- drivers/nvme/host/ioctl.c | 44 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index b9f17dc87de9..505a548d4da5 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; @@ -93,23 +94,34 @@ static int nvme_map_user_request(struct request *req, void __user *ubuffer, struct bio *bio = NULL; void *meta = NULL; int ret; + bool fixedbufs = ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED); - if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - 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); + /* fixedbufs is only for non-vectored io */ + WARN_ON_ONCE(fixedbufs); + 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 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); if (ret) goto out; bio = req->bio; @@ -136,7 +148,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) { @@ -152,7 +164,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; } @@ -231,7 +243,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); } @@ -285,7 +297,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); @@ -331,7 +343,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); @@ -475,9 +487,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; }