]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nvme: multipath: round-robin: fix single non-optimized path case
authorMartin Wilck <mwilck@suse.com>
Thu, 6 Aug 2020 13:19:31 +0000 (15:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:26:55 +0000 (11:26 +0200)
[ Upstream commit 93eb0381e13d249a18ed4aae203291ff977e7ffb ]

If there's only one usable, non-optimized path, nvme_round_robin_path()
returns NULL, which is wrong. Fix it by falling back to "old", like in
the single optimized path case. Also, if the active path isn't changed,
there's no need to re-assign the pointer.

Fixes: 3f6e3246db0e ("nvme-multipath: fix logic for non-optimized paths")
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin George <marting@netapp.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/multipath.c

index 484aad0d0c9c6c6110ee8132a74e5b93ad3dd130..0a458f7880887106e2fc0968ae20380cf6757e76 100644 (file)
@@ -249,12 +249,17 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
                        fallback = ns;
        }
 
-       /* No optimized path found, re-check the current path */
+       /*
+        * The loop above skips the current path for round-robin semantics.
+        * Fall back to the current path if either:
+        *  - no other optimized path found and current is optimized,
+        *  - no other usable path found and current is usable.
+        */
        if (!nvme_path_is_disabled(old) &&
-           old->ana_state == NVME_ANA_OPTIMIZED) {
-               found = old;
-               goto out;
-       }
+           (old->ana_state == NVME_ANA_OPTIMIZED ||
+            (!fallback && old->ana_state == NVME_ANA_NONOPTIMIZED)))
+               return old;
+
        if (!fallback)
                return NULL;
        found = fallback;