path checker refactor and misc fixes
Benjamin Marzinski
maintainercover path checker refactor and misc fixes
This patchset is based on discussions I had with Martin Wilck about my last, partially applied patchset. It's based on top of his mwilck-tip branch, 6a312b6c "GitHub workflows: native.yml: run root tests". These patches are mostly orthogonal to the libmp_mapinfo() work. I'll rebase them if further changes to that patchset stop them form applying cleanly.
The first two patches are reposts of patches from my earlier patchset, redone to work with the new libmp_mapinfo() API. They make it possible to add maps by WWID with "multipathd add map".
The rest of the patches are work and bugfixes related to refactoring checkerloop so that
1. multipath devices get resynced with the kernel occasionally, even if they have not paths
2. If multiple paths from a multipath device are checked in the same loop, the multipath device will only get resynced once.
3. All the paths of a multipath device will converge to being checked at the same time (at least as much as their differing checkint values will allow).
4. The times for checking the paths of each multipath device will spread out as much as possible so multipathd doesn't do all of it's checking in a burst.
5. path checking is done my multipath device (for initialized paths, the uninitialized paths are handled after all the adopted paths are handled).
Items 1 & 2 are handled by patch 12 and preceding patches.
Items 3 & 4 and handled by patch 19 and preceding patches.
Item 5 is handled by patch 20 and 21.
Benjamin Marzinski (22):
libmultipath: rename dm_map_present_by_wwid() and add outputs
multipathd: make cli_add_map() handle adding maps by WWID correctly
multipathd: remove checker restart optimization
multipathd: refactor path state getting code into a helper
multipathd: handle uninitialized paths in new function
multipathd: make check_path() static
multipathd: remove redundant checks in handle_uninitialized_path()
multipathd: check paths immediately after failing udev initialization
multipathd: set pp->tick = max_checkint in handle_uninitialized_path
multipathd: return 0 from path_check() if that path wasn't checked
multipathd: reorder path state checks
multipathd: adjust when mpp is synced with the kernel
multipathd: resync map after setup_map in ev_remove_path
multipathd: resync map after setup_map in resize_map
multipathd: always resync map in reload_and_sync_map
multipathd: correctly handle paths removed for a wwid change
multipathd: handle changed wwid when adding partial path
multipathd: don't read conf->checkint twice in check_path
multipathd: make multipath devices manage their path check times
multipathd: factor out actual path checking loop from checkerloop
multipathd: check paths in order by mpp
multipathd: clean up the correct wwid in check_path_wwid_change
libmultipath/config.c | 13 + libmultipath/config.h | 1 + libmultipath/configure.c | 1 + libmultipath/devmapper.c | 16 +- libmultipath/devmapper.h | 2 +- libmultipath/libmultipath.version | 5 + libmultipath/structs.c | 1 + libmultipath/structs.h | 3 + libmultipath/structs_vec.c | 6 + libmultipath/valid.c | 2 +- multipathd/cli_handlers.c | 65 ++-- multipathd/main.c | 571 +++++++++++++++++++----------- multipathd/main.h | 2 +- tests/valid.c | 12 +- 14 files changed, 431 insertions(+), 269 deletions(-)
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 1/22 libmultipath: rename dm_map_present_by_wwid() and add outputs
add arguments to dm_map_present_by_wwid() to allow optionally fetching the device name and minor number for the devices found by WWID. These will be used by a later patch. Since it can now also be used to get the name and minor number of a device from its WWID, rename it to dm_find_map_by_wwid()
--- libmultipath/devmapper.c | 16 ++++++++++++---- libmultipath/devmapper.h | 2 +- libmultipath/valid.c | 2 +- tests/valid.c | 12 ++++++------ 4 files changed, 20 insertions(+), 12 deletions(-)
libmultipath/devmapper.c +12 -4
@@ -872,16 +872,24 @@ int dm_is_mpath(const char *name) } } -int dm_map_present_by_wwid (const char *wwid) +/* if name is non-NULL, it must point to an array of WWID_SIZE bytes */ +int dm_find_map_by_wwid (const char *wwid,char *name,int *minor) {char tmp[DM_UUID_LEN ]; +struct dm_info dmi; +int rc;if (safe_sprintf (tmp,UUID_PREFIX "%s" , wwid))return DMP_ERR ; -return libmp_mapinfo (DM_MAP_BY_UUID , - (mapid_t ) { .str = tmp }, - (mapinfo_t ) { .name =NULL }); + rc =libmp_mapinfo (DM_MAP_BY_UUID , + (mapid_t ) { .str = tmp }, + (mapinfo_t ) { .name = name, + .dmi = minor ? &dmi :NULL }); +if (rc ==DMP_OK && minor) + *minor = dmi.minor; + +return rc; }static int dm_dev_t (const char *mapname,char *dev_t,int len)
libmultipath/devmapper.h +1 -1
@@ -132,7 +132,7 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags);int dm_simplecmd_noflush (int task,const char *name,uint16_t udev_flags);int dm_addmap_create (struct multipath *mpp,char *params);int dm_addmap_reload (struct multipath *mpp,char *params,int flush); -int dm_map_present_by_wwid (const char *uuid); +int dm_find_map_by_wwid (const char *wwid,char *name,int *minor);enum {DM_IS_MPATH_NO ,
libmultipath/valid.c +1 -1
@@ -360,7 +360,7 @@ is_path_valid(const char *name, struct config *conf, struct path *pp,if (check_wwids_file (pp->wwid,0 ) ==0 )return PATH_IS_VALID_NO_CHECK ; -if (dm_map_present_by_wwid (pp->wwid) ==DMP_OK ) +if (dm_find_map_by_wwid (pp->wwid,NULL ,NULL ) ==DMP_OK )return PATH_IS_VALID ;/* all these act like FIND_MULTIPATHS_STRICT for finding if a
tests/valid.c +6 -6
@@ -189,10 +189,10 @@ int __wrap_check_wwids_file(char *wwid, int write_wwid)return -1 ; } -int __wrap_dm_map_present_by_wwid (const char *uuid) +int __wrap_dm_find_map_by_wwid (const char *wwid,char *name,int *minor) {int ret =mock_type (int); - assert_string_equal(uuid, mock_ptr_type(char *)); + assert_string_equal(wwid, mock_ptr_type(char *));return ret; }
@@ -271,8 +271,8 @@ static void setup_passing(char *name, char *wwid, unsigned int check_multipathd,will_return (__wrap_check_wwids_file, wwid);if (stage ==STAGE_CHECK_WWIDS )return ; -will_return (__wrap_dm_map_present_by_wwid,0 ); -will_return (__wrap_dm_map_present_by_wwid, wwid); +will_return (__wrap_dm_find_map_by_wwid,0 ); +will_return (__wrap_dm_find_map_by_wwid, wwid); }static void test_bad_arguments (void **state)
@@ -516,8 +516,8 @@ static void test_check_uuid_present(void **state)memset (&pp,0 ,sizeof (pp)); conf.find_multipaths =FIND_MULTIPATHS_STRICT ;setup_passing (name, wwid,CHECK_MPATHD_RUNNING ,STAGE_CHECK_WWIDS ); -will_return (__wrap_dm_map_present_by_wwid,1 ); -will_return (__wrap_dm_map_present_by_wwid, wwid); +will_return (__wrap_dm_find_map_by_wwid,1 ); +will_return (__wrap_dm_find_map_by_wwid, wwid);assert_int_equal (is_path_valid (name, &conf, &pp, true),PATH_IS_VALID );assert_string_equal (pp.dev, name);
Signature · 1 line
2.45.0
Re: [PATCH 01/22] libmultipath: rename dm_map_present_by_wwid() and add outputs
Hi Ben,
Quoted 10 lines · Benjamin Marzinski
add arguments to
dm_map_present_by_wwid()to allow optionally fetching
the device name and minor number for the devices found by WWID. These
will be used by a later patch. Since it can now also be used to get the
name and minor number of a device from its WWID, rename it todm_find_map_by_wwid()Signed-off-by Benjamin Marzinski <[email protected]>
Is this supposed to apply over my v1 patchseries? That patch series needed major amends, and I'm getting merge conflicts trying to apply it on v2. I can untangle that, but it'd be easier to figure out if we'd setted on a final reviewed version of my patch set.
Regards
Martin
Re: [PATCH 01/22] libmultipath: rename dm_map_present_by_wwid() and add outputs
Quoted 12 lines · Martin Wilck
Hi Ben,
Quoted 9 lines · Benjamin Marzinski
add arguments to
dm_map_present_by_wwid()to allow optionally fetching
the device name and minor number for the devices found by WWID. These
will be used by a later patch. Since it can now also be used to get the
name and minor number of a device from its WWID, rename it todm_find_map_by_wwid()
Quoted 7 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Is this supposed to apply over my v1 patchseries? That patch series needed major amends, and I'm getting merge conflicts trying to apply it
on v2. I can untangle that, but it'd be easier to figure out if we'd setted on a final reviewed version of my patch set.
Never mind, my email filter seems to have swallowed part of the series. The full series applies cleanly to my v2 tree.
Martin
Re: [PATCH 01/22] libmultipath: rename dm_map_present_by_wwid() and add outputs
In reply to Benjamin MarzinskiQuoted 29 lines · Benjamin Marzinski
add arguments to
dm_map_present_by_wwid()to allow optionally fetching
the device name and minor number for the devices found by WWID. These
will be used by a later patch. Since it can now also be used to get the
name and minor number of a device from its WWID, rename it todm_find_map_by_wwid()Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/devmapper.c | 16 ++++++++++++----
libmultipath/devmapper.h | 2 +-
libmultipath/valid.c | 2 +-
tests/valid.c | 12 ++++++------4 files changed, 20 insertions(+), 12 deletions(-)libmultipath/devmapper.h +0
-0@@ -132,7 +132,7 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags);int
dm_simplecmd_noflush(int task, const char *name,uint16_tudev_flags);
intdm_addmap_create(struct multipath *mpp, char *params); intdm_addmap_reload(struct multipath *mpp, char *params, int flush);
libmultipath/devmapper.h int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags); · line 135
Quoted 2 lines
libmultipath/devmapper.h +1
-1-int dm_map_present_by_wwid (const char *uuid); +int dm_find_map_by_wwid (const char *wwid,char *name,int *minor);
Nitpick: According to my personal taste, it would be cleaner to pass in the entire dm_info structure rather than just the minor number. One day we may need other fields as well.
Martin
Benjamin Marzinski
maintainerRe: [PATCH 01/22] libmultipath: rename dm_map_present_by_wwid() and add outputs
Quoted 28 lines · Martin Wilck
Quoted 27 lines · Benjamin Marzinski
add arguments to
dm_map_present_by_wwid()to allow optionally fetching
the device name and minor number for the devices found by WWID. These
will be used by a later patch. Since it can now also be used to get the
name and minor number of a device from its WWID, rename it todm_find_map_by_wwid()Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/devmapper.c | 16 ++++++++++++----
libmultipath/devmapper.h | 2 +-
libmultipath/valid.c | 2 +-
tests/valid.c | 12 ++++++------4 files changed, 20 insertions(+), 12 deletions(-)libmultipath/devmapper.h +0
-0@@ -132,7 +132,7 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags);int
dm_simplecmd_noflush(int task, const char *name,uint16_tudev_flags);
intdm_addmap_create(struct multipath *mpp, char *params); intdm_addmap_reload(struct multipath *mpp, char *params, int
Quoted 8 lines
libmultipath/devmapper.h int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags); · line 135
Quoted 4 lines
flush);
libmultipath/devmapper.h +1
-1-int dm_map_present_by_wwid (const char *uuid); +int dm_find_map_by_wwid (const char *wwid,char *name,int *minor);Nitpick: According to my personal taste, it would be cleaner to pass in the entire
dm_infostructure rather than just the minor number. One day we may need other fields as well.
Sure.
Quoted 2 lines
Martin
Benjamin Marzinski
maintainerPATCH 2/22 multipathd: make cli_add_map() handle adding maps by WWID correctly
In reply to Benjamin Marzinskicli_add_map() runs filter_wwid() on the input param as if it were a WWID, but dm_get_major_minor() will never find the multipath device if the user actually passes in a WWID. To handle this case, call get_refwwid() early in the function, and use dm_find_map_by_wwid() to check if the map exists, and find its alias and minor number.
Also, the do/while loop is unnecessarily confusing and only avoids one repeated function call. Remove it to simplify cli_add_map().
--- libmultipath/libmultipath.version | 5 +++ multipathd/cli_handlers.c | 59 ++++++++++--------------------- 2 files changed, 24 insertions(+), 40 deletions(-)
libmultipath/libmultipath.version +5 -0
@@ -242,3 +242,8 @@ global: local: *; }; + +LIBMULTIPATH_25.1.0 { +global: + dm_find_map_by_wwid; +} LIBMULTIPATH_25.0.0;
multipathd/cli_handlers.c +19 -40
76 lines not on this page · raw message
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 3/22 multipathd: remove checker restart optimization
In reply to Benjamin MarzinskiFuture commits will make this optimization unusable.
--- multipathd/main.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
multipathd/main.c +5 -22
@@ -2704,7 +2704,7 @@ checkerloop (void *ap)while (1 ) {struct timespec diff_time, start_time, end_time; -int num_paths =0 , strict_timing, rc =0 , i =0 ; +int num_paths =0 , strict_timing, rc =0 ;unsigned int ticks =0 ;enum checker_state checker_state =CHECKER_STARTING ;
@@ -2723,7 +2723,7 @@ checkerloop (void *ap)sd_notify (0 ,"WATCHDOG=1" );#endif while (checker_state !=CHECKER_FINISHED ) { -unsigned int paths_checked =0 ; +unsigned int paths_checked =0 , i;struct timespec chk_start_time;pthread_cleanup_push (cleanup_lock, &vecs->lock);
@@ -2733,28 +2733,11 @@ checkerloop (void *ap)if (checker_state ==CHECKER_STARTING ) {vector_foreach_slot (vecs->pathvec, pp, i) pp->is_checked = false; - i =0 ; checker_state =CHECKER_RUNNING ; - }else { -/* -* Paths could have been removed since we -* dropped the lock. Find the path to continue -* checking at. Since paths can be removed from -* anywhere in the vector, but can only be added -* at the end, the last checked path must be -* between its old location, and the start or -* the vector. -*/ -if (i >=VECTOR_SIZE (vecs->pathvec)) - i =VECTOR_SIZE (vecs->pathvec) -1 ; -while ((pp =VECTOR_SLOT (vecs->pathvec, i))) { -if (pp->is_checked == true) -break ; - i--; - } - i++; } - vector_foreach_slot_after (vecs->pathvec, pp, i) { + vector_foreach_slot(vecs->pathvec, pp, i) { +if (pp->is_checked) +continue ; pp->is_checked = true; rc =check_path (vecs, pp, ticks);if (rc <0 ) {
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 4/22 multipathd: refactor path state getting code into a helper
In reply to Benjamin MarzinskiPull the code that gets the new path state out into a helper function named check_path_state(), in preparation for splittig check_path() into two functions.
--- multipathd/main.c | 64 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 26 deletions(-)
multipathd/main.c +38 -26
@@ -2305,6 +2305,43 @@ should_skip_path(struct path *pp){return 0 ; } +static int +check_path_state (struct path *pp) +{ +int newstate; +struct config *conf; + + newstate =path_offline (pp); +if (newstate ==PATH_UP ) { + conf =get_multipath_config (); +pthread_cleanup_push (put_multipath_config, conf); + newstate =get_state (pp, conf,1 , newstate); +pthread_cleanup_pop (1 ); + }else { +checker_clear_message (&pp->checker); +condlog (3 ,"%s: state %s, checker not called" , + pp->dev,checker_state_name (newstate)); + } +/* +* Wait for uevent for removed paths; +* some LLDDs like zfcp keep paths unavailable +* without sending uevents. +*/ +if (newstate ==PATH_REMOVED ) + newstate =PATH_DOWN ; + +if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED ) { +condlog (2 ,"%s: unusable path (%s) - checker failed" , + pp->dev,checker_state_name (newstate)); +LOG_MSG (2 , pp); + conf =get_multipath_config (); +pthread_cleanup_push (put_multipath_config, conf); +pathinfo (pp, conf,0 ); +pthread_cleanup_pop (1 ); + } +return newstate; +} +/* * Returns '1' if the path has been checked, '-1' if it was blacklisted * and '0' otherwise
@@ -2384,33 +2421,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)*/ pp->tick = checkint; - newstate =path_offline (pp); -if (newstate ==PATH_UP ) { - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); - newstate =get_state (pp, conf,1 , newstate); -pthread_cleanup_pop (1 ); - }else { -checker_clear_message (&pp->checker); -condlog (3 ,"%s: state %s, checker not called" , - pp->dev,checker_state_name (newstate)); - } -/* -* Wait for uevent for removed paths; -* some LLDDs like zfcp keep paths unavailable -* without sending uevents. -*/ -if (newstate ==PATH_REMOVED ) - newstate =PATH_DOWN ; - + newstate =check_path_state (pp);if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED ) { -condlog (2 ,"%s: unusable path (%s) - checker failed" , - pp->dev,checker_state_name (newstate)); -LOG_MSG (2 , pp); - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); -pathinfo (pp, conf,0 ); -pthread_cleanup_pop (1 );return 1 ; }else if ((newstate !=PATH_UP && newstate !=PATH_GHOST && newstate !=PATH_PENDING ) && (pp->state ==PATH_DELAYED )) {
Signature · 1 line
2.45.0
Re: [PATCH 04/22] multipathd: refactor path state getting code into a helper
Quoted 21 lines · Benjamin Marzinski
Pull the code that gets the new path state out into a helper function named
check_path_state(), in preparation for splittigcheck_path()into two functions.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 64 ++++++++++++++++++++++++++++----------------- --1 file changed, 38 insertions(+), 26 deletions(-)multipathd/main.c +1
-1- + newstate =check_path_state (pp);if (newstate ==
PATH_WILD|| newstate ==PATH_UNCHECKED) {(quoted diff) +0
-1- condlog(2, "%s: unusable path (%s) - checkerfailed",
multipathd/main.c +0
-6- pp->dev, checker_state_name(newstate)); -LOG_MSG (2 , pp); - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); -pathinfo (pp, conf,0 ); -pthread_cleanup_pop (1 );
Quoted 1 line
return 1;
Nit: Remove braces here?
Quoted 3 lines
} else if ((newstate !=
PATH_UP&& newstate !=PATH_GHOST&& newstate !=PATH_PENDING) && (pp->state==PATH_DELAYED)) {
Thanks,
Martin
Martin Wilck
Reviewed-byRe: [PATCH 04/22] multipathd: refactor path state getting code into a helper
Quoted 4 lines · Martin Wilck
Quoted 1 line · Benjamin Marzinski
return 1;
Nit: Remove braces here?
Ok, you did this later on.
Benjamin Marzinski
maintainerPATCH 5/22 multipathd: handle uninitialized paths in new function
In reply to Benjamin MarzinskiPull the code to handle uninitialized paths out of check_path() and into a new function called handle_uninitialized_paths(). This should cause no functional changes.
--- multipathd/main.c | 171 ++++++++++++++++++++++++++++------------------ 1 file changed, 105 insertions(+), 66 deletions(-)
multipathd/main.c +105 -66
@@ -2343,8 +2343,7 @@ check_path_state(struct path *pp) }/* -* Returns '1' if the path has been checked, '-1' if it was blacklisted -* and '0' otherwise +* Returns '1' if the path has been checked and '0' otherwise */ int check_path (struct vectors * vecs,struct path * pp,unsigned int ticks)
@@ -2354,16 +2353,13 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)int chkr_new_path_up =0 ;int disable_reinstate =0 ;int oldchkrstate = pp->chkrstate; -int retrigger_tries;unsigned int checkint, max_checkint;struct config *conf;int marginal_pathgroups, marginal_changed =0 ;int ret;bool need_reload; -if (((pp->initialized ==INIT_OK || pp->initialized ==INIT_PARTIAL || - pp->initialized ==INIT_REQUESTED_UDEV ) && !pp->mpp) || - pp->initialized ==INIT_REMOVED ) +if (pp->initialized ==INIT_REMOVED )return 0 ;if (pp->tick)
@@ -2372,7 +2368,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)return 0 ;/* don't check this path yet */ conf =get_multipath_config (); - retrigger_tries = conf->retrigger_tries; checkint = conf->checkint; max_checkint = conf->max_checkint; marginal_pathgroups = conf->marginal_pathgroups;
@@ -2383,38 +2378,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; }; -if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV ) { -if (pp->retriggers < retrigger_tries) { -static const char change[] ="change" ; -ssize_t ret; - -condlog (2 ,"%s: triggering change event to reinitialize" , - pp->dev); - pp->initialized =INIT_REQUESTED_UDEV ; - pp->retriggers++; - ret =sysfs_attr_set_value (pp->udev,"uevent" , change, -sizeof (change) -1 ); -if (ret !=sizeof (change) -1 ) -log_sysfs_attr_set_value (1 , ret, -"%s: failed to trigger change event" , - pp->dev); -return 0 ; - }else { -condlog (1 ,"%s: not initialized after %d udev retriggers" , - pp->dev, retrigger_tries); -/* -* Make sure that the "add missing path" code path -* below may reinstate the path later, if it ever -* comes up again. -* The WWID needs not be cleared; if it was set, the -* state hadn't been INIT_MISSING_UDEV in the first -* place. -*/ - pp->initialized =INIT_FAILED ; -return 0 ; - } - } -/* * provision a next check soonest, * in case we exit abnormally from here
@@ -2435,32 +2398,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint;return 1 ; } -if (!pp->mpp) { -if (!strlen (pp->wwid) && - (pp->initialized ==INIT_FAILED || - pp->initialized ==INIT_NEW ) && - (newstate ==PATH_UP || newstate ==PATH_GHOST )) { -condlog (2 ,"%s: add missing path" , pp->dev); - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); - ret =pathinfo (pp, conf,DI_ALL |DI_BLACKLIST ); -pthread_cleanup_pop (1 ); -/* INIT_OK implies ret == PATHINFO_OK */ -if (pp->initialized ==INIT_OK ) { -ev_add_path (pp, vecs,1 ); - pp->tick =1 ; - }else { -if (ret ==PATHINFO_SKIPPED ) -return -1 ; -/* -* We failed multiple times to initialize this -* path properly. Don't re-check too often. -*/ - pp->checkint = max_checkint; - } - } -return 0 ; - }/* * Async IO in flight. Keep the previous path state * and reschedule as soon as possible
@@ -2679,6 +2616,104 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)return 1 ; } +/* +* Returns -1 if the path was blacklisted, and 0 otherwise +*/ +static int +handle_uninitialized_path (struct vectors * vecs,struct path * pp, +unsigned int ticks) +{ +int newstate; +int retrigger_tries; +unsigned int checkint, max_checkint; +struct config *conf; +int ret; + +if (((pp->initialized ==INIT_OK || pp->initialized ==INIT_PARTIAL || + pp->initialized ==INIT_REQUESTED_UDEV ) && !pp->mpp) || + pp->initialized ==INIT_REMOVED ) +return 0 ; + +if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; +if (pp->tick) +return 0 ;/* don't check this path yet */ + + conf =get_multipath_config (); + retrigger_tries = conf->retrigger_tries; + checkint = conf->checkint; + max_checkint = conf->max_checkint; +put_multipath_config (conf); + +if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV ) { +if (pp->retriggers < retrigger_tries) { +static const char change[] ="change" ; +ssize_t ret; + +condlog (2 ,"%s: triggering change event to reinitialize" , + pp->dev); + pp->initialized =INIT_REQUESTED_UDEV ; + pp->retriggers++; + ret =sysfs_attr_set_value (pp->udev,"uevent" , change, +sizeof (change) -1 ); +if (ret !=sizeof (change) -1 ) +log_sysfs_attr_set_value (1 , ret, +"%s: failed to trigger change event" , + pp->dev); +return 0 ; + }else { +condlog (1 ,"%s: not initialized after %d udev retriggers" , + pp->dev, retrigger_tries); +/* +* Make sure that the "add missing path" code path +* below may reinstate the path later, if it ever +* comes up again. +* The WWID needs not be cleared; if it was set, the +* state hadn't been INIT_MISSING_UDEV in the first +* place. +*/ + pp->initialized =INIT_FAILED ; +return 0 ; + } + } + +/* +* provision a next check soonest, +* in case we exit abnormally from here +*/ + pp->tick = checkint; + + newstate =check_path_state (pp); + +if (!pp->mpp) { +if (!strlen (pp->wwid) && + (pp->initialized ==INIT_FAILED || + pp->initialized ==INIT_NEW ) && + (newstate ==PATH_UP || newstate ==PATH_GHOST )) { +condlog (2 ,"%s: add missing path" , pp->dev); + conf =get_multipath_config (); +pthread_cleanup_push (put_multipath_config, conf); + ret =pathinfo (pp, conf,DI_ALL |DI_BLACKLIST ); +pthread_cleanup_pop (1 ); +/* INIT_OK implies ret == PATHINFO_OK */ +if (pp->initialized ==INIT_OK ) { +ev_add_path (pp, vecs,1 ); + pp->tick =1 ; + }else { +if (ret ==PATHINFO_SKIPPED ) +return -1 ; +/* +* We failed multiple times to initialize this +* path properly. Don't re-check too often. +*/ + pp->checkint = max_checkint; + } + } +return 0 ; + } +return 0 ; +} +enum checker_state {CHECKER_STARTING ,CHECKER_RUNNING ,
@@ -2751,7 +2786,11 @@ checkerloop (void *ap)if (pp->is_checked)continue ; pp->is_checked = true; - rc =check_path (vecs, pp, ticks); +if (pp->mpp) + rc =check_path (vecs, pp, ticks); +else + rc =handle_uninitialized_path (vecs, pp, + ticks);if (rc <0 ) {condlog (1 ,"%s: check_path() failed, removing" , pp->dev);
Signature · 1 line
2.45.0
Re: [PATCH 05/22] multipathd: handle uninitialized paths in new function
Quoted 167 lines · Benjamin Marzinski
Pull the code to handle uninitialized paths out of
check_path()and into
a new function calledhandle_uninitialized_paths(). This should cause no functional changes.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 171 ++++++++++++++++++++++++++++---------------- --1 file changed, 105 insertions(+), 66 deletions(-)multipathd/main.c +0
-0@@ -2343,8 +2343,7 @@ check_path_state(struct path *pp) }
/*
- * Returns '1' if the path has been checked, '-1' if it was blacklisted
- * and '0' otherwise
+ * Returns '1' if the path has been checked and '0' otherwise */
int
check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)multipathd/main.c +0
-1@@ -2354,16 +2353,13 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) int chkr_new_path_up = 0; int disable_reinstate = 0; int oldchkrstate = pp->chkrstate; -int retrigger_tries; unsigned int checkint, max_checkint; struct config *conf; int marginal_pathgroups, marginal_changed = 0; int ret; bool need_reload;multipathd/main.c +0
-1- if (((pp->initialized == INIT_OK || pp->initialized ==
INIT_PARTIAL||multipathd/main.c +0
-1- pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp)||
multipathd/main.c +1
-1- pp->initialized == INIT_REMOVED) +if (pp->initialized ==INIT_REMOVED )return 0;
if (pp->tick)multipathd/main.c +0
-0@@ -2372,7 +2368,6 @@ check_path (struct vectors * vecs, struct path* pp, unsigned int ticks) return 0; /* don't check this path yet */
conf =get_multipath_config();multipathd/main.c +0
-1- retrigger_tries = conf->retrigger_tries;checkint =
conf->checkint;
max_checkint=conf->max_checkint;marginal_pathgroups=conf->marginal_pathgroups;multipathd/main.c +0
-0@@ -2383,38 +2378,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; };multipathd/main.c +0
-6-if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV ) { -if (pp->retriggers < retrigger_tries) { -static const char change[] ="change" ; -ssize_t ret; - - condlog(2, "%s: triggering change event toreinitialize",
multipathd/main.c +0
-4- pp->dev); - pp->initialized =INIT_REQUESTED_UDEV ; - pp->retriggers++; - ret = sysfs_attr_set_value(pp->udev,"uevent", change,
multipathd/main.c +0
-1- sizeof(change) -1);
multipathd/main.c +0
-3-if (ret !=sizeof (change) -1 ) - log_sysfs_attr_set_value(1, ret, - "%s: failedto trigger change event",
multipathd/main.c +0
-4- pp->dev); -return 0 ; - }else { - condlog(1, "%s: not initialized after %dudev retriggers",
multipathd/main.c +0
-3- pp->dev, retrigger_tries); -/* -* Make sure that the "add missing path" code path
multipathd/main.c +0
-1-* below may reinstate the path later, if it ever
multipathd/main.c +0
-2-* comes up again. -* The WWID needs not be cleared; if it was set, the
multipathd/main.c +0
-1-* state hadn't been INIT_MISSING_UDEV in the first
multipathd/main.c +0
-7-* place. -*/ - pp->initialized =INIT_FAILED ; -return 0 ; - } - } -/*
* provision a next check soonest,
* in case we exit abnormally from heremultipathd/main.c +0
-9@@ -2435,32 +2398,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; return 1; } -if (!pp->mpp) { -if (!strlen (pp->wwid) && - (pp->initialized == INIT_FAILED || - pp->initialized == INIT_NEW) && - (newstate == PATH_UP || newstate == PATH_GHOST)) { -condlog (2 ,"%s: add missing path" , pp->dev); - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); - ret = pathinfo(pp, conf, DI_ALL |
DI_BLACKLIST);multipathd/main.c +0
-10-pthread_cleanup_pop (1 ); -/* INIT_OK implies ret == PATHINFO_OK */ -if (pp->initialized ==INIT_OK ) { -ev_add_path (pp, vecs,1 ); - pp->tick =1 ; - }else { -if (ret ==PATHINFO_SKIPPED ) -return -1 ; -/* -* We failed multiple times to initialize this
multipathd/main.c +0
-1-* path properly. Don't re-check too often.
multipathd/main.c +0
-6-*/ - pp->checkint = max_checkint; - } - } -return 0 ; - }/*
* Async IO in flight. Keep the previous path state
* and reschedule as soon as possiblemultipathd/main.c +0
-0@@ -2679,6 +2616,104 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 1; }multipathd/main.c +14
-0+/* +* Returns -1 if the path was blacklisted, and 0 otherwise +*/ +static int +handle_uninitialized_path(struct vectors * vecs, struct path * pp, + unsigned int ticks) +{ + int newstate; + int retrigger_tries; + unsigned int checkint, max_checkint; + struct config *conf; + int ret; + + if (((pp->initialized == INIT_OK || pp->initialized ==
INIT_PARTIAL||multipathd/main.c +1
-0+ pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp)||
multipathd/main.c
Quoted 2 lines
multipathd/main.c +2
-0+ pp->initialized == INIT_REMOVED) +return 0 ;
!pp->mpp always holds if this function is called, so we can skip this part of the test.
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2640
Quoted 5 lines
multipathd/main.c +5
-0+ +if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; +if (pp->tick) +return 0 ;/* don't check this path yet */
IMO it would make sense to move this code into checkerloop(). Actually we could make sure that for those paths that are initialized but not part of an mpp (see above), pp->tick is always zero.
Quoted 47 lines
multipathd/main.c +13
-0+ + conf =get_multipath_config (); + retrigger_tries = conf->retrigger_tries; + checkint = conf->checkint; + max_checkint = conf->max_checkint; +put_multipath_config (conf); + +if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV ) { +if (pp->retriggers < retrigger_tries) { +static const char change[] ="change" ; +ssize_t ret; + + condlog(2, "%s: triggering change event toreinitialize",
multipathd/main.c +4
-0+ pp->dev); + pp->initialized =INIT_REQUESTED_UDEV ; + pp->retriggers++; + ret = sysfs_attr_set_value(pp->udev,"uevent", change,
multipathd/main.c +1
-0+ sizeof(change) -1);
multipathd/main.c +3
-0+if (ret !=sizeof (change) -1 ) + log_sysfs_attr_set_value(1, ret, + "%s: failedto trigger change event",
multipathd/main.c +4
-0+ pp->dev); +return 0 ; + }else { + condlog(1, "%s: not initialized after %dudev retriggers",
multipathd/main.c +3
-0+ pp->dev, retrigger_tries); +/* +* Make sure that the "add missing path" code path
multipathd/main.c +1
-0+* below may reinstate the path later, if it ever
multipathd/main.c +2
-0+* comes up again. +* The WWID needs not be cleared; if it was set, the
multipathd/main.c +1
-0+* state hadn't been INIT_MISSING_UDEV in the first
multipathd/main.c +6
-0+* place. +*/ + pp->initialized =INIT_FAILED ; +return 0 ; + } + }
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2688
Quoted 10 lines
multipathd/main.c +10
-0+ +/* +* provision a next check soonest, +* in case we exit abnormally from here +*/ + pp->tick = checkint; + + newstate =check_path_state (pp); + +if (!pp->mpp) {
Again, this test can be skipped, or am I overlooking something?
Quoted 53 lines
multipathd/main.c +4
-0+if (!strlen (pp->wwid) && + (pp->initialized == INIT_FAILED || + pp->initialized == INIT_NEW) && + (newstate == PATH_UP || newstate == PATH_GHOST)){
multipathd/main.c +3
-0+condlog (2 ,"%s: add missing path" , pp->dev); + conf =get_multipath_config (); + pthread_cleanup_push(put_multipath_config,conf);
multipathd/main.c +1
-0+ ret = pathinfo(pp, conf, DI_ALL |
DI_BLACKLIST);multipathd/main.c +10
-0+pthread_cleanup_pop (1 ); +/* INIT_OK implies ret == PATHINFO_OK */ +if (pp->initialized ==INIT_OK ) { +ev_add_path (pp, vecs,1 ); + pp->tick =1 ; + }else { +if (ret ==PATHINFO_SKIPPED ) +return -1 ; +/* +* We failed multiple times to initialize this
multipathd/main.c +1
-0+* path properly. Don't re-check too often.
multipathd/main.c +9
-0+*/ + pp->checkint = max_checkint; + } + } +return 0 ; + } +return 0 ; +} +enum
checker_state{
CHECKER_STARTING,
CHECKER_RUNNING,multipathd/main.c +5
-1@@ -2751,7 +2786,11 @@ checkerloop (void *ap) if (pp->is_checked) continue; pp->is_checked = true; - rc =check_path (vecs, pp, ticks); +if (pp->mpp) + rc =check_path (vecs, pp, ticks); +else + rc =handle_uninitialized_path (vecs, pp, + ticks);if (rc < 0) {
condlog(1, "%s:check_path()failed, removing",
pp->dev);
Re: [PATCH 05/22] multipathd: handle uninitialized paths in new function
Quoted 14 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
Pull the code to handle uninitialized paths out of
check_path()and into
a new function calledhandle_uninitialized_paths(). This should cause
no functional changes.Quoted 6 lines
Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 171 ++++++++++++++++++++++++++++-------------- --
--1 file changed, 105 insertions(+), 66 deletions(-)
Quoted 3 lines
!pp->mpp always holds if this function is called, so we can skip this part of the test.
Just realized that you did this in patch 7.
LGTM, then, but if you resubmit, I suggest you just squash these two.
Martin
Benjamin Marzinski
maintainerRe: [PATCH 05/22] multipathd: handle uninitialized paths in new function
Quoted 15 lines · Martin Wilck
Quoted 14 lines · Martin Wilck
Quoted 12 lines · Benjamin Marzinski
Pull the code to handle uninitialized paths out of
check_path()and into
a new function calledhandle_uninitialized_paths(). This should cause
no functional changes.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 171 ++++++++++++++++++++++++++++-------------- --
--1 file changed, 105 insertions(+), 66 deletions(-)
Quoted 7 lines
Quoted 3 lines
!pp->mpp always holds if this function is called, so we can skip this part of the test.
Just realized that you did this in patch 7.
LGTM, then, but if you resubmit, I suggest you just squash these two.
Sure.
Quoted 2 lines
Martin
Benjamin Marzinski
maintainerPATCH 6/22 multipathd: make check_path() static
In reply to Benjamin Marzinski--- multipathd/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
multipathd/main.c +1 -1
@@ -2345,7 +2345,7 @@ check_path_state(struct path *pp)/* * Returns '1' if the path has been checked and '0' otherwise */ -int +static int check_path (struct vectors * vecs,struct path * pp,unsigned int ticks) {int newstate;
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 7/22 multipathd: remove redundant checks in handle_uninitialized_path()
In reply to Benjamin Marzinski--- multipathd/main.c | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-)
multipathd/main.c +23 -28
@@ -2629,9 +2629,8 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp,struct config *conf;int ret; -if (((pp->initialized ==INIT_OK || pp->initialized ==INIT_PARTIAL || - pp->initialized ==INIT_REQUESTED_UDEV ) && !pp->mpp) || - pp->initialized ==INIT_REMOVED ) +if (pp->initialized !=INIT_NEW && pp->initialized !=INIT_FAILED && + pp->initialized !=INIT_MISSING_UDEV )return 0 ;if (pp->tick)
@@ -2645,7 +2644,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, max_checkint = conf->max_checkint;put_multipath_config (conf); -if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV ) { +if (pp->initialized ==INIT_MISSING_UDEV ) {if (pp->retriggers < retrigger_tries) {static const char change[] ="change" ;ssize_t ret;
@@ -2685,31 +2684,27 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, newstate =check_path_state (pp); -if (!pp->mpp) { -if (!strlen (pp->wwid) && - (pp->initialized ==INIT_FAILED || - pp->initialized ==INIT_NEW ) && - (newstate ==PATH_UP || newstate ==PATH_GHOST )) { -condlog (2 ,"%s: add missing path" , pp->dev); - conf =get_multipath_config (); -pthread_cleanup_push (put_multipath_config, conf); - ret =pathinfo (pp, conf,DI_ALL |DI_BLACKLIST ); -pthread_cleanup_pop (1 ); -/* INIT_OK implies ret == PATHINFO_OK */ -if (pp->initialized ==INIT_OK ) { -ev_add_path (pp, vecs,1 ); - pp->tick =1 ; - }else { -if (ret ==PATHINFO_SKIPPED ) -return -1 ; -/* -* We failed multiple times to initialize this -* path properly. Don't re-check too often. -*/ - pp->checkint = max_checkint; - } +if (!strlen (pp->wwid) && + (pp->initialized ==INIT_FAILED || pp->initialized ==INIT_NEW ) && + (newstate ==PATH_UP || newstate ==PATH_GHOST )) { +condlog (2 ,"%s: add missing path" , pp->dev); + conf =get_multipath_config (); +pthread_cleanup_push (put_multipath_config, conf); + ret =pathinfo (pp, conf,DI_ALL |DI_BLACKLIST ); +pthread_cleanup_pop (1 ); +/* INIT_OK implies ret == PATHINFO_OK */ +if (pp->initialized ==INIT_OK ) { +ev_add_path (pp, vecs,1 ); + pp->tick =1 ; + }else { +if (ret ==PATHINFO_SKIPPED ) +return -1 ; +/* +* We failed multiple times to initialize this +* path properly. Don't re-check too often. +*/ + pp->checkint = max_checkint; } -return 0 ; }return 0 ; }
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 8/22 multipathd: check paths immediately after failing udev initialization
In reply to Benjamin MarzinskiWhen handle_uninitialized_path() moves a path from INIT_MISSING_UDEV to INIT_FAILED, it has already waited for conf->retrigger_delay seconds. It might as well check the path state now, instead of waiting for the next iteration.
--- multipathd/main.c | 1 - 1 file changed, 1 deletion(-)
multipathd/main.c +0 -1
@@ -2672,7 +2672,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp,* place. */ pp->initialized =INIT_FAILED ; -return 0 ; } }
Signature · 1 line
2.45.0
Re: [PATCH 08/22] multipathd: check paths immediately after failing udev initialization
Quoted 9 lines · Benjamin Marzinski
When
handle_uninitialized_path()moves a path fromINIT_MISSING_UDEVtoINIT_FAILED, it has already waited forconf->retrigger_delayseconds. It
might as well check the path state now, instead of waiting for the next
iteration.Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH 9/22 multipathd: set pp->tick = max_checkint in handle_uninitialized_path
In reply to Benjamin MarzinskiWhen handle_uninitialized_path() checks a path, it will either:
1. trigger a new uevent to initalize the path, in which case it won't check the path again until that uevent is processed and updates pp->tick
2. blacklist the path, in which case the path gets removed
3. intialize the path correctly, in which case it sets pp->tick = 1
4. fail to initialize the path, in which case it was supposed to set pp->tick to max_checkint, but instead it set pp->checkint to max_checkint, which never worked correctly.
By setting pp->tick to max_checkint at the start, handle_uninitialized_path() will continue to work as it previously did, except in case 4, where in now works correctly. There's no point in messing with pp->checkint for paths that haven't been initialized yet.
--- multipathd/main.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
multipathd/main.c +3 -17
@@ -2625,7 +2625,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, {int newstate;int retrigger_tries; -unsigned int checkint, max_checkint;struct config *conf;int ret;
@@ -2640,8 +2639,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, conf =get_multipath_config (); retrigger_tries = conf->retrigger_tries; - checkint = conf->checkint; - max_checkint = conf->max_checkint; + pp->tick = conf->max_checkint;put_multipath_config (conf);if (pp->initialized ==INIT_MISSING_UDEV ) {
@@ -2675,12 +2673,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, } } -/* -* provision a next check soonest, -* in case we exit abnormally from here -*/ - pp->tick = checkint; - newstate =check_path_state (pp); if (!strlen(pp->wwid) &&
@@ -2695,14 +2687,8 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp,if (pp->initialized ==INIT_OK ) {ev_add_path (pp, vecs,1 ); pp->tick =1 ; - }else { -if (ret ==PATHINFO_SKIPPED ) -return -1 ; -/* -* We failed multiple times to initialize this -* path properly. Don't re-check too often. -*/ - pp->checkint = max_checkint; + }else if (ret ==PATHINFO_SKIPPED ) { +return -1 ; } }return 0 ;
Signature · 1 line
2.45.0
Re: [PATCH 09/22] multipathd: set pp->tick = max_checkint in handle_uninitialized_path
Quoted 10 lines · Benjamin Marzinski
When
handle_uninitialized_path()checks a path, it will either:
1. trigger a new uevent to initalize the path, in which case it won't check the path again until that uevent is processed and updatespp->tick
2. blacklist the path, in which case the path gets removed
3. intialize the path correctly, in which case it setspp->tick= 1
4. fail to initialize the path, in which case it was supposed to setpp->ticktomax_checkint, but instead it setpp->checkinttomax_checkint, which never worked correctly.
Quoted 8 lines
By setting
pp->ticktomax_checkintat the start,handle_uninitialized_path()will continue to work as it previously did,
except in case 4, where in now works correctly. There's no point in messing withpp->checkintfor paths that haven't been initialized yet.Signed-off-by Benjamin Marzinski <[email protected]>
Q: I suppose it makes sense to backport this to earlier releases?
Martin
Benjamin Marzinski
maintainerRe: [PATCH 09/22] multipathd: set pp->tick = max_checkint in handle_uninitialized_path
Quoted 18 lines · Martin Wilck
Quoted 17 lines · Benjamin Marzinski
When
handle_uninitialized_path()checks a path, it will either:
1. trigger a new uevent to initalize the path, in which case it won't check the path again until that uevent is processed and updatespp->tick
2. blacklist the path, in which case the path gets removed
3. intialize the path correctly, in which case it setspp->tick= 1
4. fail to initialize the path, in which case it was supposed to setpp->ticktomax_checkint, but instead it setpp->checkinttomax_checkint, which never worked correctly.By setting
pp->ticktomax_checkintat the start,handle_uninitialized_path()will continue to work as it previously did,
except in case 4, where in now works correctly. There's no point in messing withpp->checkintfor paths that haven't been initialized yet.
Quoted 5 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Reviewed-by Martin Wilck <[email protected]>Q: I suppose it makes sense to backport this to earlier releases?
It's not a horrible bug. Previously, we set pp->tick to checkint early in the function. This just means that these problematic paths will be checked every checkint instead of every max_checkint.
Also, do you mean distros backporting this change? I'm not sure how much value there is in maintaining upstream stable branches.
-Ben
Quoted 2 lines
Martin
Re: [PATCH 09/22] multipathd: set pp->tick = max_checkint in handle_uninitialized_path
Quoted 31 lines · Benjamin Marzinski
Quoted 24 lines · Martin Wilck
Quoted 23 lines · Benjamin Marzinski
When
handle_uninitialized_path()checks a path, it will either:
1. trigger a new uevent to initalize the path, in which case it won't
check the path again until that uevent is processed and updates
pp->tick
2. blacklist the path, in which case the path gets removed
3. intialize the path correctly, in which case it setspp->tick= 1
4. fail to initialize the path, in which case it was supposed to set
pp->ticktomax_checkint, but instead it setpp->checkinttomax_checkint, which never worked correctly.By setting
pp->ticktomax_checkintat the start,handle_uninitialized_path()will continue to work as it previously
did,
except in case 4, where in now works correctly. There's no point in
messing withpp->checkintfor paths that haven't been initialized yet.Quoted 5 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Reviewed-by Martin Wilck <[email protected]>Q: I suppose it makes sense to backport this to earlier releases?
Quoted 7 lines
It's not a horrible bug. Previously, we set
pp->tickto checkint early
in the function. This just means that these problematic paths will be checked every checkint instead of everymax_checkint.Also, do you mean distros backporting this change? I'm not sure how much value there is in maintaining upstream stable branches.
Yes, I was referring to distro backporting. I don't want to start stable branches upstream, although we've had several cases where I thought it might be worth it.
Martin
Benjamin Marzinski
maintainerPATCH 10/22 multipathd: return 0 from path_check() if that path wasn't checked
In reply to Benjamin MarzinskiIf check_path_state() returns PATH_WILD or PATH_UNCHECKED, then the path wasn't correctly checked, and path_check() should return 0.
--- multipathd/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
multipathd/main.c +1 -1
@@ -2386,7 +2386,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) newstate =check_path_state (pp);if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED ) { -return 1 ; +return 0 ; }else if ((newstate !=PATH_UP && newstate !=PATH_GHOST && newstate !=PATH_PENDING ) && (pp->state ==PATH_DELAYED )) {/* If path state become failed again cancel path delay state */
Signature · 1 line
2.45.0
Re: [PATCH 10/22] multipathd: return 0 from path_check() if that path wasn't checked
Quoted 2 lines · Benjamin Marzinski
If
check_path_state()returnsPATH_WILDorPATH_UNCHECKED, then the path wasn't correctly checked, andpath_check()should return 0.
You mean check_path(). Other than that,
Quoted 2 lines
Signed-off-by Benjamin Marzinski <[email protected]>
Reviewed_by: Martin Wilck <[email protected]>
Benjamin Marzinski
maintainerRe: [PATCH 10/22] multipathd: return 0 from path_check() if that path wasn't checked
Quoted 5 lines · Martin Wilck
Quoted 2 lines · Benjamin Marzinski
If
check_path_state()returnsPATH_WILDorPATH_UNCHECKED, then the path wasn't correctly checked, andpath_check()should return 0.You mean
check_path(). Other than that,
I'll fix that in the next version.
-Ben
Quoted 5 lines
Quoted 3 lines
Signed-off-by Benjamin Marzinski <[email protected]>
Reviewed_by: Martin Wilck <[email protected]>
Benjamin Marzinski
maintainerPATCH 11/22 multipathd: reorder path state checks
In reply to Benjamin MarzinskiReorder the path state checks in check_path(), so that it first does all the checks which can result in returning with the path unchecked or removed from the multipath device.
--- multipathd/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
multipathd/main.c +12 -12
@@ -2385,19 +2385,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->tick = checkint; newstate =check_path_state (pp); -if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED ) { +if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED )return 0 ; - }else if ((newstate !=PATH_UP && newstate !=PATH_GHOST && - newstate !=PATH_PENDING ) && (pp->state ==PATH_DELAYED )) { -/* If path state become failed again cancel path delay state */ - pp->state = newstate; -/* -* path state bad again should change the check interval time -* to the shortest delay -*/ - pp->checkint = checkint; -return 1 ; - }/* * Async IO in flight. Keep the previous path state * and reschedule as soon as possible
@@ -2436,6 +2425,17 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)return 0 ; } +if ((newstate !=PATH_UP && newstate !=PATH_GHOST && + newstate !=PATH_PENDING ) && (pp->state ==PATH_DELAYED )) { +/* If path state become failed again cancel path delay state */ + pp->state = newstate; +/* +* path state bad again should change the check interval time +* to the shortest delay +*/ + pp->checkint = checkint; +return 1 ; + }if ((newstate ==PATH_UP || newstate ==PATH_GHOST ) && (san_path_check_enabled (pp->mpp) ||marginal_path_check_enabled (pp->mpp))) {
Signature · 1 line
2.45.0
Re: [PATCH 11/22] multipathd: reorder path state checks
Quoted 6 lines · Benjamin Marzinski
Reorder the path state checks in
check_path(), so that it first does all the checks which can result in returning with the path unchecked or
removed from the multipath device.Signed-off-by Benjamin Marzinski <[email protected]>
This will move the code in question to after the call to update_multipath_strings().
But that logic is modified in the next patch anyway, so
Benjamin Marzinski
maintainerPATCH 12/22 multipathd: adjust when mpp is synced with the kernel
In reply to Benjamin MarzinskiMove the code to sync the mpp device state into a helper function and add a counter to to make sure that the device is synced at least once every max_checkint secs. This makes sure that multipath devices with no paths will still get synced with the kernel. Also, if multiple paths are checked in the same loop, the multipath device will only be synced with the kernel once, since every time the mpp is synced in any code path, mpp->sync_tick is reset.
The code still syncs the mpp before updating the path state for two main reasons.
1. Sometimes multipathd leaves the mpp with a garbage state. Future patches will fix most of these cases, but the code intentially does not remove the mpp is resyncing fails while checking paths. But this does leave the mpp with a garbage state.
2. The kernel chages the multipath state independently of multipathd. If the kernel fails a path, a uevent will arrive shortly. But the kernel doesn't provide any notification when it switches the active path group or if it ends up picking a different one than multipathd selected. Multipathd needs to know the actual current pathgroup to know when it should be switching them.
--- libmultipath/configure.c | 1 + libmultipath/structs.h | 2 ++ libmultipath/structs_vec.c | 5 +++ multipathd/main.c | 64 +++++++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 22 deletions(-)
libmultipath/configure.c +1 -0
@@ -358,6 +358,7 @@ int setup_map(struct multipath *mpp, char **params, struct vectors *vecs)sysfs_set_scsi_tmo (conf, mpp); marginal_pathgroups = conf->marginal_pathgroups; + mpp->sync_tick = conf->max_checkint;pthread_cleanup_pop (1 );if (!mpp->features || !mpp->hwhandler || !mpp->selector) {
libmultipath/structs.h +2 -0
@@ -453,6 +453,8 @@ struct multipath {int ghost_delay;int ghost_delay_tick;int queue_mode; +unsigned int sync_tick; +bool is_checked;uid_t uid;gid_t gid;mode_t mode;
libmultipath/structs_vec.c +5 -0
@@ -505,10 +505,15 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags)char __attribute__((cleanup (cleanup_charp))) *params =NULL ;char __attribute__((cleanup (cleanup_charp))) *status =NULL ;unsigned long long size = mpp->size; +struct config *conf;if (!mpp)return r; + conf =get_multipath_config (); + mpp->sync_tick = conf->max_checkint; +put_multipath_config (conf); + r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, (mapid_t) { .str = mpp->alias }, (mapinfo_t) {
multipathd/main.c +42 -22
100 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH 12/22] multipathd: adjust when mpp is synced with the kernel
Quoted 152 lines · Benjamin Marzinski
Move the code to sync the mpp device state into a helper function and add a counter to to make sure that the device is synced at least once every
max_checkintsecs. This makes sure that multipath devices with no
paths will still get synced with the kernel. Also, if multiple paths are checked in the same loop, the multipath device will only be synced
with the kernel once, since every time the mpp is synced in any code path,mpp->sync_tickis reset.The code still syncs the mpp before updating the path state for two main reasons.
1. Sometimes multipathd leaves the mpp with a garbage state. Future patches will fix most of these cases, but the code intentially does not remove the mpp is resyncing fails while checking paths. But this does leave the mpp with a garbage state.
2. The kernel chages the multipath state independently of multipathd. If
the kernel fails a path, a uevent will arrive shortly. But the kernel
doesn't provide any notification when it switches the active path group or if it ends up picking a different one than multipathd
selected. Multipathd needs to know the actual current pathgroup to know when it should be switching them.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/configure.c | 1 +
libmultipath/structs.h | 2 ++libmultipath/structs_vec.c| 5 +++
multipathd/main.c | 64 +++++++++++++++++++++++++----------- --4 files changed, 50 insertions(+), 22 deletions(-)multipathd/main.c +0
-0@@ -2342,6 +2342,37 @@ check_path_state(struct path *pp) return newstate; }multipathd/main.c +10
-0+static void +do_check_mpp (struct vectors * vecs,struct multipath *mpp) +{ +int i, ret; +struct path *pp; + + mpp->is_checked = true; + ret =update_multipath_strings (mpp, vecs->pathvec); +if (ret !=DMP_OK ) { + condlog(1, "%s: %s", mpp->alias, ret ==
DMP_NOT_FOUND?multipathd/main.c +11
-0+ "device not found" : + "couldn't synchronize with kernel state"); + vector_foreach_slot (mpp->paths, pp, i) + pp->dmstate =PSTATE_UNDEF ; +return ; + } +set_no_path_retry (mpp); +} + +static void +check_mpp(struct vectors * vecs, struct multipath *mpp, unsigned intticks)
multipathd/main.c +10
-0+{ +if (mpp->sync_tick) + mpp->sync_tick -= (mpp->sync_tick > ticks) ? ticks : + mpp->sync_tick; +if (mpp->sync_tick) +return ; + +do_check_mpp (vecs, mpp); +} +/*
* Returns '1' if the path has been checked and '0' otherwise */multipathd/main.c +0
-1@@ -2356,7 +2387,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) unsigned int checkint, max_checkint; struct config *conf; int marginal_pathgroups, marginal_changed = 0; -int ret; bool need_reload;
if (pp->initialized==INIT_REMOVED)multipathd/main.c +0
-9@@ -2395,26 +2425,6 @@ check_path (struct vectors * vecs, struct path* pp, unsigned int ticks) pp->tick = 1; return 0; } -/* -* Synchronize with kernel state -*/ - ret =update_multipath_strings (pp->mpp, vecs->pathvec); -if (ret !=DMP_OK ) { -if (ret ==DMP_NOT_FOUND ) { -/* multipath device missing. Likely removed */ - condlog(1, "%s: multipath device '%s' not found", - pp->dev, pp->mpp ? pp->mpp->alias :"");
multipathd/main.c +0
-3-return 0 ; - }else - condlog(1, "%s: Couldn't synchronize withkernel state",
multipathd/main.c +0
-4- pp->dev); - pp->dmstate =PSTATE_UNDEF ; - } -/* if update_multipath_strings orphaned the path, quit early */
multipathd/main.c +0
-4-if (!pp->mpp) -return 0 ; -set_no_path_retry (pp->mpp); -if (
pp->recheck_wwid==RECHECK_WWID_ON&& (newstate ==PATH_UP|| newstate ==PATH_GHOST) && ((pp->state!=PATH_UP&&pp->state!=PATH_GHOST) ||multipathd/main.c +3
-1@@ -2424,7 +2434,12 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) handle_path_wwid_change(pp, vecs); return 0; } - +if (!pp->mpp->is_checked) { +do_check_mpp (vecs, pp->mpp); +/* if update_multipath_strings orphaned the path, quit early */
multipathd/main.c +3
-0+if (!pp->mpp) +return 0 ; + }if ((newstate !=
PATH_UP&& newstate !=PATH_GHOST&& newstate !=PATH_PENDING) && (pp->state==PATH_DELAYED)) {
/* If path state become failed again cancel path delay state */multipathd/main.c +1
-0@@ -2752,12 +2767,17 @@ checkerloop (void *ap) while (checker_state != CHECKER_FINISHED) { unsigned int paths_checked = 0, i; struct timespec chk_start_time; +struct multipath *mpp;
pthread_cleanup_push(cleanup_lock, &vecs-Quoted 1 line
lock);
lock(&vecs->lock);
pthread_testcancel();
multipathd/main.c checkerloop (void *ap) · line 2776
Quoted 2 lines
multipathd/main.c +2
-0+vector_foreach_slot (vecs->mpvec, mpp, i) + mpp->is_checked = false;
Why is this not done inside the "if (checker_state == CHECKER_STARTING) code path?
Martin
Quoted 9 lines
get_monotonic_time(&chk_start_time); if (checker_state==CHECKER_STARTING) {multipathd/main.c +1
-0+ vector_foreach_slot(vecs->mpvec,mpp, i)
multipathd/main.c +1
-0+check_mpp (vecs, mpp, ticks);
vector_foreach_slot(vecs->pathvec, pp, i)
pp->is_checked= false;checker_state=CHECKER_RUNNING;
Benjamin Marzinski
maintainerRe: [PATCH 12/22] multipathd: adjust when mpp is synced with the kernel
Quoted 52 lines · Martin Wilck
Quoted 51 lines · Benjamin Marzinski
Move the code to sync the mpp device state into a helper function and add a counter to to make sure that the device is synced at least once every
max_checkintsecs. This makes sure that multipath devices with no
paths will still get synced with the kernel. Also, if multiple paths are checked in the same loop, the multipath device will only be synced
with the kernel once, since every time the mpp is synced in any code path,mpp->sync_tickis reset.The code still syncs the mpp before updating the path state for two main reasons.
1. Sometimes multipathd leaves the mpp with a garbage state. Future patches will fix most of these cases, but the code intentially does not remove the mpp is resyncing fails while checking paths. But this does leave the mpp with a garbage state.
2. The kernel chages the multipath state independently of multipathd. If
the kernel fails a path, a uevent will arrive shortly. But the kernel
doesn't provide any notification when it switches the active path group or if it ends up picking a different one than multipathd
selected. Multipathd needs to know the actual current pathgroup to know when it should be switching them.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/configure.c | 1 +
libmultipath/structs.h | 2 ++libmultipath/structs_vec.c| 5 +++
multipathd/main.c | 64 +++++++++++++++++++++++++----------- --4 files changed, 50 insertions(+), 22 deletions(-)multipathd/main.c +1
-0@@ -2752,12 +2767,17 @@ checkerloop (void *ap) while (checker_state != CHECKER_FINISHED) { unsigned int paths_checked = 0, i; struct timespec chk_start_time; +struct multipath *mpp;
pthread_cleanup_push(cleanup_lock, &vecs-
Quoted 8 lines
multipathd/main.c checkerloop (void *ap) · line 2776
Quoted 5 lines
Quoted 1 line
lock);
lock(&vecs->lock);
pthread_testcancel();multipathd/main.c +2
-0+vector_foreach_slot (vecs->mpvec, mpp, i) + mpp->is_checked = false;Why is this not done inside the "if (
checker_state==CHECKER_STARTING) code path?
Since we slept here, there was more time for something to change in a way where we needed to resync the state. Also, like I mention in the comments, there are places where we fail in some function that is updating the mpp state and don't resync it with the kernel. I'm fairly sure (but not totally certain) future patches catch all of these except for failing to update the state in the checker function itself. (We've never removed the multipath device for failing to resync its state in the check_path(), unlike failures when responding to an event or after reloading the device. This makes sense to me. Since we're doing these resyncs in check_path() routinely, not because we think something has changed, it seems reasonable to assume that nothing has changed if we fail to resync).
Clearing is_checked here doesn't guarantee that we will resync the mpp. Only that we will resync if we need to check one of its paths, after the interruption. When we switch to checking paths by mpp later, this will never happen, except in corner cases.
-Ben
Quoted 12 lines
Martin
Quoted 9 lines
get_monotonic_time(&chk_start_time); if (checker_state==CHECKER_STARTING) {multipathd/main.c +1
-0+ vector_foreach_slot(vecs->mpvec,mpp, i)
multipathd/main.c +1
-0+check_mpp (vecs, mpp, ticks);
vector_foreach_slot(vecs->pathvec, pp, i)
pp->is_checked= false;checker_state=CHECKER_RUNNING;
Benjamin Marzinski
maintainerPATCH 13/22 multipathd: resync map after setup_map in ev_remove_path
In reply to Benjamin MarzinskiIn ev_remove_path() it was possible to exit after calling setup_map() without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all.
It's safe to exit before calling setup_map() if either wait_for_udev or need_do_map is set. In both cases, setup_map() will later be called, either by a uevent or by the calling function.
Once setup_map() has been called, setup_multipath() and sync_map_state() are now always called, to make sure the mpp matches the kernel state.
--- multipathd/main.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-)
multipathd/main.c +19 -21
@@ -1395,6 +1395,8 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)* avoid referring to the map of an orphaned path */ if ((mpp = pp->mpp)) { +char devt[BLK_DEV_SIZE ]; +/* * Mark the path as removed. In case of success, we * will delete it for good. Otherwise, it will be deleted
@@ -1428,12 +1430,6 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) flush_map_nopaths(mpp, vecs)) goto out; -if (setup_map (mpp, ¶ms, vecs)) { -condlog (0 ,"%s: failed to setup map for" -" removal of path %s" , mpp->alias, pp->dev); - goto fail; - } -if (mpp->wait_for_udev) { mpp->wait_for_udev =2 ; retval =REMOVE_PATH_DELAY ;
@@ -1444,33 +1440,35 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) retval =REMOVE_PATH_DELAY ; goto out; } + +if (setup_map (mpp, ¶ms, vecs)) { +condlog (0 ,"%s: failed to setup map for" +" removal of path %s" , mpp->alias, pp->dev); + goto fail; + }/* * reload the map */ mpp->action =ACT_RELOAD ; +strlcpy (devt, pp->dev_t,sizeof (devt));if (domap (mpp, params,1 ) ==DOMAP_FAIL ) {condlog (0 ,"%s: failed in domap for " "removal of path %s" , mpp->alias, pp->dev); retval =REMOVE_PATH_FAILURE ; - }else { -/* -* update our state from kernel -*/ -char devt[BLK_DEV_SIZE ]; - -strlcpy (devt, pp->dev_t,sizeof (devt)); - -/* setup_multipath will free the path -* regardless of whether it succeeds or -* fails */ -if (setup_multipath (vecs, mpp)) -return REMOVE_PATH_MAP_ERROR ; -sync_map_state (mpp); + } +/* +* update mpp state from kernel even if domap failed. +* If the path was removed from the mpp, setup_multipath will +* free the path regardless of whether it succeeds or fails +*/ +if (setup_multipath (vecs, mpp)) +return REMOVE_PATH_MAP_ERROR ; +sync_map_state (mpp); +if (retval ==REMOVE_PATH_SUCCESS )condlog (2 ,"%s: path removed from map %s" , devt, mpp->alias); - } }else {/* mpp == NULL */ if ((i =find_slot (vecs->pathvec, (void *)pp)) !=-1 )
Signature · 1 line
2.45.0
Re: [PATCH 13/22] multipathd: resync map after setup_map in ev_remove_path
Quoted 55 lines · Benjamin Marzinski
In
ev_remove_path()it was possible to exit after callingsetup_map()without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all.It's safe to exit before calling
setup_map()if eitherwait_for_udevorneed_do_mapis set. In both cases,setup_map()will later be called,
either by a uevent or by the calling function.Once
setup_map()has been called,setup_multipath()andsync_map_state()
are now always called, to make sure the mpp matches the kernel state.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 40 +++++++++++++++++++---------------------1 file changed, 19 insertions(+), 21 deletions(-)multipathd/main.c +2
-0@@ -1395,6 +1395,8 @@ ev_remove_path (struct path *pp, struct vectors* vecs, int need_do_map) * avoid referring to the map of an orphaned path */ if ((mpp = pp->mpp)) { +char devt[BLK_DEV_SIZE ]; + /** Mark the path as removed. In case of success, we * will delete it for good. Otherwise, it will be deleted
multipathd/main.c +0
-0@@ -1428,12 +1430,6 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) flush_map_nopaths(mpp, vecs)) goto out;multipathd/main.c +0
-3-if (setup_map (mpp, ¶ms, vecs)) { - condlog(0, "%s: failed to setup map for" - " removal of path %s", mpp->alias,
pp->dev);multipathd/main.c +0
-3- goto fail; - } -if (
mpp->wait_for_udev) {mpp->wait_for_udev= 2; retval =REMOVE_PATH_DELAY;multipathd/main.c +2
-0@@ -1444,33 +1440,35 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) retval = REMOVE_PATH_DELAY; goto out; } + +if (setup_map (mpp, ¶ms, vecs)) {
multipathd/main.c ev_remove_path (struct path *pp, struct · line 1455
Quoted 10 lines
multipathd/main.c +5
-0+condlog (0 ,"%s: failed to setup map for" +" removal of path %s" , mpp->alias, pp->dev); + goto fail; + } /* * reload the map */ mpp->action = ACT_RELOAD; +strlcpy (devt, pp->dev_t,sizeof (devt));
Move this statement further down, directly before the call to setup_multipath(), perhaps? It's only for the condlog anyway.
Except for that, LGTM.
Martin
Quoted 40 lines
multipathd/main.c +0
-0if (domap(mpp, params, 1) == DOMAP_FAIL) {
condlog(0, "%s: failed in domap for " "removal of path %s", mpp->alias, pp->dev); retval =REMOVE_PATH_FAILURE;multipathd/main.c +3
-14- }else { -/* -* update our state from kernel -*/ -char devt[BLK_DEV_SIZE ]; - -strlcpy (devt, pp->dev_t,sizeof (devt)); - -/* setup_multipath will free the path -* regardless of whether it succeeds or -* fails */ -if (setup_multipath (vecs, mpp)) -return REMOVE_PATH_MAP_ERROR ; -sync_map_state (mpp); + } +/* +* update mpp state from kernel even if domap failed.
multipathd/main.c +1
-0+* If the path was removed from the mpp,
setup_multipathwillmultipathd/main.c +1
-0+* free the path regardless of whether it succeeds or fails
multipathd/main.c +4
-0+*/ +if (setup_multipath (vecs, mpp)) +return REMOVE_PATH_MAP_ERROR ; +sync_map_state (mpp);multipathd/main.c +1
-0+if (retval ==REMOVE_PATH_SUCCESS )
condlog(2, "%s: path removed from map %s", devt, mpp->alias);multipathd/main.c +0
-1- }} else {
/* mpp == NULL */
if ((i =find_slot(vecs->pathvec, (void *)pp)) != -
1)
Benjamin Marzinski
maintainerRe: [PATCH 13/22] multipathd: resync map after setup_map in ev_remove_path
Quoted 61 lines · Martin Wilck
Quoted 60 lines · Benjamin Marzinski
In
ev_remove_path()it was possible to exit after callingsetup_map()without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all.It's safe to exit before calling
setup_map()if eitherwait_for_udevorneed_do_mapis set. In both cases,setup_map()will later be called,
either by a uevent or by the calling function.Once
setup_map()has been called,setup_multipath()andsync_map_state()
are now always called, to make sure the mpp matches the kernel state.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/main.c | 40 +++++++++++++++++++---------------------1 file changed, 19 insertions(+), 21 deletions(-)multipathd/main.c +2
-0@@ -1395,6 +1395,8 @@ ev_remove_path (struct path *pp, struct vectors* vecs, int need_do_map) * avoid referring to the map of an orphaned path */ if ((mpp = pp->mpp)) { +char devt[BLK_DEV_SIZE ]; + /** Mark the path as removed. In case of success, we * will delete it for good. Otherwise, it will be deleted
multipathd/main.c +0
-0@@ -1428,12 +1430,6 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) flush_map_nopaths(mpp, vecs)) goto out;multipathd/main.c +0
-3-if (setup_map (mpp, ¶ms, vecs)) { - condlog(0, "%s: failed to setup map for" - " removal of path %s", mpp->alias,
pp->dev);multipathd/main.c +0
-3- goto fail; - } -if (
mpp->wait_for_udev) {mpp->wait_for_udev= 2; retval =REMOVE_PATH_DELAY;multipathd/main.c +6
-0@@ -1444,33 +1440,35 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) retval = REMOVE_PATH_DELAY; goto out; } + +if (setup_map (mpp, ¶ms, vecs)) { +condlog (0 ,"%s: failed to setup map for" +" removal of path %s" , mpp->alias, pp->dev); + goto fail; + }
Quoted 9 lines
multipathd/main.c ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) · line 1453
Quoted 5 lines
multipathd/main.c +1
-0/* * reload the map */ mpp->action = ACT_RELOAD; +strlcpy (devt, pp->dev_t,sizeof (devt));Move this statement further down, directly before the call to
setup_multipath(), perhaps? It's only for the condlog anyway.
Sure.
Quoted 45 lines
Except for that, LGTM.
Martin
Quoted 40 lines
multipathd/main.c +0
-0if (domap(mpp, params, 1) == DOMAP_FAIL) {
condlog(0, "%s: failed in domap for " "removal of path %s", mpp->alias, pp->dev); retval =REMOVE_PATH_FAILURE;multipathd/main.c +3
-14- }else { -/* -* update our state from kernel -*/ -char devt[BLK_DEV_SIZE ]; - -strlcpy (devt, pp->dev_t,sizeof (devt)); - -/* setup_multipath will free the path -* regardless of whether it succeeds or -* fails */ -if (setup_multipath (vecs, mpp)) -return REMOVE_PATH_MAP_ERROR ; -sync_map_state (mpp); + } +/* +* update mpp state from kernel even if domap failed.
multipathd/main.c +1
-0+* If the path was removed from the mpp,
setup_multipathwillmultipathd/main.c +1
-0+* free the path regardless of whether it succeeds or fails
multipathd/main.c +4
-0+*/ +if (setup_multipath (vecs, mpp)) +return REMOVE_PATH_MAP_ERROR ; +sync_map_state (mpp);multipathd/main.c +1
-0+if (retval ==REMOVE_PATH_SUCCESS )
condlog(2, "%s: path removed from map %s", devt, mpp->alias);multipathd/main.c +0
-1- }} else {
/* mpp == NULL */
if ((i =find_slot(vecs->pathvec, (void *)pp)) != -
1)
Benjamin Marzinski
maintainerPATCH 14/22 multipathd: resync map after setup_map in resize_map
In reply to Benjamin MarzinskiIn resize_map() it was possible to exit after calling setup_map() without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all.
Once setup_map() has been called, setup_multipath() and sync_map_state() are now always called, to make sure the mpp matches the kernel state.
--- multipathd/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
multipathd/main.c +6 -3
@@ -1534,6 +1534,7 @@ needs_ro_update(struct multipath *mpp, int ro)int resize_map (struct multipath *mpp,unsigned long long size,struct vectors * vecs) { +int ret =0 ; char *params __attribute__((cleanup(cleanup_charp))) = NULL;unsigned long long orig_size = mpp->size;
@@ -1543,7 +1544,8 @@ int resize_map(struct multipath *mpp, unsigned long long size,condlog (0 ,"%s: failed to setup map for resize : %s" , mpp->alias,strerror (errno)); mpp->size = orig_size; -return 1 ; + ret =1 ; + goto out; } mpp->action =ACT_RESIZE ; mpp->force_udev_reload =1 ;
@@ -1551,13 +1553,14 @@ int resize_map(struct multipath *mpp, unsigned long long size,condlog (0 ,"%s: failed to resize map : %s" , mpp->alias,strerror (errno)); mpp->size = orig_size; -return 1 ; + ret =1 ; } +out:if (setup_multipath (vecs, mpp) !=0 )return 2 ;sync_map_state (mpp); -return 0 ; +return ret; } static int
Signature · 1 line
2.45.0
Benjamin Marzinski
maintainerPATCH 15/22 multipathd: always resync map in reload_and_sync_map
In reply to Benjamin Marzinskireload_and_sync_map() needs to always resync the map after calling reload_map(), because the mpp state may no longer match the kernel state if reload_map() fails.
--- multipathd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
multipathd/main.c +4 -2
@@ -2188,13 +2188,15 @@ static int reload_map(struct vectors *vecs, struct multipath *mpp,int reload_and_sync_map (struct multipath *mpp,struct vectors *vecs) { +int ret =0 ; +if (reload_map (vecs, mpp,1 )) -return 1 ; + ret =1 ;if (setup_multipath (vecs, mpp) !=0 )return 2 ;sync_map_state (mpp); -return 0 ; +return ret; }static int check_path_reinstate_state (struct path * pp) {
Signature · 1 line
2.45.0
Re: [PATCH 15/22] multipathd: always resync map in reload_and_sync_map
Quoted 5 lines · Benjamin Marzinski
reload_and_sync_map()needs to always resync the map after callingreload_map(), because the mpp state may no longer match the kernel state ifreload_map()fails.Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH 16/22 multipathd: correctly handle paths removed for a wwid change
In reply to Benjamin MarzinskiIf check_path() exitted because the path's wwid changed and it was removed, checkerloop() wasn't decrementing the pathvec loop count. This caused the next path to be skipped by the checker loop.
To solve this, make check_path() return -1 when a path is removed, make handle_uninitialized_path() also remove the path if it was blacklisted, and make checkerloop() just decrement the loop count when a path returns -1.
--- multipathd/main.c | 33 ++++++++++++++++++++------------- multipathd/main.h | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-)
multipathd/main.c +20 -13
@@ -974,20 +974,24 @@ rescan_path(struct udev_device *ud) } } -void +/* Returns true if the path was removed */ +bool handle_path_wwid_change (struct path *pp,struct vectors *vecs) {struct udev_device *udd;static const char add[] ="add" ;ssize_t ret;char dev[FILE_NAME_SIZE ]; +bool removed = false;if (!pp || !pp->udev) -return ; +return removed;strlcpy (dev, pp->dev,sizeof (dev)); udd =udev_device_ref (pp->udev); -if (!(ev_remove_path (pp, vecs,1 ) &REMOVE_PATH_SUCCESS ) && pp->mpp) { +if (ev_remove_path (pp, vecs,1 ) &REMOVE_PATH_SUCCESS ) { + removed = true; + }else if (pp->mpp) { pp->dmstate =PSTATE_FAILED ;dm_fail_path (pp->mpp->alias, pp->dev_t); }
@@ -997,6 +1001,7 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs)if (ret !=sizeof (add) -1 )log_sysfs_attr_set_value (1 , ret,"%s: failed to trigger add event" , dev); +return removed; }bool
@@ -2377,7 +2382,8 @@ check_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) }/* -* Returns '1' if the path has been checked and '0' otherwise +* Returns '1' if the path has been checked, -1 if the path was removed, +* and '0' otherwise */ static int check_path (struct vectors * vecs,struct path * pp,unsigned int ticks)
@@ -2434,8 +2440,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->dmstate == PSTATE_FAILED) && check_path_wwid_change(pp)) {condlog (0 ,"%s: path wwid change detected. Removing" , pp->dev); -handle_path_wwid_change (pp, vecs); -return 0 ; +return handle_path_wwid_change (pp, vecs)?-1 :0 ; }if (!pp->mpp->is_checked) {do_check_mpp (vecs, pp->mpp);
@@ -2635,7 +2640,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) }/* -* Returns -1 if the path was blacklisted, and 0 otherwise +* Returns -1 if the path was removed, and 0 otherwise */ static int handle_uninitialized_path(struct vectors * vecs, struct path * pp,
@@ -2706,6 +2711,12 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp,ev_add_path (pp, vecs,1 ); pp->tick =1 ; }else if (ret ==PATHINFO_SKIPPED ) { +int i; + +condlog (1 ,"%s: path blacklisted. removing" , pp->dev); +if ((i =find_slot (vecs->pathvec, (void *)pp)) !=-1 ) +vector_del_slot (vecs->pathvec, i); +free_path (pp);return -1 ; } }
@@ -2794,13 +2805,9 @@ checkerloop (void *ap)else rc =handle_uninitialized_path (vecs, pp, ticks); -if (rc <0 ) { -condlog (1 ,"%s: check_path() failed, removing" , - pp->dev); -vector_del_slot (vecs->pathvec, i); -free_path (pp); +if (rc <0 ) i--; - }else +else num_paths += rc; if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) ||
multipathd/main.h +1 -1
@@ -47,7 +47,7 @@ int setup_multipath(struct vectors * vecs, struct multipath * mpp);int update_multipath (struct vectors *vecs,char *mapname);int reload_and_sync_map (struct multipath *mpp,struct vectors *vecs); -void handle_path_wwid_change (struct path *pp,struct vectors *vecs); +bool handle_path_wwid_change (struct path *pp,struct vectors *vecs);bool check_path_wwid_change (struct path *pp);int finish_path_init (struct path *pp,struct vectors * vecs); int resize_map(struct multipath *mpp, unsigned long long size,
Signature · 1 line
2.45.0
Re: [PATCH 16/22] multipathd: correctly handle paths removed for a wwid change
Quoted 10 lines · Benjamin Marzinski
If
check_path()exitted because the path's wwid changed and it was removed,checkerloop()wasn't decrementing the pathvec loop count. This caused the next path to be skipped by the checker loop.To solve this, make
check_path()return -1 when a path is removed, makehandle_uninitialized_path()also remove the path if it was blacklisted, and makecheckerloop()just decrement the loop count when a path returns -1.Signed-off-by Benjamin Marzinski <[email protected]>
Would you mind making these return values symbolic? Other than that, LGTM.
Martin
Benjamin Marzinski
maintainerRe: [PATCH 16/22] multipathd: correctly handle paths removed for a wwid change
Quoted 10 lines · Martin Wilck
Quoted 9 lines · Benjamin Marzinski
If
check_path()exitted because the path's wwid changed and it was removed,checkerloop()wasn't decrementing the pathvec loop count. This caused the next path to be skipped by the checker loop.To solve this, make
check_path()return -1 when a path is removed, makehandle_uninitialized_path()also remove the path if it was blacklisted, and makecheckerloop()just decrement the loop count when a path returns -1.
Quoted 4 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Would you mind making these return values symbolic? Other than that, LGTM.
Yeah, I can do that.
Quoted 2 lines
Martin
Benjamin Marzinski
maintainerPATCH 17/22 multipathd: handle changed wwid when adding partial path
In reply to Benjamin MarzinskiIf multipathd noticed that the WWID didn't match the device when adding a partial path, but removing it failed, multipathd wasn't disabling the path. Instead of calling handle_path_wwid_change(), which doesn't make much sense when multipathd is expecting a uevent, just manually disable the path if ev_remove_path() fails.
--- multipathd/cli_handlers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
multipathd/cli_handlers.c +5 -1
@@ -540,7 +540,11 @@ add_partial_path(struct path *pp, struct vectors *vecs)if (strlen (wwid) &&strncmp (wwid, pp->wwid,WWID_SIZE ) !=0 ) {condlog (0 ,"%s: path wwid changed from '%s' to '%s'. removing" , pp->dev, wwid, pp->wwid); -ev_remove_path (pp, vecs,1 ); +if (!(ev_remove_path (pp, vecs,1 ) &REMOVE_PATH_SUCCESS ) && + pp->mpp) { + pp->dmstate =PSTATE_FAILED ; +dm_fail_path (pp->mpp->alias, pp->dev_t); + }udev_device_unref (udd);return -1 ; }
Signature · 1 line
2.45.0
Re: [PATCH 17/22] multipathd: handle changed wwid when adding partial path
Quoted 33 lines · Benjamin Marzinski
If multipathd noticed that the WWID didn't match the device when adding
a partial path, but removing it failed, multipathd wasn't disabling the
path. Instead of callinghandle_path_wwid_change(), which doesn't make
much sense when multipathd is expecting a uevent, just manually disable
the path ifev_remove_path()fails.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/cli_handlers.c | 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)multipathd/cli_handlers.c +0
-0@@ -540,7 +540,11 @@ add_partial_path(struct path *pp, struct vectors *vecs) if (strlen(wwid) && strncmp(wwid, pp->wwid, WWID_SIZE) != 0) {condlog(0, "%s: path wwid changed from '%s' to '%s'. removing",
pp->dev, wwid,pp->wwid);multipathd/cli_handlers.c +1
-1-ev_remove_path (pp, vecs,1 ); + if (!(ev_remove_path(pp, vecs, 1) &
REMOVE_PATH_SUCCESS) &&multipathd/cli_handlers.c +4
-0+ pp->mpp) { + pp->dmstate =PSTATE_FAILED ; +dm_fail_path (pp->mpp->alias, pp->dev_t); + }
Quoted 3 lines
udev_device_unref(udd);
return -1;
}
Is this sufficient? Can we be certain that this path won't be reinstated by sync_map_state() later on? That's at least not immediately obvious. Perhaps we should orphan the path?
Martin
Benjamin Marzinski
maintainerRe: [PATCH 17/22] multipathd: handle changed wwid when adding partial path
Quoted 34 lines · Martin Wilck
Quoted 33 lines · Benjamin Marzinski
If multipathd noticed that the WWID didn't match the device when adding
a partial path, but removing it failed, multipathd wasn't disabling the
path. Instead of callinghandle_path_wwid_change(), which doesn't make
much sense when multipathd is expecting a uevent, just manually disable
the path ifev_remove_path()fails.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/cli_handlers.c | 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)multipathd/cli_handlers.c +0
-0@@ -540,7 +540,11 @@ add_partial_path(struct path *pp, struct vectors *vecs) if (strlen(wwid) && strncmp(wwid, pp->wwid, WWID_SIZE) != 0) {condlog(0, "%s: path wwid changed from '%s' to '%s'. removing",
pp->dev, wwid,pp->wwid);multipathd/cli_handlers.c +1
-1-ev_remove_path (pp, vecs,1 ); + if (!(ev_remove_path(pp, vecs, 1) &
REMOVE_PATH_SUCCESS) &&multipathd/cli_handlers.c +4
-0+ pp->mpp) { + pp->dmstate =PSTATE_FAILED ; +dm_fail_path (pp->mpp->alias, pp->dev_t); + }
Quoted 8 lines
Quoted 3 lines
udev_device_unref(udd);
return -1;
}Is this sufficient? Can we be certain that this path won't be reinstated by
sync_map_state()later on? That's at least not immediately obvious. Perhaps we should orphan the path?
We can't orphan the path completely. That's why ev_remove_path() calls set_path_removed(), which keeps track of the fact it's still in the mpp, so that we can complete the removal once it is actually removed from the multipath device. Otherwise multipathd could just add it to another device, while it was still part of the old device.
But you are correct about sync_map_state(). Good catch. We usually never need to worry about sync_map_state() restoring paths in INIT_REMOVED, since they really have been removed. In this case we do. We should probably be setting pp->state to PATH_UNCHECKED in orphan_path() anyway, which will keep sync_map_state() from restoring it. Since the path is in INIT_REMOVED, check_path will never update it's state. But sync_map_state() should also be ignoring paths in INIT_REMOVED. I vote we do both.
-Ben
Quoted 2 lines
Martin
Benjamin Marzinski
maintainerPATCH 18/22 multipathd: don't read conf->checkint twice in check_path
In reply to Benjamin Marzinskicheck_path() already has saved the value of conf->checkint in the local variable checkint, so there's no reason to read it again.
--- multipathd/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
multipathd/main.c +1 -3
@@ -2510,9 +2510,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)* upon state change, reset the checkint * to the shortest delay */ - conf =get_multipath_config (); - pp->checkint = conf->checkint; -put_multipath_config (conf); + pp->checkint = checkint;if (newstate !=PATH_UP && newstate !=PATH_GHOST ) {/*
Signature · 1 line
2.45.0
Re: [PATCH 18/22] multipathd: don't read conf->checkint twice in check_path
Quoted 5 lines · Benjamin Marzinski
check_path()already has saved the value ofconf->checkintin the local
variable checkint, so there's no reason to read it again.Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH 19/22 multipathd: make multipath devices manage their path check times
In reply to Benjamin Marzinskimultipathd's path checking can be very bursty, with all the paths running their path checkers at the same time, and then all doing nothing while waiting for the next check time. Alternatively, the paths in a multipath device might all run their path checkers at a different time, which can keep the multipath device from having a coherent view of the state of all of its paths.
This patch makes all the paths of a multipath device converge to running their checkers at the same time, and spreads out when this time is for the different multipath devices.
To do this, the checking time is divided into adjustment intervals (conf->adjust_int), so that the checkers run at some index within this interval. conf->adjust_int is chosen so that it is at least twice as long as conf->max_checkint, and is a multiple of all possible pp->checkint values. This means that regardless of pp->checkint, the path should always be checked on the same indexes, each adjustement interval.
Each multipath device has a goal index. These are evenly spread out between 0 and conf->max_checkint. Every conf->adjust_int seconds, each multipath device should try to check all of its paths on its goal index. If a path isn't checked on the goal index, then pp->tick for the next check after the goal_idx will be decremented by one, to align it over time.
In order for the path checkers to run every pp->checkint seconds, multipathd needs to track how long a path check has been pending for, and subtract that time from the number of ticks till the checker is run again. If the checker has been pending for more that pp->checkint, the path will be rechecked on the next tick after the checker returns.
--- libmultipath/config.c | 13 ++++++ libmultipath/config.h | 1 + libmultipath/structs.c | 1 + libmultipath/structs.h | 1 + multipathd/main.c | 90 ++++++++++++++++++++++++++++++++++-------- 5 files changed, 89 insertions(+), 17 deletions(-)
libmultipath/config.c +13 -0
@@ -982,6 +982,19 @@ int _init_config (const char *file, struct config *conf) conf->checkint = conf->max_checkint;condlog (3 ,"polling interval: %d, max: %d" , conf->checkint, conf->max_checkint); +/* +* make sure that that adjust_int is at least twice as large +* as checkint and is a multiple of all possible values of +* pp->checkint. +*/ +if (conf->max_checkint % conf->checkint ==0 ) { + conf->adjust_int =2 * conf->max_checkint; + }else { + conf->adjust_int = conf->checkint; +while (2 * conf->adjust_int < conf->max_checkint) + conf->adjust_int *=2 ; + conf->adjust_int *= conf->max_checkint; + }if (conf->blist_devnode ==NULL ) { conf->blist_devnode =vector_alloc ();
libmultipath/config.h +1 -0
@@ -147,6 +147,7 @@ struct config {int minio_rq;unsigned int checkint;unsigned int max_checkint; +unsigned int adjust_int;bool use_watchdog;int pgfailback;int rr_weight;
libmultipath/structs.c +1 -0
@@ -148,6 +148,7 @@ uninitialize_path(struct path *pp) pp->dmstate =PSTATE_UNDEF ; pp->uid_attribute =NULL ; pp->checker_timeout =0 ; + pp->pending_ticks =0 ;if (checker_selected (&pp->checker))checker_put (&pp->checker);
libmultipath/structs.h +1 -0
@@ -360,6 +360,7 @@ struct path {unsigned long long size;unsigned int checkint;unsigned int tick; +unsigned int pending_ticks;int bus;int offline;int state;
multipathd/main.c +73 -17
126 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH 19/22] multipathd: make multipath devices manage their path check times
Quoted 42 lines · Benjamin Marzinski
multipathd's path checking can be very bursty, with all the paths running their path checkers at the same time, and then all doing nothing
while waiting for the next check time. Alternatively, the paths in a multipath device might all run their path checkers at a different time,
which can keep the multipath device from having a coherent view of the
state of all of its paths.This patch makes all the paths of a multipath device converge to running
their checkers at the same time, and spreads out when this time is for
the different multipath devices.To do this, the checking time is divided into adjustment intervals (
conf->adjust_int), so that the checkers run at some index within this
interval.conf->adjust_intis chosen so that it is at least twice as long asconf->max_checkint, and is a multiple of all possiblepp->checkintvalues. This means that regardless ofpp->checkint, the path should always be checked on the same indexes, each adjustement interval.Each multipath device has a goal index. These are evenly spread out between 0 and
conf->max_checkint. Everyconf->adjust_intseconds, each
multipath device should try to check all of its paths on its goal index.
If a path isn't checked on the goal index, thenpp->tickfor the next check after thegoal_idxwill be decremented by one, to align it over time.In order for the path checkers to run every
pp->checkintseconds, multipathd needs to track how long a path check has been pending for, and subtract that time from the number of ticks till the checker is run
again. If the checker has been pending for more thatpp->checkint, the path will be rechecked on the next tick after the checker returns.
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>
Nice, thanks a lot. I have a few remarks below.
Quoted 155 lines
---
libmultipath/config.c | 13 ++++++
libmultipath/config.h | 1 +
libmultipath/structs.c | 1 +
libmultipath/structs.h | 1 +
multipathd/main.c | 90 ++++++++++++++++++++++++++++++++++------ --5 files changed, 89 insertions(+), 17 deletions(-)libmultipath/config.c +13
-0@@ -982,6 +982,19 @@ int _init_config (const char *file, struct config *conf) conf->checkint = conf->max_checkint; condlog(3, "polling interval: %d, max: %d", conf->checkint, conf->max_checkint); +/* +* make sure that that adjust_int is at least twice as large +* as checkint and is a multiple of all possible values of +* pp->checkint. +*/ +if (conf->max_checkint % conf->checkint ==0 ) { + conf->adjust_int =2 * conf->max_checkint; + }else { + conf->adjust_int = conf->checkint; +while (2 * conf->adjust_int < conf->max_checkint) + conf->adjust_int *=2 ; + conf->adjust_int *= conf->max_checkint; + }
if (conf->blist_devnode== NULL) {conf->blist_devnode=vector_alloc();libmultipath/config.h +1
-0@@ -147,6 +147,7 @@ struct config { int minio_rq; unsigned int checkint; unsigned int max_checkint; +unsigned int adjust_int; bool use_watchdog; int pgfailback; int rr_weight;libmultipath/structs.c +1
-0@@ -148,6 +148,7 @@ uninitialize_path(struct path *pp) pp->dmstate = PSTATE_UNDEF; pp->uid_attribute = NULL; pp->checker_timeout = 0; + pp->pending_ticks =0 ;
if (checker_selected(&pp->checker))
checker_put(&pp->checker);libmultipath/structs.h +1
-0@@ -360,6 +360,7 @@ struct path { unsigned long long size; unsigned int checkint; unsigned int tick; +unsigned int pending_ticks; int bus; int offline; int state;multipathd/main.c +0
-0@@ -2386,7 +2386,7 @@ check_mpp(struct vectors * vecs, structmultipath *mpp, unsigned int ticks) * and '0' otherwise */ static int
-check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
+do_check_path (struct vectors * vecs, struct path * pp) {
int newstate;
intnew_path_up= 0;multipathd/main.c +0
-0@@ -2398,14 +2398,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) int marginal_pathgroups, marginal_changed = 0; bool need_reload;multipathd/main.c +0
-8-if (pp->initialized ==INIT_REMOVED ) -return 0 ; - -if (pp->tick) - pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; -if (pp->tick) -return 0 ;/* don't check this path yet */ -conf =
get_multipath_config();
checkint =conf->checkint;
max_checkint=conf->max_checkint;multipathd/main.c +0
-0@@ -2417,12 +2409,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; };multipathd/main.c +0
-6-/* -* provision a next check soonest, -* in case we exit abnormally from here -*/ - pp->tick = checkint; -newstate =
check_path_state(pp);
if (newstate ==PATH_WILD|| newstate ==PATH_UNCHECKED) return 0;multipathd/main.c +0
-0@@ -2584,7 +2570,6 @@ check_path (struct vectors * vecs, struct path* pp, unsigned int ticks) condlog(4, "%s: delay next check %is",
pp->dev_t,pp->checkint); }multipathd/main.c +0
-1- pp->tick = pp->checkint;}
}
else if (newstate !=PATH_UP&& newstate !=PATH_GHOST) {multipathd/main.c +0
-0@@ -2637,6 +2622,76 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 1; }multipathd/main.c +2
-0+static int +check_path (struct vectors * vecs, struct path * pp, unsigned intticks,
multipathd/main.c +22
-0+ time_t start_secs) +{ +int r; +unsigned int adjust_int, max_checkint; +struct config *conf; +time_t next_idx, goal_idx; + +if (pp->initialized ==INIT_REMOVED ) +return 0 ; + +if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; +if (pp->tick) +return 0 ;/* don't check this path yet */ + + conf =get_multipath_config (); + max_checkint = conf->max_checkint; + adjust_int = conf->adjust_int; +put_multipath_config (conf); + + r =do_check_path (vecs, pp); +
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2658
Quoted 10 lines
multipathd/main.c +10
-0+/* +* do_check_path() removed or orphaned the path. +*/ +if (r <0 || !pp->mpp) +return r; + +/* +* the path checker is pending +*/ +if (pp->tick !=0 ) {
I'm not getting this logic. Please explain. Why is pp->tick != 0 at this point equivalent to the checker being pending?
Quoted 36 lines
multipathd/main.c +23
-0+ pp->pending_ticks++; +return r; + } + +/* schedule the next check */ + pp->tick = pp->checkint; +if (pp->pending_ticks >= pp->tick) + pp->tick =1 ; +else + pp->tick -= pp->pending_ticks; + pp->pending_ticks =0 ; + +if (pp->tick ==1 ) +return r; + +/* +* every mpp has a goal_idx in the range of +* 0 <= goal_idx < conf->max_checkint +* +* The next check has an index, next_idx, in the range of +* 0 <= next_idx < conf->adjust_int +* +* Every adjust_int seconds, each multipath device should try to
multipathd/main.c +1
-0+* check all of its paths on its goal_idx. If a path isn't checked
multipathd/main.c +1
-0+* on the goal_idx, then pp->tick for the next check after the
multipathd/main.c +1
-0+* goal_idx will be decremented by one, to align it over time.
multipathd/main.c +5
-0+*/ + goal_idx = (find_slot (vecs->mpvec, pp->mpp)) * + max_checkint / VECTOR_SIZE(vecs->mpvec); + next_idx = (start_secs + pp->tick) % adjust_int; + if (next_idx > goal_idx && next_idx - goal_idx < pp-Quoted 1 line
checkint)
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2690
Quoted 1 line
multipathd/main.c +1
-0+ pp->tick--;
Hm. IMHO this calculation should be little simpler, as follows:
cur_idx = start_secs % adjust_int;
if ((goal_idx - cur_idx) % pp->checkint != 0)
pp->tick--;My reasoning goes like this: If (goal_idx - cur_idx) % pp->checkint is 0, we need no adjustment, because (assuming checkint remains constant) it will be checked at the next goal_idx. Otherwise, we check one tick earlier, and will do so at the next check again, etc. This is similar to your approach, but not exactly the same, AFAICS. In particular, I am unsure about your "if (next_idx - goal_idx < pp->checkint)" condition.
If checkint grows toward max_checkint, it may take longer until this algorithm converges, but sooner or later, it should.
Instead of stepping, we could also force the idx immediately, by doing
pp->tick -= (goal_idx - cur_idx) % pp->checkint;
which would be even simpler (the check intervals would be less evenly spaced, but I don't think that would hurt us much).
Am I misguided here?
Regards
Martin
Re: [PATCH 19/22] multipathd: make multipath devices manage their path check times
Quoted 264 lines · Martin Wilck
Quoted 48 lines · Benjamin Marzinski
multipathd's path checking can be very bursty, with all the paths running their path checkers at the same time, and then all doing nothing
while waiting for the next check time. Alternatively, the paths in a
multipath device might all run their path checkers at a different time,
which can keep the multipath device from having a coherent view of the
state of all of its paths.This patch makes all the paths of a multipath device converge to running
their checkers at the same time, and spreads out when this time is for
the different multipath devices.To do this, the checking time is divided into adjustment intervals (
conf->adjust_int), so that the checkers run at some index within this
interval.conf->adjust_intis chosen so that it is at least twice as
long asconf->max_checkint, and is a multiple of all possiblepp->checkintvalues. This means that regardless ofpp->checkint, the
path should always be checked on the same indexes, each adjustement interval.Each multipath device has a goal index. These are evenly spread out between 0 and
conf->max_checkint. Everyconf->adjust_intseconds, each
multipath device should try to check all of its paths on its goal index.
If a path isn't checked on the goal index, thenpp->tickfor the next
check after thegoal_idxwill be decremented by one, to align it over
time.In order for the path checkers to run every
pp->checkintseconds, multipathd needs to track how long a path check has been pending for,
and subtract that time from the number of ticks till the checker is run
again. If the checker has been pending for more thatpp->checkint, the path will be rechecked on the next tick after the checker returns.Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Nice, thanks a lot. I have a few remarks below.
Quoted 161 lines
---
libmultipath/config.c | 13 ++++++ libmultipath/config.h | 1 +
libmultipath/structs.c | 1 +
libmultipath/structs.h | 1 +
multipathd/main.c | 90 ++++++++++++++++++++++++++++++++++---- --
--5 files changed, 89 insertions(+), 17 deletions(-)libmultipath/config.c +2
-0@@ -982,6 +982,19 @@ int _init_config (const char *file, struct config *conf) conf->checkint = conf->max_checkint; condlog(3, "polling interval: %d, max: %d", conf->checkint, conf->max_checkint); +/* +* make sure that that adjust_int is at least twice as large
libmultipath/config.c +11
-0+* as checkint and is a multiple of all possible values of +* pp->checkint. +*/ +if (conf->max_checkint % conf->checkint ==0 ) { + conf->adjust_int =2 * conf->max_checkint; + }else { + conf->adjust_int = conf->checkint; +while (2 * conf->adjust_int < conf->max_checkint) + conf->adjust_int *=2 ; + conf->adjust_int *= conf->max_checkint; + }
if (conf->blist_devnode== NULL) {conf->blist_devnode=vector_alloc();libmultipath/config.h +1
-0@@ -147,6 +147,7 @@ struct config { int minio_rq; unsigned int checkint; unsigned int max_checkint; +unsigned int adjust_int; bool use_watchdog; int pgfailback; int rr_weight;libmultipath/structs.c +1
-0@@ -148,6 +148,7 @@ uninitialize_path(struct path *pp) pp->dmstate = PSTATE_UNDEF; pp->uid_attribute = NULL; pp->checker_timeout = 0; + pp->pending_ticks =0 ;
if (checker_selected(&pp->checker))
checker_put(&pp->checker);libmultipath/structs.h +1
-0@@ -360,6 +360,7 @@ struct path { unsigned long long size; unsigned int checkint; unsigned int tick; +unsigned int pending_ticks; int bus; int offline; int state;multipathd/main.c +0
-0@@ -2386,7 +2386,7 @@ check_mpp(struct vectors * vecs, structmultipath *mpp, unsigned int ticks) * and '0' otherwise */ static int
-check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
+do_check_path (struct vectors * vecs, struct path * pp) {
int newstate;
intnew_path_up= 0;multipathd/main.c +0
-0@@ -2398,14 +2398,6 @@ check_path (struct vectors * vecs, structpath
* pp, unsigned int ticks)
intmarginal_pathgroups,marginal_changed= 0; boolneed_reload;multipathd/main.c +0
-8-if (pp->initialized ==INIT_REMOVED ) -return 0 ; - -if (pp->tick) - pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; -if (pp->tick) -return 0 ;/* don't check this path yet */ -conf =
get_multipath_config();
checkint =conf->checkint;
max_checkint=conf->max_checkint;multipathd/main.c +0
-0@@ -2417,12 +2409,6 @@ check_path (struct vectors * vecs, structpath
* pp, unsigned int ticks)
pp->checkint= checkint;
};multipathd/main.c +0
-6-/* -* provision a next check soonest, -* in case we exit abnormally from here -*/ - pp->tick = checkint; -newstate =
check_path_state(pp);
if (newstate ==PATH_WILD|| newstate ==PATH_UNCHECKED) return 0;multipathd/main.c +0
-0@@ -2584,7 +2570,6 @@ check_path (struct vectors * vecs, structpath
* pp, unsigned int ticks)
condlog(4, "%s: delay next check %is",
pp->dev_t,pp->checkint); }multipathd/main.c +0
-1- pp->tick = pp->checkint;}
}
else if (newstate !=PATH_UP&& newstate !=PATH_GHOST) {multipathd/main.c +0
-0@@ -2637,6 +2622,76 @@ check_path (struct vectors * vecs, structpath
* pp, unsigned int ticks)
return 1;
}multipathd/main.c +2
-0+static int +check_path (struct vectors * vecs, struct path * pp, unsigned intticks,
multipathd/main.c +22
-0+ time_t start_secs) +{ +int r; +unsigned int adjust_int, max_checkint; +struct config *conf; +time_t next_idx, goal_idx; + +if (pp->initialized ==INIT_REMOVED ) +return 0 ; + +if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; +if (pp->tick) +return 0 ;/* don't check this path yet */ + + conf =get_multipath_config (); + max_checkint = conf->max_checkint; + adjust_int = conf->adjust_int; +put_multipath_config (conf); + + r =do_check_path (vecs, pp); +multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2658
Quoted 10 lines
multipathd/main.c +10
-0+/* +* do_check_path() removed or orphaned the path. +*/ +if (r <0 || !pp->mpp) +return r; + +/* +* the path checker is pending +*/ +if (pp->tick !=0 ) {I'm not getting this logic. Please explain. Why is
pp->tick!= 0 at this point equivalent to the checker being pending?Quoted 35 lines
multipathd/main.c +23
-0+ pp->pending_ticks++; +return r; + } + +/* schedule the next check */ + pp->tick = pp->checkint; +if (pp->pending_ticks >= pp->tick) + pp->tick =1 ; +else + pp->tick -= pp->pending_ticks; + pp->pending_ticks =0 ; + +if (pp->tick ==1 ) +return r; + +/* +* every mpp has a goal_idx in the range of +* 0 <= goal_idx < conf->max_checkint +* +* The next check has an index, next_idx, in the range of +* 0 <= next_idx < conf->adjust_int +* +* Every adjust_int seconds, each multipath device should try to
multipathd/main.c +1
-0+* check all of its paths on its goal_idx. If a path isn't checked
multipathd/main.c +1
-0+* on the goal_idx, then pp->tick for the next check after the
multipathd/main.c +1
-0+* goal_idx will be decremented by one, to align it over time.
multipathd/main.c +5
-0+*/ + goal_idx = (find_slot (vecs->mpvec, pp->mpp)) * + max_checkint / VECTOR_SIZE(vecs->mpvec); + next_idx = (start_secs + pp->tick) % adjust_int; + if (next_idx > goal_idx && next_idx - goal_idx < pp-
Quoted 2 lines
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2690
Quoted 2 lines
Quoted 1 line
checkint)
multipathd/main.c +1
-0+ pp->tick--;
This code raises compilation errors on some architectures, see
https://github.com/openSUSE/multipath-tools/actions/runs/9942603306/job/27464440204
Martin
Benjamin Marzinski
maintainerRe: [PATCH 19/22] multipathd: make multipath devices manage their path check times
Quoted 5 lines · Martin Wilck
Quoted 4 lines · Martin Wilck
Quoted 2 lines · Benjamin Marzinski
(quoted diff) +2
-0+ next_idx = (start_secs + pp->tick) % adjust_int; + if (next_idx > goal_idx && next_idx - goal_idx < pp-
Quoted 7 lines
Quoted 2 lines
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2690
Quoted 2 lines
Quoted 1 line
checkint)
multipathd/main.c +1
-0+ pp->tick--;This code raises compilation errors on some architectures, see
https://github.com/openSUSE/multipath-tools/actions/runs/9942603306/job/27464440204Martin
Thanks. Switching to your modulo idea for checking offset will avoid this.
-Ben
Benjamin Marzinski
maintainerRe: [PATCH 19/22] multipathd: make multipath devices manage their path check times
In reply to Martin WilckQuoted 208 lines · Martin Wilck
Quoted 42 lines · Benjamin Marzinski
multipathd's path checking can be very bursty, with all the paths running their path checkers at the same time, and then all doing nothing
while waiting for the next check time. Alternatively, the paths in a multipath device might all run their path checkers at a different time,
which can keep the multipath device from having a coherent view of the
state of all of its paths.This patch makes all the paths of a multipath device converge to running
their checkers at the same time, and spreads out when this time is for
the different multipath devices.To do this, the checking time is divided into adjustment intervals (
conf->adjust_int), so that the checkers run at some index within this
interval.conf->adjust_intis chosen so that it is at least twice as long asconf->max_checkint, and is a multiple of all possiblepp->checkintvalues. This means that regardless ofpp->checkint, the path should always be checked on the same indexes, each adjustement interval.Each multipath device has a goal index. These are evenly spread out between 0 and
conf->max_checkint. Everyconf->adjust_intseconds, each
multipath device should try to check all of its paths on its goal index.
If a path isn't checked on the goal index, thenpp->tickfor the next check after thegoal_idxwill be decremented by one, to align it over time.In order for the path checkers to run every
pp->checkintseconds, multipathd needs to track how long a path check has been pending for, and subtract that time from the number of ticks till the checker is run
again. If the checker has been pending for more thatpp->checkint, the path will be rechecked on the next tick after the checker returns.Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Nice, thanks a lot. I have a few remarks below.
Quoted 160 lines
---
libmultipath/config.c | 13 ++++++
libmultipath/config.h | 1 +
libmultipath/structs.c | 1 +
libmultipath/structs.h | 1 +
multipathd/main.c | 90 ++++++++++++++++++++++++++++++++++------ --5 files changed, 89 insertions(+), 17 deletions(-)libmultipath/config.c +13
-0@@ -982,6 +982,19 @@ int _init_config (const char *file, struct config *conf) conf->checkint = conf->max_checkint; condlog(3, "polling interval: %d, max: %d", conf->checkint, conf->max_checkint); +/* +* make sure that that adjust_int is at least twice as large +* as checkint and is a multiple of all possible values of +* pp->checkint. +*/ +if (conf->max_checkint % conf->checkint ==0 ) { + conf->adjust_int =2 * conf->max_checkint; + }else { + conf->adjust_int = conf->checkint; +while (2 * conf->adjust_int < conf->max_checkint) + conf->adjust_int *=2 ; + conf->adjust_int *= conf->max_checkint; + }
if (conf->blist_devnode== NULL) {conf->blist_devnode=vector_alloc();libmultipath/config.h +1
-0@@ -147,6 +147,7 @@ struct config { int minio_rq; unsigned int checkint; unsigned int max_checkint; +unsigned int adjust_int; bool use_watchdog; int pgfailback; int rr_weight;libmultipath/structs.c +1
-0@@ -148,6 +148,7 @@ uninitialize_path(struct path *pp) pp->dmstate = PSTATE_UNDEF; pp->uid_attribute = NULL; pp->checker_timeout = 0; + pp->pending_ticks =0 ;
if (checker_selected(&pp->checker))
checker_put(&pp->checker);libmultipath/structs.h +1
-0@@ -360,6 +360,7 @@ struct path { unsigned long long size; unsigned int checkint; unsigned int tick; +unsigned int pending_ticks; int bus; int offline; int state;multipathd/main.c +0
-0@@ -2386,7 +2386,7 @@ check_mpp(struct vectors * vecs, structmultipath *mpp, unsigned int ticks) * and '0' otherwise */ static int
-check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
+do_check_path (struct vectors * vecs, struct path * pp) {
int newstate;
intnew_path_up= 0;multipathd/main.c +0
-0@@ -2398,14 +2398,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) int marginal_pathgroups, marginal_changed = 0; bool need_reload;multipathd/main.c +0
-8-if (pp->initialized ==INIT_REMOVED ) -return 0 ; - -if (pp->tick) - pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; -if (pp->tick) -return 0 ;/* don't check this path yet */ -conf =
get_multipath_config();
checkint =conf->checkint;
max_checkint=conf->max_checkint;multipathd/main.c +0
-0@@ -2417,12 +2409,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; };multipathd/main.c +0
-6-/* -* provision a next check soonest, -* in case we exit abnormally from here -*/ - pp->tick = checkint; -newstate =
check_path_state(pp);
if (newstate ==PATH_WILD|| newstate ==PATH_UNCHECKED) return 0;multipathd/main.c +0
-0@@ -2584,7 +2570,6 @@ check_path (struct vectors * vecs, struct path* pp, unsigned int ticks) condlog(4, "%s: delay next check %is",
pp->dev_t,pp->checkint); }multipathd/main.c +0
-1- pp->tick = pp->checkint;}
}
else if (newstate !=PATH_UP&& newstate !=PATH_GHOST) {multipathd/main.c +0
-0@@ -2637,6 +2622,76 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 1; }multipathd/main.c +2
-0+static int +check_path (struct vectors * vecs, struct path * pp, unsigned intticks,
multipathd/main.c +27
-0+ time_t start_secs) +{ +int r; +unsigned int adjust_int, max_checkint; +struct config *conf; +time_t next_idx, goal_idx; + +if (pp->initialized ==INIT_REMOVED ) +return 0 ; + +if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; +if (pp->tick) +return 0 ;/* don't check this path yet */ + + conf =get_multipath_config (); + max_checkint = conf->max_checkint; + adjust_int = conf->adjust_int; +put_multipath_config (conf); + + r =do_check_path (vecs, pp); + +/* +* do_check_path() removed or orphaned the path. +*/ +if (r <0 || !pp->mpp) +return r;
Quoted 8 lines
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2658
Quoted 5 lines
multipathd/main.c +5
-0+ +/* +* the path checker is pending +*/ +if (pp->tick !=0 ) {I'm not getting this logic. Please explain. Why is
pp->tick!= 0 at this point equivalent to the checker being pending?
It's not actually just pending. This also happens for a specific case of PATH_DELAY paths. The short answer is that we should always respect a pp->tick value set directly in do_check_path(), since that means that we are supposed to recheck as soon as possible. And as far as incrementing pp->pending_ticks for PATH_DELAY devices, it seemed harmless. It will just make the first recheck after a path stops being delayed happen sooner.
But you are correct, and it's not hard to clear pp->pending_ticks when the path is in the PATH_DELAY state.
Actually setting pp->ticks to 1 for PATH_DELAY paths seems wrong. I believe the only reason to do it is to make sure that we re-enqueue the path for io err checking on time. But we know exactly how long we need to wait until we do that, so we should be setting pp->tick to the correct time when we need to, and leaving it alone otherwise. And it shouldn't have anything to do with whether or not the path is in the marginal pathgroup.
Quoted 36 lines
Quoted 36 lines
multipathd/main.c +23
-0+ pp->pending_ticks++; +return r; + } + +/* schedule the next check */ + pp->tick = pp->checkint; +if (pp->pending_ticks >= pp->tick) + pp->tick =1 ; +else + pp->tick -= pp->pending_ticks; + pp->pending_ticks =0 ; + +if (pp->tick ==1 ) +return r; + +/* +* every mpp has a goal_idx in the range of +* 0 <= goal_idx < conf->max_checkint +* +* The next check has an index, next_idx, in the range of +* 0 <= next_idx < conf->adjust_int +* +* Every adjust_int seconds, each multipath device should try to
multipathd/main.c +1
-0+* check all of its paths on its goal_idx. If a path isn't checked
multipathd/main.c +1
-0+* on the goal_idx, then pp->tick for the next check after the
multipathd/main.c +1
-0+* goal_idx will be decremented by one, to align it over time.
multipathd/main.c +5
-0+*/ + goal_idx = (find_slot (vecs->mpvec, pp->mpp)) * + max_checkint / VECTOR_SIZE(vecs->mpvec); + next_idx = (start_secs + pp->tick) % adjust_int; + if (next_idx > goal_idx && next_idx - goal_idx < pp-
Quoted 8 lines
multipathd/main.c check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) · line 2690
Quoted 2 lines
Quoted 1 line
checkint)
multipathd/main.c +1
-0+ pp->tick--;Hm. IMHO this calculation should be little simpler, as follows:
cur_idx = start_secs % adjust_int; if ((goal_idx - cur_idx) % pp->checkint != 0) pp->tick--;
We need to use next_idx instead of cur_idx. cur_idx is the time when the path checker completed, not when it started. If the checker returned PATH_PENDING, these two times will be different. Since path checkers may not always take the same amount of time to complete, we can't use their completing time to line them up on the same index. Instead we track how long the checker was pending for, and remove that from the length of time till the next check, so that checkers always start every pp->checkint seconds.
But you are correct that we could just use
((goal_idx - next_idx) % pp->checkint != 0)
Quoted 6 lines
My reasoning goes like this: If (
goal_idx-cur_idx) %pp->checkintis 0, we need no adjustment, because (assuming checkint remains constant) it will be checked at the nextgoal_idx. Otherwise, we check one tick earlier, and will do so at the next check again, etc. This is similar to your approach, but not exactly the same, AFAICS. In particular, I am unsure about your "if (next_idx-goal_idx<pp->checkint)" condition.
The idea was that we would only modify pp->tick once per adjust_int. But in reflection, there's really no reason to do that. Your version makes more sense.
Quoted 9 lines
If checkint grows toward
max_checkint, it may take longer until this algorithm converges, but sooner or later, it should.Instead of stepping, we could also force the idx immediately, by doing
pp->tick -= (goal_idx - cur_idx) % pp->checkint;which would be even simpler (the check intervals would be less evenly spaced, but I don't think that would hurt us much).
I think you mean:
pp->tick -= (cur_idx - goal_idx) % pp->checkint;
But at any rate, I think we should try to keep the intervals mostly the same. Plus I feel like shortening the intervals makes the most sense, while the above will sometimes shorten and sometimes lengthen them.
-Ben
Quoted 4 lines
Am I misguided here?
Regards
Martin
Benjamin Marzinski
maintainerPATCH 20/22 multipathd: factor out actual path checking loop from checkerloop
In reply to Benjamin MarzinskiMove the code that actually loops through the paths and checks them into a separate function, to stop it from being so heavily indented. This will be more imporant when a future patch makes paths checked by mpp.
No functional changes.
--- multipathd/main.c | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 30 deletions(-)
multipathd/main.c +35 -30
@@ -2782,6 +2782,38 @@ enum checker_state { CHECKER_FINISHED, }; +static enum checker_state +check_paths (struct vectors *vecs,unsigned int ticks,int *num_paths_p) +{ +unsigned int paths_checked =0 ; +struct timespec diff_time, start_time, end_time; +struct path *pp; +int i, rc; + +get_monotonic_time (&start_time); + vector_foreach_slot(vecs->pathvec, pp, i) { +if (pp->is_checked) +continue ; + pp->is_checked = true; +if (pp->mpp) + rc =check_path (vecs, pp, ticks, start_time.tv_sec); +else + rc =handle_uninitialized_path (vecs, pp, ticks); +if (rc <0 ) + i--; +else + *num_paths_p += rc; +if (++paths_checked %128 ==0 && + (lock_has_waiters (&vecs->lock) ||waiting_clients ())) { +get_monotonic_time (&end_time); +timespecsub (&end_time, &start_time, &diff_time); +if (diff_time.tv_sec >0 ) +return CHECKER_RUNNING ; + } + } +return CHECKER_FINISHED ; +} +static void *checkerloop (void *ap) {
@@ -2813,7 +2845,7 @@ checkerloop (void *ap)while (1 ) {struct timespec diff_time, start_time, end_time; -int num_paths =0 , strict_timing, rc =0 ; +int num_paths =0 , strict_timing;unsigned int ticks =0 ;enum checker_state checker_state =CHECKER_STARTING ;
@@ -2832,16 +2864,14 @@ checkerloop (void *ap)sd_notify (0 ,"WATCHDOG=1" );#endif while (checker_state !=CHECKER_FINISHED ) { -unsigned int paths_checked =0 , i; -struct timespec chk_start_time;struct multipath *mpp; +int i;pthread_cleanup_push (cleanup_lock, &vecs->lock);lock (&vecs->lock);pthread_testcancel ();vector_foreach_slot (vecs->mpvec, mpp, i) mpp->is_checked = false; -get_monotonic_time (&chk_start_time);if (checker_state ==CHECKER_STARTING ) { vector_foreach_slot(vecs->mpvec, mpp, i)check_mpp (vecs, mpp, ticks);
@@ -2849,32 +2879,7 @@ checkerloop (void *ap) pp->is_checked = false; checker_state =CHECKER_RUNNING ; } - vector_foreach_slot(vecs->pathvec, pp, i) { -if (pp->is_checked) -continue ; - pp->is_checked = true; -if (pp->mpp) - rc =check_path (vecs, pp, ticks, - chk_start_time.tv_sec); -else - rc =handle_uninitialized_path (vecs, pp, - ticks); -if (rc <0 ) - i--; -else - num_paths += rc; -if (++paths_checked %128 ==0 && - (lock_has_waiters (&vecs->lock) || -waiting_clients ())) { -get_monotonic_time (&end_time); -timespecsub (&end_time, &chk_start_time, - &diff_time); -if (diff_time.tv_sec >0 ) - goto unlock; - } - } - checker_state =CHECKER_FINISHED ; -unlock: + checker_state =check_paths (vecs, ticks, &num_paths);lock_cleanup_pop (vecs->lock);if (checker_state !=CHECKER_FINISHED ) {/* Yield to waiters */
Signature · 1 line
2.45.0
Re: [PATCH 20/22] multipathd: factor out actual path checking loop from checkerloop
Quoted 8 lines · Benjamin Marzinski
Move the code that actually loops through the paths and checks them into
a separate function, to stop it from being so heavily indented. This will be more imporant when a future patch makes paths checked by mpp.No functional changes.
Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH 21/22 multipathd: check paths in order by mpp
In reply to Benjamin MarzinskiInstead of checking all of the paths in vecs->pathvec in order, first check all the paths in each multipath device. Then check the uninitialized paths.
One issue with checking paths this way is that the multipath device can be resynced or even removed while a path is being checked. The path can also be removed. If there is any change to the multipath device, multipathd needs to loop through its paths again, because the current indexes may not longer be valid.
To do this change mpp->is_checked to an int called mpp->synced_count, and increment it whenever the multipath device gets resynced. After each path is checked, make sure that the multipath device still exists, that mpp->synced_count hasn't changed. If either has happened, restart checking at the current index in mpvec (which will either be the same mpp if it was just resynced, or the next mpp if the last one was deleted). Since the multipath device is resynced when its first path is checked, this restart will happen to every multipath device at least once per loop. But the paths themselves aren't rechecked, so it's not much overhead.
If resyncing a multipath device fails in do_check_mpp(), there may be path devices that have pp->mpp set, but are no longer in one of the multipath device's pathgroups, and thus will not get checked. This almost definitely means the multipath device was deleted. If do_check_mpp() failed to resync the device, but it wasn't deleted, it will get called again in max_checkint seconds even if it no longer has mpp->pg set, and the paths will get checked again after that.
--- libmultipath/structs.h | 2 +- libmultipath/structs_vec.c | 1 + multipathd/main.c | 54 ++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 9 deletions(-)
libmultipath/structs.h +1 -1
@@ -455,7 +455,7 @@ struct multipath {int ghost_delay_tick;int queue_mode;unsigned int sync_tick; -bool is_checked; +int synced_count;uid_t uid;gid_t gid;mode_t mode;
libmultipath/structs_vec.c +1 -0
@@ -513,6 +513,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) conf =get_multipath_config (); mpp->sync_tick = conf->max_checkint;put_multipath_config (conf); + mpp->synced_count++; r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, (mapid_t) { .str = mpp->alias },
multipathd/main.c +46 -8
85 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [PATCH 21/22] multipathd: check paths in order by mpp
Quoted 12 lines · Benjamin Marzinski
Instead of checking all of the paths in
vecs->pathvecin order, first check all the paths in each multipath device. Then check the uninitialized paths.One issue with checking paths this way is that the multipath device can
be resynced or even removed while a path is being checked. The path can
also be removed. If there is any change to the multipath device, multipathd needs to loop through its paths again, because the current indexes may not longer be valid.
Quoted 13 lines
To do this change
mpp->is_checkedto an int calledmpp->synced_count, and increment it whenever the multipath device gets resynced. After each
path is checked, make sure that the multipath device still exists, thatmpp->synced_counthasn't changed. If either has happened, restart checking at the current index in mpvec (which will either be the same mpp if it was just resynced, or the next mpp if the last one was deleted). Since the multipath device is resynced when its first path is
checked, this restart will happen to every multipath device at least once per loop. But the paths themselves aren't rechecked, so it's not much overhead.
Why don't we just sync the map once before we start checking the paths, instead of doing it when the first path is checked?
Quoted 108 lines
If resyncing a multipath device fails in
do_check_mpp(), there may be path devices that havepp->mppset, but are no longer in one of the multipath device's pathgroups, and thus will not get checked. This almost definitely means the multipath device was deleted. Ifdo_check_mpp()failed to resync the device, but it wasn't deleted, it will get called again inmax_checkintseconds even if it no longer hasmpp->pgset, and the paths will get checked again after that.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/structs.h | 2 +-libmultipath/structs_vec.c| 1 +
multipathd/main.c | 54 ++++++++++++++++++++++++++++++++---- --3 files changed, 48 insertions(+), 9 deletions(-)libmultipath/structs.h +1
-1@@ -455,7 +455,7 @@ struct multipath { int ghost_delay_tick; int queue_mode; unsigned int sync_tick; -bool is_checked; +int synced_count; uid_t uid; gid_t gid; mode_t mode;libmultipath/structs_vec.c +1
-0@@ -513,6 +513,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) conf = get_multipath_config(); mpp->sync_tick = conf->max_checkint; put_multipath_config(conf); + mpp->synced_count++;
r = libmp_mapinfo(DM_MAP_BY_NAME |MAPINFO_MPATH_ONLY, (mapid_t) { .str =mpp->alias},multipathd/main.c +0
-0@@ -2356,7 +2356,6 @@ do_check_mpp(struct vectors * vecs, struct multipath *mpp) int i, ret; struct path *pp;multipathd/main.c +0
-1- mpp->is_checked = true;ret =
update_multipath_strings(mpp, vecs->pathvec); if (ret !=DMP_OK) {
condlog(1, "%s: %s",mpp->alias, ret ==DMP_NOT_FOUND?multipathd/main.c +0
-0@@ -2428,7 +2427,7 @@ do_check_path (struct vectors * vecs, struct path * pp)condlog(0, "%s: path wwid change detected. Removing",
pp->dev);
returnhandle_path_wwid_change(pp, vecs)? -1 : 0; }multipathd/main.c +1
-1-if (!pp->mpp->is_checked) { +if (pp->mpp->synced_count ==0 ) {
do_check_mpp(vecs, pp->mpp);
/* ifupdate_multipath_stringsorphaned the path, quit early */
if (!pp->mpp)multipathd/main.c +1
-0@@ -2787,18 +2786,57 @@ check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) { unsigned int paths_checked = 0; struct timespec diff_time, start_time, end_time; +struct multipath *mpp; struct path *pp; int i, rc;
get_monotonic_time(&start_time);multipathd/main.c +22
-0+ + vector_foreach_slot(vecs->mpvec, mpp, i) { +struct pathgroup *pgp; +struct path *pp; +int j, k; +bool check_for_waiters = false; +/* maps can be rechecked, so this is not always 0 */ +int synced_count = mpp->synced_count; + + vector_foreach_slot (mpp->pg, pgp, j) { + vector_foreach_slot (pgp->paths, pp, k) { +if (!pp->mpp || pp->is_checked) +continue ; + pp->is_checked = true; + rc =check_path (vecs, pp, ticks, + start_time.tv_sec); +if (rc >0 ) + *num_paths_p +=1 ; +if (++paths_checked %128 ==0 ) + check_for_waiters = true; +/* +* mpp has been removed or resynced. Path may
multipathd/main.c +3
-0+* have been removed. +*/ + if (VECTOR_SLOT(vecs->mpvec, i) !=mpp ||
multipathd/main.c +1
-0+ synced_count != mpp-Quoted 1 line
synced_count) {
multipathd/main.c check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) · line 2822
Quoted 3 lines
multipathd/main.c +3
-0+ i--; + goto next_mpp; + }
I'm aware that you have implemented the rather vague idea I had mentioned previously, thanks a lot for that.
This is ok, but the fact that the arrays we are looping over can be modified deeply inside functions inside the loop feels fragile. I wonder if it would be possible to clean up our code flow such that neither mpp nor path objects can be removed at this point the code.
The sync code could set flags on paths and / or multipath objects that tell the caller that these objects are no longer valid, and we could remove them when we're done with the loop. I'm aware that we'd still need to cover path group changes. Perhaps we should create a temporary array of all paths in the map (possibly sorted by major/minor number). We'd ignore newly added paths (they should have been checked recently anyway, shouldn't they?) and skip over paths that are flagged as being removed.
I realize I'm making vague suggestions again. Your current work shows that this is more complicated than I first imagined. Thanks a lot for considering all the corner cases.
This isn't something I'd expect to change in the current patch set, just something to think about for the future.
Quoted 30 lines
multipathd/main.c +5
-0+ } + } +next_mpp: + if (check_for_waiters && + (lock_has_waiters(&vecs->lock) ||
waiting_clients())) {multipathd/main.c +2
-0+get_monotonic_time (&end_time); + timespecsub(&end_time, &start_time,
&diff_time);multipathd/main.c +4
-0+if (diff_time.tv_sec >0 ) +return CHECKER_RUNNING ; + } + }
vector_foreach_slot(vecs->pathvec, pp, i){multipathd/main.c +1
-1-if (pp->is_checked) +if (pp->mpp || pp->is_checked)continue;
pp->is_checked= true;multipathd/main.c +0
-2-if (pp->mpp) - rc = check_path(vecs, pp, ticks,start_time.tv_sec);
multipathd/main.c +0
-2-else - rc = handle_uninitialized_path(vecs, pp,ticks);
multipathd/main.c +2
-0+ + rc =handle_uninitialized_path (vecs, pp, ticks);if (rc < 0)
i--;
else
multipathd/main.c checkerloop (void *ap) · line 2912
Quoted 5 lines
multipathd/main.c +1
-1@@ -2871,7 +2909,7 @@ checkerloop (void *ap) lock(&vecs->lock); pthread_testcancel(); vector_foreach_slot(vecs->mpvec, mpp, i) - mpp->is_checked = false; + mpp->synced_count =0 ;
Why do we need to reset this? Can't we just increment the counter whenever we sync, and let it wrap at UINT_MAX?
Quoted 4 lines
multipathd/main.c +0
-0if (checker_state == CHECKER_STARTING) { vector_foreach_slot(vecs->mpvec, mpp, i)
check_mpp(vecs, mpp, ticks);
Benjamin Marzinski
maintainerRe: [PATCH 21/22] multipathd: check paths in order by mpp
Quoted 27 lines · Martin Wilck
Quoted 12 lines · Benjamin Marzinski
Instead of checking all of the paths in
vecs->pathvecin order, first check all the paths in each multipath device. Then check the uninitialized paths.One issue with checking paths this way is that the multipath device can
be resynced or even removed while a path is being checked. The path can
also be removed. If there is any change to the multipath device, multipathd needs to loop through its paths again, because the current indexes may not longer be valid.Quoted 13 lines
To do this change
mpp->is_checkedto an int calledmpp->synced_count, and increment it whenever the multipath device gets resynced. After each
path is checked, make sure that the multipath device still exists, thatmpp->synced_counthasn't changed. If either has happened, restart checking at the current index in mpvec (which will either be the same mpp if it was just resynced, or the next mpp if the last one was deleted). Since the multipath device is resynced when its first path is
checked, this restart will happen to every multipath device at least once per loop. But the paths themselves aren't rechecked, so it's not much overhead.
Quoted 2 lines
Why don't we just sync the map once before we start checking the paths, instead of doing it when the first path is checked?
I guess we could loop through all the paths of a multipath device and see if any of them are due for a check this loop. The if the path checker returns pending we will have resynced the map for no benefit, and we will continue to do so until the checker completes. This could lead to us doing more resyncs than we were before, with no added benefit.
Quoted 115 lines
Quoted 108 lines
If resyncing a multipath device fails in
do_check_mpp(), there may be path devices that havepp->mppset, but are no longer in one of the multipath device's pathgroups, and thus will not get checked. This almost definitely means the multipath device was deleted. Ifdo_check_mpp()failed to resync the device, but it wasn't deleted, it will get called again inmax_checkintseconds even if it no longer hasmpp->pgset, and the paths will get checked again after that.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/structs.h | 2 +-libmultipath/structs_vec.c| 1 +
multipathd/main.c | 54 ++++++++++++++++++++++++++++++++---- --3 files changed, 48 insertions(+), 9 deletions(-)libmultipath/structs.h +1
-1@@ -455,7 +455,7 @@ struct multipath { int ghost_delay_tick; int queue_mode; unsigned int sync_tick; -bool is_checked; +int synced_count; uid_t uid; gid_t gid; mode_t mode;libmultipath/structs_vec.c +1
-0@@ -513,6 +513,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) conf = get_multipath_config(); mpp->sync_tick = conf->max_checkint; put_multipath_config(conf); + mpp->synced_count++;
r = libmp_mapinfo(DM_MAP_BY_NAME |MAPINFO_MPATH_ONLY, (mapid_t) { .str =mpp->alias},multipathd/main.c +0
-0@@ -2356,7 +2356,6 @@ do_check_mpp(struct vectors * vecs, struct multipath *mpp) int i, ret; struct path *pp;multipathd/main.c +0
-1- mpp->is_checked = true;ret =
update_multipath_strings(mpp, vecs->pathvec); if (ret !=DMP_OK) {
condlog(1, "%s: %s",mpp->alias, ret ==DMP_NOT_FOUND?multipathd/main.c +0
-0@@ -2428,7 +2427,7 @@ do_check_path (struct vectors * vecs, struct path * pp)condlog(0, "%s: path wwid change detected. Removing",
pp->dev);
returnhandle_path_wwid_change(pp, vecs)? -1 : 0; }multipathd/main.c +1
-1-if (!pp->mpp->is_checked) { +if (pp->mpp->synced_count ==0 ) {
do_check_mpp(vecs, pp->mpp);
/* ifupdate_multipath_stringsorphaned the path, quit early */
if (!pp->mpp)multipathd/main.c +1
-0@@ -2787,18 +2786,57 @@ check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) { unsigned int paths_checked = 0; struct timespec diff_time, start_time, end_time; +struct multipath *mpp; struct path *pp; int i, rc;
get_monotonic_time(&start_time);multipathd/main.c +22
-0+ + vector_foreach_slot(vecs->mpvec, mpp, i) { +struct pathgroup *pgp; +struct path *pp; +int j, k; +bool check_for_waiters = false; +/* maps can be rechecked, so this is not always 0 */ +int synced_count = mpp->synced_count; + + vector_foreach_slot (mpp->pg, pgp, j) { + vector_foreach_slot (pgp->paths, pp, k) { +if (!pp->mpp || pp->is_checked) +continue ; + pp->is_checked = true; + rc =check_path (vecs, pp, ticks, + start_time.tv_sec); +if (rc >0 ) + *num_paths_p +=1 ; +if (++paths_checked %128 ==0 ) + check_for_waiters = true; +/* +* mpp has been removed or resynced. Path may
multipathd/main.c +3
-0+* have been removed. +*/ + if (VECTOR_SLOT(vecs->mpvec, i) !=mpp ||
multipathd/main.c +1
-0+ synced_count != mpp-Quoted 1 line
synced_count) {multipathd/main.c check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) · line 2822
Quoted 3 lines
multipathd/main.c +3
-0+ i--; + goto next_mpp; + }I'm aware that you have implemented the rather vague idea I had mentioned previously, thanks a lot for that.
Quoted 4 lines
This is ok, but the fact that the arrays we are looping over can be modified deeply inside functions inside the loop feels fragile. I wonder if it would be possible to clean up our code flow such that neither mpp nor path objects can be removed at this point the code.
We could handle the paths WWID changing by just failng it immediately, and then removing it after we check the other paths. But unless we either wanted to resync even when it was unnecessary like I mentioned above, or we decide that we don't need to resync before updating the path state, then no. There will be cases when we need to start checking the path to see if we need to resync and when we resync the device could be gone or have changed pathgroups.
Now, there's no reason I know of why we must resync the multipath device before checking a path. I want to do it mostly because I think there is a good chance that we will run into some weird corner case behaviors if we stop doing it. It's nice to grab a lock so no other thread can change the state, and then make get it to match the kernel state, before you start changing that state based on you path check results. But the moment after you grab that state it could already be out of date, so multipathd needs to handle that possibility regardless.
Also the current changes already open us up to new corner cases. For instance, if you fail calling update_multipath_strings() in do_check_mpp(), mpp->pg may well be cleared. This means that you won't end up checking any of the other paths in that multipath device until something else reloads the device, either an event or check_mpp(). We could work around this by calling check_path() for paths with pp->mpp set but that haven't been checked yet in the loop where we currently just call handle_uninitialized_path(). I debated doing this, but almost always when do_check_mpp() fails, it will be because the device was removed.
Another solution could be to set sync_tick to something low if we fail when resyncing the mpp. That would let us process the remove event that is almost definitely waiting for us, but still retry syncing the mpp state soonish if that's not the case. I should probably do that regardless of whether we check the unchecked paths with pp->mpp set in the uninitialized paths loop.
But at any rate, we could try simply not resyncing the map until after checking the paths, and handling whatever bugs appear. Or even try something that dovetails with what I believe is your bigger vision, where we start all the path checkers for all the paths of a device, and only look to see which ones have completed once we're all done. If some of the path checkers returned, we could save the checker results in pp->newstate, check if the wwids changed and handle that, and then resync the mpp and update it's state based on the checker results for it's current paths.
But yeah, that's work for a different day.
Quoted 46 lines
The sync code could set flags on paths and / or multipath objects that tell the caller that these objects are no longer valid, and we could remove them when we're done with the loop. I'm aware that we'd still need to cover path group changes. Perhaps we should create a temporary array of all paths in the map (possibly sorted by major/minor number). We'd ignore newly added paths (they should have been checked recently anyway, shouldn't they?) and skip over paths that are flagged as being removed.
I realize I'm making vague suggestions again. Your current work shows that this is more complicated than I first imagined. Thanks a lot for considering all the corner cases.
This isn't something I'd expect to change in the current patch set, just something to think about for the future.
Quoted 30 lines
multipathd/main.c +5
-0+ } + } +next_mpp: + if (check_for_waiters && + (lock_has_waiters(&vecs->lock) ||
waiting_clients())) {multipathd/main.c +2
-0+get_monotonic_time (&end_time); + timespecsub(&end_time, &start_time,
&diff_time);multipathd/main.c +4
-0+if (diff_time.tv_sec >0 ) +return CHECKER_RUNNING ; + } + }
vector_foreach_slot(vecs->pathvec, pp, i){multipathd/main.c +1
-1-if (pp->is_checked) +if (pp->mpp || pp->is_checked)continue;
pp->is_checked= true;multipathd/main.c +0
-2-if (pp->mpp) - rc = check_path(vecs, pp, ticks,start_time.tv_sec);
multipathd/main.c +0
-2-else - rc = handle_uninitialized_path(vecs, pp,ticks);
multipathd/main.c +2
-0+ + rc =handle_uninitialized_path (vecs, pp, ticks);if (rc < 0)
i--;
elsemultipathd/main.c +0
-0@@ -2871,7 +2909,7 @@ checkerloop (void *ap)
Quoted 8 lines
multipathd/main.c checkerloop (void *ap) · line 2912
Quoted 5 lines
multipathd/main.c +1
-1lock(&vecs->lock); pthread_testcancel(); vector_foreach_slot(vecs->mpvec, mpp, i) - mpp->is_checked = false; + mpp->synced_count =0 ;Why do we need to reset this? Can't we just increment the counter whenever we sync, and let it wrap at
UINT_MAX?
We need to restart looping through the mpp paths whenever mpp->synced_count has changed, but we only call do_check_mpp() in do_check_path() if mpp->synced_count is 0, since we only want to do that once per time we check the mpp. I should probably rename that to do_sync_mpp().
Quoted 4 lines
Quoted 4 lines
multipathd/main.c +0
-0if (checker_state == CHECKER_STARTING) { vector_foreach_slot(vecs->mpvec, mpp, i)
check_mpp(vecs, mpp, ticks);
Benjamin Marzinski
maintainerPATCH 22/22 multipathd: clean up the correct wwid in check_path_wwid_change
In reply to Benjamin MarzinskiAfter check_path_wwid_change() grabbed a new copy of the wwid, it was stripping trailing whitespace off of pp->wwid, instead of the copy it just got.
--- multipathd/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
multipathd/main.c +2 -2
@@ -1025,9 +1025,9 @@ check_path_wwid_change(struct path *pp) }/*Strip any trailing blanks */ -for (i =strlen (pp->wwid); i >0 && pp->wwid[i-1 ] ==' ' ; i--); +for (i =strlen (wwid); i >0 && wwid[i-1 ] ==' ' ; i--);/* no-op */ - pp->wwid[i] ='\0' ; + wwid[i] ='\0' ;condlog (4 ,"%s: Got wwid %s by sgio" , pp->dev, wwid);if (strncmp (wwid, pp->wwid,WWID_SIZE )) {
Signature · 1 line
2.45.0
Re: [PATCH 22/22] multipathd: clean up the correct wwid in check_path_wwid_change
Quoted 5 lines · Benjamin Marzinski
After
check_path_wwid_change()grabbed a new copy of the wwid, it was stripping trailing whitespace off ofpp->wwid, instead of the copy it just got.Signed-off-by Benjamin Marzinski <[email protected]>
I'd suggest adding:
4660cff ("multipathd: add recheck_wwid option to verify the path wwid")
Benjamin Marzinski
maintainerRe: [PATCH 22/22] multipathd: clean up the correct wwid in check_path_wwid_change
Quoted 11 lines · Martin Wilck
Quoted 5 lines · Benjamin Marzinski
After
check_path_wwid_change()grabbed a new copy of the wwid, it was stripping trailing whitespace off ofpp->wwid, instead of the copy it just got.Signed-off-by Benjamin Marzinski <[email protected]>Reviewed-by Martin Wilck <[email protected]>I'd suggest adding:
4660cff ("multipathd: addrecheck_wwidoption to verify the path wwid")
Sure.