update_pathvec_from_dm() may set mpp->need_reload if it finds inconsistent
settings. In this case, the map should be reloaded, but so far we don't
do this reliably. A previous patch added a call to reload_and_sync_map()
in the CHECKER_FINISHED state, but in the mean time the checker may have
waited for checker threads to finish, and may have dropped and re-acquired the
vecs lock. As mpp->need_reload is a serious but rare condition, also try
to fix it early in the checker loop. Because of the previous patch, we
can call reload_and_sync_map() here.

Fixes: https://github.com/opensvc/multipath-tools/issues/105
Signed-off-by: Martin Wilck <mwi...@suse.com>
---
 multipathd/main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 131dab6..18083c7 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2450,12 +2450,25 @@ get_new_state(struct path *pp)
 static int
 do_sync_mpp(struct vectors *vecs, struct multipath *mpp)
 {
-       int ret;
+       const int MAX_RETRIES = 1;
+       int ret, retry = 0;
 
+try_again:
        ret = refresh_multipath(vecs, mpp);
        if (ret)
                return ret;
 
+       else if (mpp->need_reload) {
+               if (retry++ < MAX_RETRIES) {
+                       condlog(2, "%s: %s needs reload", __func__, mpp->alias);
+                       if (reload_and_sync_map(mpp, vecs) == 2)
+                               /* map removed */
+                               return 1;
+                       goto try_again;
+               } else
+                       condlog(1, "%s: %s still needs reload after %d retries",
+                               __func__, mpp->alias, retry);
+       }
        set_no_path_retry(mpp);
        return 0;
 }
-- 
2.47.0


Reply via email to