From patchwork Fri Sep 2 15:16:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12964344 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 55794ECAAD5 for ; Fri, 2 Sep 2022 15:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237135AbiIBPlG (ORCPT ); Fri, 2 Sep 2022 11:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236955AbiIBPki (ORCPT ); Fri, 2 Sep 2022 11:40:38 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FBCB79ED8 for ; Fri, 2 Sep 2022 08:27:15 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220902152710epoutp02881e6882bf4cc677c26c29c0df5dd796~RFKOSIMVS1948519485epoutp025 for ; Fri, 2 Sep 2022 15:27:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220902152710epoutp02881e6882bf4cc677c26c29c0df5dd796~RFKOSIMVS1948519485epoutp025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662132430; bh=A9eeh4RBJYaAco8jXNywjr3avubLO7fkkdnIseGNno0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vKNYzuyoa2kIzfmmsYa6+/whVTa9bEfb9nayWEqU3SPb9EBWGDNZ8XnOCd48P3GNV jU1jlCCpq0a4p0JjgXQpf3r/FpvbHqP+dEIlatwqOywZ9GCofxAnYLGW1+E4LaVoSx YCQvSwR1WouuLPTLs936jAV04VIhkmuAKoI/GX8I= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220902152709epcas5p45ab565a5f3ec4ae2332904a0d94f8a14~RFKNtBsIV1431014310epcas5p4R; Fri, 2 Sep 2022 15:27:09 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.176]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MK1x71x7lz4x9Pp; Fri, 2 Sep 2022 15:27:07 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 1F.AE.54060.BC022136; Sat, 3 Sep 2022 00:27:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220902152706epcas5p11f1a11710a6ba985f4679a5cfe131bf8~RFKKdBa4z2163521635epcas5p1d; Fri, 2 Sep 2022 15:27:06 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220902152706epsmtrp20fbe6a87fdee07c0b120417cc49d97e5~RFKKb672S0776407764epsmtrp2c; Fri, 2 Sep 2022 15:27:06 +0000 (GMT) X-AuditID: b6c32a4b-e33fb7000000d32c-40-631220cb0c2c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D5.BE.18644.9C022136; Sat, 3 Sep 2022 00:27:06 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220902152704epsmtip243a97ccab43acdb3d30aae73a246015e~RFKI58CXx1851718517epsmtip2O; Fri, 2 Sep 2022 15:27:04 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v3 1/4] io_uring: introduce io_uring_cmd_import_fixed Date: Fri, 2 Sep 2022 20:46:54 +0530 Message-Id: <20220902151657.10766-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902151657.10766-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmlu5pBaFkgy9bOC2aJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6hpaWpgrKeQl5qbaKrn4BOi6ZeYAHaekUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJ KTAp0CtOzC0uzUvXy0stsTI0MDAyBSpMyM7omjKHpWC1UMXWoz0sDYxr+bsYOTkkBEwkOs+t Ze1i5OIQEtjNKLHiy2smCOcTo8SRf80sEM5nRomdbxuZYFrW3XwFVbWLUWLtowPMcFXrJx1i 72Lk4GAT0JS4MLkUpEFEwEvi/u33YDuYQXa8vdHIDpIQFgiQWHPmFSuIzSKgKvHsUgcLiM0r YCGx+8g1Roht8hIzL30Hq+cUsJR4evUNK0SNoMTJmU/A6pmBapq3zgY7QkKgl0Piy6PjzBDN LhK3H5yFOltY4tXxLewQtpTE53d72SDsZIlLM89B1ZRIPN5zEMq2l2g91c8M8gwz0DPrd+lD 7OKT6P39hAkkLCHAK9HRJgRRrShxb9JTVghbXOLhjCWsECUeEu/fZUOCp4dRYuvSfvYJjPKz kHwwC8kHsxCWLWBkXsUomVpQnJueWmxaYJyXWg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RaU5qcWHGKU5WJTEeS90nYwXEkhPLEnNTk0tSC2C yTJxcEo1MNmw2X7dx+Cq49v9XHvntXuOq7vmXgnr3PC9P94/wTnr7lum438XMnlNS5kUrNzv eLXu4jRX+fXyXm8vrr7Ses3KuGvqwbxJW/tCQnhUzpUd4PtxRqY0myfkqvEyPfOVR86JbRfy znnjmHzt8u1T2X8+fT107KPVIq8Auen/o4Xn7TmWqyIR/HT1Ee5YnXN/Tx35KsUeHbp7Zuzz YPPoR4V5u7dr+j8ROyYirH22d9I+BZeZl/tXbrn5cQLf7GzHzcX31PvYGHqTRE5+dOHMfiwT aaDzR6+zhiHv/4Kqr+1rvH7xHY06NPdUXH/z9tD3U/0v/D1zWSk5O0nscJb12SVtmukf7XVU u//UrBO4eFyJpTgj0VCLuag4EQCF6oxX8AIAAA== X-CMS-MailID: 20220902152706epcas5p11f1a11710a6ba985f4679a5cfe131bf8 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220902152706epcas5p11f1a11710a6ba985f4679a5cfe131bf8 References: <20220902151657.10766-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 | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 58676c0a398f..dba6fb47aa6c 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -4,6 +4,7 @@ #include #include +#include enum io_uring_cmd_flags { IO_URING_F_COMPLETE_DEFER = 1, @@ -32,6 +33,8 @@ struct io_uring_cmd { }; #if defined(CONFIG_IO_URING) +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd); void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2); void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd, void (*task_work_cb)(struct io_uring_cmd *)); @@ -59,6 +62,11 @@ static inline void io_uring_free(struct task_struct *tsk) __io_uring_free(tsk); } #else +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, + struct iov_iter *iter, void *ioucmd) +{ + return -1; +} static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t ret2) { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 6f99dbd5d550..8cddd18ad10b 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -7,6 +7,7 @@ #include #include "io_uring.h" +#include "rsrc.h" #include "uring_cmd.h" static void io_uring_cmd_work(struct io_kiocb *req, bool *locked) @@ -124,3 +125,13 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) return IOU_ISSUE_SKIP_COMPLETE; } + +int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, + int rw, struct iov_iter *iter, void *ioucmd) +{ + struct io_kiocb *req = cmd_to_io_kiocb(ioucmd); + struct io_mapped_ubuf *imu = req->imu; + + return io_import_fixed(rw, iter, imu, ubuf, len); +} +EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); From patchwork Fri Sep 2 15:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12964345 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 89211C001B5 for ; Fri, 2 Sep 2022 15:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236673AbiIBPlG (ORCPT ); Fri, 2 Sep 2022 11:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237144AbiIBPki (ORCPT ); Fri, 2 Sep 2022 11:40:38 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C4C117AF4 for ; Fri, 2 Sep 2022 08:27:16 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220902152713epoutp02544a97fc593b61c050ab7e0841a55be8~RFKRiC5Qx1990519905epoutp023 for ; Fri, 2 Sep 2022 15:27:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220902152713epoutp02544a97fc593b61c050ab7e0841a55be8~RFKRiC5Qx1990519905epoutp023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662132433; bh=ILUq2T7fRPv/zyXJyrYGRvaMUuZi/T01H6Bp/bPmDLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xour01JLW402yXaBQesUwKQ7gAu/kE9L9I4rWAHkNMe2ThSJfkG+PzcnVpfQwnXlV OqmKa7fjGmbyi+D//4tMQH5a670sIhbM7wO7PdBAipW9wtjNF8RliKQk5GET6J3TCV aSC2Hf3QCXTitDPAYRrKQtXTdoCVoNzrbFWJGJk4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220902152712epcas5p3bf5152e4a7d9b5cf8d786e9838a44d9e~RFKQsK5uR3034430344epcas5p3Z; Fri, 2 Sep 2022 15:27:12 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MK1xB1cyzz4x9Pr; Fri, 2 Sep 2022 15:27:10 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9C.30.53458.EC022136; Sat, 3 Sep 2022 00:27:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220902152709epcas5p1a1bd433cac6040c492e347edae484ca5~RFKN1imt_0055200552epcas5p1D; Fri, 2 Sep 2022 15:27:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220902152709epsmtrp15f5ed19d44ac026bc96949461a8797a2~RFKN0xagT2718227182epsmtrp1V; Fri, 2 Sep 2022 15:27:09 +0000 (GMT) X-AuditID: b6c32a4a-a5bff7000000d0d2-25-631220ce8276 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E0.2C.14392.DC022136; Sat, 3 Sep 2022 00:27:09 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220902152708epsmtip2537ab4f0b5bdcc8db11b244ba6923b73~RFKMQtYOf1851618516epsmtip2T; Fri, 2 Sep 2022 15:27:07 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v3 2/4] io_uring: introduce fixed buffer support for io_uring_cmd Date: Fri, 2 Sep 2022 20:46:55 +0530 Message-Id: <20220902151657.10766-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902151657.10766-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA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 FZ+8brlpz/iR+W/Get9tHuv9056az82e+oc13flIfOHU6H8imvPuLZl24+OlFRl3Xt7bdktn r5HmRa8PZ5VYijMSDbWYi4oTAX57DqzuAgAA X-CMS-MailID: 20220902152709epcas5p1a1bd433cac6040c492e347edae484ca5 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220902152709epcas5p1a1bd433cac6040c492e347edae484ca5 References: <20220902151657.10766-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 | 3 ++- include/uapi/linux/io_uring.h | 9 +++++++++ io_uring/uring_cmd.c | 18 +++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index dba6fb47aa6c..6ca633b88816 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -16,6 +16,7 @@ enum io_uring_cmd_flags { IO_URING_F_SQE128 = 4, IO_URING_F_CQE32 = 8, IO_URING_F_IOPOLL = 16, + IO_URING_F_FIXEDBUFS = 32, }; struct io_uring_cmd { @@ -28,7 +29,7 @@ struct io_uring_cmd { void *cookie; }; u32 cmd_op; - u32 pad; + u32 flags; u8 pdu[32]; /* available inline for free use */ }; diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 48e5c70e0baf..c80ce6912d8d 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; + __u16 uring_cmd_flags; }; __u64 user_data; /* data to be passed back at completion time */ /* pack this to avoid bogus arm OABI complaints */ @@ -219,6 +220,14 @@ enum io_uring_op { IORING_OP_LAST, }; +/* + * sqe->uring_cmd_flags + * IORING_URING_CMD_FIXED use registered buffer; pass thig flag + * along with setting sqe->buf_index. + */ +#define IORING_URING_CMD_FIXED (1U << 0) + + /* * sqe->fsync_flags */ diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 8cddd18ad10b..ea989a348d98 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -76,8 +77,21 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); - if (sqe->rw_flags || sqe->__pad1) + if (sqe->__pad1) return -EINVAL; + + ioucmd->flags = READ_ONCE(sqe->uring_cmd_flags); + req->buf_index = READ_ONCE(sqe->buf_index); + if (ioucmd->flags & IORING_URING_CMD_FIXED) { + struct io_ring_ctx *ctx = req->ctx; + u16 index; + + if (unlikely(req->buf_index >= ctx->nr_user_bufs)) + return -EFAULT; + index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); + req->imu = ctx->user_bufs[index]; + io_req_set_rsrc_node(req, ctx, 0); + } ioucmd->cmd = sqe->cmd; ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); return 0; @@ -102,6 +116,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) req->iopoll_completed = 0; WRITE_ONCE(ioucmd->cookie, NULL); } + if (ioucmd->flags & IORING_URING_CMD_FIXED) + issue_flags |= IO_URING_F_FIXEDBUFS; if (req_has_async_data(req)) ioucmd->cmd = req->async_data; From patchwork Fri Sep 2 15:16:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12964347 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 9AFCDC001B5 for ; Fri, 2 Sep 2022 15:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237254AbiIBPlK (ORCPT ); Fri, 2 Sep 2022 11:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237260AbiIBPko (ORCPT ); Fri, 2 Sep 2022 11:40:44 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE6F6116E31 for ; Fri, 2 Sep 2022 08:27:22 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220902152716epoutp03c712d19cb3baefdfc7c04b97cd204fe2~RFKUcGAtI0351203512epoutp030 for ; Fri, 2 Sep 2022 15:27:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220902152716epoutp03c712d19cb3baefdfc7c04b97cd204fe2~RFKUcGAtI0351203512epoutp030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662132436; bh=Dm/Nnr6JGnmxszsDZaW5IiaJ+M26+G4F49QpwlNNnaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4R+IuJap7nE4hwifspjU7vn+rvCQceUYWn1gQPKyJElMTvWC5auvybiRUpplhK7b 9PdldLQSphNYn209g9e2w45PWsXfA5YTE8oMVRLx2DpJjN/TC/CbLjFhEk89+Zxt4H l7RU3vKwMG941M8inHcJGu8pL0LPrrCxArkIXYQw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220902152716epcas5p1e0e29ab5939703ae6c11dba634a250a1~RFKTquwV80055200552epcas5p1M; Fri, 2 Sep 2022 15:27:16 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MK1xF4Tm6z4x9Px; Fri, 2 Sep 2022 15:27:13 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 4D.30.53458.1D022136; Sat, 3 Sep 2022 00:27:13 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220902152712epcas5p2622e861ac4a5ae9820a9af9442d556b4~RFKQtdbXp2622926229epcas5p2w; Fri, 2 Sep 2022 15:27:12 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220902152712epsmtrp1b4e675935859b06e5a8dce3c8f8b3097~RFKQsox9P2718227182epsmtrp1W; Fri, 2 Sep 2022 15:27:12 +0000 (GMT) X-AuditID: b6c32a4a-caffb7000000d0d2-2a-631220d129dc Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 07.BE.18644.0D022136; Sat, 3 Sep 2022 00:27:12 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220902152711epsmtip2273e14672649e055b5ee7c33538dc9f4~RFKPQIn-L1295812958epsmtip23; Fri, 2 Sep 2022 15:27:11 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v3 3/4] block: add helper to map bvec iterator for passthrough Date: Fri, 2 Sep 2022 20:46:56 +0530 Message-Id: <20220902151657.10766-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902151657.10766-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmpu5FBaFkg/ONChZNE/4yW8xZtY3R YvXdfjaLmwd2MlmsXH2UyeJd6zkWi6P/37JZTDp0jdFi7y1ti/nLnrI7cHnsnHWX3ePy2VKP Tas62Tw2L6n32H2zgc2jb8sqRo/Pm+QC2KOybTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwM dQ0tLcyVFPISc1NtlVx8AnTdMnOAjlNSKEvMKQUKBSQWFyvp29kU5ZeWpCpk5BeX2CqlFqTk FJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGdMPrabsWC5ZMWlL8cYGxj7RLoYOTkkBEwk9p/r Zu5i5OIQEtjNKHF8yUlWCOcTo8S3123sEM5nRon2d4eAyjjAWla8q4WI72KUePl8HxNcUXd7 PxtIEZuApsSFyaUgK0QEvCTu334PNpUZZMXqv29ZQRLCApESHbtuMoHYLAKqEvuPb2UEsXkF LCSmtPewQNwnLzHz0nd2EJtTwFLi6dU3rBA1ghInZz4Bq2EGqmneOhvsBwmBTg6JH8+Xs0M0 u0jcOHyLDcIWlnh1fAtUXEriZX8blJ0scWnmOSYIu0Ti8Z6DULa9ROupfrCPmYGeWb9LH2IX n0Tv7ydMkIDglehoE4KoVpS4N+kpK4QtLvFwxhIo20Piz9OzjJDw6WGUWL/8G/sERvlZSF6Y heSFWQjbFjAyr2KUTC0ozk1PLTYtMMpLLYdHbHJ+7iZGcBrV8trB+PDBB71DjEwcjIcYJTiY lUR4px4WSBbiTUmsrEotyo8vKs1JLT7EaAoM44nMUqLJ+cBEnlcSb2hiaWBiZmZmYmlsZqgk zjtFmzFZSCA9sSQ1OzW1ILUIpo+Jg1OqgYmh+LXGhXfxR1l87vakKKn2aDx+2i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W23avemp8smnuE+cZ9htcfbxaG/jjKw Z0j09aqt1Y3UuXJBtznWWqMq2Tzpzzfh8NDMvqb+6HLLW4t09xQekL90+GHJ08P1ExUPTfKM v94VpePawl5izZz68sbtBS3af6/uWjZRNGXH9dh5K/zY+nfPeStY9HeD+Z3z+Rz8E+y7Vryc 8smzz1GDZVVy/5kty9+4TypMsLO5/8jkq9FLo9WdjYJFZYkCsU7ftBWOfDdYa/msMmhD6Cpj 7QKb4pmP1ZRYijMSDbWYi4oTAYOujLrvAgAA X-CMS-MailID: 20220902152712epcas5p2622e861ac4a5ae9820a9af9442d556b4 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220902152712epcas5p2622e861ac4a5ae9820a9af9442d556b4 References: <20220902151657.10766-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 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 f3768876d618..0f7dc568e34b 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -612,6 +612,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 b43c81d91892..83bef362f0f9 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -970,6 +970,7 @@ struct rq_map_data { bool from_user; }; +int blk_rq_map_user_bvec(struct request *rq, struct iov_iter *iter); int blk_rq_map_user(struct request_queue *, struct request *, struct rq_map_data *, void __user *, unsigned long, gfp_t); int blk_rq_map_user_iov(struct request_queue *, struct request *, From patchwork Fri Sep 2 15:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12964348 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 16D26C54EE9 for ; Fri, 2 Sep 2022 15:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237057AbiIBPlZ (ORCPT ); Fri, 2 Sep 2022 11:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237197AbiIBPlI (ORCPT ); Fri, 2 Sep 2022 11:41:08 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BBB13D4F for ; Fri, 2 Sep 2022 08:28:54 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220902152851epoutp0413be37acda95c0f794c78eff2f026bae~RFLs9GwqQ0532605326epoutp04G for ; Fri, 2 Sep 2022 15:28:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220902152851epoutp0413be37acda95c0f794c78eff2f026bae~RFLs9GwqQ0532605326epoutp04G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662132531; bh=R/7IxdDqZAFv1UkLuGaTnie2Vp6DVZlh+y9vQjzdh70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHP8sum6MxyhMtHvALoUPKmPAdSkYyowPrG+1IJ2rPheMX1/Yc16g89yehhK7pYcB kkl8DqBTs4hp0oNx9XxcG4a6+0uHDSqqVnt189IG0sVux+RfejQKfm6ZNBPWWQofQ9 7vDbKAOuMaUifsssq17kKMj1G3pjuMy6HSWUHxk8= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220902152851epcas5p3a505991ca6dbf1db9ed1d487f68f7f31~RFLsOysd51431414314epcas5p3t; Fri, 2 Sep 2022 15:28:51 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MK1xK5cQLz4x9Pv; Fri, 2 Sep 2022 15:27:17 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A1.D5.59633.5D022136; Sat, 3 Sep 2022 00:27:17 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220902152717epcas5p26905ce7cb48e9d278976a301d73c297f~RFKUt6TBl0881008810epcas5p2J; Fri, 2 Sep 2022 15:27:17 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220902152717epsmtrp10650adaa11baa1794771ba9f9f2cc073~RFKUtHqKo2718227182epsmtrp1Z; Fri, 2 Sep 2022 15:27:17 +0000 (GMT) X-AuditID: b6c32a49-dfdff7000000e8f1-ec-631220d5651d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 48.BE.18644.4D022136; Sat, 3 Sep 2022 00:27:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220902152715epsmtip22bfcaff5914460519ecbe6fcc63a1c98~RFKTRlgV_1295812958epsmtip25; Fri, 2 Sep 2022 15:27:15 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v3 4/4] nvme: wire up fixed buffer support for nvme passthrough Date: Fri, 2 Sep 2022 20:46:57 +0530 Message-Id: <20220902151657.10766-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902151657.10766-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOJsWRmVeSWpSXmKPExsWy7bCmhu5VBaFkgwsLtCyaJvxltpizahuj xeq7/WwWNw/sZLJYufook8W71nMsFkf/v2WzmHToGqPF3lvaFvOXPWV34PLYOesuu8fls6Ue m1Z1snlsXlLvsftmA5tH35ZVjB6fN8kFsEdl22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY 6hpaWpgrKeQl5qbaKrn4BOi6ZeYAHaekUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJ KTAp0CtOzC0uzUvXy0stsTI0MDAyBSpMyM44NHM+Y8Ff5YqnB6ewNjAulO1i5OSQEDCRWPXy P1sXIxeHkMBuRomTD+eyQDifGCXW/F3FAlIlJPAZyLleDdOxuP8vVNEuRon79+cxwxV9mCnU xcjBwSagKXFhcilIWETAS+L+7fesIPXMIBtW/33LCpIQFoiSWDjrAFgvi4CqxPWXr9lAbF4B C4muf8sYIZbJS8y89J0dxOYUsJR4evUNK0SNoMTJmU/AjmMGqmneOpsZor6XQ+LmNXkI20Xi 6d9JbBC2sMSr41vYIWwpiZf9bVB2ssSlmeeYIOwSicd7DkLZ9hKtp/qZQX5hBvpl/S59iFV8 Er2/nzCBhCUEeCU62oQgqhUl7k16ygphi0s8nLEEyvaQuPJ7FzMkqHoYJZZMv8I0gVF+FpIP ZiH5YBbCtgWMzKsYJVMLinPTU4tNCwzzUsvh0Zqcn7uJEZxCtTx3MN598EHvECMTB+MhR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1CKY LBMHp1QDk+uVilaHy/sZDvxvKZK82PXV27BK7J3FZD4RR64Zf+Zx5SQuayu4VDNV67pZe3Hj LOcPn85+5uCbw///ZX7h3RZ3T8kDEjZ/b5pemv7vl8aJjx4vPm3Zu77K+/S7m3MubbK2L9H/ UL6pevOXjr/39RVftnZ6rpQ9eyct+MWxw8u61qpzmNXfy0/IffXFecUilTtuM7SnSt+dUmFc 92zh0oSGr7l/tvM6GQp1OaTZbZCd/dblbNPTm95bn3508zGf75euIMMWXuB8j9mySXlKo9zR Z983993kX7UzkMXuiPk03tuKfidvvF1p7KoyK+lhMAt7m7XWrEMbHheeO5rykMv/8fvFDiVP 390LuO340leJpTgj0VCLuag4EQAmfqSK8AIAAA== X-CMS-MailID: 20220902152717epcas5p26905ce7cb48e9d278976a301d73c297f X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220902152717epcas5p26905ce7cb48e9d278976a301d73c297f References: <20220902151657.10766-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..5a4649293e86 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -65,10 +65,11 @@ static int nvme_finish_user_metadata(struct request *req, void __user *ubuf, } static struct request *nvme_alloc_user_request(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, + struct nvme_command *cmd, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, void **metap, unsigned timeout, bool vec, - blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags) + blk_opf_t rq_flags, blk_mq_req_flags_t blk_flags, + struct io_uring_cmd *ioucmd, bool fixedbufs) { bool write = nvme_is_write(cmd); struct nvme_ns *ns = q->queuedata; @@ -89,14 +90,27 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, if (ubuffer && bufflen) { if (!vec) - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen, - GFP_KERNEL); + if (fixedbufs) { + struct iov_iter iter; + + ret = io_uring_cmd_import_fixed(ubuffer, + bufflen, rq_data_dir(req), + &iter, ioucmd); + if (ret < 0) + goto out; + ret = blk_rq_map_user_bvec(req, &iter); + } else { + ret = blk_rq_map_user(q, req, NULL, + nvme_to_user_ptr(ubuffer), + bufflen, GFP_KERNEL); + } else { struct iovec fast_iov[UIO_FASTIOV]; struct iovec *iov = fast_iov; struct iov_iter iter; - ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, + ret = import_iovec(rq_data_dir(req), + nvme_to_user_ptr(ubuffer), bufflen, UIO_FASTIOV, &iov, &iter); if (ret < 0) goto out; @@ -132,7 +146,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, } static int nvme_submit_user_cmd(struct request_queue *q, - struct nvme_command *cmd, void __user *ubuffer, + struct nvme_command *cmd, u64 ubuffer, unsigned bufflen, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, u64 *result, unsigned timeout, bool vec) { @@ -142,7 +156,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, int ret; req = nvme_alloc_user_request(q, cmd, ubuffer, bufflen, meta_buffer, - meta_len, meta_seed, &meta, timeout, vec, 0, 0); + meta_len, meta_seed, &meta, timeout, vec, 0, 0, NULL, 0); if (IS_ERR(req)) return PTR_ERR(req); @@ -220,7 +234,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) c.rw.appmask = cpu_to_le16(io.appmask); return nvme_submit_user_cmd(ns->queue, &c, - nvme_to_user_ptr(io.addr), length, + io.addr, length, metadata, meta_len, lower_32_bits(io.slba), NULL, 0, false); } @@ -274,7 +288,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &result, timeout, false); @@ -320,7 +334,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns, timeout = msecs_to_jiffies(cmd.timeout_ms); status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, - nvme_to_user_ptr(cmd.addr), cmd.data_len, + cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata), cmd.metadata_len, 0, &cmd.result, timeout, vec); @@ -457,11 +471,11 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, rq_flags |= REQ_POLLED; retry: - req = nvme_alloc_user_request(q, &c, nvme_to_user_ptr(d.addr), + req = nvme_alloc_user_request(q, &c, d.addr, d.data_len, nvme_to_user_ptr(d.metadata), d.metadata_len, 0, &meta, d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0, vec, rq_flags, - blk_flags); + blk_flags, ioucmd, issue_flags & IO_URING_F_FIXEDBUFS); if (IS_ERR(req)) return PTR_ERR(req); req->end_io = nvme_uring_cmd_end_io;