nvmet: clean up command parsing a bit
authorChristoph Hellwig <hch@lst.de>
Fri, 25 Oct 2019 13:38:58 +0000 (15:38 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 4 Nov 2019 17:56:42 +0000 (10:56 -0700)
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>
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/core.c

index cd2c3a79f3b5223f004b2a430f95e70ca77a3e68..56c21b5011852b15eaf899e625d5a15b251b14b3 100644 (file)
@@ -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;
index cde58c001b23a652739851a253b1ca399813af77..28438b833c1b0e97bea34b2436ed69e45a7043ba 100644 (file)
@@ -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);