Add a helper to find if a request has flag REQ_NVME_MPATH set.

An advantage of this is that for !CONFIG_NVME_MULTIPATH, the code is
compiled out, so we avoid the check.

Signed-off-by: John Garry <[email protected]>
---
 drivers/nvme/host/core.c |  6 +++---
 drivers/nvme/host/nvme.h | 13 +++++++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 76249871dd7c2..2d0faec902eb2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -409,7 +409,7 @@ static inline enum nvme_disposition 
nvme_decide_disposition(struct request *req)
        if ((nvme_req(req)->status & NVME_SCT_SC_MASK) == NVME_SC_AUTH_REQUIRED)
                return AUTHENTICATE;
 
-       if (req->cmd_flags & REQ_NVME_MPATH) {
+       if (nvme_is_mpath_request(req)) {
                if (nvme_is_path_error(nvme_req(req)->status) ||
                    blk_queue_dying(req->q))
                        return FAILOVER;
@@ -442,7 +442,7 @@ static inline void __nvme_end_req(struct request *req)
        }
        nvme_end_req_zoned(req);
        nvme_trace_bio_complete(req);
-       if (req->cmd_flags & REQ_NVME_MPATH)
+       if (nvme_is_mpath_request(req))
                nvme_mpath_end_request(req);
 }
 
@@ -762,7 +762,7 @@ blk_status_t nvme_fail_nonready_command(struct nvme_ctrl 
*ctrl,
            state != NVME_CTRL_DELETING &&
            state != NVME_CTRL_DEAD &&
            !test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags) &&
-           !blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH))
+           !blk_noretry_request(rq) && !nvme_is_mpath_request(rq))
                return BLK_STS_RESOURCE;
 
        if (!(rq->rq_flags & RQF_DONTPREP))
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 397e8685f6c38..6b5977610d886 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1042,11 +1042,16 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
 void nvme_mpath_start_request(struct request *rq);
 void nvme_mpath_end_request(struct request *rq);
 
+static inline bool nvme_is_mpath_request(struct request *req)
+{
+       return req->cmd_flags & REQ_NVME_MPATH;
+}
+
 static inline void nvme_trace_bio_complete(struct request *req)
 {
        struct nvme_ns *ns = req->q->queuedata;
 
-       if ((req->cmd_flags & REQ_NVME_MPATH) && req->bio)
+       if (nvme_is_mpath_request(req) && req->bio)
                trace_block_bio_complete(ns->head->disk->queue, req->bio);
 }
 
@@ -1145,6 +1150,10 @@ static inline void nvme_mpath_start_freeze(struct 
nvme_subsystem *subsys)
 static inline void nvme_mpath_default_iopolicy(struct nvme_subsystem *subsys)
 {
 }
+static inline bool nvme_is_mpath_request(struct request *req)
+{
+       return false;
+}
 static inline void nvme_mpath_start_request(struct request *rq)
 {
 }
@@ -1213,7 +1222,7 @@ static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
 
 static inline void nvme_start_request(struct request *rq)
 {
-       if (rq->cmd_flags & REQ_NVME_MPATH)
+       if (nvme_is_mpath_request(rq))
                nvme_mpath_start_request(rq);
        blk_mq_start_request(rq);
 }
-- 
2.43.5


Reply via email to