multipathd: start marginal path checker thread lazily
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 2/2 multipathd: start marginal path checker thread lazily
I noticed that the io_error checker thread accounts for most of the activity of multipathd even if the marginal path checking paramters are not set (which is still the default in most installations I assume).
Therefore, start the io_error checker thread only if there's at least one map with marginal error path checking configured. Also, make sure the thread is really up when start_io_err_stat_thread() returns.
This requires adding a "vecs" argument to setup_map, because vecs needs to be passed to the io_error checking code.
--- libmultipath/configure.c | 14 +++++++++--- libmultipath/configure.h | 3 ++- libmultipath/io_err_stat.c | 55 ++++++++++++++++++++++++++++++++++++++++++---- libmultipath/structs_vec.c | 3 ++- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 8 ++----- 6 files changed, 69 insertions(+), 16 deletions(-)
libmultipath/configure.c +11 -3
@@ -41,6 +41,7 @@#include "uxsock.h" #include "wwids.h" #include "sysfs.h" +#include "io_err_stat.h" /* group paths in pg by host adapter */
@@ -255,7 +256,8 @@ int rr_optimize_path_order(struct pathgroup *pgp)return 0 ; } -int setup_map (struct multipath *mpp,char *params,int params_size) +int setup_map (struct multipath *mpp,char *params,int params_size, +struct vectors *vecs) {struct pathgroup * pgp;struct config *conf;
@@ -315,6 +317,12 @@ int setup_map(struct multipath *mpp, char *params, int params_size)sysfs_set_scsi_tmo (mpp, conf->checkint);put_multipath_config (conf); + +if (mpp->marginal_path_double_failed_time >0 && + mpp->marginal_path_err_sample_time >0 && + mpp->marginal_path_err_recheck_gap_time >0 && + mpp->marginal_path_err_rate_threshold >=0 ) +start_io_err_stat_thread (vecs);/* * assign paths to path groups -- start with no groups and all paths * in mpp->paths
@@ -1019,7 +1027,7 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,verify_paths (mpp, vecs); params[0 ] ='\0' ; -if (setup_map (mpp, params,PARAMS_SIZE )) { +if (setup_map (mpp, params,PARAMS_SIZE , vecs)) {remove_map (mpp, vecs,0 );continue ; }
@@ -1348,7 +1356,7 @@ int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, } } } -if (setup_map (mpp, params,PARAMS_SIZE )) { +if (setup_map (mpp, params,PARAMS_SIZE , vecs)) {condlog (0 ,"%s: failed to setup map" , mpp->alias);return 1 ; }
libmultipath/configure.h +2 -1
@@ -28,7 +28,8 @@ enum actions {struct vectors ; -int setup_map (struct multipath * mpp,char * params,int params_size ); +int setup_map (struct multipath * mpp,char * params,int params_size, +struct vectors *vecs );int domap (struct multipath * mpp,char * params,int is_daemon);int reinstate_paths (struct multipath *mpp);int coalesce_paths (struct vectors *vecs,vector curmp,char * refwwid,int force_reload,enum mpath_cmds cmd);
libmultipath/io_err_stat.c +51 -4
116 lines not on this page · raw message
libmultipath/structs_vec.c +2 -1
@@ -18,6 +18,7 @@#include "prio.h" #include "configure.h" #include "libdevmapper.h" +#include "io_err_stat.h" /* * creates or updates mpp->paths reading mpp->pg
@@ -426,7 +427,7 @@ retry: mpp->action =ACT_RELOAD ;extract_hwe_from_path (mpp); -if (setup_map (mpp, params,PARAMS_SIZE )) { +if (setup_map (mpp, params,PARAMS_SIZE , vecs)) {condlog (0 ,"%s: failed to setup new map in update" , mpp->alias); retries =-1 ; goto fail;
multipathd/cli_handlers.c +1 -1
@@ -894,7 +894,7 @@ int resize_map(struct multipath *mpp, unsigned long long size, mpp->size = size;update_mpp_paths (mpp, vecs->pathvec); -setup_map (mpp, params,PARAMS_SIZE ); +setup_map (mpp, params,PARAMS_SIZE , vecs); mpp->action =ACT_RESIZE ; mpp->force_udev_reload =1 ;if (domap (mpp, params,1 ) <=0 ) {
multipathd/main.c +2 -6
@@ -734,7 +734,7 @@ rescan:/* * push the map to the device-mapper */ -if (setup_map (mpp, params,PARAMS_SIZE )) { +if (setup_map (mpp, params,PARAMS_SIZE , vecs)) {condlog (0 ,"%s: failed to setup map for addition of new " "path %s" , mpp->alias, pp->dev); goto fail_map;
@@ -873,7 +873,7 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)*/ } -if (setup_map (mpp, params,PARAMS_SIZE )) { +if (setup_map (mpp, params,PARAMS_SIZE , vecs)) {condlog (0 ,"%s: failed to setup map for" " removal of path %s" , mpp->alias, pp->dev); goto fail;
@@ -2489,10 +2489,6 @@ child (void * param)/* * start threads */ - rc =start_io_err_stat_thread (vecs); -if (rc) - goto failed; -if ((rc =pthread_create (&check_thr, &misc_attr, checkerloop, vecs))) {condlog (0 ,"failed to create checker loop thread: %d" , rc); goto failed;
Signature · 1 line
2.16.1
Quoted 12 lines · Martin Wilck
I noticed that the
io_errorchecker thread accounts for most of the activity of multipathd even if the marginal path checking paramters are not set (which is still the default in most installations I assume).Therefore, start the
io_errorchecker thread only if there's at least one map with marginal error path checking configured. Also, make sure the thread is really up whenstart_io_err_stat_thread()returns.This requires adding a "vecs" argument to
setup_map, because vecs needs to be passed to theio_errorchecking code.Signed-off-by Martin Wilck <[email protected]>
Quoted 9 lines
--- libmultipath/configure.c | 14 +++++++++--- libmultipath/configure.h | 3 ++- libmultipath/io_err_stat.c | 55 ++++++++++++++++++++++++++++++++++++++++++---- libmultipath/structs_vec.c | 3 ++- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 8 ++----- 6 files changed, 69 insertions(+), 16 deletions(-)
Cheers,
Hannes
Signature · 10 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Hannes Reinecke
Reviewed-byRe: [PATCH v2 1/2] libmultipath: fix race in stop_io_err_stat_thread
In reply to a message not in the archiveQuoted 23 lines · Martin Wilck
It's wrong, and unnecessary, to call
pthread_killafterpthread_cancel. I have observed cases where theio_errchecker thread hung in libpthread after receiving the USR2 signal, in particular when multipathd is run under strace. (If multipathd is killed with SIGINT under strace, and theio_errorthread is running, it happens almost every time). If this happens, theio_errthread
tries to obtain a mutex in the urcu code (presumablyrcu_unregister_thread()) and the main thread hangs inpthread_join().With the change from this patch, the thread is shut down cleanly. I haven't observed the hang under strace with the patch.
Signed-off-by Martin Wilck <[email protected]>--- libmultipath/io_err_stat.c | 1 - 1 file changed, 1 deletion(-)libmultipath/io_err_stat.c +0
-0
libmultipath/io_err_stat.c destroy_ctx: · line 754
Quoted 7 lines
libmultipath/io_err_stat.c +0
-1@@ -749,7 +749,6 @@ destroy_ctx:void stop_io_err_stat_thread (void ) {pthread_cancel (io_err_stat_thr); -pthread_kill (io_err_stat_thr,SIGUSR2 );pthread_join (io_err_stat_thr,NULL );free_io_err_pathvec (paths);io_destroy (ioctx);
Good point.
Cheers,
Hannes
Signature · 10 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel