From patchwork Fri Aug 19 10:30:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12948691 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 5E9D2C3F6B0 for ; Fri, 19 Aug 2022 10:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348376AbiHSKky (ORCPT ); Fri, 19 Aug 2022 06:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348443AbiHSKkv (ORCPT ); Fri, 19 Aug 2022 06:40:51 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22961F0768 for ; Fri, 19 Aug 2022 03:40:44 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220819104038epoutp03dc0343aadc6d6f696cea385c80396102~MuOD56OhY1595915959epoutp03k for ; Fri, 19 Aug 2022 10:40:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220819104038epoutp03dc0343aadc6d6f696cea385c80396102~MuOD56OhY1595915959epoutp03k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660905639; bh=luIncdN4Xs0/S1pPktHEcbVCfvwuJAGRaiPlDpqB9Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZkIoehf28+eBDdzlbBP2VPwURt49X+6kc8prOs9YVBccXeP/SAlVQrb606vYJaa5R A+QeirYW4m82sjUbdVej3iR1OJTOGFJKcRFIP3TMQgFpfEMlFM5YlDnF475p/+FyjY oSA/fJqAv3S3j7MaJqHGyaJL26n1htSr8rP0oczM= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220819104038epcas5p394a9a6345e766d02cb41514c87f13a59~MuODdweyj1255012550epcas5p3_; Fri, 19 Aug 2022 10:40:38 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4M8JF03yxjz4x9Pw; Fri, 19 Aug 2022 10:40:36 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 0E.63.49150.4A86FF26; Fri, 19 Aug 2022 19:40:36 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220819104036epcas5p2bb4d9b2cccbdfcdb460e085abe7fd1a8~MuOBVSWKC3086930869epcas5p2y; Fri, 19 Aug 2022 10:40:36 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220819104036epsmtrp1782211f8f9e4e8aae82d93c33472bf4f~MuOBUVhuW1513515135epsmtrp1B; Fri, 19 Aug 2022 10:40:36 +0000 (GMT) X-AuditID: b6c32a4b-37dff7000000bffe-ca-62ff68a4bec6 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 58.85.08802.3A86FF26; Fri, 19 Aug 2022 19:40:35 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220819104034epsmtip134ff85bbc9da877d52a3fdac6d6bab82~MuN-cbf4l0468404684epsmtip15; Fri, 19 Aug 2022 10:40: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, ming.lei@redhat.com, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next 1/4] io_uring: introduce io_uring_cmd_import_fixed Date: Fri, 19 Aug 2022 16:00:18 +0530 Message-Id: <20220819103021.240340-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819103021.240340-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGJsWRmVeSWpSXmKPExsWy7bCmlu6SjP9JBjPey1g0TfjLbLH6bj+b xc0DO5ksVq4+ymTxrvUci8XR/2/ZLCYdusZosfeWtsX8ZU/ZLQ5NbmZy4PK4fLbUY9OqTjaP zUvqPXbfbGDzeL/vKptH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6hpaWpgrKeQl5qbaKrn4BOi6ZeYAHaekUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJ KTAp0CtOzC0uzUvXy0stsTI0MDAyBSpMyM548iqy4Dx/RevaDqYGxkm8XYycHBICJhL3lyxk 7WLk4hAS2M0oceNcCwuE84lRYsGdiUwgVUICnxkltl7Nhum4enopK0R8F6PE5mYniAagmtuz pgB1c3CwCWhKXJhcClIjImAksf/TSbANzAIXGCVONn1lBqkRFvCWWPtYE6SGRUBVYv3epSwg Nq+ApcS2fWeYIHbJS8y89J0dxOYUsJKYtfQqG0SNoMTJmU/A6pmBapq3zmYGmS8h0MohcXbp ZVaIZheJwx8XsUHYwhKvjm9hh7ClJF72t0HZyRKXZp6DWlYi8XjPQSjbXqL1VD/YncxAv6zf pQ+xi0+i9/cTJpCwhACvREebEES1osS9SU+htopLPJyxBMr2kOj+c4QdEjy9jBKLf1xgncAo PwvJC7OQvDALYdsCRuZVjJKpBcW56anFpgXGeanl8FhNz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TlYlMR5L3SdjBcSSE8sSc1OTS1ILYLJMnFw SjUweemfl7mxZ4niQ/GZHyPVbgUduFrEfU/uoc/80KKQC9panwTlGpd+t6r3evk5MSxDwute QDODzH+WPdeaRDXM5qa5v1z8L3jKnAtsxol12/hOX93dcKha9tb5H+dnbtNYpeK3Vfzr4u0n mTf07ZdxtH8oHTZvV8+SmprMTXJzmp68NnjWd2djq2lX3aW7aXH3M6VqLvq3y7eJ7nA7rav3 S9ltq7uFluyj0s9f3fsm3+rZsIbbI17vzcmDs0r3N9j+sLFZWNKrnarRuuSddmPBlGyX63Fh zD9mHVopVnfcZ3f4JRP5TptIxgNN0t4Cb1v3Hl08NTNK3FvZ5Ldz4m7DuprVZ1qWsKv+FfMr 6VqgxFKckWioxVxUnAgA1ciFCuwCAAA= X-CMS-MailID: 20220819104036epcas5p2bb4d9b2cccbdfcdb460e085abe7fd1a8 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220819104036epcas5p2bb4d9b2cccbdfcdb460e085abe7fd1a8 References: <20220819103021.240340-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 | 7 +++++++ io_uring/uring_cmd.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 58676c0a398f..60aba10468fc 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -32,6 +32,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 +61,11 @@ static inline void io_uring_free(struct task_struct *tsk) __io_uring_free(tsk); } #else +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd) +{ + return -1; +} static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t ret2) { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 8900856fa588..ff65cc8ab6cc 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -121,3 +121,13 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) return IOU_ISSUE_SKIP_COMPLETE; } + +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, + int rw, struct iov_iter *iter, void *ioucmd) +{ + struct io_kiocb *req = container_of(ioucmd, struct io_kiocb, uring_cmd); + struct io_mapped_ubuf *imu = req->imu; + + return io_import_fixed(rw, iter, imu, ubuf, len); +} +EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); From patchwork Fri Aug 19 10:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12948693 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 DC268C32789 for ; Fri, 19 Aug 2022 10:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348445AbiHSKk5 (ORCPT ); Fri, 19 Aug 2022 06:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348451AbiHSKky (ORCPT ); Fri, 19 Aug 2022 06:40:54 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93747F4383 for ; Fri, 19 Aug 2022 03:40:52 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220819104047epoutp028c2f083ffd46a67451058f83698cf05d~MuOL5Ixpa1795917959epoutp02P for ; Fri, 19 Aug 2022 10:40:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220819104047epoutp028c2f083ffd46a67451058f83698cf05d~MuOL5Ixpa1795917959epoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660905647; bh=jbua48Q58XlA+8adVklDtQ//CCw/sQv/vde37Fg5XWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeAJnTGwBOpKMZLGTuurQaVDjDEfEFxLLX2f9pN5VdMBn0VVi/BO/VpMl+L84qHRW N7j/CdysudUV/KKLuG42j1QfAuVr41PWEbTio7TmmqjFJMzepMb7TacYVyqEl8xZrX 8z+orTDdSMhwy1CJSkefg8CG6ptG7jqcTfS025Zs= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220819104043epcas5p248f8ce6ed4cbbc4e4ca7d141b2a7b874~MuOIcVbzi3177231772epcas5p2D; Fri, 19 Aug 2022 10:40:43 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4M8JF52rytz4x9Pv; Fri, 19 Aug 2022 10:40:41 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 9F.63.49150.7A86FF26; Fri, 19 Aug 2022 19:40:39 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220819104038epcas5p265c9385cfd9189d20ebfffeaa4d5efae~MuODxaAfn3086930869epcas5p22; Fri, 19 Aug 2022 10:40:38 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220819104038epsmtrp103129c4c48ecb00fbb7dcbdb843f3b49~MuODwby3d1513515135epsmtrp1E; Fri, 19 Aug 2022 10:40:38 +0000 (GMT) X-AuditID: b6c32a4b-37dff7000000bffe-d0-62ff68a77345 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FD.7C.08905.6A86FF26; Fri, 19 Aug 2022 19:40:38 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220819104037epsmtip1bbf0de911f42c1ac039aac8296d27063~MuOCQaBz40577205772epsmtip1h; Fri, 19 Aug 2022 10:40: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, ming.lei@redhat.com, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next 2/4] io_uring: introduce fixed buffer support for io_uring_cmd Date: Fri, 19 Aug 2022 16:00:19 +0530 Message-Id: <20220819103021.240340-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819103021.240340-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmlu7yjP9JBht/sVo0TfjLbLH6bj+b xc0DO5ksVq4+ymTxrvUci8XR/2/ZLCYdusZosfeWtsX8ZU/ZLQ5NbmZy4PK4fLbUY9OqTjaP zUvqPXbfbGDzeL/vKptH35ZV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20ebfffeaa4d5efae X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220819104038epcas5p265c9385cfd9189d20ebfffeaa4d5efae References: <20220819103021.240340-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Anuj Gupta Add IORING_OP_URING_CMD_FIXED opcode that enables 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 | 5 ++++- include/uapi/linux/io_uring.h | 1 + io_uring/opdef.c | 10 ++++++++++ io_uring/rw.c | 3 ++- io_uring/uring_cmd.c | 18 +++++++++++++++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 60aba10468fc..40961d7c3827 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -5,6 +5,8 @@ #include #include +#include + enum io_uring_cmd_flags { IO_URING_F_COMPLETE_DEFER = 1, IO_URING_F_UNLOCKED = 2, @@ -15,6 +17,7 @@ enum io_uring_cmd_flags { IO_URING_F_SQE128 = 4, IO_URING_F_CQE32 = 8, IO_URING_F_IOPOLL = 16, + IO_URING_F_FIXEDBUFS = 32, }; struct io_uring_cmd { @@ -33,7 +36,7 @@ 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) + 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 *)); diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 1463cfecb56b..80ea35d1ed5c 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -203,6 +203,7 @@ enum io_uring_op { IORING_OP_SOCKET, IORING_OP_URING_CMD, IORING_OP_SENDZC_NOTIF, + IORING_OP_URING_CMD_FIXED, /* this goes last, obviously */ IORING_OP_LAST, diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 9a0df19306fe..7d5731b84c92 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -472,6 +472,16 @@ const struct io_op_def io_op_defs[] = { .issue = io_uring_cmd, .prep_async = io_uring_cmd_prep_async, }, + [IORING_OP_URING_CMD_FIXED] = { + .needs_file = 1, + .plug = 1, + .name = "URING_CMD_FIXED", + .iopoll = 1, + .async_size = uring_cmd_pdu_size(1), + .prep = io_uring_cmd_prep, + .issue = io_uring_cmd, + .prep_async = io_uring_cmd_prep_async, + }, [IORING_OP_SENDZC_NOTIF] = { .name = "SENDZC_NOTIF", .needs_file = 1, diff --git a/io_uring/rw.c b/io_uring/rw.c index 1a4fb8a44b9a..3c7b94bffa62 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -1005,7 +1005,8 @@ int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin) if (READ_ONCE(req->iopoll_completed)) break; - if (req->opcode == IORING_OP_URING_CMD) { + if (req->opcode == IORING_OP_URING_CMD || + req->opcode == IORING_OP_URING_CMD_FIXED) { struct io_uring_cmd *ioucmd = (struct io_uring_cmd *)rw; ret = req->file->f_op->uring_cmd_iopoll(ioucmd); diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index ff65cc8ab6cc..9383150b2949 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -3,11 +3,13 @@ #include #include #include +#include #include #include "io_uring.h" #include "uring_cmd.h" +#include "rsrc.h" static void io_uring_cmd_work(struct io_kiocb *req, bool *locked) { @@ -74,6 +76,18 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (sqe->rw_flags || sqe->__pad1) return -EINVAL; + + req->buf_index = READ_ONCE(sqe->buf_index); + if (req->opcode == IORING_OP_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 index; + + if (unlikely(req->buf_index >= ctx->nr_user_bufs)) + return -EFAULT; + index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); + req->imu = ctx->user_bufs[index]; + io_req_set_rsrc_node(req, ctx, 0); + } ioucmd->cmd = sqe->cmd; ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); return 0; @@ -98,6 +112,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) req->iopoll_completed = 0; WRITE_ONCE(ioucmd->cookie, NULL); } + if (req->opcode == IORING_OP_URING_CMD_FIXED) + issue_flags |= IO_URING_F_FIXEDBUFS; if (req_has_async_data(req)) ioucmd->cmd = req->async_data; @@ -125,7 +141,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, struct iov_iter *iter, void *ioucmd) { - struct io_kiocb *req = container_of(ioucmd, struct io_kiocb, uring_cmd); + struct io_kiocb *req = cmd_to_io_kiocb(ioucmd); struct io_mapped_ubuf *imu = req->imu; return io_import_fixed(rw, iter, imu, ubuf, len); From patchwork Fri Aug 19 10:30:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12948692 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 62CA4C32774 for ; Fri, 19 Aug 2022 10:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348443AbiHSKk4 (ORCPT ); Fri, 19 Aug 2022 06:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348446AbiHSKkv (ORCPT ); Fri, 19 Aug 2022 06:40:51 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E34ACF43B1 for ; Fri, 19 Aug 2022 03:40:50 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220819104049epoutp0390536bc7fa39bd29a7d02e7814ec897a~MuONk-kPC1596215962epoutp03v for ; Fri, 19 Aug 2022 10:40:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220819104049epoutp0390536bc7fa39bd29a7d02e7814ec897a~MuONk-kPC1596215962epoutp03v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660905649; bh=tzGYFtcZm58+i7gZlKId0iWHEtzko0JqMTEVRvMBpzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rtycfx26PR5oZLJLtSuSjplNsUqu1psetw6EScllqWVn7Ia2aN7Vo8igZEydNqZpw aKoxDP/U3lm0cjQowsv3bOyocgCTIPIm4NsYk6v2Q+e+ygxqS4A1gjuTyG967wjqro 2F90q/XmsTMsaSPoOzIwFk/u2nv/uDuSylWUw0EU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220819104049epcas5p19ed8c5a3cdb95ec6cd0fc9f22e6abcb5~MuONOiVE30663706637epcas5p1t; Fri, 19 Aug 2022 10:40:49 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4M8JF95dJxz4x9Px; Fri, 19 Aug 2022 10:40:45 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0B.E3.49477.AA86FF26; Fri, 19 Aug 2022 19:40:42 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220819104042epcas5p177f384cd4c15918f666c7eacc4dfab4c~MuOHCpSKa0652106521epcas5p1v; Fri, 19 Aug 2022 10:40:42 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220819104042epsmtrp1ad49f1f504746d22c6b0f7358e4b0c0a~MuOHB57cr1513515135epsmtrp1I; Fri, 19 Aug 2022 10:40:42 +0000 (GMT) X-AuditID: b6c32a49-82dff7000000c145-83-62ff68aa7b76 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D9.85.08802.AA86FF26; Fri, 19 Aug 2022 19:40:42 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220819104040epsmtip1bd7bae4cb87fe4a4ae49f8560660bba2~MuOE-h6LQ0577205772epsmtip1i; Fri, 19 Aug 2022 10:40:39 +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, ming.lei@redhat.com, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next 3/4] block: add helper to map bvec iterator for passthrough Date: Fri, 19 Aug 2022 16:00:20 +0530 Message-Id: <20220819103021.240340-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819103021.240340-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmlu6qjP9JBs33LSyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeL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VWKrEUZyQaajEXFScCAH0cK9DwAgAA X-CMS-MailID: 20220819104042epcas5p177f384cd4c15918f666c7eacc4dfab4c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220819104042epcas5p177f384cd4c15918f666c7eacc4dfab4c References: <20220819103021.240340-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Add blk_rq_map_user_fixedb which maps the bvec iterator into a bio and places that into the request. This helper is to be used in nvme for uring-passthrough with fixed-buffer. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta --- block/blk-map.c | 71 ++++++++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 72 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index d0ff80a9902e..ee17cc78bf00 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -611,6 +611,77 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, } EXPORT_SYMBOL(blk_rq_map_user); +/* Prepare bio for passthrough IO given an existing bvec iter */ +int blk_rq_map_user_bvec(struct request *rq, struct iov_iter *iter) +{ + struct request_queue *q = rq->q; + size_t iter_count, nr_segs; + struct bio *bio; + struct bio_vec *bv, *bvec_arr, *bvprvp = NULL; + struct queue_limits *lim = &q->limits; + unsigned int nsegs = 0, bytes = 0; + int ret, i; + + iter_count = iov_iter_count(iter); + nr_segs = iter->nr_segs; + + if (!iter_count || (iter_count >> 9) > queue_max_hw_sectors(q)) + return -EINVAL; + if (nr_segs > queue_max_segments(q)) + return -EINVAL; + if (rq->cmd_flags & REQ_POLLED) { + blk_opf_t opf = rq->cmd_flags | REQ_ALLOC_CACHE; + + /* no iovecs to alloc, as we already have a BVEC iterator */ + bio = bio_alloc_bioset(NULL, 0, opf, GFP_KERNEL, + &fs_bio_set); + if (!bio) + return -ENOMEM; + } else { + bio = bio_kmalloc(0, GFP_KERNEL); + if (!bio) + return -ENOMEM; + bio_init(bio, NULL, bio->bi_inline_vecs, 0, req_op(rq)); + } + bio_iov_bvec_set(bio, iter); + blk_rq_bio_prep(rq, bio, nr_segs); + + /* loop to perform a bunch of sanity checks */ + bvec_arr = (struct bio_vec *)iter->bvec; + for (i = 0; i < nr_segs; i++) { + bv = &bvec_arr[i]; + /* + * If the queue doesn't support SG gaps and adding this + * offset would create a gap, disallow it. + */ + if (bvprvp && bvec_gap_to_prev(lim, bvprvp, bv->bv_offset)) { + ret = -EINVAL; + goto out_free; + } + + /* check full condition */ + if (nsegs >= nr_segs || bytes > UINT_MAX - bv->bv_len) { + ret = -EINVAL; + goto out_free; + } + + if (bytes + bv->bv_len <= iter_count && + bv->bv_offset + bv->bv_len <= PAGE_SIZE) { + nsegs++; + bytes += bv->bv_len; + } else { + ret = -EINVAL; + goto out_free; + } + bvprvp = bv; + } + return 0; +out_free: + bio_map_put(bio); + return ret; +} +EXPORT_SYMBOL(blk_rq_map_user_bvec); + /** * blk_rq_unmap_user - unmap a request with user data * @bio: start of bio list diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 9d1af7a0a401..a7c9c836d2f3 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -971,6 +971,7 @@ struct rq_map_data { bool from_user; }; +int blk_rq_map_user_fixedb(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 Fri Aug 19 10:30:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12948694 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 6A674C32771 for ; Fri, 19 Aug 2022 10:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348450AbiHSKk5 (ORCPT ); Fri, 19 Aug 2022 06:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348452AbiHSKky (ORCPT ); Fri, 19 Aug 2022 06:40:54 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D9B6F075C for ; Fri, 19 Aug 2022 03:40:52 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220819104050epoutp030bcea46718e35d36016f9bc6cadf7fb6~MuOO-H06v1672816728epoutp03T for ; Fri, 19 Aug 2022 10:40:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220819104050epoutp030bcea46718e35d36016f9bc6cadf7fb6~MuOO-H06v1672816728epoutp03T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660905650; bh=jVFwLJ5FLHYEcU2SFU9ctfDNtTJjbt60WwBHMemg378=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T08z+p+PcofxMh4fGG1A6kSspvqIuGE6RjEOUtyGgZldTIxDW5LJez7NF8QztERuv 8E5VGCFlSHTAqZ7Cxz2RyXHjbA6M0m972g6B2btqwT9c9Qzocq3DwT/jj8jftpFYfY 0WKuM2Qy3ydlNk9EIfqgbra5EAne1VswG5m6pV24= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220819104049epcas5p132ffb16b2ee1ad35f40b6daf94608be4~MuON3huIn0663706637epcas5p1v; Fri, 19 Aug 2022 10:40:49 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4M8JFC6nY3z4x9Py; Fri, 19 Aug 2022 10:40:47 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 31.30.09494.DA86FF26; Fri, 19 Aug 2022 19:40:45 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220819104045epcas5p117a9fcb0c3143e877e75e24ceba4f381~MuOKBZuMo0658906589epcas5p1r; Fri, 19 Aug 2022 10:40:45 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220819104045epsmtrp107ad4c1773c12ffcfddd701f2f479a73~MuOKAraCY1513515135epsmtrp1M; Fri, 19 Aug 2022 10:40:45 +0000 (GMT) X-AuditID: b6c32a4a-1ebff70000012516-2d-62ff68ad2660 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CA.85.08802.DA86FF26; Fri, 19 Aug 2022 19:40:45 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220819104043epsmtip179a427156a083ce978bdad743c917f7f~MuOIhIS3p0577205772epsmtip1j; Fri, 19 Aug 2022 10:40:43 +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, ming.lei@redhat.com, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next 4/4] nvme: wire up fixed buffer support for nvme passthrough Date: Fri, 19 Aug 2022 16:00:21 +0530 Message-Id: <20220819103021.240340-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819103021.240340-1-joshi.k@sams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1XYpY7yY9/vfexO2Omce6hK8e6eiqAFt49wfdReFq79QTdT7mP9F8X08t9z xVqft81elxKY0i2//x5jpaXLaaWm+kWeHknXogV2he8Urj3IK7974/FU7gNv9760WtnmP0tp 7YH6p88/b1BiKc5INNRiLipOBAAkQHBq8AIAAA== X-CMS-MailID: 20220819104045epcas5p117a9fcb0c3143e877e75e24ceba4f381 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220819104045epcas5p117a9fcb0c3143e877e75e24ceba4f381 References: <20220819103021.240340-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org if io_uring sends passthrough command with IO_URING_F_FIXEDBUFS flag, use the pre-registered buffer to form the bio. While at it modify nvme_submit_user_cmd to take ubuffer as plain integer argument, and do away with nvme_to_user_ptr conversion in callers. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- drivers/nvme/host/ioctl.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 7756b439a688..5f2e2d31f5c7 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -65,10 +65,11 @@ static int nvme_finish_user_metadata(struct request *req, void __user *ubuf, } static struct request *nvme_alloc_user_request(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, + struct nvme_command *cmd, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, void **metap, unsigned timeout, bool vec, - blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags) + blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags, + struct io_uring_cmd *ioucmd, bool fixedbufs) { bool write = nvme_is_write(cmd); struct nvme_ns *ns = q->queuedata; @@ -89,14 +90,27 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, if (ubuffer && bufflen) { if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - GFP_KERNEL); + if (fixedbufs) { + struct iov_iter iter; + + ret = io_uring_cmd_import_fixed(ubuffer, + bufflen, rq_data_dir(req), + &iter, ioucmd); + if (ret < 0) + goto out; + ret = blk_rq_map_user_fixedb(req, &iter); + } else { + ret = blk_rq_map_user(q, req, NULL, + nvme_to_user_ptr(ubuffer), + bufflen, GFP_KERNEL); + } else { struct iovec fast_iov[UIO_FASTIOV]; struct iovec *iov = fast_iov; struct iov_iter iter; - ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, + ret = import_iovec(rq_data_dir(req), + nvme_to_user_ptr(ubuffer), bufflen, UIO_FASTIOV, &iov, &iter); if (ret < 0) goto out; @@ -132,7 +146,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, } static int nvme_submit_user_cmd(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, + struct nvme_command *cmd, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, u64 *result, unsigned timeout, bool vec) { @@ -142,7 +156,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, int ret; req = nvme_alloc_user_request(q, cmd, ubuffer, bufflen, meta_buffer, - meta_len, meta_seed, &meta, timeout, vec, 0, 0); + meta_len, meta_seed, &meta, timeout, vec, 0, 0, NULL, 0); if (IS_ERR(req)) return PTR_ERR(req); @@ -220,7 +234,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) c.rw.appmask = cpu_to_le16(io.appmask); return nvme_submit_user_cmd(ns->queue, &c, - nvme_to_user_ptr(io.addr), length, + io.addr, length, metadata, meta_len, lower_32_bits(io.slba), NULL, 0, false); } @@ -274,7 +288,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &result, timeout, false); @@ -320,7 +334,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &cmd.result, timeout, vec); @@ -457,11 +471,11 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, rq_flags |= REQ_POLLED; retry: - req = nvme_alloc_user_request(q, &c, nvme_to_user_ptr(d.addr), + req = nvme_alloc_user_request(q, &c, d.addr, d.data_len, nvme_to_user_ptr(d.metadata), d.metadata_len, 0, &meta, d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0, vec, rq_flags, - blk_flags); + blk_flags, ioucmd, issue_flags & IO_URING_F_FIXEDBUFS); if (IS_ERR(req)) return PTR_ERR(req); req->end_io = nvme_uring_cmd_end_io;