Move the code that handles the checker_state == CHECKER_FINISHED state into a separate function for better readability. Subsequent patches will add code to this function. Replace the "&& reload_and_sync_map()" conditional by a subordinate if statement, as this expresses the logic of the code better. Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> --- multipathd/main.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 25aab09..988c82c 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2967,6 +2967,29 @@ update_paths(struct vectors *vecs, int *num_paths_p, time_t start_secs) return CHECKER_FINISHED; } +static void checker_finished(struct vectors *vecs, unsigned int ticks) +{ + struct multipath *mpp; + int i; + + vector_foreach_slot(vecs->mpvec, mpp, i) { + bool inconsistent; + + sync_mpp(vecs, mpp, ticks); + inconsistent = mpp->need_reload; + if (update_mpp_prio(mpp) || inconsistent) + if (reload_and_sync_map(mpp, vecs) == 2) { + /* multipath device deleted */ + i--; + continue; + } + /* need_reload was cleared in dm_addmap and then set again */ + if (inconsistent && mpp->need_reload) + condlog(1, "BUG: %s; map remained in inconsistent state after reload", + mpp->alias); + } +} + static void * checkerloop (void *ap) { @@ -3034,24 +3057,8 @@ checkerloop (void *ap) if (checker_state == CHECKER_UPDATING_PATHS) checker_state = update_paths(vecs, &num_paths, start_time.tv_sec); - if (checker_state == CHECKER_FINISHED) { - vector_foreach_slot(vecs->mpvec, mpp, i) { - bool inconsistent; - - sync_mpp(vecs, mpp, ticks); - inconsistent = mpp->need_reload; - if ((update_mpp_prio(mpp) || inconsistent) && - reload_and_sync_map(mpp, vecs) == 2) { - /* multipath device deleted */ - i--; - continue; - } - /* need_reload was cleared in dm_addmap and then set again */ - if (inconsistent && mpp->need_reload) - condlog(1, "BUG: %s; map remained in inconsistent state after reload", - mpp->alias); - } - } + if (checker_state == CHECKER_FINISHED) + checker_finished(vecs, ticks); lock_cleanup_pop(vecs->lock); } -- 2.47.1