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 | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index be542f6..0823484 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2967,6 +2967,31 @@ 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; + } + /* + * If we reloaded due to inconsistent state, + * schedule another sync at the next tick. + */ + if (inconsistent) + mpp->sync_tick = 1; + } +} + static void * checkerloop (void *ap) { @@ -3034,26 +3059,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; - } - /* - * If we reloaded due to inconsistent state, - * schedule another sync at the next tick. - */ - if (inconsistent) - mpp->sync_tick = 1; - } - } + if (checker_state == CHECKER_FINISHED) + checker_finished(vecs, ticks); lock_cleanup_pop(vecs->lock); } -- 2.47.0