All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [RFC PATCH 2/8] nvme-core: export existing ctrl and ns interfaces
Date: Wed, 4 Apr 2018 14:59:37 +0300	[thread overview]
Message-ID: <02e99d9a-7c33-c853-d2b4-c68fce493eac@grimberg.me> (raw)
In-Reply-To: <20180330065747.20962-3-chaitanya.kulkarni@wdc.com>



On 03/30/2018 09:57 AM, Chaitanya Kulkarni wrote:
> We export existing nvme ctrl and ns management APIs so that
> target passthru code can manage the nvme ctrl.
> 
> This is a preparation patch for implementing NVMe Over Fabric
> target passthru feature.

I'd only export only the passthru portion of nvme_user_cmd and use
that.

Something like the (untested):
--
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 383c4d0bc5ff..fce6b090a3a0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1162,22 +1162,14 @@ static void nvme_passthru_end(struct nvme_ctrl 
*ctrl, u32 effects)
                 nvme_queue_scan(ctrl);
  }

-static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
-                       struct nvme_passthru_cmd __user *ucmd)
+int nvme_execute_passtru_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
+               struct nvme_passthru_cmd *cmd)
  {
-       struct nvme_passthru_cmd cmd;
         struct nvme_command c;
         unsigned timeout = 0;
         u32 effects;
         int status;

-       if (!capable(CAP_SYS_ADMIN))
-               return -EACCES;
-       if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
-               return -EFAULT;
-       if (cmd.flags)
-               return -EINVAL;
-
         memset(&c, 0, sizeof(c));
         c.common.opcode = cmd.opcode;
         c.common.flags = cmd.flags;
@@ -1201,6 +1193,24 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, 
struct nvme_ns *ns,
                         0, &cmd.result, timeout);
         nvme_passthru_end(ctrl, effects);

+       return status;
+}
+EXPORT_SYMBOL_GPL(nvme_execute_passtru_cmd);
+
+static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
+                       struct nvme_passthru_cmd __user *ucmd)
+{
+       struct nvme_passthru_cmd cmd;
+       int status;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
+       if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
+               return -EFAULT;
+       if (cmd.flags)
+               return -EINVAL;
+
+       status = nvme_execute_passtru_cmd(ctrl, ns, cmd);
         if (status >= 0) {
                 if (put_user(cmd.result, &ucmd->result))
                         return -EFAULT;
--

  reply	other threads:[~2018-04-04 11:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30  6:57 [RFC PATCH 0/8] nvmet: implement target passthru commands support Chaitanya Kulkarni
2018-03-30  6:57 ` [RFC PATCH 1/8] nvme-core: add new interfaces Chaitanya Kulkarni
2018-03-30 17:48   ` Logan Gunthorpe
2018-04-02 23:25     ` Chaitanya Kulkarni
2018-04-04 11:52   ` Sagi Grimberg
2018-04-13 17:27     ` Christoph Hellwig
2018-03-30  6:57 ` [RFC PATCH 2/8] nvme-core: export existing ctrl and ns interfaces Chaitanya Kulkarni
2018-04-04 11:59   ` Sagi Grimberg [this message]
2018-03-30  6:57 ` [RFC PATCH 3/8] nvmet: add passthru members in target subsys Chaitanya Kulkarni
2018-03-30  6:57 ` [RFC PATCH 4/8] nvmet: use const values for id-ctrl Chaitanya Kulkarni
2018-03-30 18:50   ` Logan Gunthorpe
2018-04-02 23:27     ` Chaitanya Kulkarni
2018-04-13 17:28     ` Christoph Hellwig
2018-03-30  6:57 ` [RFC PATCH 5/8] nvmet: export nvmet_add_async_event api Chaitanya Kulkarni
2018-03-30  6:57 ` [RFC PATCH 6/8] nvmet: add target passthru command support Chaitanya Kulkarni
2018-03-30  6:57 ` [RFC PATCH 7/8] nvmet: integrate passthru code with target core Chaitanya Kulkarni
2018-03-30  6:57 ` [RFC PATCH 8/8] nvmet: add configfs interface for target passthru Chaitanya Kulkarni
2018-03-30 18:13   ` Logan Gunthorpe
2018-04-03  0:13     ` Chaitanya Kulkarni
2018-04-03  3:21       ` Logan Gunthorpe
2018-04-13 17:30     ` Christoph Hellwig
2018-04-13 17:37       ` Logan Gunthorpe
2018-04-13 21:50         ` Stephen  Bates
2018-03-30 17:46 ` [RFC PATCH 0/8] nvmet: implement target passthru commands support Logan Gunthorpe
2018-04-02 23:23   ` Chaitanya Kulkarni
2018-04-04 11:44 ` Sagi Grimberg
2018-04-13 17:35   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02e99d9a-7c33-c853-d2b4-c68fce493eac@grimberg.me \
    --to=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.