linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet: Cleanup nvmet_req_init() branching
@ 2019-10-25 19:37 Logan Gunthorpe
  2019-10-25 23:58 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Logan Gunthorpe @ 2019-10-25 19:37 UTC (permalink / raw)
  To: linux-kernel, linux-nvme, Christoph Hellwig
  Cc: Logan Gunthorpe, Sagi Grimberg, Stephen Bates

Instead of checking for fabrics and discovery commands in
a long and growing if else tree, parse these commands inside
nvmet_parse_admin_cmd(). These commands are all submitted on
the admin queue (qid=0) so it makes sense that they be grouped
together.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---

This is a prep patch for the nvmet passthru patch set. It was part
of Christoph's feedback.

 drivers/nvme/target/admin-cmd.c | 5 +++++
 drivers/nvme/target/core.c      | 6 +-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 831a062d27cb..d446e6e45bcb 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -813,6 +813,11 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 	struct nvme_command *cmd = req->cmd;
 	u16 ret;

+	if (nvme_is_fabrics(cmd))
+		return nvmet_parse_fabrics_cmd(req);
+	if (req->sq->ctrl->subsys->type == NVME_NQN_DISC)
+		return nvmet_parse_discovery_cmd(req);
+
 	ret = nvmet_check_ctrl_status(req, cmd);
 	if (unlikely(ret))
 		return ret;
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 3a67e244e568..54668da82db9 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -892,14 +892,10 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
 	}

 	if (unlikely(!req->sq->ctrl))
-		/* will return an error for any Non-connect command: */
+		/* will return an error for any non-connect command: */
 		status = nvmet_parse_connect_cmd(req);
 	else if (likely(req->sq->qid != 0))
 		status = nvmet_parse_io_cmd(req);
-	else if (nvme_is_fabrics(req->cmd))
-		status = nvmet_parse_fabrics_cmd(req);
-	else if (req->sq->ctrl->subsys->type == NVME_NQN_DISC)
-		status = nvmet_parse_discovery_cmd(req);
 	else
 		status = nvmet_parse_admin_cmd(req);

--
2.20.1

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nvmet: Cleanup nvmet_req_init() branching
  2019-10-25 19:37 [PATCH] nvmet: Cleanup nvmet_req_init() branching Logan Gunthorpe
@ 2019-10-25 23:58 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2019-10-25 23:58 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: Sagi Grimberg, Stephen Bates, linux-kernel, linux-nvme,
	Christoph Hellwig

On Fri, Oct 25, 2019 at 01:37:39PM -0600, Logan Gunthorpe wrote:
> This is a prep patch for the nvmet passthru patch set. It was part
> of Christoph's feedback.

Looks like he sent the same patch just ahead of this one.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-25 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 19:37 [PATCH] nvmet: Cleanup nvmet_req_init() branching Logan Gunthorpe
2019-10-25 23:58 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).