From patchwork Fri Sep 30 06:27:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612167 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 1F940C433F5 for ; Fri, 30 Sep 2022 06:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiI3GnK (ORCPT ); Fri, 30 Sep 2022 02:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiI3GnG (ORCPT ); Fri, 30 Sep 2022 02:43:06 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A5821664B7 for ; Thu, 29 Sep 2022 23:43:03 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064302epoutp03280f767f25ae8ed4db14daca7f992774~ZkElfpqyU2454324543epoutp03c for ; Fri, 30 Sep 2022 06:43:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064302epoutp03280f767f25ae8ed4db14daca7f992774~ZkElfpqyU2454324543epoutp03c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520182; bh=iirM43BcaFmNufDrlcC4cnJ4qMGLT6ODyYNtDEbayfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udMfmdNy3h53CYy1rL82WFdN53ocdsR3GvQ75vBpDmb2uWwvCumPCZtJXP7tzrczb AJ5Kg2mpvj3wJD81VHpVOaiz9dkWtkCXicY6B9Xe3DnumeRhY6fZVfdB0wnQO2nXak Tpyl9fZNYXR86oYT/d/Ip72Vbxmd4jIh0Wbkajrc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220930064301epcas5p470c8c3a98d97db4ffce9fc1b004f520a~ZkEk94old0991309913epcas5p4G; Fri, 30 Sep 2022 06:43:01 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf0zR5QcNz4x9Pv; Fri, 30 Sep 2022 06:42:59 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id F4.81.56352.1FF86336; Fri, 30 Sep 2022 15:42:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220930063805epcas5p2c8eb80f32507f011baedc6d6b4d3f38d~ZkARgs2-G0421904219epcas5p2J; Fri, 30 Sep 2022 06:38:05 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220930063805epsmtrp2029d4b9faa8809abbf41e4dfa7a134c1~ZkARf8VOj2166321663epsmtrp2N; Fri, 30 Sep 2022 06:38:05 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-8d-63368ff14d90 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AA.59.14392.DCE86336; Fri, 30 Sep 2022 15:38:05 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063804epsmtip2eb631af26284418926a8f1c7d83a45c3~ZkAP-bYK-1483614836epsmtip26; Fri, 30 Sep 2022 06:38:04 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v12 01/12] io_uring: add io_uring_cmd_import_fixed Date: Fri, 30 Sep 2022 11:57:38 +0530 Message-Id: <20220930062749.152261-2-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEJsWRmVeSWpSXmKPExsWy7bCmlu7HfrNkg5MneCyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnAKTAr3i xNzi0rx0vbzUEitDAwMjU6DChOyMJ8cnsRT8F6zYPfkyYwPjT74uRk4OCQETiV+PPrJ1MXJx CAnsZpR48+oFI4TziVFi59LrUM43RomeI2dZYVo6d02FatnLKLH+yDqoqs+MEo2T2thAqtgE 1CWOPG9lBLFFBIwk9n86yQpSxCxwk1Hi0N5nzCAJYQFvibZP71lAbBYBVYmjj7rBbF4BK4mH B56xQKyTl5h56Tt7FyMHB6eAtUTzohyIEkGJkzOfgJUwA5U0b53NDDJfQuAvu8StNT+YIXpd JBqnXmeCsIUlXh3fwg5hS0l8freXDcJOl/hx+SlUTYFE87F9jBC2vUTrqX5mkL3MApoS63fp Q4RlJaaeWscEsZdPovf3E6hWXokd82BsJYn2lXOgbAmJvecaoGwPiR2TnkEDq49R4vPdvywT GBVmIflnFpJ/ZiGsXsDIvIpRMrWgODc9tdi0wD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ZVVqUX58UWlOavEhRmkOFiVx3gtdJ+OFBNITS1KzU1MLUotgskwcnFINTIeO sd4r/tv9Wb/hVeLbRS8LLwpksb96r230Kv6IqX7CxKk3bqqL/D1S8niDipN70fMe6+0zVvpx ZSwRExeyTn77Z237bTMG/vcHPFdPPzjlc9eGZY7/+3p/enSp2K1T4bMx5AkWXZV045xoRLbD KwltYXVJq2PptsK/qjiWNkX9q+ZT3cFp+2K518pbm3dpaW/bcOvDIj8Tc84lMjmM5f5yKWeu 2754FPDF+tNymzWGjCJfZ4d93bLybr/qycbnFtPPZAQUHsitM+gLjyy8UahTrL3Ra7qxEd/0 4rUHb3XGdkS+Mv3CuvLFFbEUvQ2pmt5/X+28e3+y8GveQrnVis+mCkx+8/wlH1/qpW0bbJRY ijMSDbWYi4oTAYjiMrzqAgAA X-CMS-MailID: 20220930063805epcas5p2c8eb80f32507f011baedc6d6b4d3f38d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063805epcas5p2c8eb80f32507f011baedc6d6b4d3f38d References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 Fri Sep 30 06:27:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611323 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 5EA7EC4332F for ; Fri, 30 Sep 2022 06:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbiI3GnW (ORCPT ); Fri, 30 Sep 2022 02:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbiI3GnP (ORCPT ); Fri, 30 Sep 2022 02:43:15 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD9A1F8C15 for ; Thu, 29 Sep 2022 23:43:13 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064312epoutp03e0972b4afd2f769e24d61b0f557681b3~ZkEvCWVex2454724547epoutp03U for ; Fri, 30 Sep 2022 06:43:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064312epoutp03e0972b4afd2f769e24d61b0f557681b3~ZkEvCWVex2454724547epoutp03U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520192; bh=GI1cGmjn/uczqFvlY4jKGGH0aTlldptSuRlcNl6S7vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nme0KQWw9re5e1Ropqw2hNhQInfU/4ubvqS9Qb6FsaWlheNQovmg1LsRE8mIboQ2S A3U87HdeSf5oa/KMC5+vwLnHkNMfffeWjuddrzvtc12MxbnMvU6NtXxX3XmHmp77cP bZF962pVlQph8M3jxH06+jwLBu3vp+AtX4kNWed8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220930064311epcas5p42a2ccb49f18bcef2f579b5eba76df3ee~ZkEuFRPut1262412624epcas5p4A; Fri, 30 Sep 2022 06:43:11 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Mf0zb3gLPz4x9Px; Fri, 30 Sep 2022 06:43:07 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D4.2D.39477.BFF86336; Fri, 30 Sep 2022 15:43:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220930063809epcas5p328b9e14ead49e9612b905e6f5b6682f7~ZkAU8XC6J1908719087epcas5p3u; Fri, 30 Sep 2022 06:38:09 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220930063809epsmtrp28cbec7bc6c529cd4d0967173f41a1dcb~ZkAU7Qcia2166321663epsmtrp2Z; Fri, 30 Sep 2022 06:38:09 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-d5-63368ffb8d2c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8E.32.18644.1DE86336; Fri, 30 Sep 2022 15:38:09 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063807epsmtip233c580625990a69d575ad9f0b553a5c5~ZkATcNc5m1483714837epsmtip2A; Fri, 30 Sep 2022 06:38:07 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH for-next v12 02/12] io_uring: introduce fixed buffer support for io_uring_cmd Date: Fri, 30 Sep 2022 11:57:39 +0530 Message-Id: <20220930062749.152261-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAA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SjT5Ud2l2xT43ZaPYdlsjt KTqB7TfubV+SdtfZza1tH9uWx36KD7/b2nyIES69wrD6TMiZLSpnC2XrfNPKXCV0rvxezLpB iaU4I9FQi7moOBEAX8uNv+oCAAA= X-CMS-MailID: 20220930063809epcas5p328b9e14ead49e9612b905e6f5b6682f7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063809epcas5p328b9e14ead49e9612b905e6f5b6682f7 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 | 18 +++++++++++++++++- 3 files changed, 27 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..05e8ad8cef87 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -77,7 +78,22 @@ 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); + } + if (ioucmd->flags & ~IORING_URING_CMD_FIXED) return -EINVAL; ioucmd->cmd = sqe->cmd; ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); From patchwork Fri Sep 30 06:27:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612166 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 A321AC433F5 for ; Fri, 30 Sep 2022 06:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbiI3Gnn (ORCPT ); Fri, 30 Sep 2022 02:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbiI3Gnc (ORCPT ); Fri, 30 Sep 2022 02:43:32 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17416208570 for ; Thu, 29 Sep 2022 23:43:27 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064326epoutp0364b1b7ff81f471d60373ec8ca0dc9981~ZkE8Obf6O2689226892epoutp03m for ; Fri, 30 Sep 2022 06:43:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064326epoutp0364b1b7ff81f471d60373ec8ca0dc9981~ZkE8Obf6O2689226892epoutp03m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520206; bh=ThnCd0QThrZCq2pxruHyWZ5UgpjXQN5hDvf0/hIjKhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWhKp9CV6W5kFAzcwgQlMbDvIFSMOniW336DWQGd8VSpoNpLXgZO1mqnrqaNs3T4C xpZEjwADZEnm5hiM6Hm2pPZNtOr70Jp9NBBODUWDYA0UV5iM+36H8zRF9i4HSPPeU9 kQzHFpgnlYvLbsroie79Lsm8A5PNeznpWWZ481/A= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220930064325epcas5p3fb8eefad42a351c401392784ca151c4a~ZkE7pZWjL1801418014epcas5p38; Fri, 30 Sep 2022 06:43:25 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Mf0zs22bJz4x9Pr; Fri, 30 Sep 2022 06:43:21 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id B7.A1.56352.90096336; Fri, 30 Sep 2022 15:43:21 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063811epcas5p43cce58f5e1589c3e3780ce0cfd563986~ZkAXERA8S2578525785epcas5p4B; Fri, 30 Sep 2022 06:38:11 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063811epsmtrp151807c3d2d197186d2db4f69bc5d057c~ZkAXDc2av2657326573epsmtrp1M; Fri, 30 Sep 2022 06:38:11 +0000 (GMT) X-AuditID: b6c32a4b-383ff7000001dc20-f5-63369009e006 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FC.59.14392.3DE86336; Fri, 30 Sep 2022 15:38:11 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063810epsmtip2562009c1830622fb08678d770eb8253d~ZkAVvBefV1736317363epsmtip2T; Fri, 30 Sep 2022 06:38:10 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v12 03/12] block: add blk_rq_map_user_io Date: Fri, 30 Sep 2022 11:57:40 +0530 Message-Id: <20220930062749.152261-4-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmhi7nBLNkgw/tPBZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYjHp0DVGi723tC3mL3vK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-MailID: 20220930063811epcas5p43cce58f5e1589c3e3780ce0cfd563986 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063811epcas5p43cce58f5e1589c3e3780ce0cfd563986 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Create a helper blk_rq_map_user_io for mapping of vectored as well as non-vectored requests. This will help in saving dupilcation of code at few places in scsi and nvme. Signed-off-by: Anuj Gupta Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- block/blk-map.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/block/blk-map.c b/block/blk-map.c index 7693f8e3c454..0e37bbedd46c 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -611,6 +611,42 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, } EXPORT_SYMBOL(blk_rq_map_user); +int blk_rq_map_user_io(struct request *req, struct rq_map_data *map_data, + void __user *ubuf, unsigned long buf_len, gfp_t gfp_mask, + bool vec, int iov_count, bool check_iter_count, int rw) +{ + int ret = 0; + + if (vec) { + struct iovec fast_iov[UIO_FASTIOV]; + struct iovec *iov = fast_iov; + struct iov_iter iter; + + ret = import_iovec(rw, ubuf, iov_count ? iov_count : buf_len, + UIO_FASTIOV, &iov, &iter); + if (ret < 0) + return ret; + + if (iov_count) { + /* SG_IO howto says that the shorter of the two wins */ + iov_iter_truncate(&iter, buf_len); + if (check_iter_count && !iov_iter_count(&iter)) { + kfree(iov); + return -EINVAL; + } + } + + ret = blk_rq_map_user_iov(req->q, req, map_data, &iter, + gfp_mask); + kfree(iov); + } else if (buf_len) { + ret = blk_rq_map_user(req->q, req, map_data, ubuf, buf_len, + gfp_mask); + } + return ret; +} +EXPORT_SYMBOL(blk_rq_map_user_io); + /** * 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 50811d0fb143..ba18e9bdb799 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -985,6 +985,8 @@ struct rq_map_data { 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_io(struct request *, struct rq_map_data *, + void __user *, unsigned long, gfp_t, bool, int, bool, int); int blk_rq_map_user_iov(struct request_queue *, struct request *, struct rq_map_data *, const struct iov_iter *, gfp_t); int blk_rq_unmap_user(struct bio *); From patchwork Fri Sep 30 06:27:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611322 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 4056EC433FE for ; Fri, 30 Sep 2022 06:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbiI3Gnw (ORCPT ); Fri, 30 Sep 2022 02:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiI3Gnl (ORCPT ); Fri, 30 Sep 2022 02:43:41 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E06C77DD for ; Thu, 29 Sep 2022 23:43:36 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220930064334epoutp049e6da6ea32180685440371aa6c89cef7~ZkFEHOjUN0752207522epoutp04_ for ; Fri, 30 Sep 2022 06:43:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220930064334epoutp049e6da6ea32180685440371aa6c89cef7~ZkFEHOjUN0752207522epoutp04_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520215; bh=RrGN7gLKOrzQZiNkA25VZ8kKhcB7stJufxn/uiDuDos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1znv79YuTlZoMzv0dx9/h7w+VEVBP/09ynW7c7c21EnWscYNFgFzegH/qbwfgUf6 K/nYrPdltylNqMd2uc8x41ZjZZCvIUy5wdNGRgt4b7P3a65WWetyJbpsPQw8Sqgq75 NzLTpew0wbs7ConIX4wnCjC03jR9djoCsEwDUX88= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220930064334epcas5p4d47b56ee27d1b6989a42bfeed7a7a331~ZkFDqPS742213522135epcas5p4z; Fri, 30 Sep 2022 06:43:34 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Mf1044B6Pz4x9QL; Fri, 30 Sep 2022 06:43:32 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 95.4D.39477.41096336; Fri, 30 Sep 2022 15:43:32 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220930063815epcas5p1e056d6a2a53949296a7657de804fd2ec~ZkAaoOaJY0150801508epcas5p1Y; Fri, 30 Sep 2022 06:38:15 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063815epsmtrp1c42f33706405ad36c52c664215ba6c85~ZkAanSiKK2641426414epsmtrp1q; Fri, 30 Sep 2022 06:38:15 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-5b-633690140bda Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B0.42.18644.7DE86336; Fri, 30 Sep 2022 15:38:15 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063813epsmtip2d3d3f55932b7ca094ce0eb8ce5594c7c~ZkAYRv-iN1736317363epsmtip2U; Fri, 30 Sep 2022 06:38:12 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v12 04/12] scsi: Use blk_rq_map_user_io helper Date: Fri, 30 Sep 2022 11:57:41 +0530 Message-Id: <20220930062749.152261-5-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmuq7IBLNkg2mfZCyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxWLSoWuMFntvaVvMX/aU3aL7+g42B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqX rpeXWmJlaGBgZApUmJCd8X7OROaCN0IVzx7dZ2pg7OXvYuTkkBAwkbiwbD5jFyMXh5DAbkaJ iZ9eM0M4nxglFr/5zQbhfGaUuHnwHVAZB1hL4wceiPguRomGja9YQEaBFZ2YagZiswmoSxx5 3soIYosIGEns/3SSFaSB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Lk4hAS2MEocb3hHFsXIydQXELi1MtljBC2sMTKf8/ZIYo+Mkps6bsNVsQmoC5x5Hkr WJGIgJnE0sNrWECKmEEmrXu2GCwhLOAuseLSNkaQbSwCqhLHezVBwrwCVhKzd7dDLZCXmHnp OztICaeAtUTzohyQsBBQyec979khygUlTs58wgJiMwOVN2+dzTyBUWAWktQsJKkFjEyrGCVT C4pz03OLDQuM8lLL9YoTc4tL89L1kvNzNzGCQ11LawfjnlUf9A4xMnEwHmKU4GBWEuEVLzBN FuJNSaysSi3Kjy8qzUktPsQozcGiJM57oetkvJBAemJJanZqakFqEUyWiYNTqoGp6Ps0RQVD +61fjU3S/8379HyD3qau9OaZ67W36xhd+vBge6+4/kq/I4L3r7+1mxbzetkT6XMPlxnkhpRO WrDjy+FvJ/NZJ58+LdScsaFdIrY4wSXKfMKiNoYaEzXbOtn6efoh8y8yJmqzfq84qfm4L/bs 8WWslmufXa06k2yYY/Juw7q+YKunE59mrd21So9/lzrzYenUaZsKnXLn8bHazVqnuVXn6jaj W3Hv7p62PxWy2y14+66FXxal1LUsf3dFSnrGF9fbbFHKjfO2npeJTWNe8alBf2vP1OpFGpWW 9VbcXsU/v3VcjEja4LRqfbHi761vmDVPBG/t/fXej+32Cx3HM8FG0+6LX8o+rjuRQYmlOCPR UIu5qDgRAAP5ZDTkAgAA X-CMS-MailID: 20220930063815epcas5p1e056d6a2a53949296a7657de804fd2ec X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063815epcas5p1e056d6a2a53949296a7657de804fd2ec References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the new blk_rq_map_user_io helper instead of duplicating code at various places. Additionally this also takes advantage of the on-stack iov fast path. Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_ioctl.c | 22 +++------------------- drivers/scsi/sg.c | 22 ++-------------------- 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 729e309e6034..2d20da55fb64 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -449,25 +449,9 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) if (ret < 0) goto out_put_request; - ret = 0; - if (hdr->iovec_count && hdr->dxfer_len) { - struct iov_iter i; - struct iovec *iov = NULL; - - ret = import_iovec(rq_data_dir(rq), hdr->dxferp, - hdr->iovec_count, 0, &iov, &i); - if (ret < 0) - goto out_put_request; - - /* SG_IO howto says that the shorter of the two wins */ - iov_iter_truncate(&i, hdr->dxfer_len); - - ret = blk_rq_map_user_iov(rq->q, rq, NULL, &i, GFP_KERNEL); - kfree(iov); - } else if (hdr->dxfer_len) - ret = blk_rq_map_user(rq->q, rq, NULL, hdr->dxferp, - hdr->dxfer_len, GFP_KERNEL); - + ret = blk_rq_map_user_io(rq, NULL, hdr->dxferp, hdr->dxfer_len, + GFP_KERNEL, hdr->iovec_count && hdr->dxfer_len, + hdr->iovec_count, 0, rq_data_dir(rq)); if (ret) goto out_put_request; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 94c5e9a9309c..ce34a8ad53b4 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1804,26 +1804,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) md->from_user = 0; } - if (iov_count) { - struct iovec *iov = NULL; - struct iov_iter i; - - res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i); - if (res < 0) - return res; - - iov_iter_truncate(&i, hp->dxfer_len); - if (!iov_iter_count(&i)) { - kfree(iov); - return -EINVAL; - } - - res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC); - kfree(iov); - } else - res = blk_rq_map_user(q, rq, md, hp->dxferp, - hp->dxfer_len, GFP_ATOMIC); - + res = blk_rq_map_user_io(rq, md, hp->dxferp, hp->dxfer_len, + GFP_ATOMIC, iov_count, iov_count, 1, rw); if (!res) { srp->bio = rq->bio; From patchwork Fri Sep 30 06:27:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612165 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 ED5DAC4332F for ; Fri, 30 Sep 2022 06:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbiI3GoB (ORCPT ); Fri, 30 Sep 2022 02:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbiI3Gnw (ORCPT ); Fri, 30 Sep 2022 02:43:52 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3163FC77CA for ; Thu, 29 Sep 2022 23:43:51 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064349epoutp03a559012df4fd9abf185c2157d4928a7a~ZkFRzOO8m2785727857epoutp03H for ; Fri, 30 Sep 2022 06:43:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064349epoutp03a559012df4fd9abf185c2157d4928a7a~ZkFRzOO8m2785727857epoutp03H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520229; bh=WITDi33ml99AN+RGdGVtg2lKafCL3RqyWwE1SQoSUh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y3fCFxajJ7LCZMpzJmJUpwj7PdCggnnGqnVUk1DIMgxWly9VHc9ROpolURY/iIJFK nchtI7UXb8jw0v7Msr/qYjGKuroQ5b5Wf+H9h7V1OTfwYvcjVjgriS6HtpfQpBw7S0 SFYdgzzpuQt7iyXAv/8T+uHxdcOZWwPHpPZA51qQ= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220930064348epcas5p1eafe37e427728f0cad44d70610bfb76c~ZkFQ2XQ0m1245912459epcas5p1J; Fri, 30 Sep 2022 06:43:48 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf10J3dZxz4x9QF; Fri, 30 Sep 2022 06:43:44 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 3B.C1.56352.F1096336; Fri, 30 Sep 2022 15:43:43 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063818epcas5p4e321f0efa5a53759ea19eb8f1c63deef~ZkAdQ7OlH2578525785epcas5p4Q; Fri, 30 Sep 2022 06:38:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220930063818epsmtrp2a492bfbec5c70d3905530c31b54b44aa~ZkAdQGGWy2225522255epsmtrp2G; Fri, 30 Sep 2022 06:38:18 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-5b-6336901f972d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 40.69.14392.ADE86336; Fri, 30 Sep 2022 15:38:18 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063816epsmtip20492c0efc41135e268a92438ef82aefc~ZkAb3nZUD1763417634epsmtip2E; Fri, 30 Sep 2022 06:38:16 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v12 05/12] nvme: Use blk_rq_map_user_io helper Date: Fri, 30 Sep 2022 11:57:42 +0530 Message-Id: <20220930062749.152261-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmuq78BLNkg4lH2C2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxWLSoWuMFntvaVvMX/aU3aL7+g42B06Py2dLPTat6mTz2Lyk3mP3 zQY2j74tqxg9Pm+SC2CLyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xN tVVy8QnQdcvMATpJSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgUqBXnJhbXJqX rpeXWmJlaGBgZApUmJCdcbF3JmPBMs6KT2dfszYwbmfvYuTgkBAwkfg4zbiLkYtDSGA3o8TW /3MYuxg5gZxPjBIH/1tC2N8YJea9ZQexQeqX3z7JCtGwl1FiactDRgjnM6NEy6mfzCBVbALq Ekeet4JNEhEwktj/CaKDWWATo8Sv68eYQFYLC7hLrNzhA1LDIqAqMXX3LlYQm1fASmL5sRls ENvkJWZe+g52KaeAtUTzohyIEkGJkzOfsIDYzEAlzVtnM4OMlxD4yy7xc9lkZoheF4ltU25D XS0s8er4FihbSuLzu71Q89Mlflx+ygRhF0g0H9vHCGHbS7Se6mcG2cssoCmxfpc+RFhWYuqp dUwQe/kken8/gWr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hgmJdarlecmFtcmpeul5yfu4kRHOxamjsYt6/6oHeIkYmD8RCjBAezkgiv eIFpshBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeC10n44UE0hNLUrNTUwtSi2CyTBycUg1M6U3z VuVuyAtQ8bW8mnX+mZIeV40Bd6yrnOyPxXKWZcExAk+fZF3eKBKUdPHfPZ5zx3942rCoLHpe F7meZ2dtyaIy8+mb7A+X6F/fHxO75+SFwG2Z307Ub7QXrQ9+t7wz+e68DdKiPRHTIuzqdj7e ZcpeffH+lMInzu1ss6LXFx0rPLIt8ef2zoI9olLLHMsExG3blC/oRsxMPnfQs02YMfDjiUvd ps+kpqU9V/2hx73/0vH4BVwZHuFxQVOSj56Wdp17XCy0PzpRdXEy7960b+JffJ+7bpghMOnM ZsN1r9kk/+SFrG2subS/7+fEifPmvf2g8+nJtqc7HM4or96bsYLLfepDDnv9nh0rLqfFKrEU ZyQaajEXFScCAD4LOrTlAgAA X-CMS-MailID: 20220930063818epcas5p4e321f0efa5a53759ea19eb8f1c63deef X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063818epcas5p4e321f0efa5a53759ea19eb8f1c63deef References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org User blk_rq_map_user_io instead of duplicating the same code at different places Signed-off-by: Anuj Gupta --- drivers/nvme/host/ioctl.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 914b142b6f2b..3746a02a88ef 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -88,22 +88,8 @@ static struct request *nvme_alloc_user_request(struct request_queue *q, nvme_req(req)->flags |= NVME_REQ_USERCMD; 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); - } + ret = blk_rq_map_user_io(req, NULL, ubuffer, bufflen, + GFP_KERNEL, vec, 0, 0, rq_data_dir(req)); if (ret) goto out; bio = req->bio; From patchwork Fri Sep 30 06:27:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611321 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 1467EC4332F for ; Fri, 30 Sep 2022 06:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbiI3GoQ (ORCPT ); Fri, 30 Sep 2022 02:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbiI3GoC (ORCPT ); Fri, 30 Sep 2022 02:44:02 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97CDAC77C9 for ; Thu, 29 Sep 2022 23:44:01 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220930064400epoutp04ccf6e9e94ef0fc311a68145ffca5b8e1~ZkFbfXbOR0755407554epoutp04M for ; Fri, 30 Sep 2022 06:44:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220930064400epoutp04ccf6e9e94ef0fc311a68145ffca5b8e1~ZkFbfXbOR0755407554epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520240; bh=Bj/wqbB7bQ5vziUIbpyKvUfT7C3Sk/Q8I9T3WCZwdKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIGLvnDl5JGTSqw307xw7Bu0IE5a4/kOaR/MCdyh7MZ/lObtxDLTY93FWuubUk51N 20IvC3zxetOoN7R1qz1eQxQm4Wz8WTr0NV92TNfIdxysVWkVKdxwLR/bMlzfXBrpB/ v/QqNdvV6BasAxdj+9MKGzz95hHfV8dfzRgCSz5c= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220930064359epcas5p150c03a3389aca6e41e13eaeef638a7a8~ZkFav6CKN0319903199epcas5p1H; Fri, 30 Sep 2022 06:43:59 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf10Y52Zjz4x9Q0; Fri, 30 Sep 2022 06:43:57 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A2.C5.26992.C2096336; Fri, 30 Sep 2022 15:43:56 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063821epcas5p48d4ec5136d487ea779ac74e2c0b740ac~ZkAgnrmDC2890728907epcas5p4O; Fri, 30 Sep 2022 06:38:21 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220930063821epsmtrp2c130222ea93037c62d1839088dcf0378~ZkAgm-h192234822348epsmtrp2C; Fri, 30 Sep 2022 06:38:21 +0000 (GMT) X-AuditID: b6c32a49-319fb70000016970-5e-6336902c0c42 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E2.69.14392.DDE86336; Fri, 30 Sep 2022 15:38:21 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063819epsmtip29eabf3de3c9eec84a845550e916f145b~ZkAeFtNjb1763417634epsmtip2I; Fri, 30 Sep 2022 06:38:19 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v12 06/12] nvme: refactor nvme_add_user_metadata Date: Fri, 30 Sep 2022 11:57:43 +0530 Message-Id: <20220930062749.152261-7-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmlq7OBLNkg533lSxW3+1ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpu0X39R1sDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWlW2TkZqYklqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ib aqvk4hOg65aZA3SSkkJZYk4pUCggsbhYSd/Opii/tCRVISO/uMRWKbUgJafApECvODG3uDQv XS8vtcTK0MDAyBSoMCE74/SBUywF00QqPj76x9jAOFOgi5GTQ0LAROJN83a2LkYuDiGB3YwS 67fuYYJwPjFKfO5+zgrhfGOUeHzjFgtMy+eVf6ASexkl/mzuYodwPjNKnDnxmBGkik1AXeLI 81YwW0TASGL/p5NgHcwCWxglmtctZgdJCAt4Srzr7GIC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WWPnvOTtE0UdGiXtPPoAl2ATUJY48bwWz RQTMJJYeXsMCUsQssItRYu7Wb8wgCWEBT4l3nV1MIDaLgKrEkmmTWEFsXgEriQs3drFBbJCX mHnpO9AGDg5OAWuJ5kU5IGEhoJLPe96zQ5QLSpyc+QTsOGag8uats5knMArMQpKahSS1gJFp FaNkakFxbnpusWGBYV5quV5xYm5xaV66XnJ+7iZGcLhrae5g3L7qg94hRiYOxkOMEhzMSiK8 4gWmyUK8KYmVValF+fFFpTmpxYcYpTlYlMR5L3SdjBcSSE8sSc1OTS1ILYLJMnFwSjUwnbuT aFGq8rgiaXl8pYzdz1OVVsb7lPXLJ2zkldcRuFw7d7/OP0Wj+gidBx9SHDtM/NvZn4WKePh7 Gy/bNmUa36OMfydWLXH9+j4rNbjsdOvDOZm1T/UYDddkLJ48yT7zhwhLf95OlqP3bW039Tm1 TH60KkPKZtO300vu7ElqmjCLxW4/e32l25N/k0KmLTm76myqy/sV785tM7eapNYnf3DeYuMl Ho8ldCbz6u8rrvQUPFzw6SJz+Jka1kMzZu2IeL6dXXDflY3dGz+c443ni+/PYZJ8/vnrXW+T 19rOW97xz/xdv+95eEXOhuNGGrZFRnmSj/i1f69677tmX/BqpgLlxG/3Q97MPMF7auqFPUos xRmJhlrMRcWJAPDxIXjmAgAA X-CMS-MailID: 20220930063821epcas5p48d4ec5136d487ea779ac74e2c0b740ac X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063821epcas5p48d4ec5136d487ea779ac74e2c0b740ac References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi 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 3746a02a88ef..bcaa6b3f97ca 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; @@ -96,13 +100,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 Fri Sep 30 06:27:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612164 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 AA28DC433F5 for ; Fri, 30 Sep 2022 06:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbiI3GoX (ORCPT ); Fri, 30 Sep 2022 02:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbiI3GoO (ORCPT ); Fri, 30 Sep 2022 02:44:14 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75CFC77DB for ; Thu, 29 Sep 2022 23:44:12 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064411epoutp03ca6fb9f5aa58d1db704b2075f4015332~ZkFmC0ODV2798727987epoutp03L for ; Fri, 30 Sep 2022 06:44:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064411epoutp03ca6fb9f5aa58d1db704b2075f4015332~ZkFmC0ODV2798727987epoutp03L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520251; bh=+erqF/H/+cbelwAdq7fVoTxCoPBYnaLkKBmydd0SmkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sa+ksZH9/OcqJxFgZJCDAykWGOXRk8LVMrd+Ot+SUYUF1dNGDnMnjky5/nzgIWcDL oDNriH5RuHRJftoq5QUqY03yMOYZskP7OLQOx668NBkoU2zaQtFJnmyRe8DHuJLCRJ 4z34DGti1K/eeJCYqw+1W+bWii4Cey4hVOisyrdA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220930064410epcas5p2625b560d79d247e22dcd3095ac796f85~ZkFlnz4Cg2832628326epcas5p2H; Fri, 30 Sep 2022 06:44:10 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf10m4xPzz4x9Q0; Fri, 30 Sep 2022 06:44:08 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F9.7D.39477.83096336; Fri, 30 Sep 2022 15:44:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063824epcas5p4f829f3b8673e2603cdc9a799ca44ea6e~ZkAjNiF0e1804318043epcas5p4H; Fri, 30 Sep 2022 06:38:24 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063824epsmtrp13c7e3ecc15037231b997c8cfd600f39c~ZkAjMnJ6Y2641426414epsmtrp11; Fri, 30 Sep 2022 06:38:24 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-eb-63369038ec43 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 94.42.18644.0EE86336; Fri, 30 Sep 2022 15:38:24 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063822epsmtip22fc3d2adde5543f8c23de5f85cead259~ZkAhW5p821763417634epsmtip2J; Fri, 30 Sep 2022 06:38:22 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v12 07/12] nvme: refactor nvme_alloc_request Date: Fri, 30 Sep 2022 11:57:44 +0530 Message-Id: <20220930062749.152261-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEJsWRmVeSWpSXmKPExsWy7bCmhq7FBLNkg5XfVS2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnAKTAr3i xNzi0rx0vbzUEitDAwMjU6DChOyM5pmNjAVtahVTL01iaWA8I9fFyMkhIWAi8fLhXOYuRi4O IYHdjBKH50xjgnA+MUrMf9nPAuF8ZpS4d/4gO0zL9xWHWSESuxglOh/uY4arWn26lwWkik1A XeLI81ZGEFtEwEhi/6eTYB3MAjcZJZqP7WMCSQgLuEocerOXDcRmEVCVWHB8KVicV8BK4t/W iywQ6+QlZl76DrSag4NTwFqieVEORImgxMmZT8BKmIFKmrfOBjtCQqCVQ+LMtTusEL0uEvv+ fYSyhSVeHd8C9YKUxMv+Nig7XeLH5adMEHYByG2MELa9ROupfmaQvcwCmhLrd+lDhGUlpp5a xwSxl0+i9/cTqFZeiR3zYGwlifaVc6BsCYm95xqgbA+JloU/oOHbxyjx8dZ19gmMCrOQ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fjnlUf9A4xMnEwHmKU 4GBWEuEVLzBNFuJNSaysSi3Kjy8qzUktPsQozcGiJM57oetkvJBAemJJanZqakFqEUyWiYNT qoFpenKj5j79ne/SqqcycH6/uGSvoZXkpiJJp89utfFv+7x+/4vbvv+xqq/8/ZwDXkctm4qn LequLj3K4vc0jW3BGz775CNmZ66+WyBuscmjZrPM1aebj98zqYpaNXnO3Wd9Si6n3oiX+jo0 LFHieX525fKAp3wxN1puZL65en1ewM2WN99l5s6xtr1ecPpH4pWIk7sTztus9Z72aMcJ72jD 1JyOkE/HwuYuvu8pOL08NTLi+P/55T+WSrTvd2swPBol/GoHy3IlsQ4lSbvw5FpzR4b6ypA9 8/91P3v+xyO5dHW3yZ1HfEr+Zb8tpl16LS15j2n+RTupZzLSO6x7TLYq72y//vVShPTFWwaJ gdM+K7EUZyQaajEXFScCAGHCyojrAgAA X-CMS-MailID: 20220930063824epcas5p4f829f3b8673e2603cdc9a799ca44ea6e X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063824epcas5p4f829f3b8673e2603cdc9a799ca44ea6e References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi nvme_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 Signed-off-by: Anuj Gupta Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 90 +++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index bcaa6b3f97ca..3f1e7af19716 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -70,54 +70,57 @@ 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) { - ret = blk_rq_map_user_io(req, NULL, ubuffer, bufflen, - GFP_KERNEL, vec, 0, 0, rq_data_dir(req)); - 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; +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; + + ret = blk_rq_map_user_io(req, NULL, ubuffer, bufflen, GFP_KERNEL, vec, + 0, 0, rq_data_dir(req)); + + 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, @@ -132,11 +135,18 @@ static int nvme_submit_user_cmd(struct request_queue *q, u32 effects; 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); + req->timeout = timeout; + if (ubuffer && bufflen) { + ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer, + meta_len, meta_seed, &meta, vec); + if (ret) + return ret; + } + bio = req->bio; ctrl = nvme_req(req)->ctrl; @@ -456,6 +466,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; @@ -495,13 +506,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) + return ret; + } if (issue_flags & IO_URING_F_IOPOLL && rq_flags & REQ_POLLED) { if (unlikely(!req->bio)) { From patchwork Fri Sep 30 06:27:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611320 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 66449C43217 for ; Fri, 30 Sep 2022 06:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbiI3Goi (ORCPT ); Fri, 30 Sep 2022 02:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbiI3Go2 (ORCPT ); Fri, 30 Sep 2022 02:44:28 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDCAC77D4 for ; Thu, 29 Sep 2022 23:44:27 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064425epoutp0364e4f547bcdb4b40b4762e410658de78~ZkFzVYucY2825128251epoutp03S for ; Fri, 30 Sep 2022 06:44:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064425epoutp0364e4f547bcdb4b40b4762e410658de78~ZkFzVYucY2825128251epoutp03S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520265; bh=2l6r1DB02hn4cQZvMEIiXdgX6TaGb69i56uQGNumnms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZ8NV62On6AR8MsDXpuYe5iYfJBXX4LcSTjGyLrw7kYYlX7OHBTLbgICSvk2vfMhx UcsnF/epUsOJqHJnjpHlkBEYbK4/m6ClgqEcSJEsanEj1ZUaRnuuiLpfVaSZl+4mcZ 2b8YTraV0oiJ9X+GxVFiqQUGLWdtjXxMglcHH4J4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220930064425epcas5p20de9d92698b041556465d4c22df60c84~ZkFy3sFDd0972109721epcas5p25; Fri, 30 Sep 2022 06:44:25 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Mf1121Qzzz4x9Pq; Fri, 30 Sep 2022 06:44:22 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 03.02.56352.64096336; Fri, 30 Sep 2022 15:44:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063826epcas5p491d9bc62214c1d7c8c24c883299edfb7~ZkAlF8ByA1804318043epcas5p4L; Fri, 30 Sep 2022 06:38:26 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063826epsmtrp13b1d534abf3cebea898c89a74730547e~ZkAlFF3H22641426414epsmtrp12; Fri, 30 Sep 2022 06:38:26 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-0b-6336904639b5 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 64.69.14392.2EE86336; Fri, 30 Sep 2022 15:38:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063825epsmtip2a4279c2b0a76b59303f29082e3e0416e~ZkAjvCG4M1763417634epsmtip2K; Fri, 30 Sep 2022 06:38:25 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Anuj Gupta Subject: [PATCH for-next v12 08/12] block: rename bio_map_put to blk_mq_map_bio_put Date: Fri, 30 Sep 2022 11:57:45 +0530 Message-Id: <20220930062749.152261-9-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmpq7bBLNkg+MtHBZNE/4yW6y+289m cfPATiaLlauPMlm8az3HYjHp0DVGi723tC3mL3vKbtF9fQebA6fH5bOlHptWdbJ5bF5S77H7 ZgObR9+WVYwenzfJBbBFZdtkpCampBYppOYl56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam 2iq5+AToumXmAJ2kpFCWmFMKFApILC5W0rezKcovLUlVyMgvLrFVSi1IySkwKdArTswtLs1L 18tLLbEyNDAwMgUqTMjOWLvvA1PBO46KpvlfmBsY57N3MXJySAiYSNw+9oyxi5GLQ0hgN6PE 8n/XmCCcT4wS83bcYYNwvjFK3PndwgTTcu/zAqiWvYwSk/Z1MUM4nxklFvWdABvMJqAuceR5 KyOILSJgJLH/00lWkCJmgU2MEr+uHwMbJSwQKtG1ZR4riM0ioCqx+t4noGYODl4BK4k/xywh tslLzLz0HSzMKWAt0bwoByTMKyAocXLmExYQmxmopHnrbGaI8p/sEpP7bSFsF4nLu8+wQdjC Eq+Ob4H6WUriZX8blJ0u8ePyU6jHCiSaj+1jhLDtJVpP9TODrGUW0JRYv0sfIiwrMfXUOiaI tXwSvb+fQLXySuyYB2MrSbSvnANlS0jsPdcAZXtI3JzdC2YLCfQxSsy+qj6BUWEWkm9mIflm FsLmBYzMqxglUwuKc9NTi00LjPNSy+FxnJyfu4kRnEi1vHcwPnrwQe8QIxMH4yFGCQ5mJRFe 8QLTZCHelMTKqtSi/Pii0pzU4kOMpsDAnsgsJZqcD0zleSX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f/1qtY3l6V7Re/PPdR Uv5NlZOiKTc/qPMoa2ft0wv27GatvDTr9u5vVccZylkNZpa5fbx5+EO6+6uzbU7rQo++XXqq WFtg6duuqdrXgnY6SFy59OnGN8O42cc5l18R9G5brRlfc+R2vp6I0Y3EnWozHPs/uM/Ls4uO 79NNn/H3q85q+2CLI/OXr9RdfTPWeeGl/9UL33lkuXvy7OtbnbIv4fohxrVFB5h7dV0emPvJ FT/RYlZifPJXY4lLvmx5wRPGbAfv7yyS8/N6LrU03dteX87O7XX9t8RH1Y9mbfy2SizFGYmG WsxFxYkAOGILcuUCAAA= X-CMS-MailID: 20220930063826epcas5p491d9bc62214c1d7c8c24c883299edfb7 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063826epcas5p491d9bc62214c1d7c8c24c883299edfb7 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch renames existing bio_map_put function to blk_mq_map_bio_put. Signed-off-by: Anuj Gupta Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- block/blk-map.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index 0e37bbedd46c..84b13a4158b7 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -231,7 +231,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, return ret; } -static void bio_map_put(struct bio *bio) +static void blk_mq_map_bio_put(struct bio *bio) { if (bio->bi_opf & REQ_ALLOC_CACHE) { bio_put(bio); @@ -331,7 +331,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, out_unmap: bio_release_pages(bio, false); - bio_map_put(bio); + blk_mq_map_bio_put(bio); return ret; } @@ -672,7 +672,7 @@ int blk_rq_unmap_user(struct bio *bio) next_bio = bio; bio = bio->bi_next; - bio_map_put(next_bio); + blk_mq_map_bio_put(next_bio); } return ret; From patchwork Fri Sep 30 06:27:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612163 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 81BF2C433F5 for ; Fri, 30 Sep 2022 06:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbiI3GpA (ORCPT ); Fri, 30 Sep 2022 02:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiI3Goy (ORCPT ); Fri, 30 Sep 2022 02:44:54 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D71D71181B for ; Thu, 29 Sep 2022 23:44:41 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220930064440epoutp01221a9fa001a8e93b621a508b936dbde4~ZkGA-MG-j0192401924epoutp01L for ; Fri, 30 Sep 2022 06:44:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220930064440epoutp01221a9fa001a8e93b621a508b936dbde4~ZkGA-MG-j0192401924epoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520280; bh=cqR0g8fK47YXPZZiJGboAfOg3ijONkyZyl3d/RvlPg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZfkKLXRehJa3sHwe1bRBXG9xELflsBfXx94yjzhLalQfiay/SAh82JMFwsFMFXSK iXn4Dk/KbmBUZ2q04XjbGu+KF3DD5lDbCeQNU+8HJhClBADcf/x+ARlFlckvB2C6MB A+tG4vBjwDKxz5IT5dQQR9kf3d4wTObRa5PPHkqk= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220930064439epcas5p38f7c5aae95dd4174da48e99b858c5329~ZkGAXRrmJ1351713517epcas5p3y; Fri, 30 Sep 2022 06:44:39 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf11K073Tz4x9Q4; Fri, 30 Sep 2022 06:44:37 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E0.BD.39477.25096336; Fri, 30 Sep 2022 15:44:34 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220930063828epcas5p2bfddb254b0dffde77e99c2acc4440bde~ZkAnH2S_40571405714epcas5p2Q; Fri, 30 Sep 2022 06:38:28 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220930063828epsmtrp27f4756bfbec6a6ce339880f3d5b69fcf~ZkAnG3ouY2225522255epsmtrp2Y; Fri, 30 Sep 2022 06:38:28 +0000 (GMT) X-AuditID: b6c32a4a-007ff70000019a35-69-633690526e7e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A5.69.14392.4EE86336; Fri, 30 Sep 2022 15:38:28 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063827epsmtip2d2be7b9725dfd98574b953d0f2d94b34~ZkAlvYSsR1763417634epsmtip2L; Fri, 30 Sep 2022 06:38:27 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v12 09/12] block: factor out blk_rq_map_bio_alloc helper Date: Fri, 30 Sep 2022 11:57:46 +0530 Message-Id: <20220930062749.152261-10-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDJsWRmVeSWpSXmKPExsWy7bCmum7QBLNkg/179S1W3+1ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpu0X39R1sDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWlW2TkZqYklqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ib aqvk4hOg65aZA3SSkkJZYk4pUCggsbhYSd/Opii/tCRVISO/uMRWKbUgJafApECvODG3uDQv XS8vtcTK0MDAyBSoMCE7Y+nDTsaCFQIV21/rNzDO5e1i5OSQEDCRmP7oMWsXIxeHkMBuRom+ P5OhnE+MEv+3T2SHcL4xSjztu88E0zJt/zFmiMReRonXv65BVX1mlFj/cwojSBWbgLrEkeet YLaIgJHE/k8nweYyC2xhlGhet5gdJCEsECyx+H4/K4jNIqAqcX/XO2YQm1fAWmL1r5uMEOvk JWZe+g5Uz8HBCRRvXpQDUSIocXLmExYQmxmopHnrbLCLJAR+sktcn/SNFaLXReLP+stsELaw xKvjW9ghbCmJz+/2QsXTJX5cfgr1WoFE87F9UHvtJVpP9TOD7GUW0JRYv0sfIiwrMfXUOiaI vXwSvb+fQLXySuyYB2MrSbSvnANlS0jsPdcAZXtITP7eDQ3fPkaJK3e+ME1gVJiF5J9ZSP6Z hbB6ASPzKkbJ1ILi3P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JDjNIcLErivBe6TsYLCaQnlqRmp6YWpBbBZJk4OKUamJZ/dhI/ pnujY6/b46wwn5g4+5Y7OwKX874OEa962nDiWWFz0sHSrdn/i7Lf3qpT+894XqtQ7EKfdMeT HzsCNjYu/G3+5nCMMmew6mG1Hq93PvmB7zKkVxmcrjgiteTN1pPzV3kVFn20PrHbZq9C5PQ2 1opTM5cpud27fNopwG9P9JQ23Y66rM8SKzzmMk5zdOFhuHN04dy6hPM3OIVvswrLCXVaau9+ dsKmX+xRnOm0n655sn8ula5bvktvWVL/+arr5s2znR7OmmnC5FMUfGAl54TTuurWMhUiody5 q5W9JdSCXG/4cm489X95zvUXrNdXvVSoqDS9PcHgwCWny48SVv5ovfeiR195A0u9iRJLcUai oRZzUXEiAMlnOMLlAgAA X-CMS-MailID: 20220930063828epcas5p2bfddb254b0dffde77e99c2acc4440bde X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063828epcas5p2bfddb254b0dffde77e99c2acc4440bde References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi Move bio allocation logic from bio_map_user_iov to a new helper blk_rq_map_bio_alloc. It is named so because functionality is opposite of what is done inside blk_mq_map_bio_put. This is a prep patch. Signed-off-by: Kanchan Joshi --- block/blk-map.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index 84b13a4158b7..d6ea377394a9 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -241,17 +241,10 @@ static void blk_mq_map_bio_put(struct bio *bio) } } -static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, - gfp_t gfp_mask) +static struct bio *blk_rq_map_bio_alloc(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 = blk_rq_map_bio_alloc(rq, nr_vecs, gfp_mask); + if (bio == NULL) + return -ENOMEM; while (iov_iter_count(iter)) { struct page **pages, *stack_pages[UIO_FASTIOV]; From patchwork Fri Sep 30 06:27:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611319 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 7FFB2C43217 for ; Fri, 30 Sep 2022 06:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbiI3GpU (ORCPT ); Fri, 30 Sep 2022 02:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbiI3GpK (ORCPT ); Fri, 30 Sep 2022 02:45:10 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C37F28E3E for ; Thu, 29 Sep 2022 23:44:56 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220930064454epoutp03eed5be4d4eee0d2bedf0f766c52973f8~ZkGOKCMD32785727857epoutp03p for ; Fri, 30 Sep 2022 06:44:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220930064454epoutp03eed5be4d4eee0d2bedf0f766c52973f8~ZkGOKCMD32785727857epoutp03p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520294; bh=tDC98zhUChsoFxyax6OGBO2ZGu3ypq6Y8ZQCxc+Plfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZL+No5DInG82hyUQlmn9tGqHZ8aMqYn84o3M/jWlv9aUaRDh2I9SEaJr93S8jiXgr /Hf31PtkgZ3axZA+jBoL7Pd3T+Vx8/oakA5LBURR7feL7iEpehrtRyMchJGv3HBtjT PPuJE46zObixyEDYi+QOBOQr/WjTk/HW10QZqD4Q= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220930064453epcas5p30182b25ffd0a63d0d2c10c1a766c6605~ZkGNsxaas2067520675epcas5p3j; Fri, 30 Sep 2022 06:44:53 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Mf11Z6kncz4x9QK; Fri, 30 Sep 2022 06:44:50 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C9.CD.39477.F5096336; Fri, 30 Sep 2022 15:44:47 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063831epcas5p4b6a8559dedd39ef423a0b9a317163969~ZkApTi86I2025120251epcas5p4H; Fri, 30 Sep 2022 06:38:31 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063831epsmtrp1de3393fe7c03723a16fede328b3bd0c3~ZkApSranM2641426414epsmtrp14; Fri, 30 Sep 2022 06:38:31 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-bb-6336905f0964 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 76.69.14392.7EE86336; Fri, 30 Sep 2022 15:38:31 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063829epsmtip215b19387b98af7ff187f06f2ff8ba3c2~ZkAnvK22K1483614836epsmtip2P; Fri, 30 Sep 2022 06:38:29 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v12 10/12] block: extend functionality to map bvec iterator Date: Fri, 30 Sep 2022 11:57:47 +0530 Message-Id: <20220930062749.152261-11-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHJsWRmVeSWpSXmKPExsWy7bCmum78BLNkg5NvzC2aJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5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cas5p4b6a8559dedd39ef423a0b9a317163969 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063831epcas5p4b6a8559dedd39ef423a0b9a317163969 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi Extend blk_rq_map_user_iov so that it can handle bvec iterator, using the new blk_rq_map_user_bvec function. 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 Suggested-by: Christoph Hellwig --- block/blk-map.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/block/blk-map.c b/block/blk-map.c index d6ea377394a9..34735626b00f 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -548,6 +548,62 @@ 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) +{ + struct request_queue *q = rq->q; + size_t nr_iter = iov_iter_count(iter); + size_t nr_segs = iter->nr_segs; + struct bio_vec *bvecs, *bvprvp = NULL; + struct queue_limits *lim = &q->limits; + unsigned int nsegs = 0, bytes = 0; + struct bio *bio; + size_t i; + + 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 = blk_rq_map_bio_alloc(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++) { + struct bio_vec *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)) { + blk_mq_map_bio_put(bio); + return -EREMOTEIO; + } + /* 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: + blk_mq_map_bio_put(bio); + return -EINVAL; +} + /** * blk_rq_map_user_iov - map user data to a request, for passthrough requests * @q: request queue where request should be inserted @@ -567,24 +623,35 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, struct rq_map_data *map_data, const struct iov_iter *iter, gfp_t gfp_mask) { - bool copy = false; + bool copy = false, map_bvec = false; unsigned long align = q->dma_pad_mask | queue_dma_alignment(q); struct bio *bio = NULL; struct iov_iter i; int ret = -EINVAL; - if (!iter_is_iovec(iter)) - goto fail; - if (map_data) copy = true; else if (blk_queue_may_bounce(q)) copy = true; else if (iov_iter_alignment(iter) & align) copy = true; + else if (iov_iter_is_bvec(iter)) + map_bvec = true; + else if (!iter_is_iovec(iter)) + copy = true; else if (queue_virt_boundary(q)) copy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter); + if (map_bvec) { + ret = blk_rq_map_user_bvec(rq, iter); + if (!ret) + return 0; + if (ret != -EREMOTEIO) + goto fail; + /* fall back to copying the data on limits mismatches */ + copy = true; + } + i = *iter; do { if (copy) From patchwork Fri Sep 30 06:27:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 612162 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 8DD8AC433FE for ; Fri, 30 Sep 2022 06:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbiI3GpV (ORCPT ); Fri, 30 Sep 2022 02:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiI3GpL (ORCPT ); Fri, 30 Sep 2022 02:45:11 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18B413686B for ; Thu, 29 Sep 2022 23:45:07 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220930064505epoutp04bce5477f95491cc635e186eefeb3732d~ZkGYercxs1060910609epoutp04N for ; Fri, 30 Sep 2022 06:45:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220930064505epoutp04bce5477f95491cc635e186eefeb3732d~ZkGYercxs1060910609epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520305; bh=CK6y+4CJTbXEJ0DmfDZkP4QxoZPfh+zQGIa6zysu96A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgc7gzoQIEwehF9HQbRgpqbXm0F955ummTBavvjmnJJnFa9Qaz0XLNqs51SoHJXnB 1Bd9F7fy5trVYi/X2jjyw6AdqBvyt6SancrIusDyofk562H+pkbzpxzn2sih+K9FZ6 n4G35sNDHZLzG8rPXRtqypuT9Zca+ZlJIgXjDdRk= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220930064504epcas5p387d9215a71fc1001602b342944e40c8f~ZkGXni4yE2565825658epcas5p3e; Fri, 30 Sep 2022 06:45:04 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Mf11p5r3jz4x9Pp; Fri, 30 Sep 2022 06:45:02 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 80.42.56352.E6096336; Fri, 30 Sep 2022 15:45:02 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220930063833epcas5p40fbff95f9d132f5a42dda80d307426e9~ZkArb25FD2024220242epcas5p4O; Fri, 30 Sep 2022 06:38:33 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063833epsmtrp1912c3123d85a5da197775af2451df46c~ZkArbLujp2657326573epsmtrp1i; Fri, 30 Sep 2022 06:38:33 +0000 (GMT) X-AuditID: b6c32a4b-5f7fe7000001dc20-cd-6336906e21ce Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A7.69.14392.9EE86336; Fri, 30 Sep 2022 15:38:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063831epsmtip2804e2adf4659edb5c4242e57518e9635~ZkAp4CasY1483614836epsmtip2Q; Fri, 30 Sep 2022 06:38:31 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi , Anuj Gupta Subject: [PATCH for-next v12 11/12] nvme: pass ubuffer as an integer Date: Fri, 30 Sep 2022 11:57:48 +0530 Message-Id: <20220930062749.152261-12-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAJsWRmVeSWpSXmKPExsWy7bCmum7eBLNkgysr9CyaJvxltlh9t5/N 4uaBnUwWK1cfZbJ413qOxeLo/7dsFpMOXWO02HtL22L+sqfsFt3Xd7A5cHlcPlvqsWlVJ5vH 5iX1HrtvNrB59G1ZxejxeZNcAFtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnAKTAr3i xNzi0rx0vbzUEitDAwMjU6DChOyMe1vLCqbJVTScn8/YwPheoouRk0NCwETiyJ1dbF2MXBxC ArsZJRrX7WKHcD4xSpy8sgYq841R4uP6O6wwLS0LjkBV7WWUOHr+MyuE85lR4lvPFmaQKjYB dYkjz1sZQWwRASOJ/Z9OghUxC9xklGg+to8JJCEs4CLx5OYTsCIWAVWJh/v3AtkcHLwC1hIH DyVCbJOXmHnpOztImBMo3LwoByTMKyAocXLmExYQmxmopHnrbGaQ8RICjRwS525OgLrURaLn /ytmCFtY4tXxLewQtpTEy/42KDtd4sflp0wQdgHIaYwQtr1E66l+ZpC9zAKaEut36UOEZSWm nlrHBLGXT6L39xOoVl6JHfNgbCWJ9pVzoGwJib3nGqBsD4kVC/qYIWHVxyjR9e4O0wRGhVlI /pmF5J9ZCKsXMDKvYpRMLSjOTU8tNi0wzksth0dycn7uJkZwUtXy3sH46MEHvUOMTByMhxgl OJiVRHjFC0yThXhTEiurUovy44tKc1KLDzGaAoN7IrOUaHI+MK3nlcQbmlgamJiZmZlYGpsZ KonzLp6hlSwkkJ5YkpqdmlqQWgTTx8TBKdXAtKdxv1F3wLnDZaxhNbFNmwTjNuQfOcSUsusv V4L39/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uC e/vrC43Tt/PdDz1d82DX31/Lw3oWfuhzCJovJXvnUahwuWNUx7RQn+jeuJ8OTLcvLVLyKErY nVlhoFMr6MN2xtTun7mk0aPjR43uhPZ3GW602HrIk/FH58Fl7wqj97taGF7hfKAhxZRVr3Dl zpnDs66X6k9Wn1F3dI+iyTvzs+2P1zC8Fah/8vVcjZn0yoYt80Q+1O5qvfDe/PxUhWXcnxkO K7EUZyQaajEXFScCAJ2CE+bpAgAA X-CMS-MailID: 20220930063833epcas5p40fbff95f9d132f5a42dda80d307426e9 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063833epcas5p40fbff95f9d132f5a42dda80d307426e9 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi This is a prep patch. Modify nvme_submit_user_cmd and nvme_map_user_request 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 Reviewed-by: Christoph Hellwig --- drivers/nvme/host/ioctl.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 3f1e7af19716..7a41caa9bfd2 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; @@ -94,8 +95,8 @@ static int nvme_map_user_request(struct request *req, void __user *ubuffer, void *meta = NULL; int ret; - ret = blk_rq_map_user_io(req, NULL, ubuffer, bufflen, GFP_KERNEL, vec, - 0, 0, rq_data_dir(req)); + ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer), bufflen, + GFP_KERNEL, vec, 0, 0, rq_data_dir(req)); if (ret) goto out; @@ -124,7 +125,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) { @@ -142,7 +143,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) return ret; } @@ -226,7 +227,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); } @@ -280,7 +281,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); @@ -326,7 +327,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); @@ -512,9 +513,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) return ret; } From patchwork Fri Sep 30 06:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 611318 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 DB00FC433FE for ; Fri, 30 Sep 2022 06:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiI3Gpc (ORCPT ); Fri, 30 Sep 2022 02:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbiI3Gpa (ORCPT ); Fri, 30 Sep 2022 02:45:30 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40D0F29C91 for ; Thu, 29 Sep 2022 23:45:26 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220930064523epoutp021d62b44789107eed9d4f63e14099e364~ZkGo7fqJx0356303563epoutp02X for ; Fri, 30 Sep 2022 06:45:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220930064523epoutp021d62b44789107eed9d4f63e14099e364~ZkGo7fqJx0356303563epoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1664520323; bh=y6eU8gXdSDyGpk0CFHu/m5477ll3V22Pel3mdMYIG5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eraHUqrVxpSVUvng+aT2/stGVQIu066XqHA4RaeoT1ce/UO1GTmZKUZfbsq/+U7uj GHjKvLBfmrebkGfAFLGICDp64wj05sGFDdmbPPT5m2d0Up6f0QT3TsHB/hl8lYhznN dy+GXtTq4LjFt6kiEqULRdQ1mk/6Cimw53YQp25k= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220930064519epcas5p1f4b6305c843b30af21c038ed2d3f9455~ZkGljPZUL0319903199epcas5p1D; Fri, 30 Sep 2022 06:45:19 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.182]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Mf1253hSVz4x9Px; Fri, 30 Sep 2022 06:45:17 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 14.76.26992.B7096336; Fri, 30 Sep 2022 15:45:15 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220930063835epcas5p2812f8e3d0758b19c01198034fcddc019~ZkAtkt3FD2490824908epcas5p2G; Fri, 30 Sep 2022 06:38:35 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220930063835epsmtrp1f220e4263663f078bb6eb40068e11d0b~ZkAtjykoX2657326573epsmtrp1k; Fri, 30 Sep 2022 06:38:35 +0000 (GMT) X-AuditID: b6c32a49-0c7ff70000016970-e3-6336907bb16d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 98.42.18644.BEE86336; Fri, 30 Sep 2022 15:38:35 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220930063834epsmtip255a8b7b75bd5e31699222aef48896eff~ZkAsEqGso1763417634epsmtip2R; Fri, 30 Sep 2022 06:38:34 +0000 (GMT) From: Anuj Gupta 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, linux-scsi@vger.kernel.org, Kanchan Joshi Subject: [PATCH for-next v12 12/12] nvme: wire up fixed buffer support for nvme passthrough Date: Fri, 30 Sep 2022 11:57:49 +0530 Message-Id: <20220930062749.152261-13-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220930062749.152261-1-anuj20.g@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmlm71BLNkgyen2C1W3+1ns7h5YCeT xcrVR5ks3rWeY7E4+v8tm8WkQ9cYLfbe0raYv+wpu0X39R1sDpwel8+Wemxa1cnmsXlJvcfu mw1sHn1bVjF6fN4kF8AWlW2TkZqYklqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ib aqvk4hOg65aZA3SSkkJZYk4pUCggsbhYSd/Opii/tCRVISO/uMRWKbUgJafApECvODG3uDQv XS8vtcTK0MDAyBSoMCE74+6/m+wFt7kr7lzia2A8x9nFyMkhIWAisXL3POYuRi4OIYHdjBJ3 JqxmhXA+MUrsPrCbDcL5zCgx8XYbC0zL8r8rmCASuxglWq9cZYGrenJgBiNIFZuAusSR561g toiAkcT+TyfB5jILbGGUaF63mL2LkYNDWCBWYtUKORCTRUBV4t/5EpByXgFriZa2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AEm4C6xJHnrWBF IgJmEksPr2EBKWIW2MUoMXfrN2aQhLBAtMShDxOAEhwcLAKqEv/Ol4CEeQWsJVra/jNBLJCX mHnpOztICSdQvHlRDkhYSMBK4vOe9+wQ5YISJ2c+YQGxmYHKm7fOZp7AKDALSWoWktQCRqZV jJKpBcW56bnFhgVGeanlesWJucWleel6yfm5mxjBoa6ltYNxz6oPeocYmTgYDzFKcDArifCK F5gmC/GmJFZWpRblxxeV5qQWH2KU5mBREue90HUyXkggPbEkNTs1tSC1CCbLxMEp1cBUbVN8 3cGhbo6bV+NMTvdL1ZMm7XfLVFdnfxV0iT9Jarbhh6gjoUevmMRNzN5UyRuUHPR9RmvenaRI 6b13pqeY5XSmZXDv4emMW+v1eJn4ToddBTcfxGUFV65iXiZs7zuNgf2owOTTPVe/Hfxdutdj 63OeD99S/RgNJySkp2Z80S7X2K3XYOIQn6gX4ulSvKtZrNW7UFrwlcvS9pxVE/58fLGz9vmb bV2bPaLyOXtPb856PfebX2xx2YKUS+uLI99sOjtnU/R7jZPXz9zyeiuxOdZw29L5d04YbeoX 7Fohbnxcg/OWkd0Uzw32SzIyw5LECkUWVEk5X/EM85rcohNUPVUgZuLu0Joz3QJxjkosxRmJ hlrMRcWJABaeFrvkAgAA X-CMS-MailID: 20220930063835epcas5p2812f8e3d0758b19c01198034fcddc019 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220930063835epcas5p2812f8e3d0758b19c01198034fcddc019 References: <20220930062749.152261-1-anuj20.g@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Kanchan Joshi 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. Signed-off-by: Kanchan Joshi --- drivers/nvme/host/ioctl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 7a41caa9bfd2..81f5550b670d 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -95,8 +95,22 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, void *meta = NULL; int ret; - ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer), bufflen, - GFP_KERNEL, vec, 0, 0, rq_data_dir(req)); + if (ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED)) { + struct iov_iter iter; + + /* fixedbufs is only for non-vectored io */ + if (WARN_ON_ONCE(vec)) + return -EINVAL; + 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_io(req, NULL, nvme_to_user_ptr(ubuffer), + bufflen, GFP_KERNEL, vec, 0, 0, + rq_data_dir(req)); + } if (ret) goto out;