From patchwork Tue Sep 27 17:36: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: 12991055 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 E44C5C07E9D for ; Tue, 27 Sep 2022 17:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233341AbiI0Rt2 (ORCPT ); Tue, 27 Sep 2022 13:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbiI0Rs6 (ORCPT ); Tue, 27 Sep 2022 13:48:58 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA529A6A3 for ; Tue, 27 Sep 2022 10:46:31 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220927174630epoutp031ce681fc894d455aaabd7b0dd08ca9f4~YyMA6Qw022268822688epoutp03j for ; Tue, 27 Sep 2022 17:46:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220927174630epoutp031ce681fc894d455aaabd7b0dd08ca9f4~YyMA6Qw022268822688epoutp03j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300790; bh=6HR7pDfEWCQApaFHaY1z8P5ClzoEBjIEJhDVePj5Z8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CW5MqZOWodT97RqQnmic7jU/P7GBKmZLoD6sAGTVqnxH2txWGpGc0FUmu3ELsT2y5 QxJKSNp27669gngyvOKE7AUydG0UVTeKVs6gBqWPtc2HiA4C416zYOkQ2+XUHHJL1U brNxdJR2p833g5wrv4eEEK0WKjf5Lc5IIkwgf9vg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220927174629epcas5p2182427ae4915d3268c0b4714d7a73934~YyMAM1E-c1324413244epcas5p20; Tue, 27 Sep 2022 17:46:29 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4McRrM0PzFz4x9Pp; Tue, 27 Sep 2022 17:46:27 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 78.08.26992.2F633336; Wed, 28 Sep 2022 02:46:26 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220927174626epcas5p4002acda6f0578ee314ee5e611b8d6662~YyL9OEkhy2946929469epcas5p44; Tue, 27 Sep 2022 17:46:26 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174626epsmtrp2a19f332ab991fa507a79f5882b473637~YyL9NQyCg3251332513epsmtrp2c; Tue, 27 Sep 2022 17:46:26 +0000 (GMT) X-AuditID: b6c32a49-0c7ff70000016970-2e-633336f25396 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 72.86.18644.2F633336; Wed, 28 Sep 2022 02:46:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174624epsmtip1cd45388de89debfd4591b5c8da8f430e~YyL716u1W0699506995epsmtip1h; Tue, 27 Sep 2022 17:46:24 +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 v10 1/7] io_uring: add io_uring_cmd_import_fixed Date: Tue, 27 Sep 2022 23:06:04 +0530 Message-Id: <20220927173610.7794-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdlhTQ/eTmXGywee91hZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqX rpeXWmJlaGBgZApUmJCd8X/WTKaCVUIVL19/ZWpgnMvfxcjJISFgIvHx6CrmLkYuDiGB3YwS M/a8ZgJJCAl8YpT4f14XIvGZUWLjgd2sMB3/OnczQSR2MUqsm/OBGa7q9od+9i5GDg42AU2J C5NLQRpEBIwk9n86yQpSwwyy4u2NRnaQhLCAp0TPg1lg61gEVCU2rL3OBmLzCphLzFvWxQyx TV5i5qXvYDM5BSwkDn/MhCgRlDg58wkLiM0MVNK8dTbYDRICf9kl3l28C3Wpi8T13beYIGxh iVfHt7BD2FISn9/tZYOwkyUuzTwHVVMi8XjPQSjbXqL1VD8zyF5moF/W79KH2MUn0fv7CRNI WEKAV6KjTQiiWlHi3qSnUFvFJR7OWAJle0jMuryMHRI83YwSd36fZprAKD8LyQuzkLwwC2Hb AkbmVYySqQXFuempxaYFhnmp5fB4Tc7P3cQITphanjsY7z74oHeIkYmD8RCjBAezkgjv76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PuKVe4c/IvSuOaeVrRmkvz+OYzZluFqzda8pJbkv/sqIm0P/9c6zjGlgSW1fc///dH60xUF L5RkRKyZpL/ixpe7d8NKpC5X2L86dcnETamp4rAXi68D9xwHwbDGUtHzDxv17630/lxi+vXR yX/6V7d86mqbGmhVceb92QtvCtdtfibCvuCe8sVahW9vjDS/RkTO3Zsl4cMrsjhUdJP5xHu7 tXqneUhInHi/bdc107QVk647cZrkKV/KTvqfoKDwX7p+6y293W9PHristJjV9b355Olct7S9 P7VGpdlxhKt5LG3k9upij85vOcHVdsK4VZy5YtKxzsuabf4sEWmhH78cWT5ZsM5Bw2W6Ektx RqKhFnNRcSIAHX7EsuUCAAA= X-CMS-MailID: 20220927174626epcas5p4002acda6f0578ee314ee5e611b8d6662 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174626epcas5p4002acda6f0578ee314ee5e611b8d6662 References: <20220927173610.7794-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 Tue Sep 27 17:36:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991056 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 448BCC6FA86 for ; Tue, 27 Sep 2022 17:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233383AbiI0Rta (ORCPT ); Tue, 27 Sep 2022 13:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233614AbiI0Rs7 (ORCPT ); Tue, 27 Sep 2022 13:48:59 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEAC71D3589 for ; Tue, 27 Sep 2022 10:46:34 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220927174633epoutp0378626d2268a0bc6b1785cb9ce3005a29~YyMDsOnLx3168031680epoutp03C for ; Tue, 27 Sep 2022 17:46:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220927174633epoutp0378626d2268a0bc6b1785cb9ce3005a29~YyMDsOnLx3168031680epoutp03C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300793; bh=2f95MMw1JaP2a2qx6h2pgrT8vnSnYyP4Ul8WVop1exo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAYR9N16uW6TydQQ47rPf3EDd5FHo5A1xi9JAR4IphjcwKxfClKl4eu7Nb2T47arf hbiaWUxqWIiXJencq0hfP8QESlRuqBxmYAihSzLHKGUN6OHByngj4oyar6a+lJo3NH vm2ZtZ5Wo278J70UMKcluYIt6KdVnK6i0Dbmq7ls= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220927174632epcas5p4dd6448ae88ebad9737e3589bf0e1f4be~YyMCltHJ72946929469epcas5p4_; Tue, 27 Sep 2022 17:46:32 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4McRrP44FSz4x9Pv; Tue, 27 Sep 2022 17:46:29 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 93.1F.39477.5F633336; Wed, 28 Sep 2022 02:46:29 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4~YyL-pGxQ51324413244epcas5p2z; Tue, 27 Sep 2022 17:46:28 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174628epsmtrp23f8d0307799fd395005bf7627abf1dae~YyL-oZzhm3251332513epsmtrp2e; Tue, 27 Sep 2022 17:46:28 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-8c-633336f5910b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 43.86.18644.4F633336; Wed, 28 Sep 2022 02:46:28 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174627epsmtip13333a33747e87502e44e237be49767b0~YyL_O04190699506995epsmtip1i; Tue, 27 Sep 2022 17:46:27 +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 v10 2/7] io_uring: introduce fixed buffer support for io_uring_cmd Date: Tue, 27 Sep 2022 23:06:05 +0530 Message-Id: <20220927173610.7794-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplk+LIzCtJLcpLzFFi42LZdlhTQ/ermXGywesHshZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2B06Py2dLPTat6mTz2Lyk3m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vm7DJf/jzK SPzfKZ5nC9NW1BZ6zvnTOlOJpTgj0VCLuag4EQCDreA4IAQAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsWy7bCSnO4XM+Nkg7/zDC2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJVxZMtExoKPohW3f81ia2D8LtjFyMkhIWAi Mf/OFNYuRi4OIYEdjBL3305jhUiISzRf+8EOYQtLrPz3nB2i6COjxKxTk5i7GDk42AQ0JS5M LgWpEREwk1h6eA0LSA2zwEFGicvPnrCAJIQFoiUaF/5gA7FZBFQlNh2axwxi8wqYS1w+O4MR YoG8xMxL39lBZnIKWEgc/pgJEhYCKtm66QMLRLmgxMmZECOZgcqbt85mnsAoMAtJahaS1AJG plWMkqkFxbnpucWGBUZ5qeV6xYm5xaV56XrJ+bmbGMHBrqW1g3HPqg96hxiZOBgPMUpwMCuJ 8P4+apgsxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dUA9OK G+avP2116Tqc8S9+4nyWDB03x898shNXdxYnqO//XLHiX5bqbKOuzU4FAQmpqZ5nnYq2RcaY yE871Ou0x+nNqkLzu+8Stmorx1+smfarT6k71/jotbSz01IPMn2eclZZuXc3S59UwLn53Exa 9q+3idQEczFMMH643ounQW+SxKl766VaxbwaL/BMFDJcbV99+ojc/2o/hctN/B0Krkt5Imwr j0yed295i8KTpaGPDuclhr5ceGBpZ/Nsdr7jkjUR994kvHwg3CL6k6GeZVrV2bPLDU99Fi4W umB8cEP8xeIHnR/vGjyP2msR+UExcYm4lPlsc3Hndd93q9yfKyy9pL2fnze25YF644959Uos xRmJhlrMRcWJAGlfBJTlAgAA X-CMS-MailID: 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174628epcas5p21beda845f26eedeb538cb67e286954d4 References: <20220927173610.7794-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 Tue Sep 27 17:36:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991060 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 782CEC6FA82 for ; Tue, 27 Sep 2022 17:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233450AbiI0Rtd (ORCPT ); Tue, 27 Sep 2022 13:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233635AbiI0RtC (ORCPT ); Tue, 27 Sep 2022 13:49:02 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4225D19012 for ; Tue, 27 Sep 2022 10:46:42 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220927174640epoutp01f71f4d5834bf7703e2a77931712ce9c9~YyMKvJ0mh2137021370epoutp01E for ; Tue, 27 Sep 2022 17:46:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220927174640epoutp01f71f4d5834bf7703e2a77931712ce9c9~YyMKvJ0mh2137021370epoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300800; bh=YvisQxDCCiY/YZ3UCOZ2Bjwz4ZAQa8PRkCgpg4Fkog4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=taIsjf6eAs2bVM6Q4yCb/WSWbegjokrf2bTe6SOIvO7jLLAF2yYz0c1mXxwJJjn5w 0/eSkHN0uqqS52xvo2qFGklrT2v9Feos7St+yT6bdShCT/WFrPUWvqLLf+K5UrEbPY 9In1eEVl/2+ufle3j3cKKdGUQuRQcw+23ePPx3YQ= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220927174640epcas5p2f0d193abdb140d621e6dd3c7a63079e2~YyMKW9BUA3143031430epcas5p2B; Tue, 27 Sep 2022 17:46:40 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4McRrR5TCNz4x9Pv; Tue, 27 Sep 2022 17:46:31 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 3C.79.56352.7F633336; Wed, 28 Sep 2022 02:46:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220927174631epcas5p12cd6ffbd7dad819b0af75733ce6cdd2c~YyMB_NHwQ1881118811epcas5p1R; Tue, 27 Sep 2022 17:46:31 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174631epsmtrp255e7f23830670585c2a976cb17ab4dd4~YyMB9gk6v3251332513epsmtrp2f; Tue, 27 Sep 2022 17:46:31 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-c8-633336f7aa9a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E3.86.18644.7F633336; Wed, 28 Sep 2022 02:46:31 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174629epsmtip12c9f5129ac6208bc1083716bbc42cf2b~YyMAoibdO1930019300epsmtip1N; Tue, 27 Sep 2022 17:46:29 +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 v10 3/7] nvme: refactor nvme_add_user_metadata Date: Tue, 27 Sep 2022 23:06:06 +0530 Message-Id: <20220927173610.7794-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTS/e7mXGyweID2har7/azWdw8sJPJ YuXqo0wW71rPsVgc/f+WzWLSoWuMFntvaVvMX/aU3YHD4/LZUo9NqzrZPDYvqffYfbOBzaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZY GRoYGJkCFSZkZ+w8P4mpYK9wRcsRywbGM/xdjJwcEgImEu/fPWbsYu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zpR6bVnWyeWxeUu+x+2YDm0ff llWMHp83yQWwRXHZpKTmZJalFunbJXBl7Dw/ialgr3BFyxHLBsYz/F2MnBwSAiYSJw7vZgex hQR2MEq82KQOEReXaL72gx3CFpZY+e85kM0FVPORUWLPs9XMXYwcHGwCmhIXJpeC1IgImEks PbyGBaSGWWAOo8Tly3vAmoUF3CW+L+xlBbFZBFQlzu+aB2bzCphLbL66khVigbzEzEvf2UFm cgpYSBz+mAlxj7nE1k0fWCDKBSVOznwCZjMDlTdvnc08gVFgFpLULCSpBYxMqxglUwuKc9Nz iw0LjPJSy/WKE3OLS/PS9ZLzczcxgsNbS2sH455VH/QOMTJxMB5ilOBgVhLh/X3UMFmINyWx siq1KD++qDQntfgQozQHi5I474Wuk/FCAumJJanZqakFqUUwWSYOTqkGpkwXu9l2XjfK494v XafeZVVVaTRXqvZrwOXH8+aq7Lr8Z7b7bYVJpfcn8Ose3PXu2qPjcoryd8oenNM44nPp0I3+ Fzt3cOX5m01LeL0qnNExN4rDKbfd4lJHrHPb+//s6/+U97wwZeESPMggnX/CbM+LRMk52lpm 13eIn/y4UbZL4nzKr74dPSv2/LYyOxBRNP0Yr8j/DRUKpq9s+J7x7Wh1eP+H7XnJ6VUJf+5O f7TpaOXsaZseSnMcq34cvvX460teNb9fvr9t8nfSp2CPgN4pIkdZYw6ppJtlTgucwHuOoTjQ YGrFgoXuj7xSp4cGWzzec8xV2EzmmytTp9diu/hZ6aZfFtiVnEpNEmGy0lViKc5INNRiLipO BAD0tOyj3gIAAA== X-CMS-MailID: 20220927174631epcas5p12cd6ffbd7dad819b0af75733ce6cdd2c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174631epcas5p12cd6ffbd7dad819b0af75733ce6cdd2c References: <20220927173610.7794-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 Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 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 Tue Sep 27 17:36:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991059 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 EA9E3C54EE9 for ; Tue, 27 Sep 2022 17:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233413AbiI0Rtb (ORCPT ); Tue, 27 Sep 2022 13:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233622AbiI0RtA (ORCPT ); Tue, 27 Sep 2022 13:49:00 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D0FC8432 for ; Tue, 27 Sep 2022 10:46:39 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220927174637epoutp03b43defb46c563e0e513c1363f8707ebf~YyMH2qnI63168031680epoutp03D for ; Tue, 27 Sep 2022 17:46:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220927174637epoutp03b43defb46c563e0e513c1363f8707ebf~YyMH2qnI63168031680epoutp03D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300797; bh=OWfX54HqbvG9emkZ5yG9m2A9p0d53tVfjUM9ft+8e3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6gE+UyDo0EWwXCPLeGcheXd9xcTdXGbQb2dSSusXf+36E34SgXM7aYPg/i/+JNrB 4D86S3I8grNNB8MIlBFzYCfvPPo7jUeNVuBdZY2/67ClMQiWuLeOGg5sBKwShDLgKP YqBVP3pNuOATvaD4ytNMyEIZjSgsPElN+uwVejlc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220927174637epcas5p389de44897f5bc729b521d7a889e59ab7~YyMHcUzyY2603326033epcas5p30; Tue, 27 Sep 2022 17:46:37 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4McRrV5Vxsz4x9Pw; Tue, 27 Sep 2022 17:46:34 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 64.1F.39477.AF633336; Wed, 28 Sep 2022 02:46:34 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220927174633epcas5p4d492bdebde981e2c019e30c47cf00869~YyMEZTz5x2946229462epcas5p4E; Tue, 27 Sep 2022 17:46:33 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174633epsmtrp2bc3676dfacf0cb26cbc2a3aaaec08337~YyMEYjynK3251332513epsmtrp2h; Tue, 27 Sep 2022 17:46:33 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-93-633336faf885 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A9.1D.14392.9F633336; Wed, 28 Sep 2022 02:46:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174632epsmtip1ee91eb40496b2853f7e8867313b472f1~YyMDB-hgn0699206992epsmtip1T; Tue, 27 Sep 2022 17:46:32 +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 v10 4/7] nvme: refactor nvme_alloc_request Date: Tue, 27 Sep 2022 23:06:07 +0530 Message-Id: <20220927173610.7794-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTQ/eXmXGyQc80bYvVd/vZLG4e2Mlk sXL1USaLd63nWCyO/n/LZjHp0DVGi723tC3mL3vK7sDhcflsqcemVZ1sHpuX1HvsvtnA5tG3 ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4B um6ZOUDXKCmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkus DA0MjEyBChOyM9bOvcJecFa3ouHcesYGxiUqXYycHBICJhLvJ11nBrGFBHYzSrxcXNLFyAVk f2KU+LfnHQuE841R4t2bVSwwHXvmX2OGSOxllFhw8wsbhPOZUWLWuy1AGQ4ONgFNiQuTS0Ea RASMJPZ/OskKUsMsMINRYnXHa3aQhLCAs8SJKQeZQGwWAVWJyZf+sYHYvALmEt93bGSF2CYv MfPSd3aQmZwCFhKHP2ZClAhKnJz5BOwgZqCS5q2zwQ6SEPjKLvHqTBsTRK+LRFPjS3YIW1ji 1fEtULaUxOd3e9kg7GSJSzPPQdWXSDzecxDKtpdoPdUP9gsz0C/rd+lD7OKT6P39hAkkLCHA K9HRJgRRrShxb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MC+1XK84Mbe4NC9dLzk/dxMjOMS1NHcwbl/1Qe8QIxMH4yFGCQ5mJRHe30cNk4V4 UxIrq1KL8uOLSnNSiw8xSnOwKInzXug6GS8kkJ5YkpqdmlqQWgSTZeLglGpgineT7d+0tCQ+ V+ZBv3bGtvPbe12Uj3TPjfvUuqufQ2JV0ETdNI/O/1WuPoz735rpnr74kWtLn0tdmUYL//qN iRuVDnd580/gcrkvdu/i5t0vTQot68R5JRf/uML2x+P11TkRF9V+WOdNPdjOxbD2pKGXlqyU +LT//5v5HkQv4p3KnBXzc/3/y+dyWS3Mk1kcY47v8dr5Nizpofqi9FCz5dd3LPOKvbJoyZoo 1qgmw7R2yQ/d79bbaBWKbuyttG19uFv7y6PJ9aJ9RkcXetwxiTTwub/uieki9mU/G06V3VWc 9yPTLXHv3ishaccMmqZ82MMubcyRHV1Rauef4sBksZRnx8JXt5c/4FCufxeuxFKckWioxVxU nAgAHlwmQOACAAA= X-CMS-MailID: 20220927174633epcas5p4d492bdebde981e2c019e30c47cf00869 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174633epcas5p4d492bdebde981e2c019e30c47cf00869 References: <20220927173610.7794-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 Tue Sep 27 17:36:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991058 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 AFA43C07E9D for ; Tue, 27 Sep 2022 17:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233433AbiI0Rtc (ORCPT ); Tue, 27 Sep 2022 13:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbiI0RtC (ORCPT ); Tue, 27 Sep 2022 13:49:02 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E962315E469 for ; Tue, 27 Sep 2022 10:46:41 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220927174640epoutp02734259e8ac1bcce3a17a88b717d2c3cf~YyMKbNKh_2537825378epoutp02b for ; Tue, 27 Sep 2022 17:46:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220927174640epoutp02734259e8ac1bcce3a17a88b717d2c3cf~YyMKbNKh_2537825378epoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300800; bh=xEHA1PhpFtWG0bamSbFFyJGRJOLAAuhGzUa6LLwM4SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cjKE6AjJubZKg+j+63mSjkxyKa9dpSLPTsOQx2XQJlQ3prTbVZTtN1ut3TNQehWJn HXsnY5nn/HZ8YM6NEbMefbz8mLFxe2aMUEyfp9s66S7SF4v3szaRvv6dLsPlgaEtxo Tv3ZmSoZvfMPEz79qPqWDZnzjAyk7WZG+H3MqRRA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220927174639epcas5p2d94a2597aa407e700a65c11c5b9b6c46~YyMJ29C0r2853728537epcas5p2O; Tue, 27 Sep 2022 17:46:39 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.182]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4McRrY1wy7z4x9Pt; Tue, 27 Sep 2022 17:46:37 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id FC.79.56352.DF633336; Wed, 28 Sep 2022 02:46:37 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220927174636epcas5p49008baa36dcbf2f61c25ba89c4707c0c~YyMG0XIEE2946929469epcas5p4D; Tue, 27 Sep 2022 17:46:36 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174636epsmtrp2d16573a4fe29b03e73e94de28c4adeb3~YyMGzsgzj3251332513epsmtrp2i; Tue, 27 Sep 2022 17:46:36 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-cf-633336fdf2f9 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5A.1D.14392.CF633336; Wed, 28 Sep 2022 02:46:36 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174635epsmtip1d56f5406bd01b5799d6d248bf9d2a2a2~YyMFajd1t0699506995epsmtip1k; Tue, 27 Sep 2022 17:46:34 +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 v10 5/7] block: factor out bio_map_get helper Date: Tue, 27 Sep 2022 23:06:08 +0530 Message-Id: <20220927173610.7794-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdlhTU/evmXGyQd9CDovVd/vZLG4e2Mlk sXL1USaLd63nWCyO/n/LZjHp0DVGi723tC3mL3vK7sDhcflsqcemVZ1sHpuX1HvsvtnA5tG3 ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4B um6ZOUDXKCmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkus DA0MjEyBChOyMw71JxTs4a+Y0XOSuY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fbe0raYv+wpuwOHx+WzpR6bVnWyeWxeUu+x+2YDm0ff llWMHp83yQWwRXHZpKTmZJalFunbJXBlHOpPKNjDXzGj5yRzA+Meni5GTg4JAROJac9+sXUx cnEICexmlHhwcw4zREJcovnaD3YIW1hi5b/nYLaQwEdGidMnOboYOTjYBDQlLkwuBQmLCJhJ LD28hgVkDrPAHEaJy5f3gNULC7hJLLs6kRXEZhFQlWjqfgUW5xUwl9gz/SQbxHx5iZmXvrOD zOQUsJA4/DETYpW5xNZNH1ggygUlTs58AmYzA5U3b53NPIFRYBaS1CwkqQWMTKsYJVMLinPT c4sNCwzzUsv1ihNzi0vz0vWS83M3MYLDW0tzB+P2VR/0DjEycTAeYpTgYFYS4f191DBZiDcl sbIqtSg/vqg0J7X4EKM0B4uSOO+FrpPxQgLpiSWp2ampBalFMFkmDk6pBqY+rvoPX2YYh88V 17n/4L/Wg/yVs+uYp+09oi70ZofR5jcNvhnX3m2xZOk+++ZJa51z6aOibxklx+/6v9Su2FB6 WswuyUFsp+xaDfUnjnY68zP2vzDqKytJnbJA8l3Xycnh7Ft/vOsvX256vPol+/1g1ULhxdY5 gt+Dq0pe7YlYIKxzyur1R4s2ljW/bd6vnyMf+bTu1odKP+O4v+paxwxq+Gy/xHzLtPmSZiW+ /Oa/cwXL9z1K7K+fd9lh39oXq3L2TE3SWb5vyZ+l8idU70y9usn96rcXSeX71NsbmeTb5k11 EVlxVvvb2d6LvvxLg0JnXu+sDnyg3sXtmLojJ2j9pP6MS/ck90ZOUfNdbH9eiaU4I9FQi7mo OBEAQSjLqN4CAAA= X-CMS-MailID: 20220927174636epcas5p49008baa36dcbf2f61c25ba89c4707c0c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174636epcas5p49008baa36dcbf2f61c25ba89c4707c0c References: <20220927173610.7794-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 Tue Sep 27 17:36:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991061 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 0FD00C6FA83 for ; Tue, 27 Sep 2022 17:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbiI0Rte (ORCPT ); Tue, 27 Sep 2022 13:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbiI0RtE (ORCPT ); Tue, 27 Sep 2022 13:49:04 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA306BD5A for ; Tue, 27 Sep 2022 10:46:45 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220927174644epoutp02040eafbf239579c289b2001ea49787ff~YyMN-7fER0070100701epoutp02U for ; Tue, 27 Sep 2022 17:46:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220927174644epoutp02040eafbf239579c289b2001ea49787ff~YyMN-7fER0070100701epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300804; bh=GlOSiXoErVKZqBReawxn7jrswKJDL5aTOisQmoB9Zsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cUoeq70lUAfQClJ74i56O1hYi/YqX19GV2hZAyJSCaz/Wpr8cpD65+k0ur76JNTn9 BXuJ7jUR4a5VgknxZs4RTBQ65F6BOmZ8C6SFAeEqd1YS8jFj7FBMPRRsF5lI7oyVTQ DYmFk4a7jq/Eax6Af4Ja3O/0dfrutjfoVblw0xiU= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220927174643epcas5p2e49f728e79181f948d62db1233f9c78f~YyMNcPxi92853728537epcas5p2d; Tue, 27 Sep 2022 17:46:43 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.183]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4McRrb6wBjz4x9Pp; Tue, 27 Sep 2022 17:46:39 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8D.79.56352.FF633336; Wed, 28 Sep 2022 02:46:39 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220927174639epcas5p22b46aed144d81d82b2a9b9de586808ac~YyMJhpRII2853728537epcas5p2N; Tue, 27 Sep 2022 17:46:39 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220927174639epsmtrp2fb2ae91112128e3ca140dd60128be690~YyMJgvtbv3251332513epsmtrp2k; Tue, 27 Sep 2022 17:46:39 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-d2-633336ff1547 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id EA.1D.14392.FF633336; Wed, 28 Sep 2022 02:46:39 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174637epsmtip1e540b5c04c91280656b47e9fdfa2265c~YyMIEMg860699206992epsmtip1V; Tue, 27 Sep 2022 17:46: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 , Anuj Gupta Subject: [PATCH for-next v10 6/7] block: extend functionality to map bvec iterator Date: Tue, 27 Sep 2022 23:06:09 +0530 Message-Id: <20220927173610.7794-7-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplk+LIzCtJLcpLzFFi42LZdlhTU/e/mXGyQd9kY4umCX+ZLVbf7Wez uHlgJ5PFytVHmSzetZ5jsTj6/y2bxaRD1xgt9t7Stpi/7Cm7A6fH5bOlHptWdbJ5bF5S77H7 ZgObR9+WVYwenzfJBbBFZdtkpCampBYppOYl56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam 2iq5+AToumXmAJ2kpFCWmFMKFApILC5W0rezKcovLUlVyMgvLrFVSi1IySkwKdArTswtLs1L 18tLLbEyNDAwMgUqTMjOmLzwFFtBm3TF64btbA2MW0S7GDk5JARMJD7tOcvaxcjFISSwm1Gi /9cnFgjnE6PExwmvGSGcb4wS/9+sZIJp+T57LTOILSSwl1Giry0Gougzo0Tnhb1Aszg42AQ0 JS5MLgWpEREwktj/6STYCmaQFav/vmUFSQgLhEi0tT4Bs1kEVCXW7mpmAbF5Bcwlen6/ZIZY Ji8x89J3dpCZnAIWEoc/ZkKUCEqcnPkErJwZqKR562xmkPkSAn/ZJe6cn8sG0esi8bLnJ9Qc YYlXx7ewQ9hSEp/f7YWqSZa4NPMc1GMlEo/3HISy7SVaT/Uzg+xlBvpl/S59iF18Er2/nzCB hCUEeCU62oQgqhUl7k16ygphi0s8nLEEyvaQuL/zLzskqLoZJX4sTZ3AKD8LyQezkHwwC2HZ AkbmVYySqQXFuempxaYFxnmp5fBoTc7P3cQITpda3jsYHz34oHeIkYmD8RCjBAezkgjv76OG yUK8KYmVValF+fFFpTmpxYcYTYEhPJFZSjQ5H5iw80riDU0sDUzMzMxMLI3NDJXEeRfP0EoW EkhPLEnNTk0tSC2C6WPi4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rJ9bN7/IJiHX102Zc9p356/DZnl9qf1fl188cE1usm6WFLP J095/xqjwP4dv47+UTcQ/9Dqrnv2vt4bIb06pdA/TZyCuSreHqvZt2+ff+SvwkX716/cLhn6 TVv31Xvh45zZKlOOn3V3zdxVyFIVckbcYO2xPZ8OTpac8bXqsL12bPSDXbN9iq3+XOZd4+Tk +CY07cdD/3aJnsZdq2bYy/1y5Hfcsn6aGb9RW4Jz3iGJDdqbN6fa6G8MKzq+Qy374GMlluKM REMt5qLiRADu0mLf5QIAAA== X-CMS-MailID: 20220927174639epcas5p22b46aed144d81d82b2a9b9de586808ac X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174639epcas5p22b46aed144d81d82b2a9b9de586808ac References: <20220927173610.7794-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Extend blk_rq_map_user_iov so that it can handle bvec iterator. It maps the pages from bvec iterator into a bio and place the bio into request. This helper will be used by nvme for uring-passthrough path when IO is done using pre-mapped buffers. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta --- block/blk-map.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index a7838879e28e..a1aa8dacb02b 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -548,6 +548,74 @@ int blk_rq_append_bio(struct request *rq, struct bio *bio) } EXPORT_SYMBOL(blk_rq_append_bio); +/* Prepare bio for passthrough IO given ITER_BVEC iter */ +static int blk_rq_map_user_bvec(struct request *rq, const struct iov_iter *iter, + bool *copy) +{ + 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; + 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)) + goto out_copy; + else if (iov_iter_alignment(iter) & align) + goto out_copy; + /* virt-alignment gap is checked anyway down, so avoid extra loop here */ + + 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, (struct iov_iter *)iter); + blk_rq_bio_prep(rq, bio, nr_segs); + + /* loop to perform a bunch of sanity checks */ + bvecs = (struct bio_vec *)iter->bvec; + for (i = 0; i < nr_segs; i++) { + bv = &bvecs[i]; + /* + * If the queue doesn't support SG gaps and adding this + * offset would create a gap, fallback to copy. + */ + if (bvprvp && bvec_gap_to_prev(lim, bvprvp, bv->bv_offset)) { + bio_map_put(bio); + goto out_copy; + } + /* 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; +out_copy: + *copy = true; + return 0; +} + /** * blk_rq_map_user_iov - map user data to a request, for passthrough requests * @q: request queue where request should be inserted @@ -573,6 +641,14 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, struct iov_iter i; int ret = -EINVAL; + if (iov_iter_is_bvec(iter)) { + ret = blk_rq_map_user_bvec(rq, iter, ©); + if (ret != 0) + goto fail; + if (copy) + goto do_copy; + return ret; + } if (!iter_is_iovec(iter)) goto fail; @@ -585,6 +661,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, else if (queue_virt_boundary(q)) copy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter); +do_copy: i = *iter; do { if (copy) From patchwork Tue Sep 27 17:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12991062 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 0A551C6FA94 for ; Tue, 27 Sep 2022 17:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233459AbiI0Rte (ORCPT ); Tue, 27 Sep 2022 13:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233644AbiI0RtE (ORCPT ); Tue, 27 Sep 2022 13:49:04 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8CB99B50 for ; Tue, 27 Sep 2022 10:46:48 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220927174646epoutp0109fdff1ddfe84c773b5a6a7330ad32c3~YyMQal8Tx2137021370epoutp01H for ; Tue, 27 Sep 2022 17:46:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220927174646epoutp0109fdff1ddfe84c773b5a6a7330ad32c3~YyMQal8Tx2137021370epoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664300806; bh=Z0IC8FwLh8tvDC+rBID68Mm7U2jdtPbcK+YXwZu6xLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b3IwtXmwNznnQ7HSZ3rDWEx2OIdpNpiyUT3cD0cJ9oaWYHgyzuGWpwQwoq8XPwuue sV2giXPCCy1T9c1FFPKbBhLeJctWAZqEi8H8sAVOE5CMS+Yd5LHOKDWLjsNafs/prZ LHfKKvUihEwtcv3R3lQdHc6CfdXPPyu2hqCGXATI= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220927174645epcas5p1368eef0b8fa5cb698e607ecdd6e8ccb8~YyMPN8soi3009630096epcas5p17; Tue, 27 Sep 2022 17:46:45 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.174]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4McRrg1Bgsz4x9Pw; Tue, 27 Sep 2022 17:46:43 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C6.1F.39477.30733336; Wed, 28 Sep 2022 02:46:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220927174642epcas5p1dafa31776d4eb8180e18f149ed25640c~YyMMUtgTU2244622446epcas5p1X; Tue, 27 Sep 2022 17:46:42 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220927174642epsmtrp1e3f38800bdd1cbac135396634c8e3c75~YyMMUBdlS2108921089epsmtrp1Q; Tue, 27 Sep 2022 17:46:42 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-a7-633337037fea Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 76.86.18644.20733336; Wed, 28 Sep 2022 02:46:42 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220927174641epsmtip1156eddfe38c69c571429239d9c4c8946~YyMLA_T640699206992epsmtip1W; Tue, 27 Sep 2022 17:46:40 +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 v10 7/7] nvme: wire up fixed buffer support for nvme passthrough Date: Tue, 27 Sep 2022 23:06:10 +0530 Message-Id: <20220927173610.7794-8-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220927173610.7794-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjk+LIzCtJLcpLzFFi42LZdlhTS5fZ3DjZYHU7u8Xqu/1sFjcP7GSy WLn6KJPFu9ZzLBZH/79ls5h06Bqjxd5b2hbzlz1ld+DwuHy21GPTqk42j81L6j1232xg8+jb sorR4/MmuQC2qGybjNTElNQihdS85PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58A XbfMHKBrlBTKEnNKgUIBicXFSvp2NkX5pSWpChn5xSW2SqkFKTkFJgV6xYm5xaV56Xp5qSVW hgYGRqZAhQnZGdN+Rxe0qlV0PP/D2MD4Q66LkZNDQsBEYsWnp2xdjFwcQgK7GSV+rfrOBOF8 YpS4fn4VK4TzmVHiRdsedpiW7xuWMYPYQgK7GCXuTwiHK1rf9Jyxi5GDg01AU+LC5FKQGhEB I4n9n06CDWIWmMEosbrjNTtIjbBAtMT5k5EgNSwCqhIL1lxkAgnzCphLnJ3BDbFKXmLmpe9g 1ZwCFhKHP2aChHkFBCVOznzCAmIzA5U0b53NDDJdQuAru8Skee8YIXpdJE7+u8gMYQtLvDq+ Bep8KYmX/W1QdrLEpZnnmCDsEonHew5C2fYSraf6mUH2MgN9sn6XPsQuPone30/ArpQQ4JXo aBOCqFaUuDfpKSuELS7xcMYSKNtDovX7U3ZI4HQzSvRdXso2gVF+FpIXZiF5YRbCtgWMzKsY JVMLinPTU4tNC4z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57oetkvJBAemJJanZqakFqEUyWiYNTqoEpuvXAsk+yKR8+ JXh/KDGqNd32w2TO0Y+lhWcc1rmZt7le2HqP7XCe2W4Bdp5GRcc0+UbW2D+mHoW/H27ubsvM VOiQXrlQ6KSD/JTL3rEWn/+whi44IxmZxDo3bWW/guHeU0dErPOqGJes4zr1vEBa1NCUN3// h9jcg9XqWy4VfErr0cl9JGjM+zjHxNe9fWK5f9Ou6HdbNL/IxPMaq/0ye8q3JeAM/0PBY1/X 3PXOfnNnzWe2zYeLPzVtfmtt6ff4u6dZZUyTQkXdItNZ1b9t9vS6rFqqmMRne1lpU9YGxyRr p8x3m7Q0zbaVc1/P51m9rqT52q3DhZlGr6OMZU5u3H/u3K01FyvmBV0rVVFiKc5INNRiLipO BAD+Fksh3AIAAA== X-CMS-MailID: 20220927174642epcas5p1dafa31776d4eb8180e18f149ed25640c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220927174642epcas5p1dafa31776d4eb8180e18f149ed25640c References: <20220927173610.7794-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 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..1a45246f0d7a 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_iov(q, req, NULL, &iter, GFP_KERNEL); + } 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; }