Userspace-RCU for config accesses
v2 cover Userspace-RCU for config accesses
Hi all,
as Benjamin Marzinski pointed out the 'config' structure is not protected, but it will be re-allocated whenever we do a reconfiguration.
This leads to inevitable race conditions, which ATM are only imperfectly handled.
With this patchset accesses to the configuration are RCU-protected, so we are guaranteed that the pointer to the configuration is always valid.
To facilitate this the patchset moves the 'cmd', 'dev', and 'dev_type' entries out of the configuration, and replaces them with local variables in multipath.
Changes to the original version:
- Fixup arguments for get_mpe_wwid() and find_mpe() as found by Ben Marzinski
- Revert to original handling in get_state() as found by Ben Marzinski
The patchset can be found at
github.com:/hreinecke/multipath-tools.git
branch rcu.v2
As usual, comments and reviews are welcome.
Hannes Reinecke (26):
Revert patch 'move filter_devnode() under vector lock' Use 'mptable' as argument for find_mpe() and get_mpe_wwid()
config: set 'deferred_remove' defaults at correct call
devmapper: explicit config settings
dmparser: use 'is_daemon' as argument for disassemble_map()
libmultipath: use 'is_daemon' as argument for domap() etc
libmultipath: drop 'daemon' configuration setting
libmultipath: Do not access 'conf->cmd' in domap()
libmultipath: add 'cmd' as argument for get_refwwid()
libmultipath: fallback to checking environment variable in
get_udev_uid()
multipath: make 'cmd' internal to multipath program
multipath: make 'dev_type' internal to the multipath program
multipath: make 'dev' internal to the multipath program
libmultipath: separate out 'udev' config entry
libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo()
discovery: Pass in 'hwtable' for get_state() and
scsi_sysfs_discovery()
libmultipath: use 'struct config' as argument for pathinfo()
checkers: use 'multipath_dir' as argument
prio: use 'multipath_dir' as argument
libmultipath: use 'timeout' as argument for getprio()
libmultipath: use explicit 'config' argument for configuration file
parsing
libmultipath: use (get,put)_multipath_config() accessors
multipathd: Fixup commandline argument handling
multipath: make 'struct config' a local variable
multipathd: use userspace RCU to access configuration
libmultipath: Allocate keywords directly
libmpathpersist/mpath_persist.c | 28 +-- libmpathpersist/mpath_persist.h | 6 +- libmultipath/checkers.c | 22 ++- libmultipath/checkers.h | 6 +- libmultipath/config.c | 43 ++--- libmultipath/config.h | 18 +- libmultipath/configure.c | 163 +++++++++++------ libmultipath/configure.h | 10 +- libmultipath/debug.c | 3 + libmultipath/devmapper.c | 21 +-- libmultipath/devmapper.h | 4 +- libmultipath/dict.c | 79 ++++---- libmultipath/dict.h | 2 +- libmultipath/discovery.c | 108 ++++++----- libmultipath/discovery.h | 12 +- libmultipath/dmparser.c | 6 +- libmultipath/dmparser.h | 2 +- libmultipath/parser.c | 61 +++---- libmultipath/parser.h | 27 +-- libmultipath/print.c | 72 ++++---- libmultipath/print.h | 16 +- libmultipath/prio.c | 40 +++-- libmultipath/prio.h | 14 +- libmultipath/prioritizers/alua.c | 12 +- libmultipath/prioritizers/alua_rtpg.c | 25 +-- libmultipath/prioritizers/alua_rtpg.h | 6 +- libmultipath/prioritizers/emc.c | 8 +- libmultipath/prioritizers/hds.c | 8 +- libmultipath/prioritizers/hp_sw.c | 46 ++--- libmultipath/prioritizers/ontap.c | 19 +- libmultipath/prioritizers/rdac.c | 8 +- libmultipath/propsel.c | 99 +++++----- libmultipath/propsel.h | 48 ++--- libmultipath/structs_vec.c | 62 ++++--- libmultipath/structs_vec.h | 13 +- libmultipath/waiter.c | 4 + libmultipath/wwids.c | 22 ++- mpathpersist/main.c | 24 ++- multipath/main.c | 199 ++++++++++++--------- multipathd/Makefile | 2 +- multipathd/cli_handlers.c | 84 ++++++--- multipathd/main.c | 327 +++++++++++++++++++++++----------- multipathd/uxlsnr.c | 5 - 43 files changed, 1057 insertions(+), 727 deletions(-)
Signature · 1 line
2.6.6
PATCH v2 1/26 Revert patch 'move filter_devnode() under vector lock'
Patch was causing a segfault during booting and is being replaced by the following series.
--- multipathd/main.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
multipathd/main.c +18 -27
@@ -580,11 +580,6 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)pthread_cleanup_push (cleanup_lock, &vecs->lock);lock (vecs->lock);pthread_testcancel (); -if (filter_devnode (conf->blist_devnode, conf->elist_devnode, - uev->kernel) >0 ) { - ret =0 ; - goto out_unlock; - } pp =find_path_by_dev (vecs->pathvec, uev->kernel);if (pp) {int r;
@@ -642,7 +637,6 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)free_path (pp); ret =1 ; } -out_unlock:lock_cleanup_pop (vecs->lock);return ret; }
@@ -786,23 +780,22 @@ fail:static int uev_remove_path (struct uevent *uev,struct vectors * vecs) { -struct path *pp =NULL ; -int ret =0 ; +struct path *pp; +int ret;condlog (2 ,"%s: remove path (uevent)" , uev->kernel);pthread_cleanup_push (cleanup_lock, &vecs->lock);lock (vecs->lock);pthread_testcancel (); -if (filter_devnode (conf->blist_devnode, conf->elist_devnode, - uev->kernel) ==0 ) { - pp =find_path_by_dev (vecs->pathvec, uev->kernel); -if (pp) - ret =ev_remove_path (pp, vecs); -else -/* Not an error; path might have been purged earlier */ -condlog (0 ,"%s: path already removed" , uev->kernel); - } + pp =find_path_by_dev (vecs->pathvec, uev->kernel); +if (pp) + ret =ev_remove_path (pp, vecs);lock_cleanup_pop (vecs->lock); +if (!pp) { +/* Not an error; path might have been purged earlier */ +condlog (0 ,"%s: path already removed" , uev->kernel); +return 0 ; + }return ret; }
@@ -912,7 +905,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) ro =uevent_get_disk_ro (uev);if (ro >=0 ) { -struct path * pp =NULL ; +struct path * pp;struct multipath *mpp =NULL ; condlog(2, "%s: update path write_protect to '%d' (uevent)",
@@ -925,10 +918,6 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)* need to be at the same indentation level, hence * this slightly convoluted codepath. */ -if (filter_devnode (conf->blist_devnode, conf->elist_devnode, - uev->kernel) >0 ) { - goto out_unlock; - } pp =find_path_by_dev (vecs->pathvec, uev->kernel);if (pp) {if (pp->initialized ==INIT_REQUESTED_UDEV ) {
@@ -948,13 +937,11 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) uev->kernel, mpp->alias, retval); } } - out_unlock:lock_cleanup_pop (vecs->lock);if (!pp) { -if (retval) -condlog (0 ,"%s: spurious uevent, path not found" , - uev->kernel); -return retval; +condlog (0 ,"%s: spurious uevent, path not found" , + uev->kernel); +return 1 ; }if (retval ==2 )return uev_add_path (uev, vecs);
@@ -1072,6 +1059,10 @@ uev_trigger (struct uevent * uev, void * trigger_data)/* * path add/remove event */ +if (filter_devnode (conf->blist_devnode, conf->elist_devnode, + uev->kernel) >0 ) + goto out; +if (!strncmp (uev->action,"add" ,3 )) { r =uev_add_path (uev, vecs); goto out;
Signature · 1 line
2.6.6
PATCH v2 2/26 Use 'mptable' as argument for find_mpe() and get_mpe_wwid()
In reply to Hannes Reinecke--- libmultipath/config.c | 8 ++++---- libmultipath/config.h | 4 ++-- libmultipath/configure.c | 2 +- libmultipath/propsel.c | 2 +- libmultipath/structs_vec.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-)
libmultipath/config.c +4 -4
@@ -125,7 +125,7 @@ find_hwe (vector hwtable, char * vendor, char * product, char * revision) }extern struct mpentry * -find_mpe (char * wwid) +find_mpe (vector mptable,char * wwid) {int i;struct mpentry * mpe;
@@ -133,7 +133,7 @@ find_mpe (char * wwid)if (!wwid)return NULL ; - vector_foreach_slot (conf->mptable, mpe, i) + vector_foreach_slot (mptable, mpe, i)if (mpe->wwid && !strcmp (mpe->wwid, wwid))return mpe;
@@ -141,7 +141,7 @@ find_mpe (char * wwid) }extern char * -get_mpe_wwid (char * alias) +get_mpe_wwid (vector mptable,char * alias) {int i;struct mpentry * mpe;
@@ -149,7 +149,7 @@ get_mpe_wwid (char * alias)if (!alias)return NULL ; - vector_foreach_slot (conf->mptable, mpe, i) + vector_foreach_slot (mptable, mpe, i)if (mpe->alias &&strcmp (mpe->alias, alias) ==0 )return mpe->wwid;
libmultipath/config.h +2 -2
@@ -179,8 +179,8 @@ struct config {struct config * conf;struct hwentry *find_hwe (vector hwtable,char * vendor,char * product,char *revision); -struct mpentry *find_mpe (char * wwid); -char *get_mpe_wwid (char * alias); +struct mpentry *find_mpe (vector mptable,char * wwid); +char *get_mpe_wwid (vector mptable,char * alias);struct hwentry *alloc_hwe (void );struct mpentry *alloc_mpe (void );
libmultipath/configure.c +1 -1
@@ -1042,7 +1042,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)/* * or may be an alias */ - refwwid =get_mpe_wwid (dev); + refwwid =get_mpe_wwid (conf->mptable, dev);/* * or directly a wwid
libmultipath/propsel.c +1 -1
@@ -409,7 +409,7 @@ select_prio (struct path * pp) goto out; } } - mpe =find_mpe (pp->wwid); + mpe =find_mpe (conf->mptable, pp->wwid);set_prio (mpe,"(LUN setting)" );set_prio (conf->overrides,"(overrides setting)" );set_prio (pp->hwe,"controller setting)" );
libmultipath/structs_vec.c +2 -2
@@ -385,7 +385,7 @@ __setup_multipath (struct vectors * vecs, struct multipath * mpp, int reset) }set_multipath_wwid (mpp); - mpp->mpe =find_mpe (mpp->wwid); + mpp->mpe =find_mpe (conf->mptable, mpp->wwid);condlog (3 ,"%s: discover" , mpp->alias);if (!mpp->hwe)
@@ -469,7 +469,7 @@ add_map_with_path (struct vectors * vecs,if (!(mpp =alloc_multipath ()))return NULL ; - mpp->mpe =find_mpe (pp->wwid); + mpp->mpe =find_mpe (conf->mptable, pp->wwid); mpp->hwe = pp->hwe;strcpy (mpp->wwid, pp->wwid);
Signature · 1 line
2.6.6
PATCH v2 3/26 config: set 'deferred_remove' defaults at correct call
In reply to Hannes ReineckeWe should be setting the defaults for 'deferred_remove' when loading the configuration file, not when creating the hardware entries.
--- libmultipath/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/config.c +1 -1
@@ -419,7 +419,6 @@ store_hwe (vector hwtable, struct hwentry * dhwe) hwe->user_friendly_names = dhwe->user_friendly_names; hwe->retain_hwhandler = dhwe->retain_hwhandler; hwe->detect_prio = dhwe->detect_prio; - conf->deferred_remove =DEFAULT_DEFERRED_REMOVE ;if (dhwe->bl_product && !(hwe->bl_product =set_param_str (dhwe->bl_product))) goto out;
@@ -622,6 +621,7 @@ load_config (char * file, struct udev *udev) conf->retrigger_tries =DEFAULT_RETRIGGER_TRIES ; conf->retrigger_delay =DEFAULT_RETRIGGER_DELAY ; conf->uev_wait_timeout =DEFAULT_UEV_WAIT_TIMEOUT ; + conf->deferred_remove =DEFAULT_DEFERRED_REMOVE ;/* * preload default hwtable
Signature · 1 line
2.6.6
PATCH v2 4/26 devmapper: explicit config settings
In reply to Hannes ReineckeRather than access 'conf' from within the code this patch moves those settings to function arguments. So with this patch we don't need to access 'struct config' anymore.
--- libmultipath/configure.c | 6 ++++-- libmultipath/devmapper.c | 21 +++++++++++---------- libmultipath/devmapper.h | 4 ++-- multipath/main.c | 2 +- multipathd/main.c | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-)
libmultipath/configure.c +4 -2
@@ -633,11 +633,13 @@ domap (struct multipath * mpp, char * params)break ;case ACT_RENAME : - r =dm_rename (mpp->alias_old, mpp->alias); + r =dm_rename (mpp->alias_old, mpp->alias, + conf->partition_delim);break ;case ACT_FORCERENAME : - r =dm_rename (mpp->alias_old, mpp->alias); + r =dm_rename (mpp->alias_old, mpp->alias, + conf->partition_delim);if (r) r =dm_addmap_reload (mpp, params,0 );break ;
libmultipath/devmapper.c +11 -10
@@ -19,7 +19,6 @@#include "debug.h" #include "memory.h" #include "devmapper.h" -#include "config.h" #include "sysfs.h" #include "log_pthread.h"
@@ -32,6 +31,8 @@#define UUID_PREFIX "mpath-"#define UUID_PREFIX_LEN 6 +static int dm_conf_verbosity; +#ifdef LIBDM_API_DEFERRED static int dm_cancel_remove_partmaps (const char * mapname);#endif
@@ -65,7 +66,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...)if (level >6 ) level =6 ; - thres = (conf) ? conf->verbosity :0 ; + thres = dm_conf_verbosity;if (thres <=3 || level > thres)return ;
@@ -94,9 +95,9 @@ dm_write_log (int level, const char *file, int line, const char *f, ...) }extern void -dm_init (void ) { +dm_init (int v) {dm_log_init (&dm_write_log); -dm_log_init_verbose (conf ? conf->verbosity +3 :0 ); +dm_log_init_verbose (v +3 ); } static int
@@ -1375,21 +1376,21 @@ rename_partmap (const char *name, void *data)for (offset =strlen (rd->old); name[offset] && !(isdigit (name[offset])); offset++);/* do nothing */ snprintf (buff,PARAMS_SIZE ,"%s%s%s" , rd->new, rd->delim, name + offset); -dm_rename (name, buff); +dm_rename (name, buff, rd->delim);condlog (4 ,"partition map %s renamed" , name);return 0 ; }int -dm_rename_partmaps (const char * old,char * new) +dm_rename_partmaps (const char * old,char * new,char *delim) {struct rename_data rd; rd.old = old; rd.new = new; -if (conf->partition_delim) - rd.delim = conf->partition_delim; +if (delim) + rd.delim = delim;if (isdigit (new[strlen (new)-1 ])) rd.delim ="p" ;else
@@ -1398,13 +1399,13 @@ dm_rename_partmaps (const char * old, char * new) }int -dm_rename (const char * old,char * new) +dm_rename (const char * old,char * new,char *delim) {int r =0 ;struct dm_task *dmt;uint32_t cookie; -if (dm_rename_partmaps (old, new)) +if (dm_rename_partmaps (old, new, delim))return r;if (!(dmt =dm_task_create (DM_DEVICE_RENAME )))
libmultipath/devmapper.h +2 -2
@@ -12,7 +12,7 @@#define MPATH_UDEV_RELOAD_FLAG 0#endif -void dm_init (void ); +void dm_init (int verbosity);int dm_prereq (void );int dm_drv_version (unsigned int * version,char * str);int dm_simplecmd_flush (int ,const char *,uint16_t );
@@ -46,7 +46,7 @@ int dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove);int dm_get_uuid (char *name,char *uuid);int dm_get_info (char * mapname,struct dm_info ** dmi); -int dm_rename (const char * old,char * new); +int dm_rename (const char * old,char * new,char * delim);int dm_reassign (const char * mapname);int dm_reassign_table (const char *name,char *old,char *new);int dm_setgeometry (struct multipath *mpp);
multipath/main.c +1 -1
@@ -583,6 +583,7 @@ main (int argc, char *argv[])exit (1 ); } +dm_init (conf->verbosity);if (dm_prereq ())exit (1 );dm_drv_version (conf->version,TGT_MPATH );
@@ -627,7 +628,6 @@ main (int argc, char *argv[])condlog (0 ,"failed to initialize prioritizers" ); goto out; } -dm_init ();if (conf->cmd ==CMD_VALID_PATH && (!conf->dev || conf->dev_type ==DEV_DEVMAP )) {
multipathd/main.c +1 -1
@@ -2111,6 +2111,7 @@ child (void * param) uxsock_timeout = conf->uxsock_timeout; +dm_init (conf->verbosity);dm_drv_version (conf->version,TGT_MPATH );if (init_checkers ()) {condlog (0 ,"failed to initialize checkers" );
@@ -2368,7 +2369,6 @@ main (int argc, char *argv[])int foreground =0 ; logsink =1 ; -dm_init ();if (getuid () !=0 ) {fprintf (stderr,"need to be root\n" );
Signature · 1 line
2.6.6
PATCH v2 5/26 dmparser: use 'is_daemon' as argument for disassemble_map()
In reply to Hannes ReineckeUse 'is_daemon' as argument for disassemble_map() so that dmparser.c doesn't need to access 'struct config' anymore.
--- libmpathpersist/mpath_persist.c | 2 +- libmultipath/dmparser.c | 6 +++--- libmultipath/dmparser.h | 2 +- libmultipath/structs_vec.c | 2 +- multipath/main.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
libmpathpersist/mpath_persist.c +1 -1
@@ -395,7 +395,7 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)condlog (3 ,"params = %s" , params);dm_get_status (mpp->alias, status);condlog (3 ,"status = %s" , status); -disassemble_map (pathvec, params, mpp); +disassemble_map (pathvec, params, mpp, conf->daemon);/* * disassemble_map() can add new paths to pathvec.
libmultipath/dmparser.c +3 -3
@@ -13,7 +13,6 @@#include "structs.h" #include "util.h" #include "debug.h" -#include "config.h" #define WORD_SIZE 64
@@ -142,7 +141,8 @@ assemble_map (struct multipath * mp, char * params, int len) }extern int -disassemble_map (vector pathvec,char * params,struct multipath * mpp) +disassemble_map (vector pathvec,char * params,struct multipath * mpp, +int is_daemon) {char * word;char * p;
@@ -351,7 +351,7 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp) WWID_SIZE - 1); }/* Only call this in multipath client mode */ -if (!conf->daemon &&store_path (pathvec, pp)) +if (!is_daemon &&store_path (pathvec, pp)) goto out1; }else { if (!strlen(pp->wwid) &&
libmultipath/dmparser.h +1 -1
@@ -1,3 +1,3 @@int assemble_map (struct multipath *,char *,int ); -int disassemble_map (vector ,char *,struct multipath *); +int disassemble_map (vector ,char *,struct multipath *,int );int disassemble_status (char *,struct multipath *);
libmultipath/structs_vec.c +1 -1
@@ -259,7 +259,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec)return 1 ; } -if (disassemble_map (pathvec, params, mpp)) { +if (disassemble_map (pathvec, params, mpp, conf->daemon)) {condlog (3 ,"%s: cannot disassemble map" , mpp->alias);return 1 ; }
multipath/main.c +1 -1
@@ -206,7 +206,7 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)dm_get_status (mpp->alias, status);condlog (3 ,"status = %s" , status); -disassemble_map (pathvec, params, mpp); +disassemble_map (pathvec, params, mpp, conf->daemon);/* * disassemble_map() can add new paths to pathvec.
Signature · 1 line
2.6.6
PATCH v2 6/26 libmultipath: use 'is_daemon' as argument for domap() etc
In reply to Hannes ReineckeUse 'is_daemon' as argument for domap() and coalesce_paths() to avoid having to access struct config.
--- libmultipath/configure.c | 16 ++++++++-------- libmultipath/configure.h | 6 +++--- libmultipath/structs_vec.c | 15 ++++++++------- libmultipath/structs_vec.h | 9 +++++---- multipath/main.c | 3 ++- multipathd/cli_handlers.c | 6 +++--- multipathd/main.c | 14 +++++++------- 7 files changed, 36 insertions(+), 33 deletions(-)
libmultipath/configure.c +8 -8
@@ -579,7 +579,7 @@ fail:#define DOMAP_DRY 3extern int -domap (struct multipath * mpp,char * params) +domap (struct multipath * mpp,char * params,int is_daemon) {int r =DOMAP_FAIL ;
@@ -655,7 +655,7 @@ domap (struct multipath * mpp, char * params)*/ if (mpp->action ==ACT_CREATE )remember_wwid (mpp->wwid); -if (!conf->daemon) { +if (!is_daemon) {/* multipath client mode */ dm_switchgroup (mpp->alias, mpp->bestpg); }else {
@@ -731,7 +731,7 @@ out: }extern int -coalesce_paths (struct vectors * vecs,vector newmp,char * refwwid,int force_reload) +coalesce_paths (struct vectors * vecs,vector newmp,char * refwwid,int force_reload,int is_daemon) {int r =1 ;int k, i;
@@ -830,7 +830,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rif (mpp->action ==ACT_UNDEF )select_action (mpp, curmp, force_reload); - r =domap (mpp, params); + r =domap (mpp, params, is_daemon);if (r ==DOMAP_FAIL || r ==DOMAP_RETRY ) { condlog(3, "%s: domap (%u) failure "
@@ -848,7 +848,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rif (r ==DOMAP_DRY )continue ; -if (!conf->daemon && !conf->allow_queueing && !check_daemon ()) { +if (!is_daemon && !conf->allow_queueing && !check_daemon ()) {if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && mpp->no_path_retry !=NO_PATH_RETRY_FAIL ) condlog(3, "%s: multipathd not running, unset "
@@ -873,7 +873,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r } } -if (!conf->daemon && mpp->action !=ACT_NOTHING ) +if (!is_daemon && mpp->action !=ACT_NOTHING )print_multipath_topology (mpp, conf->verbosity);if (newmp) {
@@ -1068,7 +1068,7 @@ out:return 1 ; } -extern int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh) +extern int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh,int is_daemon) {char params[PARAMS_SIZE ] = {0 };struct path *pp;
@@ -1091,7 +1091,7 @@ extern int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh) }select_action (mpp, vecs->mpvec,1 ); - r =domap (mpp, params); + r =domap (mpp, params, is_daemon);if (r ==DOMAP_FAIL || r ==DOMAP_RETRY ) {condlog (3 ,"%s: domap (%u) failure " "for reload map" , mpp->alias, r);
libmultipath/configure.h +3 -3
@@ -25,9 +25,9 @@ enum actions {#define FLUSH_ALL 2int setup_map (struct multipath * mpp,char * params,int params_size ); -int domap (struct multipath * mpp,char * params); +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); +int coalesce_paths (struct vectors *vecs,vector curmp,char * refwwid,int force_reload,int is_daemon);int get_refwwid (char * dev,enum devtypes dev_type,vector pathvec,char **wwid); -int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh); +int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh,int is_daemon);int sysfs_get_host_adapter_name (struct path *pp,char *adapter_name);
libmultipath/structs_vec.c +8 -7
@@ -247,7 +247,7 @@ extract_hwe_from_path(struct multipath * mpp) }static int -update_multipath_table (struct multipath *mpp,vector pathvec) +update_multipath_table (struct multipath *mpp,vector pathvec,int is_daemon) {char params[PARAMS_SIZE ] = {0 };
@@ -259,7 +259,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec)return 1 ; } -if (disassemble_map (pathvec, params, mpp, conf->daemon)) { +if (disassemble_map (pathvec, params, mpp, is_daemon)) {condlog (3 ,"%s: cannot disassemble map" , mpp->alias);return 1 ; }
@@ -314,7 +314,7 @@ void sync_paths(struct multipath *mpp, vector pathvec) }extern int -update_multipath_strings (struct multipath *mpp,vector pathvec) +update_multipath_strings (struct multipath *mpp,vector pathvec,int is_daemon) {if (!mpp)return 1 ;
@@ -326,7 +326,7 @@ update_multipath_strings (struct multipath *mpp, vector pathvec)free_pgvec (mpp->pg,KEEP_PATHS ); mpp->pg =NULL ; -if (update_multipath_table (mpp, pathvec)) +if (update_multipath_table (mpp, pathvec, is_daemon))return 1 ;sync_paths (mpp, pathvec);
@@ -365,7 +365,8 @@ set_no_path_retry(struct multipath *mpp) }extern int -__setup_multipath (struct vectors * vecs,struct multipath * mpp,int reset) +__setup_multipath (struct vectors * vecs,struct multipath * mpp, +int reset,int is_daemon) {if (dm_get_info (mpp->alias, &mpp->dmi)) {/* Error accessing table */
@@ -379,7 +380,7 @@ __setup_multipath (struct vectors * vecs, struct multipath * mpp, int reset) goto out; } -if (update_multipath_strings (mpp, vecs->pathvec)) { +if (update_multipath_strings (mpp, vecs->pathvec, is_daemon)) {condlog (0 ,"%s: failed to setup multipath" , mpp->alias); goto out; }
@@ -548,7 +549,7 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)return 2 ; } -if (__setup_multipath (vecs, mpp, reset)) +if (__setup_multipath (vecs, mpp, reset,1 ))return 1 ;/* mpp freed in setup_multipath */ /*
libmultipath/structs_vec.h +5 -4
@@ -22,10 +22,11 @@ void orphan_path (struct path * pp, const char *reason);int verify_paths (struct multipath * mpp,struct vectors * vecs);int update_mpp_paths (struct multipath * mpp,vector pathvec);int __setup_multipath (struct vectors * vecs,struct multipath * mpp, -int reset); -#define setup_multipath (vecs, mpp) __setup_multipath(vecs, mpp, 1) -int update_multipath_strings (struct multipath *mpp,vector pathvec); - +int reset,int is_daemon); +#define setup_multipath (vecs, mpp) __setup_multipath(vecs, mpp, 1, 1) +int update_multipath_strings (struct multipath *mpp,vector pathvec, +int is_daemon); +void remove_map (struct multipath * mpp,struct vectors * vecs,int purge_vec);void remove_map_and_stop_waiter (struct multipath * mpp,struct vectors * vecs,int purge_vec);void remove_maps (struct vectors * vecs);
multipath/main.c +2 -1
@@ -380,7 +380,8 @@ configure (void)/* * core logic entry point */ - r =coalesce_paths (&vecs,NULL , refwwid, conf->force_reload); + r =coalesce_paths (&vecs,NULL , refwwid, + conf->force_reload, conf->daemon); out:if (refwwid)
multipathd/cli_handlers.c +3 -3
@@ -711,7 +711,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data) rc =get_refwwid (param,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { -if (coalesce_paths (vecs,NULL , refwwid,0 )) +if (coalesce_paths (vecs,NULL , refwwid,0 , conf->daemon))condlog (2 ,"%s: coalesce_paths failed" , param);dm_lib_release ();
@@ -789,7 +789,7 @@ cli_reload(void *v, char **reply, int *len, void *data)return 1 ; } -return reload_map (vecs, mpp,0 ); +return reload_map (vecs, mpp,0 , conf->daemon); } int resize_map(struct multipath *mpp, unsigned long long size,
@@ -802,7 +802,7 @@ int resize_map(struct multipath *mpp, unsigned long long size,update_mpp_paths (mpp, vecs->pathvec);setup_map (mpp, params,PARAMS_SIZE ); mpp->action =ACT_RESIZE ; -if (domap (mpp, params) <=0 ) { +if (domap (mpp, params, conf->daemon) <=0 ) {condlog (0 ,"%s: failed to resize map : %s" , mpp->alias,strerror (errno)); mpp->size = orig_size;
multipathd/main.c +7 -7
@@ -379,7 +379,7 @@ retry: retries =-1 ; goto fail; } -if (domap (mpp, params) <=0 && retries-- >0 ) { +if (domap (mpp, params, conf->daemon) <=0 && retries-- >0 ) {condlog (0 ,"%s: map_udate sleep" , mpp->alias);sleep (1 ); goto retry;
@@ -487,7 +487,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) r =get_refwwid (dev,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { - r =coalesce_paths (vecs,NULL , refwwid,0 ); + r =coalesce_paths (vecs,NULL , refwwid,0 , conf->daemon);dm_lib_release (); }
@@ -724,7 +724,7 @@ rescan:* reload the map for the multipath mapped device */ retry: - ret =domap (mpp, params); + ret =domap (mpp, params, conf->daemon);if (ret <=0 ) {if (ret <0 && retries-- >0 ) { condlog(0, "%s: retry domap for addition of new "
@@ -866,7 +866,7 @@ ev_remove_path (struct path *pp, struct vectors * vecs)* reload the map */ mpp->action =ACT_RELOAD ; -if (domap (mpp, params) <=0 ) { +if (domap (mpp, params, conf->daemon) <=0 ) {condlog (0 ,"%s: failed in domap for " "removal of path %s" , mpp->alias, pp->dev);
@@ -931,7 +931,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } }if (mpp) { - retval =reload_map (vecs, mpp,0 ); + retval =reload_map (vecs, mpp,0 , conf->daemon);condlog (2 ,"%s: map %s reloaded (retval %d)" , uev->kernel, mpp->alias, retval);
@@ -1361,7 +1361,7 @@ int update_prio(struct path *pp, int refresh_all)int update_path_groups (struct multipath *mpp,struct vectors *vecs,int refresh) { -if (reload_map (vecs, mpp, refresh)) +if (reload_map (vecs, mpp, refresh, conf->daemon))return 1 ;dm_lib_release ();
@@ -1798,7 +1798,7 @@ configure (struct vectors * vecs, int start_waiters)/* * create new set of maps & push changed ones into dm */ -if (coalesce_paths (vecs, mpvec,NULL ,1 )) +if (coalesce_paths (vecs, mpvec,NULL ,1 , conf->daemon))return 1 ;/*
Signature · 1 line
2.6.6
PATCH v2 7/26 libmultipath: drop 'daemon' configuration setting
In reply to Hannes ReineckeThere is no need anymore to access the 'daemon' configuration setting as all callers export the 'is_daemon' argument, so it can be removed from the config structure.
--- libmpathpersist/mpath_persist.c | 2 +- libmultipath/config.h | 1 - multipath/main.c | 5 ++--- multipathd/cli_handlers.c | 6 +++--- multipathd/main.c | 18 ++++++++---------- 5 files changed, 14 insertions(+), 18 deletions(-)
libmpathpersist/mpath_persist.c +1 -1
@@ -395,7 +395,7 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)condlog (3 ,"params = %s" , params);dm_get_status (mpp->alias, status);condlog (3 ,"status = %s" , status); -disassemble_map (pathvec, params, mpp, conf->daemon); +disassemble_map (pathvec, params, mpp,0 );/* * disassemble_map() can add new paths to pathvec.
libmultipath/config.h +0 -1
@@ -115,7 +115,6 @@ struct config {int queue_without_daemon;int ignore_wwids;int checker_timeout; -int daemon;int flush_on_last_del;int attribute_flags;int fast_io_fail;
multipath/main.c +2 -3
@@ -206,7 +206,7 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)dm_get_status (mpp->alias, status);condlog (3 ,"status = %s" , status); -disassemble_map (pathvec, params, mpp, conf->daemon); +disassemble_map (pathvec, params, mpp,0 );/* * disassemble_map() can add new paths to pathvec.
@@ -381,7 +381,7 @@ configure (void)* core logic entry point */ r =coalesce_paths (&vecs,NULL , refwwid, - conf->force_reload, conf->daemon); + conf->force_reload,0 ); out:if (refwwid)
@@ -604,7 +604,6 @@ main (int argc, char *argv[]) goto out; } } - conf->daemon =0 ;if (conf->dev_type ==DEV_UEVENT ) {openlog ("multipath" ,0 ,LOG_DAEMON );setlogmask (LOG_UPTO (conf->verbosity +3 ));
multipathd/cli_handlers.c +3 -3
@@ -711,7 +711,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data) rc =get_refwwid (param,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { -if (coalesce_paths (vecs,NULL , refwwid,0 , conf->daemon)) +if (coalesce_paths (vecs,NULL , refwwid,0 ,1 ))condlog (2 ,"%s: coalesce_paths failed" , param);dm_lib_release ();
@@ -789,7 +789,7 @@ cli_reload(void *v, char **reply, int *len, void *data)return 1 ; } -return reload_map (vecs, mpp,0 , conf->daemon); +return reload_map (vecs, mpp,0 ,1 ); } int resize_map(struct multipath *mpp, unsigned long long size,
@@ -802,7 +802,7 @@ int resize_map(struct multipath *mpp, unsigned long long size,update_mpp_paths (mpp, vecs->pathvec);setup_map (mpp, params,PARAMS_SIZE ); mpp->action =ACT_RESIZE ; -if (domap (mpp, params, conf->daemon) <=0 ) { +if (domap (mpp, params,1 ) <=0 ) {condlog (0 ,"%s: failed to resize map : %s" , mpp->alias,strerror (errno)); mpp->size = orig_size;
multipathd/main.c +8 -10
@@ -379,7 +379,7 @@ retry: retries =-1 ; goto fail; } -if (domap (mpp, params, conf->daemon) <=0 && retries-- >0 ) { +if (domap (mpp, params,1 ) <=0 && retries-- >0 ) {condlog (0 ,"%s: map_udate sleep" , mpp->alias);sleep (1 ); goto retry;
@@ -487,7 +487,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) r =get_refwwid (dev,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { - r =coalesce_paths (vecs,NULL , refwwid,0 , conf->daemon); + r =coalesce_paths (vecs,NULL , refwwid,0 ,1 );dm_lib_release (); }
@@ -724,7 +724,7 @@ rescan:* reload the map for the multipath mapped device */ retry: - ret =domap (mpp, params, conf->daemon); + ret =domap (mpp, params,1 );if (ret <=0 ) {if (ret <0 && retries-- >0 ) { condlog(0, "%s: retry domap for addition of new "
@@ -866,7 +866,7 @@ ev_remove_path (struct path *pp, struct vectors * vecs)* reload the map */ mpp->action =ACT_RELOAD ; -if (domap (mpp, params, conf->daemon) <=0 ) { +if (domap (mpp, params,1 ) <=0 ) {condlog (0 ,"%s: failed in domap for " "removal of path %s" , mpp->alias, pp->dev);
@@ -931,7 +931,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } }if (mpp) { - retval =reload_map (vecs, mpp,0 , conf->daemon); + retval =reload_map (vecs, mpp,0 ,1 );condlog (2 ,"%s: map %s reloaded (retval %d)" , uev->kernel, mpp->alias, retval);
@@ -1361,7 +1361,7 @@ int update_prio(struct path *pp, int refresh_all)int update_path_groups (struct multipath *mpp,struct vectors *vecs,int refresh) { -if (reload_map (vecs, mpp, refresh, conf->daemon)) +if (reload_map (vecs, mpp, refresh,1 ))return 1 ;dm_lib_release ();
@@ -1452,7 +1452,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)/* * Synchronize with kernel state */ -if (update_multipath_strings (pp->mpp, vecs->pathvec)) { +if (update_multipath_strings (pp->mpp, vecs->pathvec,1 )) {condlog (1 ,"%s: Could not synchronize with kernel state" , pp->dev); pp->dmstate =PSTATE_UNDEF ;
@@ -1798,7 +1798,7 @@ configure (struct vectors * vecs, int start_waiters)/* * create new set of maps & push changed ones into dm */ -if (coalesce_paths (vecs, mpvec,NULL ,1 , conf->daemon)) +if (coalesce_paths (vecs, mpvec,NULL ,1 ,1 ))return 1 ;/*
@@ -1882,7 +1882,6 @@ reconfigure (struct vectors * vecs) conf->verbosity = old->verbosity; conf->bindings_read_only = old->bindings_read_only; conf->ignore_new_devs = old->ignore_new_devs; - conf->daemon =1 ;configure (vecs,1 );free_config (old); retval =0 ;
@@ -2161,7 +2160,6 @@ child (void * param)setscheduler ();set_oom_adj (); - conf->daemon =1 ;dm_udev_set_sync_support (0 );#ifdef USE_SYSTEMD envp =getenv ("WATCHDOG_USEC" );
Signature · 1 line
2.6.6
PATCH v2 8/26 libmultipath: Do not access 'conf->cmd' in domap()
In reply to Hannes Reinecke'conf->cmd' is only ever set if we're called from multipath, so we can combine the 'is_daemon' argument and the 'conf->cmd' check in domap() and avoid accessing 'conf->cmd' in domap().
--- libmultipath/config.h | 1 + libmultipath/configure.c | 7 +++++-- libmultipath/configure.h | 3 ++- multipath/main.c | 5 +++-- multipathd/main.c | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-)
libmultipath/config.h +1 -0
@@ -24,6 +24,7 @@ enum devtypes { };enum mpath_cmds { +CMD_NONE ,CMD_CREATE ,CMD_DRY_RUN ,CMD_LIST_SHORT ,
libmultipath/configure.c +5 -2
@@ -586,7 +586,7 @@ domap (struct multipath * mpp, char * params, int is_daemon)/* * last chance to quit before touching the devmaps */ -if (conf->cmd ==CMD_DRY_RUN && mpp->action !=ACT_NOTHING ) { +if (mpp->action ==ACT_DRY_RUN ) {print_multipath_topology (mpp, conf->verbosity);return DOMAP_DRY ; }
@@ -731,10 +731,11 @@ out: }extern int -coalesce_paths (struct vectors * vecs,vector newmp,char * refwwid,int force_reload,int is_daemon) +coalesce_paths (struct vectors * vecs,vector newmp,char * refwwid,int force_reload,enum mpath_cmds cmd) {int r =1 ;int k, i; +int is_daemon = (cmd ==CMD_NONE ) ?1 :0 ;char params[PARAMS_SIZE ];struct multipath * mpp;struct path * pp1;
@@ -827,6 +828,8 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rcontinue ; } +if (cmd ==CMD_DRY_RUN ) + mpp->action =ACT_DRY_RUN ;if (mpp->action ==ACT_UNDEF )select_action (mpp, curmp, force_reload);
libmultipath/configure.h +2 -1
@@ -19,6 +19,7 @@ enum actions {ACT_CREATE ,ACT_RESIZE ,ACT_FORCERENAME , + ACT_DRY_RUN, };#define FLUSH_ONE 1
@@ -27,7 +28,7 @@ enum actions {int setup_map (struct multipath * mpp,char * params,int params_size );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,int is_daemon); +int coalesce_paths (struct vectors *vecs,vector curmp,char * refwwid,int force_reload,enum mpath_cmds cmd);int get_refwwid (char * dev,enum devtypes dev_type,vector pathvec,char **wwid);int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh,int is_daemon);int sysfs_get_host_adapter_name (struct path *pp,char *adapter_name);
multipath/main.c +3 -2
@@ -381,7 +381,7 @@ configure (void)* core logic entry point */ r =coalesce_paths (&vecs,NULL , refwwid, - conf->force_reload,0 ); + conf->force_reload, conf->cmd); out:if (refwwid)
@@ -484,7 +484,8 @@ main (int argc, char *argv[]) logsink =0 ;if (load_config (DEFAULT_CONFIGFILE , udev))exit (1 ); - +/* Default to CMD_CREATE */ + conf->cmd =CMD_CREATE ;while ((arg =getopt (argc, argv,":adchl::FfM:v:p:b:BritquwW" )) !=EOF ) {switch (arg) {case 1 :printf ("optarg : %s\n" ,optarg);
multipathd/main.c +2 -2
@@ -487,7 +487,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) r =get_refwwid (dev,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { - r =coalesce_paths (vecs,NULL , refwwid,0 ,1 ); + r =coalesce_paths (vecs,NULL , refwwid,0 ,CMD_NONE );dm_lib_release (); }
@@ -1798,7 +1798,7 @@ configure (struct vectors * vecs, int start_waiters)/* * create new set of maps & push changed ones into dm */ -if (coalesce_paths (vecs, mpvec,NULL ,1 ,1 )) +if (coalesce_paths (vecs, mpvec,NULL ,1 ,CMD_NONE ))return 1 ;/*
Signature · 1 line
2.6.6
PATCH v2 9/26 libmultipath: add 'cmd' as argument for get_refwwid()
In reply to Hannes ReineckeThis patch adds an 'cmd' argument to get_refwwid(). This allows store_pathvec() to be simplified and avoids accesses to conf->cmd.
--- libmultipath/configure.c | 13 +++++++++---- libmultipath/configure.h | 3 ++- libmultipath/discovery.c | 4 +--- multipath/main.c | 4 ++-- multipathd/cli_handlers.c | 4 ++-- multipathd/main.c | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-)
libmultipath/configure.c +9 -4
@@ -925,12 +925,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r* 2 - blacklist */ extern int -get_refwwid (char * dev,enum devtypes dev_type,vector pathvec,char **wwid) +get_refwwid (enum mpath_cmds cmd,char * dev,enum devtypes dev_type, +vector pathvec,char **wwid) {int ret =1 ;struct path * pp;char buff[FILE_NAME_SIZE ];char * refwwid =NULL , tmpwwid[WWID_SIZE ]; +int flags =DI_SYSFS |DI_WWID ;if (!wwid)return 1 ;
@@ -939,6 +941,9 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)if (dev_type ==DEV_NONE )return 1 ; +if (cmd !=CMD_REMOVE_WWID ) + flags |=DI_BLACKLIST ; +if (dev_type ==DEV_DEVNODE ) {if (basenamecpy (dev, buff,FILE_NAME_SIZE ) ==0 ) { condlog(1, "basename failed for '%s' (%s)",
@@ -955,7 +960,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)return 1 ; } ret =store_pathinfo (pathvec, conf->hwtable, udevice, -DI_SYSFS |DI_WWID , &pp); + flags, &pp);udev_device_unref (udevice);if (!pp) {if (ret ==1 )
@@ -987,7 +992,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)return 1 ; } ret =store_pathinfo (pathvec, conf->hwtable, udevice, -DI_SYSFS |DI_WWID , &pp); + flags, &pp);udev_device_unref (udevice);if (!pp) {if (ret ==1 )
@@ -1012,7 +1017,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid)return 1 ; } ret =store_pathinfo (pathvec, conf->hwtable, udevice, -DI_SYSFS |DI_WWID , &pp); + flags, &pp);udev_device_unref (udevice);if (!pp) {if (ret ==1 )
libmultipath/configure.h +2 -1
@@ -29,6 +29,7 @@ int setup_map (struct multipath * mpp, char * params, int params_size );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); -int get_refwwid (char * dev,enum devtypes dev_type,vector pathvec,char **wwid); +int get_refwwid (enum mpath_cmds cmd,char * dev,enum devtypes dev_type, +vector pathvec,char **wwid);int reload_map (struct vectors *vecs,struct multipath *mpp,int refresh,int is_daemon);int sysfs_get_host_adapter_name (struct path *pp,char *adapter_name);
libmultipath/discovery.c +1 -3
@@ -90,9 +90,7 @@ store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice, goto out; } pp->udev =udev_device_ref (udevice); - err =pathinfo (pp, hwtable, - (conf->cmd ==CMD_REMOVE_WWID )? flag : - (flag |DI_BLACKLIST )); + err =pathinfo (pp, hwtable, flag);if (err) goto out;
multipath/main.c +2 -2
@@ -281,8 +281,8 @@ configure (void)* failing the translation is fatal (by policy) */ if (conf->dev) { -int failed =get_refwwid (conf->dev, conf->dev_type, pathvec, - &refwwid); +int failed =get_refwwid (conf->cmd, conf->dev, conf->dev_type, + pathvec, &refwwid);if (!refwwid) {condlog (4 ,"%s: failed to get wwid" , conf->dev);if (failed ==2 && conf->cmd ==CMD_VALID_PATH )
multipathd/cli_handlers.c +2 -2
@@ -708,8 +708,8 @@ cli_add_map (void * v, char ** reply, int * len, void * data)if (!alias && !count) {condlog (2 ,"%s: mapname not found for %d:%d" , param, major, minor); - rc =get_refwwid (param,DEV_DEVMAP , vecs->pathvec, - &refwwid); + rc =get_refwwid (CMD_NONE , param,DEV_DEVMAP , + vecs->pathvec, &refwwid);if (refwwid) {if (coalesce_paths (vecs,NULL , refwwid,0 ,1 )) condlog(2, "%s: coalesce_paths failed",
multipathd/main.c +1 -1
@@ -484,7 +484,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)return 1 ; } } - r =get_refwwid (dev,DEV_DEVMAP , vecs->pathvec, &refwwid); + r =get_refwwid (CMD_NONE , dev,DEV_DEVMAP , vecs->pathvec, &refwwid);if (refwwid) { r =coalesce_paths (vecs,NULL , refwwid,0 ,CMD_NONE );
Signature · 1 line
2.6.6
PATCH v2 10/26 libmultipath: fallback to checking environment variable in get_udev_uid()
In reply to Hannes ReineckeIf we cannot get the udev attribute via udev we should always fallback to checking the environment variable; there is no need to restrict it to a specific command.
--- libmultipath/discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/discovery.c +1 -1
@@ -1479,7 +1479,7 @@ get_udev_uid(struct path * pp, char *uid_attribute) value =udev_device_get_property_value (pp->udev, uid_attribute); -if ((!value ||strlen (value) ==0 ) && conf->cmd ==CMD_VALID_PATH ) +if (!value ||strlen (value) ==0 ) value =getenv (uid_attribute);if (value &&strlen (value)) {if (strlen (value) +1 >WWID_SIZE ) {
Signature · 1 line
2.6.6
PATCH v2 11/26 multipath: make 'cmd' internal to multipath program
In reply to Hannes ReineckeOnly the multipath program is using the 'cmd' setting, so we should be dropping it from the config structure and make it a local variable for multipath.
--- libmultipath/config.h | 1 - multipath/main.c | 73 +++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 38 deletions(-)
libmultipath/config.h +0 -1
@@ -97,7 +97,6 @@ struct mpentry {struct config {int verbosity; -enum mpath_cmds cmd;int pgpolicy_flag;int pgpolicy;enum devtypes dev_type;
multipath/main.c +36 -37
234 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v2 12/26 multipath: make 'dev_type' internal to the multipath program
In reply to Hannes ReineckeOnly the multipath program uses the 'dev_type' config entry, so we should be dropping it from the main configuration and make it a local variable to the multipath program.
--- libmultipath/config.c | 1 - libmultipath/config.h | 1 - multipath/main.c | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-)
libmultipath/config.c +0 -1
@@ -595,7 +595,6 @@ load_config (char * file, struct udev *udev) conf->verbosity =DEFAULT_VERBOSITY ; conf->udev = udev; - conf->dev_type =DEV_NONE ; conf->minio =DEFAULT_MINIO ; conf->minio_rq =DEFAULT_MINIO_RQ ;get_sys_max_fds (&conf->max_fds);
libmultipath/config.h +0 -1
@@ -99,7 +99,6 @@ struct config {int verbosity;int pgpolicy_flag;int pgpolicy; -enum devtypes dev_type;int minio;int minio_rq;int checkint;
multipath/main.c +15 -14
@@ -239,7 +239,7 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)* 1: Failure */ static int -configure (enum mpath_cmds cmd) +configure (enum mpath_cmds cmd,enum devtypes dev_type) {vector curmp =NULL ;vector pathvec =NULL ;
@@ -262,12 +262,12 @@ configure (enum mpath_cmds cmd) vecs.pathvec = pathvec; vecs.mpvec = curmp; - dev =convert_dev (conf->dev, (conf->dev_type ==DEV_DEVNODE )); + dev =convert_dev (conf->dev, (dev_type ==DEV_DEVNODE ));/* * if we have a blacklisted device parameter, exit early */ -if (dev && conf->dev_type ==DEV_DEVNODE && +if (dev && dev_type ==DEV_DEVNODE && cmd !=CMD_REMOVE_WWID && (filter_devnode (conf->blist_devnode, conf->elist_devnode, dev) >0 )) {
@@ -281,7 +281,7 @@ configure (enum mpath_cmds cmd)* failing the translation is fatal (by policy) */ if (conf->dev) { -int failed =get_refwwid (cmd, conf->dev, conf->dev_type, +int failed =get_refwwid (cmd, conf->dev, dev_type, pathvec, &refwwid);if (!refwwid) {condlog (4 ,"%s: failed to get wwid" , conf->dev);
@@ -480,6 +480,7 @@ main (int argc, char *argv[])extern int optind;int r =1 ;enum mpath_cmds cmd =CMD_CREATE ; +enum devtypes dev_type; udev =udev_new (); logsink =0 ;
@@ -554,7 +555,7 @@ main (int argc, char *argv[])exit (0 );case 'u' : cmd =CMD_VALID_PATH ; - conf->dev_type =DEV_UEVENT ; + dev_type =DEV_UEVENT ;break ;case 'w' : cmd =CMD_REMOVE_WWID ;
@@ -597,14 +598,14 @@ main (int argc, char *argv[]) goto out;strncpy (conf->dev, argv[optind],FILE_NAME_SIZE ); -if (conf->dev_type !=DEV_UEVENT ) - conf->dev_type =get_dev_type (conf->dev); -if (conf->dev_type ==DEV_NONE ) { +if (dev_type !=DEV_UEVENT ) + dev_type =get_dev_type (conf->dev); +if (dev_type ==DEV_NONE ) {condlog (0 ,"'%s' is not a valid argument\n" , conf->dev); goto out; } } -if (conf->dev_type ==DEV_UEVENT ) { +if (dev_type ==DEV_UEVENT ) {openlog ("multipath" ,0 ,LOG_DAEMON );setlogmask (LOG_UPTO (conf->verbosity +3 )); logsink =1 ;
@@ -630,12 +631,12 @@ main (int argc, char *argv[]) }if (cmd ==CMD_VALID_PATH && - (!conf->dev || conf->dev_type ==DEV_DEVMAP )) { + (!conf->dev || dev_type ==DEV_DEVMAP )) {condlog (0 ,"the -c option requires a path to check" ); goto out; }if (cmd ==CMD_VALID_PATH && - conf->dev_type ==DEV_UEVENT ) { + dev_type ==DEV_UEVENT ) {int fd; fd =mpath_connect ();
@@ -672,7 +673,7 @@ main (int argc, char *argv[]) goto out; }if (conf->remove ==FLUSH_ONE ) { -if (conf->dev_type ==DEV_DEVMAP ) { +if (dev_type ==DEV_DEVMAP ) { r =dm_suspend_and_flush_map (conf->dev); }else condlog (0 ,"must provide a map name to remove" );
@@ -683,7 +684,7 @@ main (int argc, char *argv[]) r =dm_flush_maps (); goto out; } -while ((r =configure (cmd)) <0 ) +while ((r =configure (cmd, dev_type)) <0 )condlog (3 ,"restart multipath configuration process" ); out:
@@ -693,7 +694,7 @@ out:cleanup_prio ();cleanup_checkers (); -if (conf->dev_type ==DEV_UEVENT ) +if (dev_type ==DEV_UEVENT )closelog (); out_free_config:
Signature · 1 line
2.6.6
PATCH v2 13/26 multipath: make 'dev' internal to the multipath program
In reply to Hannes ReineckeOnly the multipath program is accessing the config entry 'dev', so we should be making it a local variable.
--- libmultipath/config.c | 3 --- libmultipath/config.h | 1 - multipath/main.c | 43 +++++++++++++++++++++++-------------------- 3 files changed, 23 insertions(+), 24 deletions(-)
libmultipath/config.c +0 -3
@@ -478,9 +478,6 @@ free_config (struct config * conf)if (!conf)return ; -if (conf->dev) -FREE (conf->dev); -if (conf->multipath_dir)FREE (conf->multipath_dir);
libmultipath/config.h +0 -1
@@ -141,7 +141,6 @@ struct config {int uev_wait_timeout;unsigned int version[3 ]; -char * dev;struct udev * udev;char * multipath_dir;char * selector;
multipath/main.c +23 -20
139 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v2 14/26 libmultipath: separate out 'udev' config entry
In reply to Hannes ReineckeRather than add the 'udev' structure to the config entry we should be using a separate global variable here. Otherwise we run into a risk of udev getting out-of-sync internally when recreating the udev structure.
--- libmpathpersist/mpath_persist.c | 3 ++- libmultipath/config.c | 3 +-- libmultipath/config.h | 4 ++-- libmultipath/configure.c | 6 +++--- libmultipath/discovery.c | 18 +++++++++--------- libmultipath/print.c | 4 ++-- multipath/main.c | 4 ++-- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 12 ++++++------ 9 files changed, 28 insertions(+), 28 deletions(-)
libmpathpersist/mpath_persist.c +2 -1
@@ -34,11 +34,12 @@#define __STDC_FORMAT_MACROS 1 +struct udev *udev;int mpath_lib_init (struct udev *udev) { -if (load_config (DEFAULT_CONFIGFILE , udev)){ +if (load_config (DEFAULT_CONFIGFILE )){condlog (0 ,"Failed to initialize multipath config." );return 1 ; }
libmultipath/config.c +1 -2
@@ -577,7 +577,7 @@ process_config_dir(vector keywords, char *dir) }int -load_config (char * file,struct udev *udev) +load_config (char * file) {if (!conf) conf =alloc_config ();
@@ -591,7 +591,6 @@ load_config (char * file, struct udev *udev)if (!conf->verbosity) conf->verbosity =DEFAULT_VERBOSITY ; - conf->udev = udev; conf->minio =DEFAULT_MINIO ; conf->minio_rq =DEFAULT_MINIO_RQ ;get_sys_max_fds (&conf->max_fds);
libmultipath/config.h +2 -2
@@ -141,7 +141,6 @@ struct config {int uev_wait_timeout;unsigned int version[3 ]; -struct udev * udev;char * multipath_dir;char * selector;char * uid_attribute;
@@ -174,6 +173,7 @@ struct config { };struct config * conf; +extern struct udev * udev;struct hwentry *find_hwe (vector hwtable,char * vendor,char * product,char *revision);struct mpentry *find_mpe (vector mptable,char * wwid);
@@ -189,7 +189,7 @@ void free_mptable (vector mptable);int store_hwe (vector hwtable,struct hwentry *); -int load_config (char * file,struct udev * udev); +int load_config (char * file);struct config *alloc_config (void );void free_config (struct config * conf);
libmultipath/configure.c +3 -3
@@ -953,7 +953,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, pp =find_path_by_dev (pathvec, buff);if (!pp) { -struct udev_device *udevice =udev_device_new_from_subsystem_sysname (conf->udev,"block" , buff); +struct udev_device *udevice =udev_device_new_from_subsystem_sysname (udev,"block" , buff);if (!udevice) {condlog (2 ,"%s: can't get udev device" , buff);
@@ -985,7 +985,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, } pp =find_path_by_dev (pathvec, buff);if (!pp) { -struct udev_device *udevice =udev_device_new_from_devnum (conf->udev,'b' ,parse_devt (dev)); +struct udev_device *udevice =udev_device_new_from_devnum (udev,'b' ,parse_devt (dev));if (!udevice) {condlog (2 ,"%s: can't get udev device" , dev);
@@ -1010,7 +1010,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, }if (dev_type ==DEV_UEVENT ) { -struct udev_device *udevice =udev_device_new_from_environment (conf->udev); +struct udev_device *udevice =udev_device_new_from_environment (udev);if (!udevice) {condlog (2 ,"%s: can't get udev device" , dev);
libmultipath/discovery.c +9 -9
@@ -141,7 +141,7 @@ path_discovery (vector pathvec, struct config * conf, int flag)const char *devpath;int num_paths =0 , total_paths =0 ; - udev_iter =udev_enumerate_new (conf->udev); + udev_iter =udev_enumerate_new (udev);if (!udev_iter)return -ENOMEM ;
@@ -154,7 +154,7 @@ path_discovery (vector pathvec, struct config * conf, int flag)const char *devtype; devpath =udev_list_entry_get_name (entry);condlog (4 ,"Discover device %s" , devpath); - udevice =udev_device_new_from_syspath (conf->udev, devpath); + udevice =udev_device_new_from_syspath (udev, devpath);if (!udevice) {condlog (4 ,"%s: no udev information" , devpath);continue ;
@@ -323,7 +323,7 @@ sysfs_get_tgt_nodename (struct path *pp, char * node) value =udev_device_get_sysname (tgtdev);if (sscanf (value,"rport-%d:%d-%d" , &host, &channel, &tgtid) ==3 ) { - tgtdev =udev_device_new_from_subsystem_sysname (conf->udev, + tgtdev =udev_device_new_from_subsystem_sysname (udev,"fc_remote_ports" , value);if (tgtdev) { condlog(3, "SCSI target %d:%d:%d -> "
@@ -356,7 +356,7 @@ sysfs_get_tgt_nodename (struct path *pp, char * node) tgtid =-1 ; }if (parent && tgtname) { - tgtdev =udev_device_new_from_subsystem_sysname (conf->udev, + tgtdev =udev_device_new_from_subsystem_sysname (udev,"iscsi_session" , tgtname);if (tgtdev) {const char *value;
@@ -430,7 +430,7 @@ int sysfs_get_host_pci_name(struct path *pp, char *pci_name)return 1 ;sprintf (host_name,"host%d" , pp->sg_id.host_no); - hostdev =udev_device_new_from_subsystem_sysname (conf->udev, + hostdev =udev_device_new_from_subsystem_sysname (udev,"scsi_host" , host_name);if (!hostdev)return 1 ;
@@ -466,7 +466,7 @@ int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address)const char *value;sprintf (host_name,"host%d" , pp->sg_id.host_no); - hostdev =udev_device_new_from_subsystem_sysname (conf->udev, + hostdev =udev_device_new_from_subsystem_sysname (udev,"iscsi_host" , host_name);if (hostdev) { value = udev_device_get_sysattr_value(hostdev,
@@ -492,7 +492,7 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)sprintf (rport_id,"rport-%d:%d-%d" , pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id); - rport_dev =udev_device_new_from_subsystem_sysname (conf->udev, + rport_dev =udev_device_new_from_subsystem_sysname (udev,"fc_remote_ports" , rport_id);if (!rport_dev) { condlog(1, "%s: No fc_remote_port device for '%s'", pp->dev,
@@ -596,7 +596,7 @@ sysfs_set_session_tmo(struct multipath *mpp, struct path *pp)char value[11 ];sprintf (session_id,"session%d" , pp->sg_id.transport_id); - session_dev =udev_device_new_from_subsystem_sysname (conf->udev, + session_dev =udev_device_new_from_subsystem_sysname (udev,"iscsi_session" , session_id);if (!session_dev) { condlog(1, "%s: No iscsi session for '%s'", pp->dev,
@@ -638,7 +638,7 @@ sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp)sprintf (end_dev_id,"end_device-%d:%d" , pp->sg_id.host_no, pp->sg_id.transport_id); - sas_dev =udev_device_new_from_subsystem_sysname (conf->udev, + sas_dev =udev_device_new_from_subsystem_sysname (udev,"sas_end_device" , end_dev_id);if (!sas_dev) { condlog(1, "%s: No SAS end device for '%s'", pp->dev,
libmultipath/print.c +2 -2
@@ -530,7 +530,7 @@ snprint_host_attr (char * buff, size_t len, struct path * pp, char *attr)if (pp->sg_id.proto_id !=SCSI_PROTOCOL_FCP )return snprintf (buff, len,"[undef]" );sprintf (host_id,"host%d" , pp->sg_id.host_no); - host_dev =udev_device_new_from_subsystem_sysname (conf->udev,"fc_host" , + host_dev =udev_device_new_from_subsystem_sysname (udev,"fc_host" , host_id);if (!host_dev) {condlog (1 ,"%s: No fc_host device for '%s'" , pp->dev, host_id);
@@ -570,7 +570,7 @@ snprint_tgt_wwpn (char * buff, size_t len, struct path * pp)return snprintf (buff, len,"[undef]" );sprintf (rport_id,"rport-%d:%d-%d" , pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id); - rport_dev =udev_device_new_from_subsystem_sysname (conf->udev, + rport_dev =udev_device_new_from_subsystem_sysname (udev,"fc_remote_ports" , rport_id);if (!rport_dev) { condlog(1, "%s: No fc_remote_port device for '%s'", pp->dev,
multipath/main.c +2 -2
@@ -60,6 +60,7 @@#include <mpath_cmd.h> int logsink; +struct udev *udev;static int filter_pathvec (vector pathvec,char * refwwid)
@@ -474,7 +475,6 @@ get_dev_type(char *dev) {int main (int argc,char *argv[]) { -struct udev *udev;int arg;extern char *optarg;extern int optind;
@@ -485,7 +485,7 @@ main (int argc, char *argv[]) udev =udev_new (); logsink =0 ; -if (load_config (DEFAULT_CONFIGFILE , udev)) +if (load_config (DEFAULT_CONFIGFILE ))exit (1 );while ((arg =getopt (argc, argv,":adchl::FfM:v:p:b:BritquwW" )) !=EOF ) {switch (arg) {
multipathd/cli_handlers.c +1 -1
@@ -637,7 +637,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data) }else {struct udev_device *udevice; - udevice =udev_device_new_from_subsystem_sysname (conf->udev, + udevice =udev_device_new_from_subsystem_sysname (udev,"block" , param); r = store_pathinfo(vecs->pathvec, conf->hwtable,
multipathd/main.c +6 -6
@@ -1877,7 +1877,7 @@ reconfigure (struct vectors * vecs)/* Re-read any timezone changes */ tzset (); -if (!load_config (DEFAULT_CONFIGFILE , udev)) { +if (!load_config (DEFAULT_CONFIGFILE )) {dm_drv_version (conf->version,TGT_MPATH ); conf->verbosity = old->verbosity; conf->bindings_read_only = old->bindings_read_only;
@@ -2081,8 +2081,6 @@ child (void * param)mlockall (MCL_CURRENT |MCL_FUTURE );signal_init (); - udev =udev_new (); -setup_thread_attr (&misc_attr,64 *1024 ,1 );setup_thread_attr (&uevent_attr,DEFAULT_UEVENT_STACKSIZE *1024 ,1 );setup_thread_attr (&waiter_attr,32 *1024 ,1 );
@@ -2105,7 +2103,7 @@ child (void * param)condlog (2 ,"--------start up--------" );condlog (2 ,"read " DEFAULT_CONFIGFILE ); -if (load_config (DEFAULT_CONFIGFILE , udev)) +if (load_config (DEFAULT_CONFIGFILE )) goto failed; uxsock_timeout = conf->uxsock_timeout;
@@ -2384,6 +2382,8 @@ main (int argc, char *argv[])if (!conf)exit (1 ); + udev =udev_new (); +while ((arg =getopt (argc, argv,":dsv:k::Bn" )) !=EOF ) {switch (arg) {case 'd' :
@@ -2403,7 +2403,7 @@ main (int argc, char *argv[]) logsink =-1 ;break ;case 'k' : -if (load_config (DEFAULT_CONFIGFILE ,udev_new ())) +if (load_config (DEFAULT_CONFIGFILE ))exit (1 );uxclnt (optarg, uxsock_timeout +100 );exit (0 );
@@ -2424,7 +2424,7 @@ main (int argc, char *argv[])char * s = cmd;char * c = s; -if (load_config (DEFAULT_CONFIGFILE ,udev_new ())) +if (load_config (DEFAULT_CONFIGFILE ))exit (1 );memset (cmd,0x0 ,CMDSIZE );while (optind < argc) {
Signature · 1 line
2.6.6
PATCH v2 15/26 libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo()
In reply to Hannes Reinecke--- libmultipath/configure.c | 2 +- libmultipath/discovery.c | 4 ++-- libmultipath/discovery.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
libmultipath/configure.c +1 -1
@@ -294,7 +294,7 @@ setup_map (struct multipath * mpp, char * params, int params_size)select_delay_watch_checks (mpp);select_delay_wait_checks (mpp); -sysfs_set_scsi_tmo (mpp); +sysfs_set_scsi_tmo (mpp, conf->checkint);/* * assign paths to path groups -- start with no groups and all paths * in mpp->paths
libmultipath/discovery.c +2 -2
@@ -661,14 +661,14 @@ sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp) }int -sysfs_set_scsi_tmo (struct multipath *mpp) +sysfs_set_scsi_tmo (struct multipath *mpp,int checkint) {struct path *pp;int i;int dev_loss_tmo = mpp->dev_loss;if (mpp->no_path_retry >0 ) { -uint64_t no_path_retry_tmo = mpp->no_path_retry * conf->checkint; +uint64_t no_path_retry_tmo = mpp->no_path_retry * checkint;if (no_path_retry_tmo >MAX_DEV_LOSS_TMO ) no_path_retry_tmo =MAX_DEV_LOSS_TMO ;
libmultipath/discovery.h +1 -1
@@ -41,7 +41,7 @@ int alloc_path_with_pathinfo (vector hwtable, struct udev_device *udevice,int store_pathinfo (vector pathvec,vector hwtable,struct udev_device *udevice,int flag,struct path **pp_ptr); -int sysfs_set_scsi_tmo (struct multipath *mpp); +int sysfs_set_scsi_tmo (struct multipath *mpp,int checkint);int sysfs_get_timeout (struct path *pp,unsigned int *timeout);int sysfs_get_host_pci_name (struct path *pp,char *pci_name);int sysfs_get_iscsi_ip_address (struct path *pp,char *ip_address);
Signature · 1 line
2.6.6
PATCH v2 16/26 discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery()
In reply to Hannes Reinecke--- libmultipath/discovery.c | 28 ++++++++++++++-------------- libmultipath/discovery.h | 2 +- multipathd/main.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-)
libmultipath/discovery.c +14 -14
@@ -1067,7 +1067,7 @@ get_vpd_sgio (int fd, int pg, char * str, int maxlen) }static int -scsi_sysfs_pathinfo (struct path * pp) +scsi_sysfs_pathinfo (struct path * pp,vector hwtable) {struct udev_device *parent;const char *attr_path =NULL ;
@@ -1109,7 +1109,7 @@ scsi_sysfs_pathinfo (struct path * pp)/* * set the hwe configlet pointer */ - pp->hwe =find_hwe (conf->hwtable, pp->vendor_id, pp->product_id, pp->rev); + pp->hwe =find_hwe (hwtable, pp->vendor_id, pp->product_id, pp->rev);/* * host / bus / target / lun
@@ -1134,7 +1134,7 @@ scsi_sysfs_pathinfo (struct path * pp) }static int -ccw_sysfs_pathinfo (struct path * pp) +ccw_sysfs_pathinfo (struct path * pp,vector hwtable) {struct udev_device *parent;char attr_buff[NAME_SIZE ];
@@ -1170,7 +1170,7 @@ ccw_sysfs_pathinfo (struct path * pp)/* * set the hwe configlet pointer */ - pp->hwe =find_hwe (conf->hwtable, pp->vendor_id, pp->product_id,NULL ); + pp->hwe =find_hwe (hwtable, pp->vendor_id, pp->product_id,NULL );/* * host / bus / target / lun
@@ -1193,7 +1193,7 @@ ccw_sysfs_pathinfo (struct path * pp) }static int -cciss_sysfs_pathinfo (struct path * pp) +cciss_sysfs_pathinfo (struct path * pp,vector hwtable) {const char * attr_path =NULL ;struct udev_device *parent;
@@ -1233,7 +1233,7 @@ cciss_sysfs_pathinfo (struct path * pp)/* * set the hwe configlet pointer */ - pp->hwe =find_hwe (conf->hwtable, pp->vendor_id, pp->product_id, pp->rev); + pp->hwe =find_hwe (hwtable, pp->vendor_id, pp->product_id, pp->rev);/* * host / bus / target / lun
@@ -1323,7 +1323,7 @@ path_offline (struct path * pp) }int -sysfs_pathinfo (struct path * pp) +sysfs_pathinfo (struct path * pp,vector hwtable) {if (common_sysfs_pathinfo (pp))return 1 ;
@@ -1339,13 +1339,13 @@ sysfs_pathinfo(struct path * pp)if (pp->bus ==SYSFS_BUS_UNDEF )return 0 ;else if (pp->bus ==SYSFS_BUS_SCSI ) { -if (scsi_sysfs_pathinfo (pp)) +if (scsi_sysfs_pathinfo (pp, hwtable))return 1 ; }else if (pp->bus ==SYSFS_BUS_CCW ) { -if (ccw_sysfs_pathinfo (pp)) +if (ccw_sysfs_pathinfo (pp, hwtable))return 1 ; }else if (pp->bus ==SYSFS_BUS_CCISS ) { -if (cciss_sysfs_pathinfo (pp)) +if (cciss_sysfs_pathinfo (pp, hwtable))return 1 ; }return 0 ;
@@ -1397,7 +1397,7 @@ cciss_ioctl_pathinfo (struct path * pp, int mask) }int -get_state (struct path * pp,int daemon) +get_state (struct path * pp,vector hwtable,int daemon) {struct checker * c = &pp->checker;int state;
@@ -1406,7 +1406,7 @@ get_state (struct path * pp, int daemon)if (!checker_selected (c)) {if (daemon) { -if (pathinfo (pp, conf->hwtable,DI_SYSFS ) !=PATHINFO_OK ) { +if (pathinfo (pp, hwtable,DI_SYSFS ) !=PATHINFO_OK ) {condlog (3 ,"%s: couldn't get sysfs pathinfo" , pp->dev);return PATH_UNCHECKED ;
@@ -1610,7 +1610,7 @@ pathinfo (struct path *pp, vector hwtable, int mask)/* * fetch info available in sysfs */ -if (mask &DI_SYSFS &&sysfs_pathinfo (pp)) +if (mask &DI_SYSFS &&sysfs_pathinfo (pp, hwtable))return PATHINFO_FAILED ;if (mask &DI_BLACKLIST && mask &DI_SYSFS ) {
@@ -1649,7 +1649,7 @@ pathinfo (struct path *pp, vector hwtable, int mask)if (mask &DI_CHECKER ) {if (path_state ==PATH_UP ) { - pp->chkrstate = pp->state =get_state (pp,0 ); + pp->chkrstate = pp->state =get_state (pp, hwtable,0 );if (pp->state ==PATH_UNCHECKED || pp->state ==PATH_WILD ) goto blank;
libmultipath/discovery.h +1 -1
@@ -34,7 +34,7 @@ int path_discovery (vector pathvec, struct config * conf, int flag);int do_tur (char *);int path_offline (struct path *); -int get_state (struct path * pp,int daemon); +int get_state (struct path * pp,vector hwtable,int daemon);int pathinfo (struct path *,vector hwtable,int mask);int alloc_path_with_pathinfo (vector hwtable,struct udev_device *udevice,int flag,struct path **pp_ptr);
multipathd/main.c +1 -1
@@ -1421,7 +1421,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) newstate =PATH_DOWN ;if (newstate ==PATH_UP ) - newstate =get_state (pp,1 ); + newstate =get_state (pp, conf->hwtable,1 );else checker_clear_message (&pp->checker);
Signature · 1 line
2.6.6
PATCH v2 17/26 libmultipath: use 'struct config' as argument for pathinfo()
In reply to Hannes Reineckepathinfo() requires access to the entire configuration, not just hwtable. So don't pretend this is the case.
--- libmpathpersist/mpath_persist.c | 6 +++--- libmultipath/configure.c | 8 ++++---- libmultipath/discovery.c | 24 ++++++++++++------------ libmultipath/discovery.h | 8 ++++---- libmultipath/structs_vec.c | 2 +- multipath/main.c | 6 +++--- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 16 ++++++++-------- 8 files changed, 36 insertions(+), 36 deletions(-)
libmpathpersist/mpath_persist.c +3 -3
@@ -94,16 +94,16 @@ updatepaths (struct multipath * mpp)continue ; } pp->mpp = mpp; -pathinfo (pp, conf->hwtable,DI_ALL ); +pathinfo (pp, conf,DI_ALL );continue ; } pp->mpp = mpp;if (pp->state ==PATH_UNCHECKED || pp->state ==PATH_WILD ) -pathinfo (pp, conf->hwtable,DI_CHECKER ); +pathinfo (pp, conf,DI_CHECKER );if (pp->priority ==PRIO_UNDEF ) -pathinfo (pp, conf->hwtable,DI_PRIO ); +pathinfo (pp, conf,DI_PRIO ); } }return 0 ;
libmultipath/configure.c +4 -4
@@ -959,7 +959,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,condlog (2 ,"%s: can't get udev device" , buff);return 1 ; } - ret =store_pathinfo (pathvec, conf->hwtable, udevice, + ret =store_pathinfo (pathvec, conf, udevice, flags, &pp);udev_device_unref (udevice);if (!pp) {
@@ -991,7 +991,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,condlog (2 ,"%s: can't get udev device" , dev);return 1 ; } - ret =store_pathinfo (pathvec, conf->hwtable, udevice, + ret =store_pathinfo (pathvec, conf, udevice, flags, &pp);udev_device_unref (udevice);if (!pp) {
@@ -1016,7 +1016,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,condlog (2 ,"%s: can't get udev device" , dev);return 1 ; } - ret =store_pathinfo (pathvec, conf->hwtable, udevice, + ret =store_pathinfo (pathvec, conf, udevice, flags, &pp);udev_device_unref (udevice);if (!pp) {
@@ -1085,7 +1085,7 @@ extern int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh,update_mpp_paths (mpp, vecs->pathvec);if (refresh) { vector_foreach_slot (mpp->paths, pp, i) { - r =pathinfo (pp, conf->hwtable,DI_PRIO ); + r =pathinfo (pp, conf,DI_PRIO );if (r) {condlog (2 ,"%s: failed to refresh pathinfo" , mpp->alias);
libmultipath/discovery.c +12 -12
@@ -32,7 +32,7 @@#include "defaults.h" int -alloc_path_with_pathinfo (vector hwtable,struct udev_device *udevice, +alloc_path_with_pathinfo (struct config *conf,struct udev_device *udevice,int flag,struct path **pp_ptr) {int err =PATHINFO_FAILED ;
@@ -55,7 +55,7 @@ alloc_path_with_pathinfo (vector hwtable, struct udev_device *udevice,condlog (0 ,"pp->dev too small" ); }else { pp->udev =udev_device_ref (udevice); - err =pathinfo (pp, hwtable, flag |DI_BLACKLIST ); + err =pathinfo (pp, conf, flag |DI_BLACKLIST ); }if (err)
@@ -66,8 +66,8 @@ alloc_path_with_pathinfo (vector hwtable, struct udev_device *udevice, }int -store_pathinfo (vector pathvec,vector hwtable,struct udev_device *udevice, -int flag,struct path **pp_ptr) +store_pathinfo (vector pathvec,struct config *conf, +struct udev_device *udevice,int flag,struct path **pp_ptr) {int err =PATHINFO_FAILED ;struct path * pp;
@@ -90,7 +90,7 @@ store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice, goto out; } pp->udev =udev_device_ref (udevice); - err =pathinfo (pp, hwtable, flag); + err =pathinfo (pp, conf, flag);if (err) goto out;
@@ -126,10 +126,10 @@ path_discover (vector pathvec, struct config * conf, pp =find_path_by_dev (pathvec, (char *)devname);if (!pp) { -return store_pathinfo (pathvec, conf->hwtable, +return store_pathinfo (pathvec, conf, udevice, flag,NULL ); } -return pathinfo (pp, conf->hwtable, flag); +return pathinfo (pp, conf, flag); }int
@@ -1397,7 +1397,7 @@ cciss_ioctl_pathinfo (struct path * pp, int mask) }int -get_state (struct path * pp,vector hwtable,int daemon) +get_state (struct path * pp,struct config *conf,int daemon) {struct checker * c = &pp->checker;int state;
@@ -1406,7 +1406,7 @@ get_state (struct path * pp, vector hwtable, int daemon)if (!checker_selected (c)) {if (daemon) { -if (pathinfo (pp, hwtable,DI_SYSFS ) !=PATHINFO_OK ) { +if (pathinfo (pp, conf,DI_SYSFS ) !=PATHINFO_OK ) {condlog (3 ,"%s: couldn't get sysfs pathinfo" , pp->dev);return PATH_UNCHECKED ;
@@ -1588,7 +1588,7 @@ get_uid (struct path * pp, int path_state) }extern int -pathinfo (struct path *pp,vector hwtable,int mask) +pathinfo (struct path *pp,struct config *conf,int mask) {int path_state;
@@ -1610,7 +1610,7 @@ pathinfo (struct path *pp, vector hwtable, int mask)/* * fetch info available in sysfs */ -if (mask &DI_SYSFS &&sysfs_pathinfo (pp, hwtable)) +if (mask &DI_SYSFS &&sysfs_pathinfo (pp, conf->hwtable))return PATHINFO_FAILED ;if (mask &DI_BLACKLIST && mask &DI_SYSFS ) {
@@ -1649,7 +1649,7 @@ pathinfo (struct path *pp, vector hwtable, int mask)if (mask &DI_CHECKER ) {if (path_state ==PATH_UP ) { - pp->chkrstate = pp->state =get_state (pp, hwtable,0 ); + pp->chkrstate = pp->state =get_state (pp, conf,0 );if (pp->state ==PATH_UNCHECKED || pp->state ==PATH_WILD ) goto blank;
libmultipath/discovery.h +4 -4
@@ -34,11 +34,11 @@ int path_discovery (vector pathvec, struct config * conf, int flag);int do_tur (char *);int path_offline (struct path *); -int get_state (struct path * pp,vector hwtable,int daemon); -int pathinfo (struct path *,vector hwtable,int mask); -int alloc_path_with_pathinfo (vector hwtable,struct udev_device *udevice, +int get_state (struct path * pp,struct config * conf,int daemon); +int pathinfo (struct path * pp,struct config * conf,int mask); +int alloc_path_with_pathinfo (struct config *conf,struct udev_device *udevice,int flag,struct path **pp_ptr); -int store_pathinfo (vector pathvec,vector hwtable, +int store_pathinfo (vector pathvec,struct config *conf,struct udev_device *udevice,int flag,struct path **pp_ptr);int sysfs_set_scsi_tmo (struct multipath *mpp,int checkint);
libmultipath/structs_vec.c +1 -1
@@ -69,7 +69,7 @@ adopt_paths (vector pathvec, struct multipath * mpp)if (!find_path_by_dev (mpp->paths, pp->dev) &&store_path (mpp->paths, pp))return 1 ; -if (pathinfo (pp, conf->hwtable, +if (pathinfo (pp, conf,DI_PRIO |DI_CHECKER ))return 1 ; }
multipath/main.c +3 -3
@@ -156,19 +156,19 @@ update_paths (struct multipath * mpp)continue ; } pp->mpp = mpp; -if (pathinfo (pp, conf->hwtable,DI_ALL )) +if (pathinfo (pp, conf,DI_ALL )) pp->state =PATH_UNCHECKED ;continue ; } pp->mpp = mpp;if (pp->state ==PATH_UNCHECKED || pp->state ==PATH_WILD ) { -if (pathinfo (pp, conf->hwtable,DI_CHECKER )) +if (pathinfo (pp, conf,DI_CHECKER )) pp->state =PATH_UNCHECKED ; }if (pp->priority ==PRIO_UNDEF ) { -if (pathinfo (pp, conf->hwtable,DI_PRIO )) +if (pathinfo (pp, conf,DI_PRIO )) pp->priority =PRIO_UNDEF ; } }
multipathd/cli_handlers.c +1 -1
@@ -640,7 +640,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data) udevice =udev_device_new_from_subsystem_sysname (udev,"block" , param); - r =store_pathinfo (vecs->pathvec, conf->hwtable, + r =store_pathinfo (vecs->pathvec, conf, udevice,DI_ALL , &pp);udev_device_unref (udevice);if (!pp) {
multipathd/main.c +8 -8
@@ -213,7 +213,7 @@ need_switch_pathgroup (struct multipath * mpp, int refresh)if (refresh) vector_foreach_slot (mpp->pg, pgp, i) vector_foreach_slot (pgp->paths, pp, j) -pathinfo (pp, conf->hwtable,DI_PRIO ); +pathinfo (pp, conf,DI_PRIO );if (!mpp->pg ||VECTOR_SIZE (mpp->paths) ==0 )return 0 ;
@@ -590,7 +590,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)condlog (3 ,"%s: reinitialize path" , uev->kernel);udev_device_unref (pp->udev); pp->udev =udev_device_ref (uev->udev); - r =pathinfo (pp, conf->hwtable, + r =pathinfo (pp, conf,DI_ALL |DI_BLACKLIST );if (r ==PATHINFO_OK ) ret =ev_add_path (pp, vecs);
@@ -615,7 +615,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)/* * get path vital state */ - ret =alloc_path_with_pathinfo (conf->hwtable, uev->udev, + ret =alloc_path_with_pathinfo (conf, uev->udev,DI_ALL , &pp);if (!pp) {if (ret ==PATHINFO_SKIPPED )
@@ -1344,7 +1344,7 @@ int update_prio(struct path *pp, int refresh_all) vector_foreach_slot (pp->mpp->pg, pgp, i) { vector_foreach_slot (pgp->paths, pp1, j) { oldpriority = pp1->priority; -pathinfo (pp1, conf->hwtable,DI_PRIO ); +pathinfo (pp1, conf,DI_PRIO );if (pp1->priority != oldpriority) changed =1 ; }
@@ -1352,7 +1352,7 @@ int update_prio(struct path *pp, int refresh_all)return changed; } oldpriority = pp->priority; -pathinfo (pp, conf->hwtable,DI_PRIO ); +pathinfo (pp, conf,DI_PRIO );if (pp->priority == oldpriority)return 0 ;
@@ -1421,20 +1421,20 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) newstate =PATH_DOWN ;if (newstate ==PATH_UP ) - newstate =get_state (pp, conf->hwtable,1 ); + newstate =get_state (pp, conf,1 );else checker_clear_message (&pp->checker);if (newstate ==PATH_WILD || newstate ==PATH_UNCHECKED ) {condlog (2 ,"%s: unusable path" , pp->dev); -pathinfo (pp, conf->hwtable,0 ); +pathinfo (pp, conf,0 );return 1 ; }if (!pp->mpp) {if (!strlen (pp->wwid) && pp->initialized !=INIT_MISSING_UDEV && (newstate ==PATH_UP || newstate ==PATH_GHOST )) {condlog (2 ,"%s: add missing path" , pp->dev); -if (pathinfo (pp, conf->hwtable,DI_ALL ) ==0 ) { +if (pathinfo (pp, conf,DI_ALL ) ==0 ) {ev_add_path (pp, vecs); pp->tick =1 ; }
Signature · 1 line
2.6.6
PATCH v2 18/26 checkers: use 'multipath_dir' as argument
In reply to Hannes ReineckePass in the 'multipath_dir' config setting as explicit argument for init_checkers() and checker_get(). With this we can remove references to struct config.
--- libmultipath/checkers.c | 22 +++++++++++++--------- libmultipath/checkers.h | 6 +++--- libmultipath/propsel.c | 2 +- multipath/main.c | 2 +- multipathd/main.c | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-)
libmultipath/checkers.c +13 -9
@@ -7,7 +7,6 @@#include "debug.h" #include "checkers.h" #include "vector.h" -#include "config.h" char *checker_state_names[] = {"wild" ,
@@ -29,9 +28,9 @@ char * checker_state_name (int i)return checker_state_names[i]; } -int init_checkers (void ) +int init_checkers (char *multipath_dir) { -if (!add_checker (DEFAULT_CHECKER )) +if (!add_checker (multipath_dir,DEFAULT_CHECKER ))return 1 ;return 0 ; }
@@ -89,10 +88,10 @@ struct checker * checker_lookup (char * name)if (!strncmp (name, c->name,CHECKER_NAME_LEN ))return c; } -return add_checker (name); +return NULL ; } -struct checker *add_checker (char * name) +struct checker *add_checker (char *multipath_dir,char * name) {char libname[LIB_CHECKER_NAMELEN ];struct stat stbuf;
@@ -104,10 +103,10 @@ struct checker * add_checker (char * name)return NULL ;snprintf (c->name,CHECKER_NAME_LEN ,"%s" , name);snprintf (libname,LIB_CHECKER_NAMELEN ,"%s/libcheck%s.so" , - conf->multipath_dir, name); + multipath_dir, name);if (stat (libname,&stbuf) <0 ) {condlog (0 ,"Checker '%s' not found in %s" , - name, conf->multipath_dir); + name, multipath_dir); goto out; }condlog (3 ,"loading %s checker" , libname);
@@ -253,13 +252,18 @@ void checker_clear_message (struct checker *c) c->message[0 ] ='\0' ; } -void checker_get (struct checker * dst,char * name) +void checker_get (char *multipath_dir,struct checker * dst,char * name) { -struct checker * src =checker_lookup (name); +struct checker * src =NULL ;if (!dst)return ; +if (name &&strlen (name)) { + src =checker_lookup (name); +if (!src) + src =add_checker (multipath_dir, name); + }if (!src) { dst->check =NULL ;return ;
libmultipath/checkers.h +3 -3
@@ -119,9 +119,9 @@ struct checker { #define MSG(c, fmt, args...) snprintf((c)->message, CHECKER_MSG_LEN, fmt, ##args);char *checker_state_name (int ); -int init_checkers (void ); +int init_checkers (char *);void cleanup_checkers (void ); -struct checker *add_checker (char *); +struct checker *add_checker (char *,char *);struct checker *checker_lookup (char *);int checker_init (struct checker *,void **);void checker_put (struct checker *);
@@ -136,6 +136,6 @@ int checker_selected (struct checker *);char *checker_name (struct checker *);char *checker_message (struct checker *);void checker_clear_message (struct checker *c); -void checker_get (struct checker *,char *); +void checker_get (char *,struct checker *,char *);#endif /* _CHECKERS_H */
libmultipath/propsel.c +1 -1
@@ -328,7 +328,7 @@ select_checker(struct path *pp)do_set (checker_name, conf, checker_name,"(config file setting)" );do_default (checker_name,DEFAULT_CHECKER ); out: -checker_get (c, checker_name); +checker_get (conf->multipath_dir, c, checker_name);condlog (3 ,"%s: path_checker = %s %s" , pp->dev, c->name, origin);if (conf->checker_timeout) { c->timeout = conf->checker_timeout;
multipath/main.c +1 -1
@@ -622,7 +622,7 @@ main (int argc, char *argv[]) conf->max_fds, strerror(errno)); } -if (init_checkers ()) { +if (init_checkers (conf->multipath_dir)) {condlog (0 ,"failed to initialize checkers" ); goto out; }
multipathd/main.c +1 -1
@@ -2110,7 +2110,7 @@ child (void * param)dm_init (conf->verbosity);dm_drv_version (conf->version,TGT_MPATH ); -if (init_checkers ()) { +if (init_checkers (conf->multipath_dir)) {condlog (0 ,"failed to initialize checkers" ); goto failed; }
Signature · 1 line
2.6.6
PATCH v2 19/26 prio: use 'multipath_dir' as argument
In reply to Hannes ReineckePass in the 'multipath_dir' config setting as explicit argument for init_prio() and prio_get().
--- libmultipath/prio.c | 24 ++++++++++++++++-------- libmultipath/prio.h | 6 +++--- libmultipath/propsel.c | 16 ++++++++-------- multipath/main.c | 2 +- multipathd/main.c | 2 +- 5 files changed, 29 insertions(+), 21 deletions(-)
libmultipath/prio.c +16 -8
@@ -17,9 +17,9 @@ unsigned int get_prio_timeout(unsigned int default_timeout)return default_timeout; } -int init_prio (void ) +int init_prio (char *multipath_dir) { -if (!add_prio (DEFAULT_PRIO )) +if (!add_prio (multipath_dir,DEFAULT_PRIO ))return 1 ;return 0 ; }
@@ -78,7 +78,7 @@ struct prio * prio_lookup (char * name)if (!strncmp (name, p->name,PRIO_NAME_LEN ))return p; } -return add_prio (name); +return NULL ; }int prio_set_args (struct prio * p,char * args)
@@ -86,7 +86,7 @@ int prio_set_args (struct prio * p, char * args)return snprintf (p->args,PRIO_ARGS_LEN ,"%s" , args); } -struct prio *add_prio (char * name) +struct prio *add_prio (char *multipath_dir,char * name) {char libname[LIB_PRIO_NAMELEN ];struct stat stbuf;
@@ -98,10 +98,10 @@ struct prio * add_prio (char * name)return NULL ;snprintf (p->name,PRIO_NAME_LEN ,"%s" , name);snprintf (libname,LIB_PRIO_NAMELEN ,"%s/libprio%s.so" , - conf->multipath_dir, name); + multipath_dir, name);if (stat (libname,&stbuf) <0 ) {condlog (0 ,"Prioritizer '%s' not found in %s" , - name, conf->multipath_dir); + name, multipath_dir); goto out; }condlog (3 ,"loading %s prioritizer" , libname);
@@ -147,10 +147,18 @@ char * prio_args (struct prio * p)return p->args; } -void prio_get (struct prio * dst,char * name,char * args) +void prio_get (char *multipath_dir,struct prio * dst,char * name,char * args) { -struct prio * src =prio_lookup (name); +struct prio * src =NULL ; + +if (!dst) +return ; +if (name &&strlen (name)) { + src =prio_lookup (name); +if (!src) + src =add_prio (multipath_dir, name); + }if (!src) { dst->getprio =NULL ;return ;
libmultipath/prio.h +3 -3
@@ -53,12 +53,12 @@ struct prio { };unsigned int get_prio_timeout (unsigned int default_timeout); -int init_prio (void ); +int init_prio (char *);void cleanup_prio (void ); -struct prio *add_prio (char *); +struct prio *add_prio (char *,char *);struct prio *prio_lookup (char *);int prio_getprio (struct prio *,struct path *); -void prio_get (struct prio *,char *,char *); +void prio_get (char *,struct prio *,char *,char *);void prio_put (struct prio *);int prio_selected (struct prio *);char *prio_name (struct prio *);
libmultipath/propsel.c +8 -8
@@ -383,13 +383,13 @@ detect_prio(struct path * pp)return ;if (get_asymmetric_access_state (pp->fd, ret) <0 )return ; -prio_get (p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); +prio_get (conf->multipath_dir, p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); } -#define set_prio (src, msg) \ +#define set_prio (dir, src, msg) \ do { \ if (src && src->prio_name) { \ - prio_get(p, src->prio_name, src->prio_args); \ + prio_get(dir, p, src->prio_name, src->prio_args); \ origin = msg; \ goto out; \ } \
@@ -410,11 +410,11 @@ select_prio (struct path * pp) } } mpe =find_mpe (conf->mptable, pp->wwid); -set_prio (mpe,"(LUN setting)" ); -set_prio (conf->overrides,"(overrides setting)" ); -set_prio (pp->hwe,"controller setting)" ); -set_prio (conf,"(config file default)" ); -prio_get (p,DEFAULT_PRIO ,DEFAULT_PRIO_ARGS ); +set_prio (conf->multipath_dir, mpe,"(LUN setting)" ); +set_prio (conf->multipath_dir, conf->overrides,"(overrides setting)" ); +set_prio (conf->multipath_dir, pp->hwe,"controller setting)" ); +set_prio (conf->multipath_dir, conf,"(config file default)" ); +prio_get (conf->multipath_dir, p,DEFAULT_PRIO ,DEFAULT_PRIO_ARGS ); origin ="(internal default)" ; out:/*
multipath/main.c +1 -1
@@ -626,7 +626,7 @@ main (int argc, char *argv[])condlog (0 ,"failed to initialize checkers" ); goto out; } -if (init_prio ()) { +if (init_prio (conf->multipath_dir)) {condlog (0 ,"failed to initialize prioritizers" ); goto out; }
multipathd/main.c +1 -1
@@ -2114,7 +2114,7 @@ child (void * param)condlog (0 ,"failed to initialize checkers" ); goto failed; } -if (init_prio ()) { +if (init_prio (conf->multipath_dir)) {condlog (0 ,"failed to initialize prioritizers" ); goto failed; }
Signature · 1 line
2.6.6
PATCH v2 20/26 libmultipath: use 'timeout' as argument for getprio()
In reply to Hannes ReineckePass in the 'checker_timeout' as explicit argument when calling getprio().
--- libmultipath/discovery.c | 2 +- libmultipath/prio.c | 16 ++++++------ libmultipath/prio.h | 8 +++--- libmultipath/prioritizers/alua.c | 12 ++++----- libmultipath/prioritizers/alua_rtpg.c | 25 ++++++++++--------- libmultipath/prioritizers/alua_rtpg.h | 6 ++--- libmultipath/prioritizers/emc.c | 8 +++--- libmultipath/prioritizers/hds.c | 8 +++--- libmultipath/prioritizers/hp_sw.c | 46 +++++++++++++++++------------------ libmultipath/prioritizers/ontap.c | 19 ++++++++------- libmultipath/prioritizers/rdac.c | 8 +++--- libmultipath/propsel.c | 11 ++++++--- 12 files changed, 87 insertions(+), 82 deletions(-)
libmultipath/discovery.c +1 -1
@@ -1460,7 +1460,7 @@ get_prio (struct path * pp)return 1 ; } } - pp->priority =prio_getprio (p, pp); + pp->priority =prio_getprio (p, pp, conf->checker_timeout);if (pp->priority <0 ) {condlog (3 ,"%s: %s prio error" , pp->dev,prio_name (p)); pp->priority =PRIO_UNDEF ;
libmultipath/prio.c +8 -8
@@ -6,14 +6,14 @@#include "debug.h" #include "prio.h" -#include "config.h" static LIST_HEAD (prioritizers); -unsigned int get_prio_timeout (unsigned int default_timeout) +unsigned int get_prio_timeout (unsigned int checker_timeout, +unsigned int default_timeout) { -if (conf->checker_timeout) -return conf->checker_timeout *1000 ; +if (checker_timeout) +return checker_timeout *1000 ;return default_timeout; }
@@ -67,7 +67,7 @@ void cleanup_prio(void) } } -struct prio *prio_lookup (char * name) +static struct prio *prio_lookup (char * name) {struct prio * p;
@@ -112,7 +112,7 @@ struct prio * add_prio (char *multipath_dir, char * name) errstr); goto out; } - p->getprio = (int (*)(struct path *,char *))dlsym (p->handle,"getprio" ); + p->getprio = (int (*)(struct path *,char *,unsigned int ))dlsym (p->handle,"getprio" ); errstr =dlerror ();if (errstr !=NULL )condlog (0 ,"A dynamic linking error occurred: (%s)" , errstr);
@@ -125,9 +125,9 @@ out:return NULL ; } -int prio_getprio (struct prio * p,struct path * pp) +int prio_getprio (struct prio * p,struct path * pp,unsigned int timeout) { -return p->getprio (pp, p->args); +return p->getprio (pp, p->args, timeout); }int prio_selected (struct prio * p)
libmultipath/prio.h +4 -4
@@ -49,15 +49,15 @@ struct prio {struct list_head node;char name[PRIO_NAME_LEN ];char args[PRIO_ARGS_LEN ]; -int (*getprio)(struct path *,char *); +int (*getprio)(struct path *,char *,unsigned int ); }; -unsigned int get_prio_timeout (unsigned int default_timeout); +unsigned int get_prio_timeout (unsigned int checker_timeout, +unsigned int default_timeout);int init_prio (char *);void cleanup_prio (void );struct prio *add_prio (char *,char *); -struct prio *prio_lookup (char *); -int prio_getprio (struct prio *,struct path *); +int prio_getprio (struct prio *,struct path *,unsigned int );void prio_get (char *,struct prio *,char *,char *);void prio_put (struct prio *);int prio_selected (struct prio *);
libmultipath/prioritizers/alua.c +6 -6
@@ -51,14 +51,14 @@ static const char *aas_print_string(int rc) }int -get_alua_info (struct path * pp) +get_alua_info (struct path * pp,unsigned int timeout) {int rc;int tpg; - tpg =get_target_port_group (pp); + tpg =get_target_port_group (pp, timeout);if (tpg <0 ) { - rc =get_target_port_group_support (pp->fd); + rc =get_target_port_group_support (pp->fd, timeout);if (rc <0 )return -ALUA_PRIO_TPGS_FAILED ;if (rc ==TPGS_NONE )
@@ -66,7 +66,7 @@ get_alua_info(struct path * pp)return -ALUA_PRIO_RTPG_FAILED ; }condlog (3 ,"reported target port group is %i" , tpg); - rc =get_asymmetric_access_state (pp->fd, tpg); + rc =get_asymmetric_access_state (pp->fd, tpg, timeout);if (rc <0 )return -ALUA_PRIO_GETAAS_FAILED ;
@@ -91,7 +91,7 @@ int get_exclusive_perf_arg(char *args)return 1 ; } -int getprio (struct path * pp,char * args) +int getprio (struct path * pp,char * args,unsigned int timeout) {int rc;int aas;
@@ -102,7 +102,7 @@ int getprio (struct path * pp, char * args)return -ALUA_PRIO_NO_INFORMATION ; exclusive_perf =get_exclusive_perf_arg (args); - rc =get_alua_info (pp); + rc =get_alua_info (pp, timeout);if (rc >=0 ) { aas = (rc &0x0f ); priopath = (rc &0x80 );
libmultipath/prioritizers/alua_rtpg.c +13 -12
@@ -115,7 +115,8 @@ scsi_error(struct sg_io_hdr *hdr)* Helper function to setup and run a SCSI inquiry command. */ int -do_inquiry (int fd,int evpd,unsigned int codepage,void *resp,int resplen) +do_inquiry (int fd,int evpd,unsigned int codepage, +void *resp,int resplen,unsigned int timeout) {struct inquiry_command cmd;struct sg_io_hdr hdr;
@@ -139,7 +140,7 @@ do_inquiry(int fd, int evpd, unsigned int codepage, void *resp, int resplen) hdr.dxfer_len = resplen; hdr.sbp = sense; hdr.mx_sb_len =sizeof (sense); - hdr.timeout =get_prio_timeout (SGIO_TIMEOUT ); + hdr.timeout =get_prio_timeout (timeout,SGIO_TIMEOUT );if (ioctl (fd,SG_IO , &hdr) <0 ) {PRINT_DEBUG ("do_inquiry: IOCTL failed!\n" );
@@ -160,13 +161,13 @@ do_inquiry(int fd, int evpd, unsigned int codepage, void *resp, int resplen)* data returned by the standard inquiry command. */ int -get_target_port_group_support (int fd) +get_target_port_group_support (int fd,unsigned int timeout) {struct inquiry_data inq;int rc;memset ((unsigned char *)&inq,0 ,sizeof (inq)); - rc =do_inquiry (fd,0 ,0x00 , &inq,sizeof (inq)); + rc =do_inquiry (fd,0 ,0x00 , &inq,sizeof (inq), timeout);if (!rc) { rc =inquiry_data_get_tpgs (&inq); }
@@ -194,7 +195,7 @@ get_sysfs_pg83(struct path *pp, unsigned char *buff, int buflen) }int -get_target_port_group (struct path * pp) +get_target_port_group (struct path * pp,unsigned int timeout) {unsigned char *buf;struct vpd83_data * vpd83;
@@ -215,7 +216,7 @@ get_target_port_group(struct path * pp) rc =get_sysfs_pg83 (pp, buf, buflen);if (rc <0 ) { - rc =do_inquiry (pp->fd,1 ,0x83 , buf, buflen); + rc =do_inquiry (pp->fd,1 ,0x83 , buf, buflen, timeout);if (rc <0 ) goto out;
@@ -233,7 +234,7 @@ get_target_port_group(struct path * pp) } buflen = scsi_buflen;memset (buf,0 , buflen); - rc =do_inquiry (pp->fd,1 ,0x83 , buf, buflen); + rc =do_inquiry (pp->fd,1 ,0x83 , buf, buflen, timeout);if (rc <0 ) goto out; }
@@ -264,7 +265,7 @@ out: }int -do_rtpg (int fd,void * resp,long resplen) +do_rtpg (int fd,void * resp,long resplen,unsigned int timeout) {struct rtpg_command cmd;struct sg_io_hdr hdr;
@@ -285,7 +286,7 @@ do_rtpg(int fd, void* resp, long resplen) hdr.dxfer_len = resplen; hdr.mx_sb_len =sizeof (sense); hdr.sbp = sense; - hdr.timeout =get_prio_timeout (SGIO_TIMEOUT ); + hdr.timeout =get_prio_timeout (timeout,SGIO_TIMEOUT );if (ioctl (fd,SG_IO , &hdr) <0 )return -RTPG_RTPG_FAILED ;
@@ -300,7 +301,7 @@ do_rtpg(int fd, void* resp, long resplen) }int -get_asymmetric_access_state (int fd,unsigned int tpg) +get_asymmetric_access_state (int fd,unsigned int tpg,unsigned int timeout) {unsigned char *buf;struct rtpg_data * tpgd;
@@ -317,7 +318,7 @@ get_asymmetric_access_state(int fd, unsigned int tpg)return -RTPG_RTPG_FAILED ; }memset (buf,0 , buflen); - rc =do_rtpg (fd, buf, buflen); + rc =do_rtpg (fd, buf, buflen, timeout);if (rc <0 ) goto out; scsi_buflen = (buf[0 ] <<24 | buf[1 ] <<16 | buf[2 ] <<8 | buf[3 ]) +4 ;
@@ -333,7 +334,7 @@ get_asymmetric_access_state(int fd, unsigned int tpg) } buflen = scsi_buflen;memset (buf,0 , buflen); - rc =do_rtpg (fd, buf, buflen); + rc =do_rtpg (fd, buf, buflen, timeout);if (rc <0 ) goto out; }
libmultipath/prioritizers/alua_rtpg.h +3 -3
@@ -22,9 +22,9 @@#define RTPG_RTPG_FAILED 3#define RTPG_TPG_NOT_FOUND 4 -int get_target_port_group_support (int fd); -int get_target_port_group (struct path * pp); -int get_asymmetric_access_state (int fd,unsigned int tpg); +int get_target_port_group_support (int fd,unsigned int timeout); +int get_target_port_group (struct path * pp,unsigned int timeout); +int get_asymmetric_access_state (int fd,unsigned int tpg,unsigned int timeout);#endif /* __RTPG_H__ */
libmultipath/prioritizers/emc.c +4 -4
@@ -12,7 +12,7 @@#define pp_emc_log (prio, msg) condlog(prio, "%s: emc prio: " msg, dev) -int emc_clariion_prio (const char *dev,int fd) +int emc_clariion_prio (const char *dev,int fd,unsigned int timeout) {unsigned char sense_buffer[128 ];unsigned char sb[128 ];
@@ -31,7 +31,7 @@ int emc_clariion_prio(const char *dev, int fd) io_hdr.dxferp = sense_buffer; io_hdr.cmdp = inqCmdBlk; io_hdr.sbp = sb; - io_hdr.timeout =get_prio_timeout (60000 ); + io_hdr.timeout =get_prio_timeout (timeout,60000 ); io_hdr.pack_id =0 ;if (ioctl (fd,SG_IO , &io_hdr) <0 ) {pp_emc_log (0 ,"sending query command failed" );
@@ -81,7 +81,7 @@ out:return (ret); } -int getprio (struct path * pp,char * args) +int getprio (struct path * pp,char * args,unsigned int timeout) { -return emc_clariion_prio (pp->dev, pp->fd); +return emc_clariion_prio (pp->dev, pp->fd, timeout); }
libmultipath/prioritizers/hds.c +4 -4
@@ -84,7 +84,7 @@ #define pp_hds_log(prio, fmt, args...) \ condlog(prio, "%s: hds prio: " fmt, dev, ##args) -int hds_modular_prio (const char *dev,int fd) +int hds_modular_prio (const char *dev,int fd,unsigned int timeout) {int k;char vendor[9 ];
@@ -114,7 +114,7 @@ int hds_modular_prio (const char *dev, int fd) io_hdr.dxferp = inqBuff; io_hdr.cmdp = inqCmdBlk; io_hdr.sbp = sense_buffer; - io_hdr.timeout =get_prio_timeout (2000 );/* TimeOut = 2 seconds */ + io_hdr.timeout =get_prio_timeout (timeout,2000 );/* TimeOut = 2 seconds */ if (ioctl (fd,SG_IO , &io_hdr) <0 ) {pp_hds_log (0 ,"SG_IO error" );
@@ -168,7 +168,7 @@ int hds_modular_prio (const char *dev, int fd)return -1 ; } -int getprio (struct path * pp,char * args) +int getprio (struct path * pp,char * args,unsigned int timeout) { -return hds_modular_prio (pp->dev, pp->fd); +return hds_modular_prio (pp->dev, pp->fd, timeout); }
libmultipath/prioritizers/hp_sw.c +23 -23
84 lines not on this page · raw message
libmultipath/prioritizers/ontap.c +10 -9
@@ -71,7 +71,8 @@ static void process_sg_error(struct sg_io_hdr *io_hdr)* 0: success */ static int send_gva (const char *dev,int fd,unsigned char pg, -unsigned char *results,int *results_size) +unsigned char *results,int *results_size, +unsigned int timeout) {unsigned char sb[128 ];unsigned char cdb[10 ] = {0xc0 ,0 ,0x1 ,0xa ,0x98 ,0xa ,
@@ -89,7 +90,7 @@ static int send_gva(const char *dev, int fd, unsigned char pg, io_hdr.dxferp = results; io_hdr.cmdp = cdb; io_hdr.sbp = sb; - io_hdr.timeout =get_prio_timeout (SG_TIMEOUT ); + io_hdr.timeout =get_prio_timeout (timeout,SG_TIMEOUT ); io_hdr.pack_id =0 ;if (ioctl (fd,SG_IO , &io_hdr) <0 ) {pp_ontap_log (0 ,"SG_IO ioctl failed, errno=%d" , errno);
@@ -122,7 +123,7 @@ static int send_gva(const char *dev, int fd, unsigned char pg,* 0: Device _not_ proxy path * 1: Device _is_ proxy path */ -static int get_proxy (const char *dev,int fd) +static int get_proxy (const char *dev,int fd,unsigned int timeout) {unsigned char results[256 ];unsigned char sb[128 ];
@@ -141,7 +142,7 @@ static int get_proxy(const char *dev, int fd) io_hdr.dxferp = results; io_hdr.cmdp = cdb; io_hdr.sbp = sb; - io_hdr.timeout =get_prio_timeout (SG_TIMEOUT ); + io_hdr.timeout =get_prio_timeout (timeout,SG_TIMEOUT ); io_hdr.pack_id =0 ;if (ioctl (fd,SG_IO , &io_hdr) <0 ) { pp_ontap_log(0, "ioctl sending inquiry command failed, "
@@ -182,7 +183,7 @@ static int get_proxy(const char *dev, int fd)* 2: iSCSI software * 1: FCP proxy */ -static int ontap_prio (const char *dev,int fd) +static int ontap_prio (const char *dev,int fd,unsigned int timeout) {unsigned char results[RESULTS_MAX ];int results_size=RESULTS_MAX ;
@@ -195,7 +196,7 @@ static int ontap_prio(const char *dev, int fd) is_iscsi_software = is_iscsi_hardware = is_proxy =0 ;memset (&results,0 ,sizeof (results)); - rc =send_gva (dev, fd,0x41 , results, &results_size); + rc =send_gva (dev, fd,0x41 , results, &results_size, timeout);if (rc >=0 ) { tot_len = results[0 ] <<24 | results[1 ] <<16 | results[2 ] <<8 | results[3 ];
@@ -221,7 +222,7 @@ static int ontap_prio(const char *dev, int fd) } try_fcp_proxy: - rc =get_proxy (dev, fd); + rc =get_proxy (dev, fd, timeout);if (rc >=0 ) { is_proxy = rc; }
@@ -241,7 +242,7 @@ static int ontap_prio(const char *dev, int fd) } } -int getprio (struct path * pp,char * args) +int getprio (struct path * pp,char * args,unsigned int timeout) { -return ontap_prio (pp->dev, pp->fd); +return ontap_prio (pp->dev, pp->fd, timeout); }
libmultipath/prioritizers/rdac.c +4 -4
@@ -12,7 +12,7 @@#define pp_rdac_log (prio, msg) condlog(prio, "%s: rdac prio: " msg, dev) -int rdac_prio (const char *dev,int fd) +int rdac_prio (const char *dev,int fd,unsigned int timeout) {unsigned char sense_buffer[128 ];unsigned char sb[128 ];
@@ -31,7 +31,7 @@ int rdac_prio(const char *dev, int fd) io_hdr.dxferp = sense_buffer; io_hdr.cmdp = inqCmdBlk; io_hdr.sbp = sb; - io_hdr.timeout =get_prio_timeout (60000 ); + io_hdr.timeout =get_prio_timeout (timeout,60000 ); io_hdr.pack_id =0 ;if (ioctl (fd,SG_IO , &io_hdr) <0 ) {pp_rdac_log (0 ,"sending inquiry command failed" );
@@ -91,7 +91,7 @@ out:return (ret); } -int getprio (struct path * pp,char * args) +int getprio (struct path * pp,char * args,unsigned int timeout) { -return rdac_prio (pp->dev, pp->fd); +return rdac_prio (pp->dev, pp->fd, timeout); }
libmultipath/propsel.c +7 -4
@@ -374,14 +374,15 @@ detect_prio(struct path * pp)int ret;struct prio *p = &pp->prio;int tpgs =0 ; +unsigned int timeout = conf->checker_timeout; -if ((tpgs =get_target_port_group_support (pp->fd)) <=0 ) +if ((tpgs =get_target_port_group_support (pp->fd, timeout)) <=0 )return ; pp->tpgs = tpgs; - ret =get_target_port_group (pp); + ret =get_target_port_group (pp, timeout);if (ret <0 )return ; -if (get_asymmetric_access_state (pp->fd, ret) <0 ) +if (get_asymmetric_access_state (pp->fd, ret, timeout) <0 )return ;prio_get (conf->multipath_dir, p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); }
@@ -422,8 +423,10 @@ out:*/ if (!strncmp (prio_name (p),PRIO_ALUA ,PRIO_NAME_LEN )) {int tpgs =0 ; +unsigned int timeout = conf->checker_timeout; +if (!pp->tpgs && - (tpgs =get_target_port_group_support (pp->fd)) >=0 ) + (tpgs =get_target_port_group_support (pp->fd, timeout)) >=0 ) pp->tpgs = tpgs; }condlog (3 ,"%s: prio = %s %s" , pp->dev,prio_name (p), origin);
Signature · 1 line
2.6.6
PATCH v2 21/26 libmultipath: use explicit 'config' argument for configuration file parsing
In reply to Hannes ReineckeWhen parsing the configuration file we should be passing in 'struct config' as an explicit argument.
--- libmpathpersist/mpath_persist.c | 2 +- libmultipath/config.c | 8 ++--- libmultipath/configure.c | 36 +++++++++---------- libmultipath/dict.c | 77 +++++++++++++++++++++-------------------- libmultipath/discovery.c | 8 ++--- libmultipath/parser.c | 25 +++++++------ libmultipath/parser.h | 18 +++++----- libmultipath/print.c | 12 +++---- libmultipath/print.h | 10 +++--- libmultipath/propsel.c | 72 +++++++++++++++++++------------------- libmultipath/propsel.h | 48 ++++++++++++------------- libmultipath/structs_vec.c | 16 ++++----- libmultipath/structs_vec.h | 4 ++- libmultipath/waiter.c | 1 + mpathpersist/main.c | 1 + multipath/main.c | 12 +++---- multipathd/cli_handlers.c | 10 +++--- multipathd/main.c | 6 ++-- 18 files changed, 189 insertions(+), 177 deletions(-)
libmpathpersist/mpath_persist.c +1 -1
@@ -317,7 +317,7 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, goto out1; } -select_reservation_key (mpp); +select_reservation_key (conf, mpp);switch (rq_servact) {
libmultipath/config.c +4 -4
@@ -542,7 +542,7 @@ free_config (struct config * conf)/* if multipath fails to process the config directory, it should continue, * with just a warning message */ static void -process_config_dir (vector keywords,char *dir) +process_config_dir (struct config *conf,vector keywords,char *dir) {struct dirent **namelist;int i, n;
@@ -569,7 +569,7 @@ process_config_dir(vector keywords, char *dir) old_hwtable_size =VECTOR_SIZE (conf->hwtable);snprintf (path,LINE_MAX ,"%s/%s" , dir, namelist[i]->d_name); path[LINE_MAX -1 ] ='\0' ; -process_file (path); +process_file (conf, path);if (VECTOR_SIZE (conf->hwtable) > old_hwtable_size)factorize_hwtable (conf->hwtable, old_hwtable_size);
@@ -640,7 +640,7 @@ load_config (char * file)int builtin_hwtable_size; builtin_hwtable_size =VECTOR_SIZE (conf->hwtable); -if (process_file (file)) { +if (process_file (conf, file)) {condlog (0 ,"error parsing config file" ); goto out; }
@@ -658,7 +658,7 @@ load_config (char * file)if (conf->config_dir ==NULL ) conf->config_dir =set_default (DEFAULT_CONFIG_DIR );if (conf->config_dir && conf->config_dir[0 ] !='\0' ) -process_config_dir (conf->keywords, conf->config_dir); +process_config_dir (conf, conf->keywords, conf->config_dir);/* * fill the voids left in the config file
libmultipath/configure.c +18 -18
@@ -275,24 +275,24 @@ setup_map (struct multipath * mpp, char * params, int params_size)/* * properties selectors */ -select_pgfailback (mpp); -select_pgpolicy (mpp); -select_selector (mpp); -select_features (mpp); -select_hwhandler (mpp); -select_rr_weight (mpp); -select_minio (mpp); -select_no_path_retry (mpp); -select_mode (mpp); -select_uid (mpp); -select_gid (mpp); -select_fast_io_fail (mpp); -select_dev_loss (mpp); -select_reservation_key (mpp); -select_retain_hwhandler (mpp); -select_deferred_remove (mpp); -select_delay_watch_checks (mpp); -select_delay_wait_checks (mpp); +select_pgfailback (conf, mpp); +select_pgpolicy (conf, mpp); +select_selector (conf, mpp); +select_features (conf, mpp); +select_hwhandler (conf, mpp); +select_rr_weight (conf, mpp); +select_minio (conf, mpp); +select_no_path_retry (conf, mpp); +select_mode (conf, mpp); +select_uid (conf, mpp); +select_gid (conf, mpp); +select_fast_io_fail (conf, mpp); +select_dev_loss (conf, mpp); +select_reservation_key (conf, mpp); +select_retain_hwhandler (conf, mpp); +select_deferred_remove (conf, mpp); +select_delay_watch_checks (conf, mpp); +select_delay_wait_checks (conf, mpp);sysfs_set_scsi_tmo (mpp, conf->checkint);/*
libmultipath/dict.c +39 -38
303 lines not on this page · raw message
libmultipath/discovery.c +4 -4
@@ -1412,7 +1412,7 @@ get_state (struct path * pp, struct config *conf, int daemon)return PATH_UNCHECKED ; } } -select_checker (pp); +select_checker (conf, pp);if (!checker_selected (c)) {condlog (3 ,"%s: No checker selected" , pp->dev);return PATH_UNCHECKED ;
@@ -1452,8 +1452,8 @@ get_prio (struct path * pp)struct prio * p = &pp->prio;if (!prio_selected (p)) { -select_detect_prio (pp); -select_prio (pp); +select_detect_prio (conf, pp); +select_prio (conf, pp);if (!prio_selected (p)) {condlog (3 ,"%s: no prio selected" , pp->dev); pp->priority =PRIO_UNDEF ;
@@ -1520,7 +1520,7 @@ get_uid (struct path * pp, int path_state)ssize_t len =0 ;if (!pp->uid_attribute && !pp->getuid) -select_getuid (pp); +select_getuid (conf, pp);if (!pp->udev) {condlog (1 ,"%s: no udev information" , pp->dev);
libmultipath/parser.c +14 -11
@@ -20,6 +20,8 @@#include <syslog.h> #include <errno.h> +#include "vector.h" +#include "config.h" #include "parser.h" #include "memory.h" #include "debug.h"
@@ -37,8 +39,9 @@ void set_current_keywords (vector *k) }int -keyword_alloc (vector keywords,char *string,int (*handler) (vector ), -int (*print) (char *,int ,void *),int unique) +keyword_alloc (vector keywords,char *string, +int (*handler) (struct config *,vector ), +int (*print) (struct config *,char *,int ,void *),int unique) {struct keyword *keyword;
@@ -62,7 +65,7 @@ keyword_alloc(vector keywords, char *string, int (*handler) (vector), }int -install_keyword_root (char *string,int (*handler) (vector )) +install_keyword_root (char *string,int (*handler) (struct config *,vector )) {int r =keyword_alloc (keywords, string, handler,NULL ,1 );if (!r)
@@ -83,8 +86,8 @@ install_sublevel_end(void) }int -_install_keyword (char *string,int (*handler) (vector ), -int (*print) (char *,int ,void *),int unique) +_install_keyword (char *string,int (*handler) (struct config *,vector ), +int (*print) (struct config *,char *,int ,void *),int unique) {int i =0 ;struct keyword *keyword;
@@ -179,7 +182,7 @@ snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw, void *data) fwd +=snprintf (buff + fwd, len - fwd,"%s" , kw->string);break ;case 'v' : - r = kw->if (!r) {/* no output if no value */ buff ='\0' ;return 0 ;
@@ -466,7 +469,7 @@ validate_config_strvec(vector strvec, char *file) }static int -process_stream (FILE *stream,vector keywords,char *file) +process_stream (struct config *conf,FILE *stream,vector keywords,char *file) {int i;int r =0 , t;
@@ -520,7 +523,7 @@ process_stream(FILE *stream, vector keywords, char *file) goto out; }if (keyword->handler) { - t = (*keyword->handler) (strvec); + t = (*keyword->handler) (conf, strvec); r += t;if (t) condlog(1, "multipath.conf +%d, parsing failed: %s",
@@ -529,7 +532,7 @@ process_stream(FILE *stream, vector keywords, char *file)if (keyword->sub) { kw_level++; - r +=process_stream (stream, + r +=process_stream (conf, stream, keyword->sub, file); kw_level--; }
@@ -562,7 +565,7 @@ int alloc_keywords(void)/* Data initialization */ int -process_file (char *file) +process_file (struct config *conf,char *file) {int r;FILE *stream;
@@ -580,7 +583,7 @@ process_file(char *file)/* Stream handling */ line_nr =0 ; - r =process_stream (stream, keywords, file); + r =process_stream (conf, stream, keywords, file);fclose (stream);//free_keywords(keywords);
libmultipath/parser.h +10 -8
@@ -33,6 +33,7 @@/* local includes */ #include "vector.h" +#include "config.h" /* Global definitions */ #define EOB "}"
@@ -41,8 +42,8 @@/* ketword definition */ struct keyword {char *string; -int (*handler) (vector ); -int (*print) (char *,int ,void *); +int (*handler) (struct config *,vector ); +int (*print) (struct config *,char *,int ,void *);vector sub;int unique; };
@@ -57,13 +58,14 @@ struct keyword {for (i =0 ; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++)/* Prototypes */ -extern int keyword_alloc(vector keywords, char *string, int (*handler) (vector), -int (*print) (char *,int ,void *),int unique); -extern int install_keyword_root (char *string,int (*handler) (vector )); +extern int keyword_alloc(vector keywords, char *string, +int (*handler) (struct config *,vector ), +int (*print) (struct config *,char *,int ,void *),int unique); +extern int install_keyword_root (char *string,int (*handler) (struct config *,vector ));extern void install_sublevel (void );extern void install_sublevel_end (void ); -extern int _install_keyword (char *string,int (*handler) (vector ), -int (*print) (char *,int ,void *),int unique); +extern int _install_keyword (char *string,int (*handler) (struct config *,vector ), +int (*print) (struct config *,char *,int ,void *),int unique);#define install_keyword (str, vec, pri) _install_keyword(str, vec, pri, 1)#define install_keyword_multi (str, vec, pri) _install_keyword(str, vec, pri, 0)extern void dump_keywords (vector keydump,int level);
@@ -71,7 +73,7 @@ extern void free_keywords(vector keywords);extern vector alloc_strvec (char *string);extern void *set_value (vector strvec);extern int alloc_keywords (void ); -extern int process_file (char *conf_file); +extern int process_file (struct config *conf,char *conf_file);extern struct keyword *find_keyword (vector v,char * name);void set_current_keywords (vector *k); int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw,
libmultipath/print.c +6 -6
@@ -16,11 +16,11 @@#include "vector.h" #include "structs.h" #include "structs_vec.h" -#include "print.h" #include "dmparser.h" #include "config.h" #include "configure.h" #include "pgpolicies.h" +#include "print.h" #include "defaults.h" #include "parser.h" #include "blacklist.h"
@@ -1354,7 +1354,7 @@ out: }extern int -snprint_defaults (char * buff,int len) +snprint_defaults (struct config *conf,char * buff,int len) {int fwd =0 ;int i;
@@ -1436,7 +1436,7 @@ snprint_blacklist_devgroup (char *buff, int len, int *fwd, vector *vec) }extern int -snprint_blacklist_report (char * buff,int len) +snprint_blacklist_report (struct config *conf,char * buff,int len) {int threshold =MAX_LINE_LEN ;int fwd =0 ;
@@ -1499,7 +1499,7 @@ snprint_blacklist_report (char * buff, int len) }extern int -snprint_blacklist (char * buff,int len) +snprint_blacklist (struct config *conf,char * buff,int len) {int i;struct blentry * ble;
@@ -1576,7 +1576,7 @@ snprint_blacklist (char * buff, int len) }extern int -snprint_blacklist_except (char * buff,int len) +snprint_blacklist_except (struct config *conf,char * buff,int len) {int i;struct blentry * ele;
@@ -1685,7 +1685,7 @@ snprint_status (char * buff, int len, struct vectors *vecs) }extern int -snprint_devices (char * buff,int len,struct vectors *vecs) +snprint_devices (struct config *conf,char * buff,int len,struct vectors *vecs) {DIR *blkdir;struct dirent *blkdev;
libmultipath/print.h +5 -5
@@ -102,13 +102,13 @@ int snprint_multipath_topology_json (char * buff, int len, struct vectors * vecs);int snprint_multipath_map_json (char * buff,int len,struct multipath * mpp,int last); -int snprint_defaults (char *,int ); -int snprint_blacklist (char *,int ); -int snprint_blacklist_except (char *,int ); -int snprint_blacklist_report (char *,int ); +int snprint_defaults (struct config *,char *,int ); +int snprint_blacklist (struct config *,char *,int ); +int snprint_blacklist_except (struct config *,char *,int ); +int snprint_blacklist_report (struct config *,char *,int );int snprint_wildcards (char *,int );int snprint_status (char *,int ,struct vectors *); -int snprint_devices (char *,int ,struct vectors *); +int snprint_devices (struct config *,char *,int ,struct vectors *);int snprint_hwtable (char *,int ,vector );int snprint_mptable (char *,int ,vector );int snprint_overrides (char *,int ,struct hwentry *);
libmultipath/propsel.c +36 -36
270 lines not on this page · raw message
libmultipath/propsel.h +24 -24
48 lines not on this page · raw message
libmultipath/structs_vec.c +8 -8
@@ -6,13 +6,13 @@#include "vector.h" #include "defaults.h" #include "debug.h" +#include "config.h" #include "structs.h" #include "structs_vec.h" #include "sysfs.h" #include "waiter.h" #include "devmapper.h" #include "dmparser.h" -#include "config.h" #include "propsel.h" #include "discovery.h" #include "prio.h"
@@ -337,11 +337,11 @@ update_multipath_strings (struct multipath *mpp, vector pathvec, int is_daemon) }extern void -set_no_path_retry (struct multipath *mpp) +set_no_path_retry (struct config *conf,struct multipath *mpp) { mpp->retry_tick =0 ; mpp->nr_active =pathcount (mpp,PATH_UP ) +pathcount (mpp,PATH_GHOST ); -select_no_path_retry (mpp); +select_no_path_retry (conf, mpp);switch (mpp->no_path_retry) {case NO_PATH_RETRY_UNDEF :
@@ -396,10 +396,10 @@ __setup_multipath (struct vectors * vecs, struct multipath * mpp, mpp->alias); }if (reset) { -select_rr_weight (mpp); -select_pgfailback (mpp); -set_no_path_retry (mpp); -select_flush_on_last_del (mpp); +select_rr_weight (conf, mpp); +select_pgfailback (conf, mpp); +set_no_path_retry (conf, mpp); +select_flush_on_last_del (conf, mpp);if (VECTOR_SIZE (mpp->paths) !=0 )dm_cancel_deferred_remove (mpp); }
@@ -475,7 +475,7 @@ add_map_with_path (struct vectors * vecs,strcpy (mpp->wwid, pp->wwid);find_existing_alias (mpp, vecs); -if (select_alias (mpp)) +if (select_alias (conf, mpp)) goto out; mpp->size = pp->size;
libmultipath/structs_vec.h +3 -1
@@ -1,6 +1,8 @@#ifndef _STRUCTS_VEC_H#define _STRUCTS_VEC_H +#include "vector.h" +#include "config.h" #include "lock.h" /* struct mutex_lock {
@@ -13,7 +15,7 @@ struct vectors {vector mpvec; }; -void set_no_path_retry (struct multipath *mpp); +void set_no_path_retry (struct config *conf,struct multipath *mpp);int adopt_paths (vector pathvec,struct multipath * mpp);void orphan_paths (vector pathvec,struct multipath * mpp);
libmultipath/waiter.c +1 -0
@@ -13,6 +13,7 @@#include "vector.h" #include "memory.h" #include "checkers.h" +#include "config.h" #include "structs.h" #include "structs_vec.h" #include "devmapper.h"
mpathpersist/main.c +1 -0
@@ -5,6 +5,7 @@#include <fcntl.h> #include <checkers.h> #include <vector.h> +#include <config.h> #include <structs.h> #include <getopt.h> #include <libudev.h>
multipath/main.c +6 -6
@@ -38,11 +38,11 @@#include <devmapper.h> #include <util.h> #include <defaults.h> +#include <config.h> #include <structs.h> #include <structs_vec.h> #include <dmparser.h> #include <sysfs.h> -#include <config.h> #include <blacklist.h> #include <discovery.h> #include <debug.h>
@@ -395,7 +395,7 @@ out: }static int -dump_config (void ) +dump_config (struct config *conf) {char * c, * tmp =NULL ;char * reply;
@@ -411,19 +411,19 @@ dump_config (void)return 1 ; } c = tmp = reply; - c +=snprint_defaults (c, reply + maxlen - c); + c +=snprint_defaults (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);if (again) { reply =REALLOC (reply, maxlen *=2 );continue ; } - c +=snprint_blacklist (c, reply + maxlen - c); + c +=snprint_blacklist (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);if (again) { reply =REALLOC (reply, maxlen *=2 );continue ; } - c +=snprint_blacklist_except (c, reply + maxlen - c); + c +=snprint_blacklist_except (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);if (again) { reply =REALLOC (reply, maxlen *=2 );
@@ -549,7 +549,7 @@ main (int argc, char *argv[]) conf->ignore_wwids =1 ;break ;case 't' : - r =dump_config (); + r =dump_config (conf); goto out_free_config;case 'h' :usage (argv[0 ]);
multipathd/cli_handlers.c +5 -5
@@ -233,17 +233,17 @@ show_config (char ** r, int * len)if (!reply)return 1 ; c = reply; - c +=snprint_defaults (c, reply + maxlen - c); + c +=snprint_defaults (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);if (again)continue ; - c +=snprint_blacklist (c, reply + maxlen - c); + c +=snprint_blacklist (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);if (again)continue ; - c +=snprint_blacklist_except (c, reply + maxlen - c); + c +=snprint_blacklist_except (conf, c, reply + maxlen - c); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);if (again)
@@ -1162,7 +1162,7 @@ show_blacklist (char ** r, int * len)return 1 ; c = reply; - c +=snprint_blacklist_report (c, maxlen); + c +=snprint_blacklist_report (conf, c, maxlen); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen); }
@@ -1196,7 +1196,7 @@ show_devices (char ** r, int * len, struct vectors *vecs)return 1 ; c = reply; - c +=snprint_devices (c, maxlen, vecs); + c +=snprint_devices (conf, c, maxlen, vecs); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen); }
multipathd/main.c +4 -2
@@ -21,8 +21,6 @@#include <systemd/sd-daemon.h> #endif #include <semaphore.h> -#include <mpath_cmd.h> -#include <mpath_persist.h> #include <time.h> /*
@@ -65,6 +63,10 @@ int uxsock_timeout;#include <pgpolicies.h> #include <uevent.h> #include <log.h> + +#include <mpath_cmd.h> +#include <mpath_persist.h> +#include "prioritizers/alua_rtpg.h" #include "main.h"
Signature · 1 line
2.6.6
PATCH v2 22/26 libmultipath: use (get, put)_multipath_config() accessors
In reply to Hannes ReineckeUse (get,put)_multipath_config() accessors to mark accesses to the configuration.
--- libmpathpersist/mpath_persist.c | 4 +-- libmultipath/config.h | 2 ++ libmultipath/configure.c | 71 +++++++++++++++++++++++++++++++++++------ libmultipath/debug.c | 3 ++ libmultipath/discovery.c | 28 +++++++++++++--- libmultipath/discovery.h | 2 +- libmultipath/parser.c | 3 ++ libmultipath/structs_vec.c | 27 ++++++++++++++-- libmultipath/wwids.c | 22 +++++++++++-- mpathpersist/main.c | 12 +++++++ multipath/main.c | 14 +++++++- multipathd/cli_handlers.c | 52 +++++++++++++++++++++++++----- multipathd/main.c | 17 ++++++++-- multipathd/uxlsnr.c | 5 --- 14 files changed, 222 insertions(+), 40 deletions(-)
libmpathpersist/mpath_persist.c +2 -2
@@ -203,7 +203,7 @@ int mpath_persistent_reserve_in (int fd, int rq_servact, goto out; } -if (path_discovery (pathvec, conf,DI_SYSFS |DI_CHECKER ) <0 ) { +if (path_discovery (pathvec,DI_SYSFS |DI_CHECKER ) <0 ) { ret =MPATH_PR_DMMP_ERROR ; goto out1; }
@@ -297,7 +297,7 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, goto out; } -if (path_discovery (pathvec, conf,DI_SYSFS |DI_CHECKER ) <0 ) { +if (path_discovery (pathvec,DI_SYSFS |DI_CHECKER ) <0 ) { ret =MPATH_PR_DMMP_ERROR ; goto out1; }
libmultipath/config.h +2 -0
@@ -192,5 +192,7 @@ int store_hwe (vector hwtable, struct hwentry *);int load_config (char * file);struct config *alloc_config (void );void free_config (struct config * conf); +extern struct config *get_multipath_config (void ); +extern void put_multipath_config (struct config *);#endif
libmultipath/configure.c +61 -10
244 lines not on this page · raw message
libmultipath/debug.c +3 -0
@@ -16,9 +16,12 @@ void dlog (int sink, int prio, const char * fmt, ...) {va_list ap;int thres; +struct config *conf;va_start (ap, fmt); + conf =get_multipath_config (); thres = (conf) ? conf->verbosity :0 ; +put_multipath_config (conf);if (prio <= thres) {if (sink <1 ) {
libmultipath/discovery.c +23 -5
@@ -133,11 +133,12 @@ path_discover (vector pathvec, struct config * conf, }int -path_discovery (vector pathvec,struct config * conf,int flag) +path_discovery (vector pathvec,int flag) {struct udev_enumerate *udev_iter;struct udev_list_entry *entry;struct udev_device *udevice; +struct config *conf;const char *devpath;int num_paths =0 , total_paths =0 ;
@@ -162,9 +163,11 @@ path_discovery (vector pathvec, struct config * conf, int flag) devtype =udev_device_get_devtype (udevice);if (devtype && !strncmp (devtype,"disk" ,4 )) { total_paths++; + conf =get_multipath_config ();if (path_discover (pathvec, conf, udevice, flag) ==PATHINFO_OK ) num_paths++; +put_multipath_config (conf); }udev_device_unref (udevice); }
@@ -1446,21 +1449,27 @@ get_state (struct path * pp, struct config *conf, int daemon)static int get_prio (struct path * pp) { +struct prio * p; +struct config *conf; +if (!pp)return 0 ; -struct prio * p = &pp->prio; - + p = &pp->prio;if (!prio_selected (p)) { + conf =get_multipath_config ();select_detect_prio (conf, pp);select_prio (conf, pp); +put_multipath_config (conf);if (!prio_selected (p)) {condlog (3 ,"%s: no prio selected" , pp->dev); pp->priority =PRIO_UNDEF ;return 1 ; } } + conf =get_multipath_config (); pp->priority =prio_getprio (p, pp, conf->checker_timeout); +put_multipath_config (conf);if (pp->priority <0 ) {condlog (3 ,"%s: %s prio error" , pp->dev,prio_name (p)); pp->priority =PRIO_UNDEF ;
@@ -1518,9 +1527,13 @@ get_uid (struct path * pp, int path_state)char *c;const char *origin ="unknown" ;ssize_t len =0 ; +struct config *conf; -if (!pp->uid_attribute && !pp->getuid) +if (!pp->uid_attribute && !pp->getuid) { + conf =get_multipath_config ();select_getuid (conf, pp); +put_multipath_config (conf); + }if (!pp->udev) {condlog (1 ,"%s: no udev information" , pp->dev);
@@ -1546,6 +1559,8 @@ get_uid (struct path * pp, int path_state) len =strlen (pp->wwid); origin ="callout" ; }else { +int retrigger; +if (pp->uid_attribute) { len =get_udev_uid (pp, pp->uid_attribute); origin ="udev" ;
@@ -1555,7 +1570,10 @@ get_uid (struct path * pp, int path_state) pp->dev, strerror(-len)); } -if (len <=0 && pp->retriggers >= conf->retrigger_tries && + conf =get_multipath_config (); + retrigger = conf->retrigger_tries; +put_multipath_config (conf); +if (len <=0 && pp->retriggers >= retrigger && !strcmp (pp->uid_attribute,DEFAULT_UID_ATTRIBUTE )) { len =get_vpd_uid (pp); origin ="sysfs" ;
libmultipath/discovery.h +1 -1
@@ -30,7 +30,7 @@struct config ; -int path_discovery (vector pathvec,struct config * conf,int flag); +int path_discovery (vector pathvec,int flag);int do_tur (char *);int path_offline (struct path *);
libmultipath/parser.c +3 -0
@@ -164,6 +164,7 @@ snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw, void *data)int r;int fwd =0 ;char *f = fmt; +struct config *conf;if (!kw || !kw->print)return 0 ;
@@ -182,7 +183,9 @@ snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw, void *data) fwd +=snprintf (buff + fwd, len - fwd,"%s" , kw->string);break ;case 'v' : + conf =get_multipath_config (); r = kw->put_multipath_config (conf);if (!r) {/* no output if no value */ buff ='\0' ;return 0 ;
libmultipath/structs_vec.c +24 -3
@@ -48,8 +48,9 @@ update_mpp_paths(struct multipath * mpp, vector pathvec)extern int adopt_paths (vector pathvec,struct multipath * mpp) { -int i; +int i, ret;struct path * pp; +struct config *conf;if (!mpp)return 0 ;
@@ -69,8 +70,11 @@ adopt_paths (vector pathvec, struct multipath * mpp)if (!find_path_by_dev (mpp->paths, pp->dev) &&store_path (mpp->paths, pp))return 1 ; -if (pathinfo (pp, conf, -DI_PRIO |DI_CHECKER )) + conf =get_multipath_config (); + ret =pathinfo (pp, conf, +DI_PRIO |DI_CHECKER ); +put_multipath_config (conf); +if (ret)return 1 ; } }
@@ -237,9 +241,12 @@ extract_hwe_from_path(struct multipath * mpp)condlog (3 ,"%s: product = %s" , pp->dev, pp->product_id);condlog (3 ,"%s: rev = %s" , pp->dev, pp->rev);if (!pp->hwe) { +struct config *conf =get_multipath_config (); +condlog (3 ,"searching hwtable" ); pp->hwe =find_hwe (conf->hwtable, pp->vendor_id, pp->product_id, pp->rev); +put_multipath_config (conf); } }
@@ -355,10 +362,12 @@ set_no_path_retry(struct config *conf, struct multipath *mpp)default :dm_queue_if_no_path (mpp->alias,1 );if (mpp->nr_active ==0 ) { +struct config *conf =get_multipath_config ();/* Enter retry mode */ mpp->retry_tick = mpp->no_path_retry * conf->checkint;condlog (1 ,"%s: Entering recovery mode: max_retries=%d" , mpp->alias, mpp->no_path_retry); +put_multipath_config (conf); }break ; }
@@ -368,6 +377,8 @@ extern int __setup_multipath (struct vectors * vecs, struct multipath * mpp, int reset, int is_daemon) { + struct config *conf; +if (dm_get_info (mpp->alias, &mpp->dmi)) {/* Error accessing table */ condlog (3 ,"%s: cannot access table" , mpp->alias);
@@ -386,7 +397,9 @@ __setup_multipath (struct vectors * vecs, struct multipath * mpp, }set_multipath_wwid (mpp); + conf =get_multipath_config (); mpp->mpe =find_mpe (conf->mptable, mpp->wwid); +put_multipath_config (conf);condlog (3 ,"%s: discover" , mpp->alias);if (!mpp->hwe)
@@ -463,6 +476,7 @@ add_map_with_path (struct vectors * vecs, struct path * pp, int add_vec) {struct multipath * mpp; +struct config *conf =NULL ;if (!strlen (pp->wwid))return NULL ;
@@ -470,8 +484,10 @@ add_map_with_path (struct vectors * vecs,if (!(mpp =alloc_multipath ()))return NULL ; + conf =get_multipath_config (); mpp->mpe =find_mpe (conf->mptable, pp->wwid); mpp->hwe = pp->hwe; +put_multipath_config (conf);strcpy (mpp->wwid, pp->wwid);find_existing_alias (mpp, vecs);
@@ -561,6 +577,7 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)continue ;if (pp->state !=PATH_DOWN ) { +struct config *conf =get_multipath_config ();int oldstate = pp->state;condlog (2 ,"%s: mark as failed" , pp->dev); mpp->stat_path_failures++;
@@ -575,6 +592,7 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)*/ if (pp->tick > conf->checkint) pp->tick = conf->checkint; +put_multipath_config (conf); } } }
@@ -591,6 +609,8 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)void update_queue_mode_del_path (struct multipath *mpp) {if (--mpp->nr_active ==0 && mpp->no_path_retry >0 ) { +struct config *conf =get_multipath_config (); +/* * Enter retry mode. * meaning of +1: retry_tick may be decremented in
@@ -600,6 +620,7 @@ void update_queue_mode_del_path(struct multipath *mpp) mpp->retry_tick = mpp->no_path_retry * conf->checkint +1 ;condlog (1 ,"%s: Entering recovery mode: max_retries=%d" , mpp->alias, mpp->no_path_retry); +put_multipath_config (conf); }condlog (2 ,"%s: remaining active paths: %d" , mpp->alias, mpp->nr_active); }
libmultipath/wwids.c +19 -3
@@ -89,8 +89,11 @@ replace_wwids(vector mp)struct multipath * mpp;size_t len;int ret =-1 ; +struct config *conf; + conf =get_multipath_config (); fd =open_file (conf->wwids_file, &can_write,WWIDS_FILE_HEADER ); +put_multipath_config (conf);if (fd <0 ) goto out;if (!can_write) {
@@ -188,6 +191,7 @@ remove_wwid(char *wwid) {int fd, len, can_write;char *str;int ret =-1 ; +struct config *conf; len =strlen (wwid) +4 ;/* two slashes the newline and a zero byte */ str =malloc (len);
@@ -201,7 +205,9 @@ remove_wwid(char *wwid) { goto out; }condlog (3 ,"removing line '%s' from wwids file" , str); + conf =get_multipath_config (); fd =open_file (conf->wwids_file, &can_write,WWIDS_FILE_HEADER ); +put_multipath_config (conf);if (fd <0 ) goto out;if (!can_write) {
@@ -222,7 +228,11 @@ check_wwids_file(char *wwid, int write_wwid) {int fd, can_write, found, ret;FILE *f; +struct config *conf; + + conf =get_multipath_config (); fd =open_file (conf->wwids_file, &can_write,WWIDS_FILE_HEADER ); +put_multipath_config (conf);if (fd <0 )return -1 ;
@@ -263,14 +273,20 @@ out:int should_multipath (struct path *pp1,vector pathvec) { -int i; +int i, ignore_new_devs;;struct path *pp2; +struct config *conf; -if (!conf->find_multipaths && !conf->ignore_new_devs) + conf =get_multipath_config (); + ignore_new_devs = conf->ignore_new_devs; +if (!conf->find_multipaths && !ignore_new_devs) { +put_multipath_config (conf);return 1 ; + } +put_multipath_config (conf);condlog (4 ,"checking if %s should be multipathed" , pp1->dev); -if (!conf->ignore_new_devs) { +if (!ignore_new_devs) { vector_foreach_slot(pathvec, pp2, i) {if (pp1->dev == pp2->dev)continue ;
mpathpersist/main.c +12 -0
@@ -41,6 +41,17 @@ int construct_transportid(const char * inp, struct transportid transid[], int nuint logsink;unsigned int mpath_mx_alloc_len; +struct config *multipath_conf; + +struct config *get_multipath_config (void ) +{ +return multipath_conf; +} + +void put_multipath_config (struct config *conf) +{ +/* Noop for now */ +}int main (int argc,char * argv[]) {
@@ -90,6 +101,7 @@ int main (int argc, char * argv[]) udev =udev_new ();mpath_lib_init (udev);memset (transportids,0 ,MPATH_MX_TIDS ); + multipath_conf = conf;while (1 ) {
multipath/main.c +13 -1
@@ -61,6 +61,17 @@int logsink;struct udev *udev; +struct config *multipath_conf; + +struct config *get_multipath_config (void ) +{ +return multipath_conf; +} + +void put_multipath_config (struct config *conf) +{ +/* Noop for now */ +}static int filter_pathvec (vector pathvec,char * refwwid)
@@ -346,7 +357,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath)/* maximum info */ di_flag =DI_ALL ; -if (path_discovery (pathvec, conf, di_flag) <0 ) +if (path_discovery (pathvec, di_flag) <0 ) goto out;if (conf->verbosity >2 )
@@ -487,6 +498,7 @@ main (int argc, char *argv[]) logsink =0 ;if (load_config (DEFAULT_CONFIGFILE ))exit (1 ); + multipath_conf = conf;while ((arg =getopt (argc, argv,":adchl::FfM:v:p:b:BritquwW" )) !=EOF ) {switch (arg) {case 1 :printf ("optarg : %s\n" ,optarg);
multipathd/cli_handlers.c +44 -8
179 lines not on this page · raw message
multipathd/main.c +15 -2
@@ -111,6 +111,8 @@ struct vectors * gvecs;struct udev * udev; +struct config *multipath_conf; +const char *daemon_status (void ) {
@@ -199,6 +201,16 @@ int set_config_state(enum daemon_status state)return rc; } +struct config *get_multipath_config (void ) +{ +return multipath_conf; +} + +void put_multipath_config (struct config *conf) +{ +/* Noop for now */ +} +static int need_switch_pathgroup (struct multipath * mpp,int refresh) {
@@ -1781,7 +1793,7 @@ configure (struct vectors * vecs, int start_waiters)/* * probe for current path (from sysfs) and map (from dm) sets */ - ret =path_discovery (vecs->pathvec, conf,DI_ALL ); + ret =path_discovery (vecs->pathvec,DI_ALL );if (ret <0 )return 1 ;
@@ -1885,6 +1897,7 @@ reconfigure (struct vectors * vecs) conf->bindings_read_only = old->bindings_read_only; conf->ignore_new_devs = old->ignore_new_devs;configure (vecs,1 ); + multipath_conf = conf;free_config (old); retval =0 ; }else {
@@ -2109,7 +2122,7 @@ child (void * param) goto failed; uxsock_timeout = conf->uxsock_timeout; - + multipath_conf = conf;dm_init (conf->verbosity);dm_drv_version (conf->version,TGT_MPATH );if (init_checkers (conf->multipath_dir)) {
multipathd/uxlsnr.c +0 -5
@@ -144,11 +144,6 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data)return NULL ; } -if (!conf) { -condlog (1 ,"uxsock: configuration changed" ); -return NULL ; - } -pthread_cleanup_push (uxsock_cleanup,NULL );condlog (3 ,"uxsock: startup listener" );
Signature · 1 line
2.6.6
PATCH v2 23/26 multipathd: Fixup commandline argument handling
In reply to Hannes Reineckemultipathd would attempt to store the commandline arguments in an empty configuration, which would later be overwritten when reading in the main configuration.
And it would not pass in the arguments correctly when using the CLI interface.
So with this patch the commandline arguments are stored in global variables, which then will always overwrite settings from the configuration file.
--- multipathd/main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
multipathd/main.c +22 -11
@@ -99,6 +99,9 @@ struct mpath_event_paramunsigned int mpath_mx_alloc_len;int logsink; +int verbosity; +int bindings_read_only; +int ignore_new_devs;enum daemon_status running_state =DAEMON_INIT ;pid_t daemon_pid;pthread_mutex_t config_lock =PTHREAD_MUTEX_INITIALIZER ;
@@ -1893,9 +1896,12 @@ reconfigure (struct vectors * vecs)if (!load_config (DEFAULT_CONFIGFILE )) {dm_drv_version (conf->version,TGT_MPATH ); - conf->verbosity = old->verbosity; - conf->bindings_read_only = old->bindings_read_only; - conf->ignore_new_devs = old->ignore_new_devs; +if (verbosity) + conf->verbosity = verbosity; +if (bindings_read_only) + conf->bindings_read_only = bindings_read_only; +if (ignore_new_devs) + conf->ignore_new_devs = ignore_new_devs;configure (vecs,1 ); multipath_conf = conf;free_config (old);
@@ -2121,6 +2127,12 @@ child (void * param)if (load_config (DEFAULT_CONFIGFILE )) goto failed; +if (verbosity) + conf->verbosity = verbosity; +if (bindings_read_only) + conf->bindings_read_only = bindings_read_only; +if (ignore_new_devs) + conf->ignore_new_devs = ignore_new_devs; uxsock_timeout = conf->uxsock_timeout; multipath_conf = conf;dm_init (conf->verbosity);
@@ -2392,11 +2404,6 @@ main (int argc, char *argv[]) strerror(errno));umask (umask (077 ) |022 ); - conf =alloc_config (); - -if (!conf) -exit (1 ); - udev =udev_new ();while ((arg =getopt (argc, argv,":dsv:k::Bn" )) !=EOF ) {
@@ -2412,7 +2419,7 @@ main (int argc, char *argv[]) !isdigit(optarg[0]))exit (1 ); - conf->verbosity =atoi (optarg); + verbosity =atoi (optarg);break ;case 's' : logsink =-1 ;
@@ -2420,13 +2427,15 @@ main (int argc, char *argv[])case 'k' :if (load_config (DEFAULT_CONFIGFILE ))exit (1 ); +if (verbosity) + conf->verbosity = verbosity;uxclnt (optarg, uxsock_timeout +100 );exit (0 );case 'B' : - conf->bindings_read_only =1 ; + bindings_read_only =1 ;break ;case 'n' : - conf->ignore_new_devs =1 ; + ignore_new_devs =1 ;break ;default : fprintf(stderr, "Invalid argument '-%c'\n",
@@ -2441,6 +2450,8 @@ main (int argc, char *argv[])if (load_config (DEFAULT_CONFIGFILE ))exit (1 ); +if (verbosity) + conf->verbosity = verbosity;memset (cmd,0x0 ,CMDSIZE );while (optind < argc) {if (strchr (argv[optind],' ' ))
Signature · 1 line
2.6.6
PATCH v2 24/26 multipath: make 'struct config' a local variable
In reply to Hannes ReineckeInstead of having a global 'struct config' we should be making it a local variable. This enables us to track accesses and will allow us a race-free configuration update.
--- libmpathpersist/mpath_persist.c | 13 ++-- libmpathpersist/mpath_persist.h | 6 +- libmultipath/config.c | 13 ++-- libmultipath/config.h | 3 +- mpathpersist/main.c | 7 +- multipath/main.c | 20 ++++- multipathd/main.c | 166 +++++++++++++++++++++++++++++----------- 7 files changed, 163 insertions(+), 65 deletions(-)
libmpathpersist/mpath_persist.c +8 -5
@@ -36,12 +36,15 @@struct udev *udev; -int +struct config *mpath_lib_init (struct udev *udev) { -if (load_config (DEFAULT_CONFIGFILE )){ +struct config *conf; + + conf =load_config (DEFAULT_CONFIGFILE ); +if (!conf) {condlog (0 ,"Failed to initialize multipath config." ); -return 1 ; +return NULL ; }if (conf->max_fds) {
@@ -54,11 +57,11 @@ mpath_lib_init (struct udev *udev) conf->max_fds, strerror(errno)); } -return 0 ; +return conf; }int -mpath_lib_exit (void ) +mpath_lib_exit (struct config *conf) {dm_lib_release ();dm_lib_exit ();
libmpathpersist/mpath_persist.h +3 -3
@@ -172,9 +172,9 @@ struct prout_param_descriptor { /* PROUT parameter descriptor */* before performing reservation management functions. * RESTRICTIONS: * -* RETURNS: 0->Success, 1->Failed. +* RETURNS: struct config ->Success, NULL->Failed. */ -extern int mpath_lib_init (struct udev *udev); +extern struct config *mpath_lib_init (struct udev *udev);/*
@@ -185,7 +185,7 @@ extern int mpath_lib_init (struct udev *udev);* * RETURNS: 0->Success, 1->Failed. */ -extern int mpath_lib_exit (void ); +extern int mpath_lib_exit (struct config *conf);/*
libmultipath/config.c +6 -7
@@ -576,14 +576,13 @@ process_config_dir(struct config *conf, vector keywords, char *dir) } } -int +struct config *load_config (char * file) { -if (!conf) - conf =alloc_config (); +struct config *conf =alloc_config (); -if (!conf || !udev) -return 1 ; +if (!conf) +return NULL ;/* * internal defaults
@@ -731,9 +730,9 @@ load_config (char * file) !conf->wwids_file) goto out; -return 0 ; +return conf; out:free_config (conf); -return 1 ; +return NULL ; }
libmultipath/config.h +1 -2
@@ -172,7 +172,6 @@ struct config {vector elist_property; }; -struct config * conf;extern struct udev * udev;struct hwentry *find_hwe (vector hwtable,char * vendor,char * product,char *revision);
@@ -189,7 +188,7 @@ void free_mptable (vector mptable);int store_hwe (vector hwtable,struct hwentry *); -int load_config (char * file); +struct config *load_config (char * file);struct config *alloc_config (void );void free_config (struct config * conf);extern struct config *get_multipath_config (void );
mpathpersist/main.c +4 -3
@@ -83,6 +83,7 @@ int main (int argc, char * argv[])void *resp =NULL ;struct transportid * tmp;struct udev *udev =NULL ; +struct config *conf;if (optind == argc) {
@@ -99,7 +100,7 @@ int main (int argc, char * argv[]) } udev =udev_new (); -mpath_lib_init (udev); + conf =mpath_lib_init (udev);memset (transportids,0 ,MPATH_MX_TIDS ); multipath_conf = conf;
@@ -475,13 +476,13 @@ int main (int argc, char * argv[]) res =close (fd);if (res <0 ) { -mpath_lib_exit (); +mpath_lib_exit (conf);udev_unref (udev);return MPATH_PR_FILE_ERROR ; } out : -mpath_lib_exit (); +mpath_lib_exit (conf);udev_unref (udev);return (ret >=0 ) ? ret :MPATH_PR_OTHER ; }
multipath/main.c +18 -2
@@ -148,6 +148,7 @@ update_paths (struct multipath * mpp)int i, j;struct pathgroup * pgp;struct path * pp; +struct config *conf;if (!mpp->pg)return 0 ;
@@ -167,20 +168,26 @@ update_paths (struct multipath * mpp)continue ; } pp->mpp = mpp; + conf =get_multipath_config ();if (pathinfo (pp, conf,DI_ALL )) pp->state =PATH_UNCHECKED ; +put_multipath_config (conf);continue ; } pp->mpp = mpp;if (pp->state ==PATH_UNCHECKED || pp->state ==PATH_WILD ) { + conf =get_multipath_config ();if (pathinfo (pp, conf,DI_CHECKER )) pp->state =PATH_UNCHECKED ; +put_multipath_config (conf); }if (pp->priority ==PRIO_UNDEF ) { + conf =get_multipath_config ();if (pathinfo (pp, conf,DI_PRIO )) pp->priority =PRIO_UNDEF ; +put_multipath_config (conf); } } }
@@ -234,8 +241,11 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)disassemble_status (status, mpp);if (cmd ==CMD_LIST_SHORT || - cmd ==CMD_LIST_LONG ) + cmd ==CMD_LIST_LONG ) { +struct config *conf =get_multipath_config ();print_multipath_topology (mpp, conf->verbosity); +put_multipath_config (conf); + }if (cmd ==CMD_CREATE )reinstate_paths (mpp);
@@ -260,6 +270,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath)int di_flag =0 ;char * refwwid =NULL ;char * dev =NULL ; +struct config *conf;/* * allocate core vectors to store paths and multipaths
@@ -279,6 +290,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath)/* * if we have a blacklisted device parameter, exit early */ + conf =get_multipath_config (); if (dev && dev_type == DEV_DEVNODE && cmd != CMD_REMOVE_WWID && (filter_devnode(conf->blist_devnode,
@@ -286,8 +298,10 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath)if (cmd ==CMD_VALID_PATH )printf ("%s is not a valid multipath device path\n" , devpath); +put_multipath_config (conf); goto out; } +put_multipath_config (conf);/* * scope limiting must be translated into a wwid * failing the translation is fatal (by policy)
@@ -493,10 +507,12 @@ main (int argc, char *argv[])enum mpath_cmds cmd =CMD_CREATE ;enum devtypes dev_type;char *dev =NULL ; +struct config *conf; udev =udev_new (); logsink =0 ; -if (load_config (DEFAULT_CONFIGFILE )) + conf =load_config (DEFAULT_CONFIGFILE ); +if (!conf)exit (1 ); multipath_conf = conf;while ((arg =getopt (argc, argv,":adchl::FfM:v:p:b:BritquwW" )) !=EOF ) {
multipathd/main.c +123 -43
460 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v2 25/26 multipathd: use userspace RCU to access configuration
In reply to Hannes ReineckeAs the configuration is accessed from various threads at various points in time any configuration change is tricky. To avoid any race conditions this patch encapsulates any configuration accesses via RCU, which will avoid any races during reconfiguration.
--- libmultipath/config.h | 2 ++ libmultipath/waiter.c | 3 +++ mpathpersist/main.c | 4 ++++ multipath/main.c | 4 ++++ multipathd/Makefile | 2 +- multipathd/main.c | 42 +++++++++++++++++++++++++++++++++--------- 6 files changed, 47 insertions(+), 10 deletions(-)
libmultipath/config.h +2 -0
@@ -3,6 +3,7 @@#include <sys/types.h> #include <stdint.h> +#include <urcu.h> #define ORIGIN_DEFAULT 0#define ORIGIN_CONFIG 1
@@ -96,6 +97,7 @@ struct mpentry { };struct config { +struct rcu_head rcu;int verbosity;int pgpolicy_flag;int pgpolicy;
libmultipath/waiter.c +3 -0
@@ -9,6 +9,7 @@#include <sys/mman.h> #include <pthread.h> #include <signal.h> +#include <urcu.h> #include "vector.h" #include "memory.h"
@@ -41,6 +42,7 @@ void free_waiter (void *data)if (wp->dmt)dm_task_destroy (wp->dmt); +rcu_unregister_thread ();FREE (wp); }
@@ -167,6 +169,7 @@ void *waitevent (void *et) waiter = (struct event_thread *)et;pthread_cleanup_push (free_waiter, et); +rcu_register_thread ();while (1 ) { r =waiteventloop (waiter);
mpathpersist/main.c +4 -0
@@ -53,6 +53,10 @@ void put_multipath_config(struct config *conf)/* Noop for now */ } +void rcu_register_thread_memb (void ) {} + +void rcu_unregister_thread_memb (void ) {} +int main (int argc,char * argv[]) {int fd, c, res;
multipath/main.c +4 -0
@@ -73,6 +73,10 @@ void put_multipath_config(struct config *conf)/* Noop for now */ } +void rcu_register_thread_memb (void ) {} + +void rcu_unregister_thread_memb (void ) {} +static int filter_pathvec (vector pathvec,char * refwwid) {
multipathd/Makefile +1 -1
@@ -9,7 +9,7 @@ CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) ifdef SYSTEMD CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) endif -LDFLAGS += -lpthread -ldevmapper -lreadline +LDFLAGS += -lurcu -lpthread -ldevmapper -lreadline ifdef SYSTEMD ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) LDFLAGS += -lsystemd
multipathd/main.c +33 -9
124 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v2 26/26 libmultipath: Allocate keywords directly
In reply to Hannes ReineckeThere is no valid reason why we cannot allocate the keywords structure within the configuration data directly. So drop this weird pointer dance and use it directly.
--- libmultipath/config.c | 5 ++--- libmultipath/dict.c | 2 +- libmultipath/dict.h | 2 +- libmultipath/parser.c | 39 +++++---------------------------- libmultipath/parser.h | 13 +++++------ libmultipath/print.c | 56 +++++++++++++++++++++++------------------------ libmultipath/print.h | 6 ++--- multipath/main.c | 7 +++--- multipathd/cli_handlers.c | 8 ++++--- 9 files changed, 56 insertions(+), 82 deletions(-)
libmultipath/config.c +2 -3
@@ -632,9 +632,8 @@ load_config (char * file)/* * read the config file */ -set_current_keywords (&conf->keywords); -alloc_keywords (); -init_keywords (); + conf->keywords =vector_alloc (); +init_keywords (conf->keywords);if (filepresent (file)) {int builtin_hwtable_size;
libmultipath/dict.c +1 -1
@@ -1330,7 +1330,7 @@ snprint_deprecated (struct config *conf, char * buff, int len, void * data)#define __deprecatedvoid -init_keywords (void ) +init_keywords (vector keywords) {install_keyword_root ("defaults" ,NULL );install_keyword ("verbosity" , &def_verbosity_handler, &snprint_def_verbosity);
libmultipath/dict.h +1 -1
@@ -5,7 +5,7 @@#include "vector.h" #endif -void init_keywords (void ); +void init_keywords (vector keywords);int get_sys_max_fds (int *);int print_rr_weight (char * buff,int len,void *ptr);int print_pgfailback (char * buff,int len,void *ptr);
libmultipath/parser.c +6 -33
@@ -28,16 +28,8 @@/* local vars */ static int sublevel =0 ; -static vector keywords =NULL ; -static vector *keywords_addr =NULL ;static int line_nr; -void set_current_keywords (vector *k) -{ - keywords_addr = k; - keywords =NULL ; -} - int keyword_alloc(vector keywords, char *string, int (*handler) (struct config *, vector),
@@ -64,15 +56,6 @@ keyword_alloc(vector keywords, char *string,return 0 ; } -int -install_keyword_root (char *string,int (*handler) (struct config *,vector )) -{ -int r =keyword_alloc (keywords, string, handler,NULL ,1 ); -if (!r) - *keywords_addr = keywords; -return r; -} -void install_sublevel (void ) {
@@ -86,7 +69,8 @@ install_sublevel_end(void) }int -_install_keyword (char *string,int (*handler) (struct config *,vector ), +_install_keyword (vector keywords,char *string, +int (*handler) (struct config *,vector ),int (*print) (struct config *,char *,int ,void *),int unique) {int i =0 ;
@@ -130,7 +114,7 @@ free_keywords(vector keywords) }struct keyword * -find_keyword (vector v,char * name) +find_keyword (vector keywords,vector v,char * name) {struct keyword *keyword;int i;
@@ -150,7 +134,7 @@ find_keyword(vector v, char * name) !strcmp(keyword->string, name))return keyword;if (keyword->sub) { - keyword =find_keyword (keyword->sub, name); + keyword =find_keyword (keywords, keyword->sub, name);if (keyword)return keyword; }
@@ -555,17 +539,6 @@ out:return r; } -int alloc_keywords (void ) -{ -if (!keywords) - keywords =vector_alloc (); - -if (!keywords) -return 1 ; - -return 0 ; -} -/* Data initialization */ int process_file (struct config *conf,char *file)
@@ -573,7 +546,7 @@ process_file(struct config *conf, char *file)int r;FILE *stream; -if (!keywords) { +if (!conf->keywords) {condlog (0 ,"No keywords alocated" );return 1 ; }
@@ -586,7 +559,7 @@ process_file(struct config *conf, char *file)/* Stream handling */ line_nr =0 ; - r =process_stream (conf, stream, keywords, file); + r =process_stream (conf, stream, conf->keywords, file);fclose (stream);//free_keywords(keywords);
libmultipath/parser.h +6 -7
@@ -61,21 +61,20 @@ struct keyword {extern int keyword_alloc (vector keywords,char *string,int (*handler) (struct config *,vector ),int (*print) (struct config *,char *,int ,void *),int unique); -extern int install_keyword_root (char *string,int (*handler) (struct config *,vector )); +#define install_keyword_root (str, h) keyword_alloc(keywords, str, h, NULL, 1)extern void install_sublevel (void );extern void install_sublevel_end (void ); -extern int _install_keyword (char *string,int (*handler) (struct config *,vector ), +extern int _install_keyword (vector keywords,char *string, +int (*handler) (struct config *,vector ),int (*print) (struct config *,char *,int ,void *),int unique); -#define install_keyword (str, vec, pri) _install_keyword(str, vec, pri, 1) -#define install_keyword_multi (str, vec, pri) _install_keyword(str, vec, pri, 0) +#define install_keyword (str, vec, pri) _install_keyword(keywords, str, vec, pri, 1) +#define install_keyword_multi (str, vec, pri) _install_keyword(keywords, str, vec, pri, 0)extern void dump_keywords (vector keydump,int level);extern void free_keywords (vector keywords);extern vector alloc_strvec (char *string);extern void *set_value (vector strvec); -extern int alloc_keywords (void );extern int process_file (struct config *conf,char *conf_file); -extern struct keyword *find_keyword (vector v,char * name); -void set_current_keywords (vector *k); +extern struct keyword *find_keyword (vector keywords,vector v,char * name);int snprint_keyword (char *buff,int len,char *fmt,struct keyword *kw,void *data);
libmultipath/print.c +28 -28
222 lines not on this page · raw message
libmultipath/print.h +3 -3
@@ -109,9 +109,9 @@ int snprint_blacklist_report (struct config *, char *, int);int snprint_wildcards (char *,int );int snprint_status (char *,int ,struct vectors *);int snprint_devices (struct config *,char *,int ,struct vectors *); -int snprint_hwtable (char *,int ,vector ); -int snprint_mptable (char *,int ,vector ); -int snprint_overrides (char *,int ,struct hwentry *); +int snprint_hwtable (struct config *,char *,int ,vector ); +int snprint_mptable (struct config *,char *,int ,vector ); +int snprint_overrides (struct config *,char *,int ,struct hwentry *);int snprint_host_wwnn (char *,size_t ,struct path *);int snprint_host_wwpn (char *,size_t ,struct path *);int snprint_tgt_wwnn (char *,size_t ,struct path *);
multipath/main.c +4 -3
@@ -458,20 +458,21 @@ dump_config (struct config *conf) reply =REALLOC (reply, maxlen *=2 );continue ; } - c +=snprint_hwtable (c, reply + maxlen - c, conf->hwtable); + c +=snprint_hwtable (conf, c, reply + maxlen - c, conf->hwtable); again = ((c - reply) == maxlen);if (again) { reply =REALLOC (reply, maxlen *=2 );continue ; } - c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + c +=snprint_overrides (conf, c, reply + maxlen - c, + conf->overrides); again = ((c - reply) == maxlen);if (again) { reply =REALLOC (reply, maxlen *=2 );continue ; }if (VECTOR_SIZE (conf->mptable) >0 ) { - c +=snprint_mptable (c, reply + maxlen - c, + c +=snprint_mptable (conf, c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);if (again)
multipathd/cli_handlers.c +5 -3
@@ -252,18 +252,20 @@ show_config (char ** r, int * len)REALLOC_REPLY (reply, again, maxlen);if (again)continue ; - c +=snprint_hwtable (c, reply + maxlen - c, conf->hwtable); + c +=snprint_hwtable (conf, c, reply + maxlen - c, + conf->hwtable); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);if (again)continue ; - c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + c +=snprint_overrides (conf, c, reply + maxlen - c, + conf->overrides); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);if (again)continue ;if (VECTOR_SIZE (conf->mptable) >0 ) { - c +=snprint_mptable (c, reply + maxlen - c, + c +=snprint_mptable (conf, c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);
Signature · 1 line
2.6.6
The rcu v2 branch is now merged.
Thanks.
Quoted 108 lines · Hannes Reinecke
Hi all,
as Benjamin Marzinski pointed out the 'config' structure is not protected, but it will be re-allocated whenever we do a reconfiguration.
This leads to inevitable race conditions, which ATM are only imperfectly handled.
With this patchset accesses to the configuration are RCU-protected, so we are guaranteed that the pointer to the configuration is always valid.
To facilitate this the patchset moves the 'cmd', 'dev', and 'dev_type' entries out of the configuration, and replaces them with local variables in multipath.Changes to the original version:
- Fixup arguments forget_mpe_wwid()andfind_mpe()as found by Ben Marzinski
- Revert to original handling inget_state()as found by Ben MarzinskiThe patchset can be found at
github.com:/hreinecke/multipath-tools.git
branch rcu.v2As usual, comments and reviews are welcome.
Hannes Reinecke (26):
Revert patch 'movefilter_devnode()under vector lock' Use 'mptable' as argument forfind_mpe()andget_mpe_wwid()
config: set 'deferred_remove' defaults at correct call
devmapper: explicit config settings
dmparser: use 'is_daemon' as argument fordisassemble_map()
libmultipath: use 'is_daemon' as argument fordomap()etc
libmultipath: drop 'daemon' configuration setting
libmultipath: Do not access 'conf->cmd' indomap()
libmultipath: add 'cmd' as argument forget_refwwid()
libmultipath: fallback to checking environment variable inget_udev_uid()multipath: make 'cmd' internal to multipath program
multipath: make 'dev_type' internal to the multipath program
multipath: make 'dev' internal to the multipath program
libmultipath: separate out 'udev' config entry
libmultipath: use 'checkint' as argument forsysfs_set_scsi_tmo()
discovery: Pass in 'hwtable' forget_state()and
scsi_sysfs_discovery()
libmultipath: use 'struct config' as argument forpathinfo()
checkers: use 'multipath_dir' as argument
prio: use 'multipath_dir' as argument
libmultipath: use 'timeout' as argument forgetprio()
libmultipath: use explicit 'config' argument for configuration file
parsing
libmultipath: use (get,put)_multipath_config() accessors
multipathd: Fixup commandline argument handling
multipath: make 'struct config' a local variable
multipathd: use userspace RCU to access configuration
libmultipath: Allocate keywords directlylibmpathpersist/mpath_persist.c | 28 +-- libmpathpersist/mpath_persist.h | 6 +- libmultipath/checkers.c | 22 ++- libmultipath/checkers.h | 6 +- libmultipath/config.c | 43 ++--- libmultipath/config.h | 18 +- libmultipath/configure.c | 163 +++++++++++------ libmultipath/configure.h | 10 +- libmultipath/debug.c | 3 + libmultipath/devmapper.c | 21 +-- libmultipath/devmapper.h | 4 +- libmultipath/dict.c | 79 ++++---- libmultipath/dict.h | 2 +- libmultipath/discovery.c | 108 ++++++----- libmultipath/discovery.h | 12 +- libmultipath/dmparser.c | 6 +- libmultipath/dmparser.h | 2 +- libmultipath/parser.c | 61 +++---- libmultipath/parser.h | 27 +-- libmultipath/print.c | 72 ++++---- libmultipath/print.h | 16 +- libmultipath/prio.c | 40 +++-- libmultipath/prio.h | 14 +- libmultipath/prioritizers/alua.c | 12 +- libmultipath/prioritizers/alua_rtpg.c | 25 +-- libmultipath/prioritizers/alua_rtpg.h | 6 +- libmultipath/prioritizers/emc.c | 8 +- libmultipath/prioritizers/hds.c | 8 +- libmultipath/prioritizers/hp_sw.c | 46 ++--- libmultipath/prioritizers/ontap.c | 19 +- libmultipath/prioritizers/rdac.c | 8 +- libmultipath/propsel.c | 99 +++++----- libmultipath/propsel.h | 48 ++--- libmultipath/structs_vec.c | 62 ++++--- libmultipath/structs_vec.h | 13 +- libmultipath/waiter.c | 4 + libmultipath/wwids.c | 22 ++- mpathpersist/main.c | 24 ++- multipath/main.c | 199 ++++++++++++--------- multipathd/Makefile | 2 +- multipathd/cli_handlers.c | 84 ++++++--- multipathd/main.c | 327 +++++++++++++++++++++++----------- multipathd/uxlsnr.c | 5 - 43 files changed, 1057 insertions(+), 727 deletions(-)--
2.6.6