nvme: introduce nvme_is_fabrics to check fabrics cmd
authorMinwoo Im <minwoo.im.dev@gmail.com>
Thu, 6 Jun 2019 05:30:14 +0000 (14:30 +0900)
committerChristoph Hellwig <hch@lst.de>
Fri, 21 Jun 2019 09:08:38 +0000 (11:08 +0200)
This patch introduces a nvme_is_fabrics() inline function to check
whether or not the given command structure is for fabrics.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fabrics.c
drivers/nvme/target/core.c
drivers/nvme/target/fabrics-cmd.c
drivers/nvme/target/fc.c
include/linux/nvme.h

index 5838f7cd53ac70d6ff73f9a5a58eec088d79ba57..1994d5b42f94c52eff12b528ac03ce44760753b5 100644 (file)
@@ -578,7 +578,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
        switch (ctrl->state) {
        case NVME_CTRL_NEW:
        case NVME_CTRL_CONNECTING:
-               if (req->cmd->common.opcode == nvme_fabrics_command &&
+               if (nvme_is_fabrics(req->cmd) &&
                    req->cmd->fabrics.fctype == nvme_fabrics_type_connect)
                        return true;
                break;
index 43e8c4adc1f4d09f8bdaef4ef607bfbd9f46510f..0587707b1a257b35c04a377b3ef7b23adf92a815 100644 (file)
@@ -873,7 +873,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
                status = nvmet_parse_connect_cmd(req);
        else if (likely(req->sq->qid != 0))
                status = nvmet_parse_io_cmd(req);
-       else if (req->cmd->common.opcode == nvme_fabrics_command)
+       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);
index 3b9f79aba98f8b719b21201fe46504b452775c69..d16b55ffe79f409e0506a2611f409993b0fd48e4 100644 (file)
@@ -268,7 +268,7 @@ u16 nvmet_parse_connect_cmd(struct nvmet_req *req)
 {
        struct nvme_command *cmd = req->cmd;
 
-       if (cmd->common.opcode != nvme_fabrics_command) {
+       if (!nvme_is_fabrics(cmd)) {
                pr_err("invalid command 0x%x on unconnected queue.\n",
                        cmd->fabrics.opcode);
                req->error_loc = offsetof(struct nvme_common_command, opcode);
index 1f252c9a953a1013d011cc36c21e2c89809c453b..ce8d819f86ccc58e296696c3ce76a38479b2b87e 100644 (file)
@@ -1806,7 +1806,7 @@ nvmet_fc_prep_fcp_rsp(struct nvmet_fc_tgtport *tgtport,
         */
        rspcnt = atomic_inc_return(&fod->queue->zrspcnt);
        if (!(rspcnt % fod->queue->ersp_ratio) ||
-           sqe->opcode == nvme_fabrics_command ||
+           nvme_is_fabrics((struct nvme_command *) sqe) ||
            xfr_length != fod->req.transfer_len ||
            (le16_to_cpu(cqe->status) & 0xFFFE) || cqewd[0] || cqewd[1] ||
            (sqe->flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND)) ||
index 8028adacaff351179ee2de1ce4c50e42c4f9d994..7080923e78d1ec1948f6879df1afd53b3b29ee44 100644 (file)
@@ -1165,6 +1165,11 @@ struct nvme_command {
        };
 };
 
+static inline bool nvme_is_fabrics(struct nvme_command *cmd)
+{
+       return cmd->common.opcode == nvme_fabrics_command;
+}
+
 struct nvme_error_slot {
        __le64          error_count;
        __le16          sqid;
@@ -1186,7 +1191,7 @@ static inline bool nvme_is_write(struct nvme_command *cmd)
         *
         * Why can't we simply have a Fabrics In and Fabrics out command?
         */
-       if (unlikely(cmd->common.opcode == nvme_fabrics_command))
+       if (unlikely(nvme_is_fabrics(cmd)))
                return cmd->fabrics.fctype & 1;
        return cmd->common.opcode & 1;
 }