From: Mike Snitzer <snit...@redhat.com>

nvme: allow local retry and proper failover for REQ_FAILFAST_TRANSPORT

BZ: 1948690
Upstream Status: RHEL-only

This commit offers a more minimalist version of these 2 rhel-8.git commits:
f8fb6ea1226e2 [nvme] nvme: update failover handling to work with 
REQ_FAILFAST_TRANSPORT
7dadadb072515 [nvme] nvme: allow retry for requests with REQ_FAILFAST_TRANSPORT 
set

REQ_FAILFAST_TRANSPORT is set by upper layer software that handles
multipathing. Unlike SCSI, NVMe's error handling was specifically
designed to handle local retry for non-path errors. As such, allow
NVMe's local retry mechanism to be used for requests marked with
REQ_FAILFAST_TRANSPORT.

In this way, the mechanism of NVMe multipath or other multipath are
now equivalent. The mechanism is: non path related error will be
retried locally, path related error is handled by multipath.

Also, introduce FAILUP handling for REQ_FAILFAST_TRANSPORT. Update
NVMe to allow failover of requests marked with either REQ_NVME_MPATH
or REQ_FAILFAST_TRANSPORT. This allows such requests to be given a
disposition of either FAILOVER or FAILUP respectively.

nvme_complete_rq() is updated to call nvme_failup_req() if
nvme_decide_disposition() returns FAILUP. nvme_failup_req() ensures
the request is completed with a retryable path error.

Signed-off-by: Mike Snitzer <snit...@redhat.com>

diff a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -299,6 +299,7 @@ enum nvme_disposition {
        COMPLETE,
        RETRY,
        FAILOVER,
+       FAILUP,
 };
 
 static inline enum nvme_disposition nvme_decide_disposition(struct request 
*req)
@@ -306,15 +307,16 @@ static inline enum nvme_disposition 
nvme_decide_disposition(struct request *req)
        if (likely(nvme_req(req)->status == 0))
                return COMPLETE;
 
-       if (blk_noretry_request(req) ||
+       if ((req->cmd_flags & (REQ_FAILFAST_DEV | REQ_FAILFAST_DRIVER)) ||
            (nvme_req(req)->status & NVME_SC_DNR) ||
            nvme_req(req)->retries >= nvme_max_retries)
                return COMPLETE;
 
-       if (req->cmd_flags & REQ_NVME_MPATH) {
+       if (req->cmd_flags & (REQ_NVME_MPATH | REQ_FAILFAST_TRANSPORT)) {
                if (nvme_is_path_error(nvme_req(req)->status) ||
                    blk_queue_dying(req->q))
-                       return FAILOVER;
+                       return (req->cmd_flags & REQ_NVME_MPATH) ?
+                               FAILOVER : FAILUP;
        } else {
                if (blk_queue_dying(req->q))
                        return COMPLETE;
@@ -336,6 +338,12 @@ static inline void nvme_end_req(struct request *req)
        blk_mq_end_request(req, status);
 }
 
+static inline void nvme_failup_req(struct request *req)
+{
+       nvme_req(req)->status = NVME_SC_HOST_PATH_ERROR;
+       nvme_end_req(req);
+}
+
 void nvme_complete_rq(struct request *req)
 {
        trace_nvme_complete_rq(req);
@@ -354,6 +362,9 @@ void nvme_complete_rq(struct request *req)
        case FAILOVER:
                nvme_failover_req(req);
                return;
+       case FAILUP:
+               nvme_failup_req(req);
+               return;
        }
 }
 EXPORT_SYMBOL_GPL(nvme_complete_rq);

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1024
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to