Message ID | 20241211225909.298770-9-mwilck@suse.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | christophe varoqui |
Headers | show |
Series | multipathd: More map reload handling, and checkerloop work | expand |
On Wed, Dec 11, 2024 at 11:59:03PM +0100, Martin Wilck wrote: > Instead, move the call inside the existing loop over vecs->mpvec and call > reload_and_sync_map() from checker_finished(). Note that we can't simply > put the call deferred_failback_tick() in the "if" condition, because we > need to adjust the ticks even if update_mpp_prio() returns true. For > consistency, use separate bool variables for each condition that would > necessitate a reload. > > Signed-off-by: Martin Wilck <mwilck@suse.com> > --- > multipathd/main.c | 39 ++++++++++++++------------------------- > 1 file changed, 14 insertions(+), 25 deletions(-) > > diff --git a/multipathd/main.c b/multipathd/main.c > index b045f8b..b1f0f81 100644 > --- a/multipathd/main.c > +++ b/multipathd/main.c > @@ -2076,32 +2076,20 @@ ghost_delay_tick(struct vectors *vecs) > } > } > > -static void > -deferred_failback_tick (struct vectors *vecs) > +static bool deferred_failback_tick(struct multipath *mpp) > { > - struct multipath * mpp; > - int i; > bool need_reload; > > - vector_foreach_slot (vecs->mpvec, mpp, i) { > - /* > - * deferred failback getting sooner > - */ > - if (mpp->pgfailback > 0 && mpp->failback_tick > 0) { > - mpp->failback_tick--; > + if (mpp->pgfailback <= 0 || mpp->failback_tick <= 0) > + return false; > > - if (!mpp->failback_tick && > - need_switch_pathgroup(mpp, &need_reload)) { > - if (need_reload) { > - if (reload_and_sync_map(mpp, vecs) == 2) { > - /* multipath device removed */ > - i--; > - } > - } else > - switch_pathgroup(mpp); > - } > - } > - } > + mpp->failback_tick--; > + if (!mpp->failback_tick && > + need_switch_pathgroup(mpp, &need_reload) && > + need_reload) > + return true; > + else If (!mpp->failback_tick && need_switch_pathgroup(mpp, &need_reload) is true by need_reload isn't, don't we still need to call switch_pathgroup(mpp); -Ben > + return false; > } > > static void > @@ -2973,11 +2961,13 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) > int i; > > vector_foreach_slot(vecs->mpvec, mpp, i) { > - bool inconsistent; > + bool inconsistent, prio_reload, failback_reload; > > sync_mpp(vecs, mpp, ticks); > inconsistent = mpp->need_reload; > - if (update_mpp_prio(mpp) || inconsistent) > + prio_reload = update_mpp_prio(mpp); > + failback_reload = deferred_failback_tick(mpp); > + if (prio_reload || failback_reload || inconsistent) > if (reload_and_sync_map(mpp, vecs) == 2) { > /* multipath device deleted */ > i--; > @@ -2990,7 +2980,6 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) > if (inconsistent) > mpp->sync_tick = 1; > } > - deferred_failback_tick(vecs); > retry_count_tick(vecs->mpvec); > missing_uev_wait_tick(vecs); > ghost_delay_tick(vecs); > -- > 2.47.0
diff --git a/multipathd/main.c b/multipathd/main.c index b045f8b..b1f0f81 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2076,32 +2076,20 @@ ghost_delay_tick(struct vectors *vecs) } } -static void -deferred_failback_tick (struct vectors *vecs) +static bool deferred_failback_tick(struct multipath *mpp) { - struct multipath * mpp; - int i; bool need_reload; - vector_foreach_slot (vecs->mpvec, mpp, i) { - /* - * deferred failback getting sooner - */ - if (mpp->pgfailback > 0 && mpp->failback_tick > 0) { - mpp->failback_tick--; + if (mpp->pgfailback <= 0 || mpp->failback_tick <= 0) + return false; - if (!mpp->failback_tick && - need_switch_pathgroup(mpp, &need_reload)) { - if (need_reload) { - if (reload_and_sync_map(mpp, vecs) == 2) { - /* multipath device removed */ - i--; - } - } else - switch_pathgroup(mpp); - } - } - } + mpp->failback_tick--; + if (!mpp->failback_tick && + need_switch_pathgroup(mpp, &need_reload) && + need_reload) + return true; + else + return false; } static void @@ -2973,11 +2961,13 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) int i; vector_foreach_slot(vecs->mpvec, mpp, i) { - bool inconsistent; + bool inconsistent, prio_reload, failback_reload; sync_mpp(vecs, mpp, ticks); inconsistent = mpp->need_reload; - if (update_mpp_prio(mpp) || inconsistent) + prio_reload = update_mpp_prio(mpp); + failback_reload = deferred_failback_tick(mpp); + if (prio_reload || failback_reload || inconsistent) if (reload_and_sync_map(mpp, vecs) == 2) { /* multipath device deleted */ i--; @@ -2990,7 +2980,6 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) if (inconsistent) mpp->sync_tick = 1; } - deferred_failback_tick(vecs); retry_count_tick(vecs->mpvec); missing_uev_wait_tick(vecs); ghost_delay_tick(vecs);
Instead, move the call inside the existing loop over vecs->mpvec and call reload_and_sync_map() from checker_finished(). Note that we can't simply put the call deferred_failback_tick() in the "if" condition, because we need to adjust the ticks even if update_mpp_prio() returns true. For consistency, use separate bool variables for each condition that would necessitate a reload. Signed-off-by: Martin Wilck <mwilck@suse.com> --- multipathd/main.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-)