multipathd: More map reload handling, and checkerloop work
v4 cover multipathd: More map reload handling, and checkerloop work
This patch set goes on top of Ben's set [1] for github issue 105 [2].
Re-posting only 15/15 for v4.
Changes v3 -> v4 (all based on the review by Ben Marzinski):
15/15: add checks for pp->is_checked to avoid re-enabling path groups prematurely.
Changes v2 -> v3 (all based on the review by Ben Marzinski):
03/15: See 15/15 below
04/15: replaced the previous patch, which decreased the checker interval to
1 if the map was still inconsistent after reloading, by a warning. It's unlikely that this condition will ever occur, but if it does, we want to know.
08/15: Re-added the call to switch_pathgroups which had been mistakenly deleted. 15/15: New, compensate the fact that it is now more likely to miss the
call to enable_group() in update_path_state().
Changes v1 -> v2:
Removed patch 3 and 4 of v1 and replaced them by an alternative approach. Instead of allowing map and path removal in the checker loop, the kernel sync is moved towards the end.
Patch 5 ff. in v1 contained a bug in the new checker_finished() function. If one "tick" function returned true, the other might not be executed any more. In v2, all tick functions are executed, and the action to be taken is selected according to the combined results. Also, we won't call reload_and_sync_map() when we've already called update_map().
Patch 13 is new in v2. Patch 8 from v1 has been moved after patch 13.
(In the thread following the review of v1, I mistakenly wrote about an upcoming "v4" of this patch set. That was wrong, I meant this v2 here).
Cover letter of v1:
The first patch implements the remark I had on patch 2 on Ben's set, the 2nd is a minor cleanup.
Patch 3 moves the sync_mpp() call from the beginning to the end of the checkerloop, as suggested by Ben in [3]. If an inconsitency is found (mpp->need_reload), we reload the map and schedule another sync for the next tick (patch 4).
Patch 5 ff. reshuffle the code in checkerloop(). There is now one function, checker_finished(), that takes all actions that need to be done with the vecs lock taken after the checkers have finished. checkerloop() enters this function immediately when the checkers have finished, without dropping and re-acquiring the vecs lock. The map reload logic is completely handled in this function.
The various _tick() functions don't loop over mpvec any more; they are now just called for a single mpp, and they simply return true if a map reload is required. The actual reload action differs: if missing_uev_wait_tick() requests a reload, it needs to be a full update_map() (which calls adopt_paths()), whereas in the other cases, reload_and_sync_map() is sufficient. Patch 12 changes the reload action for the ghost delay tick.
Patch 13 removes maps if that are not found in the kernel any more. This obsoletes the map garbage collector. Unlike the logic in v1, we won't remove maps on arbitrary error conditions any more.
Reviews & comments welcome.
Regards
Martin
[1] https://lore.kernel.org/dm-devel/[email protected]/
[2] https://github.com/opensvc/multipath-tools/issues/105
[3] https://lore.kernel.org/dm-devel/[email protected]/
Martin Wilck (15):
multipathd: don't reload map in update_mpp_prio()
multipathd: remove dm_get_info() call from refresh_multipath()
multipathd: sync maps at end of checkerloop
multipathd: emit a warning if a map remains inconsistent after reload
multipathd: move yielding for waiters to start of checkerloop
multipathd: add checker_finished()
multipathd: move "tick" calls into checker_finished()
multipathd: don't call reload_and_sync_map() from
deferred_failback_tick()
multipathd: move retry_count_tick() into existing mpvec loop
multipathd: don't call update_map() from missing_uev_wait_tick()
multipathd: don't call udpate_map() from ghost_delay_tick()
multipathd: only call reload_and_sync_map() when ghost delay expires
multipathd: remove non-existent maps in checkerloop
multipathd: remove mpvec_garbage_collector()
multipathd: enable pathgroups in checker_finished()
libmultipath/structs.h | 2 +- libmultipath/structs_vec.c | 1 - multipathd/main.c | 319 +++++++++++++++++-------------------- 3 files changed, 151 insertions(+), 171 deletions(-)
Signature · 1 line
2.48.0
PATCH v4 15/15 multipathd: enable pathgroups in checker_finished()
multipathd calls enable_group() from update_path_state() if a path in a previously disabled pathgroup is reinstated. This call may be mistakenly skipped if the path group status wasn't up-to-date while update_path_state() was executed. This can happen after applying the previous patch "multipathd:
sync maps at end of checkerloop", if the kernel has disabled the group during the last checker interval.
Therefore add another check in checker_finished() after calling sync_mpp(), and enable groups if necessary. This step can be skipped if the map was reloaded, because after a reload, all pathgroups are enabled by default.
--- multipathd/main.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
multipathd/main.c +35 -1
@@ -2917,6 +2917,36 @@ update_paths(struct vectors *vecs, int *num_paths_p, time_t start_secs)return CHECKER_FINISHED ; } +static void enable_pathgroups (struct multipath *mpp) +{ +struct pathgroup *pgp; +int i; + + vector_foreach_slot(mpp->pg, pgp, i) { +struct path *pp; +int j; + +if (pgp->status !=PGSTATE_DISABLED ) +continue ; + + vector_foreach_slot(pgp->paths, pp, j) { +if (!(pp->state ==PATH_UP && + (pp->is_checked ==CHECK_PATH_CHECKED || + pp->is_checked ==CHECK_PATH_NEW_UP ))) +continue ; + +if (dm_enablegroup (mpp->alias, i +1 ) ==0 ) { +condlog (2 ,"%s: enabled pathgroup #%i" , + mpp->alias, i +1 ); + pgp->status =PGSTATE_ENABLED ; + }else +condlog (2 ,"%s: failed to enable pathgroup #%i" , + mpp->alias, i +1 ); +break ; + } + } +} +static void checker_finished (struct vectors *vecs,unsigned int ticks) {struct multipath *mpp;
@@ -2943,12 +2973,16 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) i--;continue ; } - }else if (prio_reload || failback_reload || ghost_reload || inconsistent) + }else if (prio_reload || failback_reload || ghost_reload || inconsistent) {if (reload_and_sync_map (mpp, vecs) ==2 ) {/* multipath device deleted */ i--;continue ; } + }else +/* not necessary after map reloads */ +enable_pathgroups (mpp); +/* 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",
Signature · 1 line
2.48.0
Re: [PATCH v4 15/15] multipathd: enable pathgroups in checker_finished()
Quoted 7 lines · Martin Wilck
multipathd calls
enable_group()fromupdate_path_state()if a path in a previously disabled pathgroup is reinstated. This call may be mistakenly skipped if the path group status wasn't up-to-date whileupdate_path_state()was executed. This can happen after applying the previous patch "multipathd:
sync maps at end of checkerloop", if the kernel has disabled the group during the last checker interval.
Quoted 5 lines
Therefore add another check in
checker_finished()after callingsync_mpp(), and enable groups if necessary. This step can be skipped if the map was reloaded, because after a reload, all pathgroups are enabled by default.Signed-off-by Martin Wilck <[email protected]>
Quoted 65 lines
--- multipathd/main.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)multipathd/main.c +35
-1@@ -2917,6 +2917,36 @@ update_paths(struct vectors *vecs, int *num_paths_p, time_t start_secs)return CHECKER_FINISHED ; } +static void enable_pathgroups (struct multipath *mpp) +{ +struct pathgroup *pgp; +int i; + + vector_foreach_slot(mpp->pg, pgp, i) { +struct path *pp; +int j; + +if (pgp->status !=PGSTATE_DISABLED ) +continue ; + + vector_foreach_slot(pgp->paths, pp, j) { +if (!(pp->state ==PATH_UP && + (pp->is_checked ==CHECK_PATH_CHECKED || + pp->is_checked ==CHECK_PATH_NEW_UP ))) +continue ; + +if (dm_enablegroup (mpp->alias, i +1 ) ==0 ) { +condlog (2 ,"%s: enabled pathgroup #%i" , + mpp->alias, i +1 ); + pgp->status =PGSTATE_ENABLED ; + }else +condlog (2 ,"%s: failed to enable pathgroup #%i" , + mpp->alias, i +1 ); +break ; + } + } +} +static void checker_finished (struct vectors *vecs,unsigned int ticks) {struct multipath *mpp;@@ -2943,12 +2973,16 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks) i--;continue ; } - }else if (prio_reload || failback_reload || ghost_reload || inconsistent) + }else if (prio_reload || failback_reload || ghost_reload || inconsistent) {if (reload_and_sync_map (mpp, vecs) ==2 ) {/* multipath device deleted */ i--;continue ; } + }else +/* not necessary after map reloads */ +enable_pathgroups (mpp); +/* 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",Signature · 1 line
2.48.0