From patchwork Fri Sep 23 09:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 12986388 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 5BE61C6FA86 for ; Fri, 23 Sep 2022 09:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbiIWJmW (ORCPT ); Fri, 23 Sep 2022 05:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231777AbiIWJko (ORCPT ); Fri, 23 Sep 2022 05:40:44 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C928B12F754 for ; Fri, 23 Sep 2022 02:39:21 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220923093920epoutp023e450ffb7cf4ceb17630e1a6331f1199~Xc9hQPP0O0758707587epoutp02k for ; Fri, 23 Sep 2022 09:39:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220923093920epoutp023e450ffb7cf4ceb17630e1a6331f1199~Xc9hQPP0O0758707587epoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1663925960; bh=2f95MMw1JaP2a2qx6h2pgrT8vnSnYyP4Ul8WVop1exo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNmMuW+FxZa9oLjoPhVRbAv5Mrzh5GtlOznC/uCUwaObxPLh0qQf1X3twjwd/JURi zNWGZ/7OrpSjbUfBaHjDrndA1s2luxrZR60Iv3wo0Xmn2eQqXr4x6VGUc2FqQvXuSh dDpsQRrvjU7TnL1j8r9hahVS/nJBHYUnIL0EJPRc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220923093919epcas5p44589eb00c12ab1e537feb4375df5b4fc~Xc9gxBMTY0422904229epcas5p4_; Fri, 23 Sep 2022 09:39:19 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4MYnD45cYPz4x9Pt; Fri, 23 Sep 2022 09:39:16 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 73.34.26992.2CE7D236; Fri, 23 Sep 2022 18:39:14 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220923093913epcas5p4d91766a750d6f5e87a1da0b92f6c4a2e~Xc9a4yphH0959609596epcas5p48; Fri, 23 Sep 2022 09:39:13 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220923093913epsmtrp125a3d7ed3ebdfb5432e7dd4b714f42eb~Xc9a4GpMB0923409234epsmtrp1W; Fri, 23 Sep 2022 09:39:13 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-39-632d7ec28545 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id F5.37.18644.1CE7D236; Fri, 23 Sep 2022 18:39:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220923093911epsmtip2deed05ee44574274cd4d418bf7e5afdb~Xc9ZIsjTz2919729197epsmtip2E; Fri, 23 Sep 2022 09:39:11 +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 v8 2/5] io_uring: introduce fixed buffer support for io_uring_cmd Date: Fri, 23 Sep 2022 14:58:51 +0530 Message-Id: <20220923092854.5116-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220923092854.5116-1-joshi.k@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdlhTU/dQnW6ywf6d7BZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYnH0/1s2i0mHrjFa7L2lbTF/2VN2B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqX rpeXWmJlaGBgZApUmJCdcWTLRMaCj6IVt3/NYmtg/C7YxcjBISFgIrH1p3oXIxeHkMBuRol3 R6cwQzifGCUebfwP5XxmlFj7ZQUzTMf13XoQ8V2MEm2NUxCK9j09xgZSxCagKXFhcmkXIyeH iICRxP5PJ1lBaphBVry90cgOkhAWiJG4uuoSC4jNIqAqMX3CH7A4r4C5xNM765hAbAkBeYmZ l76DxTkFLCQWbb7FBFEjKHFy5hOwXmagmuats8GOkBD4yy7RfnwLI0Szi8Tii2egbGGJV8e3 sEPYUhIv+9ug7GSJSzPPQS0rkXi85yCUbS/Reqof7GNmoGfW79KH2MUn0fv7CRMkIHglOtqE IKoVJe5NesoKYYtLPJyxBMr2kLh3tJcJEj7djBJbXm9kmsAoPwvJC7OQvDALYdsCRuZVjJKp BcW56anFpgWGeanl8HhNzs/dxAhOmFqe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k/FCAumJJanZqakFqUUwWSYOTqkGptPpwZUy 06P9N17Y3li+T6377bynJ6VeCTs0Nut6//gr2xu1e+VrjRUGPu+WHU8+qWFuMZ/fQleoi83l aMu19I/17bO37M1p8Gk8tavgw8o58xTrLFun/F16Rvf2JrVHx87F29/p0BSaFZu9Ll+k76pa 2L3PpitOTH3vbOPyebpJ/ipvKRPJhMcT0jvmKpnFHNqhoLds6q7Kprz54l6i35xWPk+efVvo kKmIe4xI0uc7fyevPGW1euYst++3HjBx5If7vr9xuyLT86GB2beTR9Lu3/+t6rr5uLPAEU3L mUHrnIMOvdp/clcvj+SruIoTsyryxWQ5mV0eXH8cIFc3TShnzrOrBTuUXT4IOX/5N02JpTgj 0VCLuag4EQBQMhzQ5QIAAA== X-CMS-MailID: 20220923093913epcas5p4d91766a750d6f5e87a1da0b92f6c4a2e X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220923093913epcas5p4d91766a750d6f5e87a1da0b92f6c4a2e References: <20220923092854.5116-1-joshi.k@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Anuj Gupta Add IORING_URING_CMD_FIXED flag that is to be used for sending io_uring command with previously registered buffers. User-space passes the buffer index in sqe->buf_index, same as done in read/write variants that uses fixed buffers. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- include/linux/io_uring.h | 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;