The code needs to check that pp->pgindex equals pp->mpp->bestpg and that
they aren't both 0 (which is an invalid pathgroup id). Since we're
already checking that they are equal, we only need to check one of them
to see if it's non-zero. Instead of checking if pp->pgindex is non-zero
for every path, just check mpp->bestpg once for the multipath device and
return immediately if it's zero.

Signed-off-by: Benjamin Marzinski <bmarz...@redhat.com>
---
 multipathd/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 3cda3c18..75bc0620 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2002,7 +2002,7 @@ do_followover_should_failback(struct path * pp)
        struct path *pp1;
        int i;
 
-       if (!pp->pgindex || pp->pgindex != pp->mpp->bestpg)
+       if (pp->pgindex != pp->mpp->bestpg)
                return 0;
 
        pgp = VECTOR_SLOT(pp->mpp->pg, pp->pgindex - 1);
@@ -2022,7 +2022,7 @@ followover_should_failback(struct multipath *mpp)
        struct pathgroup * pgp;
        int i, j;
 
-       if (mpp->pgfailback != -FAILBACK_FOLLOWOVER || !mpp->pg)
+       if (mpp->pgfailback != -FAILBACK_FOLLOWOVER || !mpp->pg || !mpp->bestpg)
                return 0;
 
        vector_foreach_slot (mpp->pg, pgp, i) {
-- 
2.45.0


Reply via email to