Skip to content

Commit

Permalink
nvmet: clean up command parsing a bit
Browse files Browse the repository at this point in the history
Move the special cases for fabrics commands and the discovery controller
to nvmet_parse_admin_cmd in preparation for adding passthrough support.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Nov 4, 2019
1 parent 05d3046 commit d84dd8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions drivers/nvme/target/admin-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,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;
Expand Down
6 changes: 1 addition & 5 deletions drivers/nvme/target/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d84dd8c

Please sign in to comment.