All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/26] Userspace-RCU for config accesses
@ 2016-06-20  8:08 Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock' Hannes Reinecke
                   ` (26 more replies)
  0 siblings, 27 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: dm-devel

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.

The patchset can be found at

github.com:/hreinecke/multipath-tools.git
branch rcu

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              | 121 +++++++------
 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, 1063 insertions(+), 734 deletions(-)

-- 
2.6.6

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock'
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid() Hannes Reinecke
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Patch was causing a segfault during booting and is being
replaced by the following series.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 multipathd/main.c | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index c0ca571..3b79aef 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock' Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-07-01 19:48   ` Benjamin Marzinski
  2016-06-20  8:08 ` [PATCH 03/26] config: set 'deferred_remove' defaults at correct call Hannes Reinecke
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 8b9e770..00f3e53 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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;
 
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 466e31e..2acee25 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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 hwtable, char * wwid);
+char * get_mpe_wwid (vector hwtable, char * alias);
 
 struct hwentry * alloc_hwe (void);
 struct mpentry * alloc_mpe (void);
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 8e938c0..a830bcd 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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->hwtable, dev);
 
 		/*
 		 * or directly a wwid
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index 4111fa5..f803cdc 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -409,7 +409,7 @@ select_prio (struct path * pp)
 			goto out;
 		}
 	}
-	mpe = find_mpe(pp->wwid);
+	mpe = find_mpe(conf->hwtable, pp->wwid);
 	set_prio(mpe, "(LUN setting)");
 	set_prio(conf->overrides, "(overrides setting)");
 	set_prio(pp->hwe, "controller setting)");
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 20a7457..b00832e 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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->hwtable, 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->hwtable, pp->wwid);
 	mpp->hwe = pp->hwe;
 
 	strcpy(mpp->wwid, pp->wwid);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/26] config: set 'deferred_remove' defaults at correct call
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock' Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid() Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 04/26] devmapper: explicit config settings Hannes Reinecke
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

We should be setting the defaults for 'deferred_remove' when
loading the configuration file, not when creating the hardware
entries.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 00f3e53..6f3c4e8 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/26] devmapper: explicit config settings
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (2 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 03/26] config: set 'deferred_remove' defaults at correct call Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 05/26] dmparser: use 'is_daemon' as argument for disassemble_map() Hannes Reinecke
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Rather 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index a830bcd..f7cd110 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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;
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 926d2f5..b50e9e6 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -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)))
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index b5df369..4bc3b11 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -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);
diff --git a/multipath/main.c b/multipath/main.c
index aadebec..0dbe281 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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)) {
diff --git a/multipathd/main.c b/multipathd/main.c
index 3b79aef..8592982 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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");
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/26] dmparser: use 'is_daemon' as argument for disassemble_map()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (3 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 04/26] devmapper: explicit config settings Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 06/26] libmultipath: use 'is_daemon' as argument for domap() etc Hannes Reinecke
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Use 'is_daemon' as argument for disassemble_map() so that
dmparser.c doesn't need to access 'struct config' anymore.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 35e8837..ad6aec9 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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.
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 98fb559..9e79ecd 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -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) &&
diff --git a/libmultipath/dmparser.h b/libmultipath/dmparser.h
index 1b45df0..e1badb0 100644
--- a/libmultipath/dmparser.h
+++ b/libmultipath/dmparser.h
@@ -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 *);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index b00832e..1b1a5f3 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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;
 	}
diff --git a/multipath/main.c b/multipath/main.c
index 0dbe281..30710ea 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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.
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/26] libmultipath: use 'is_daemon' as argument for domap() etc
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (4 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 05/26] dmparser: use 'is_daemon' as argument for disassemble_map() Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 07/26] libmultipath: drop 'daemon' configuration setting Hannes Reinecke
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Use 'is_daemon' as argument for domap() and coalesce_paths()
to avoid having to access struct config.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index f7cd110..d15d898 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -579,7 +579,7 @@ fail:
 #define DOMAP_DRY	3
 
 extern 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_r
 		if (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_r
 		if (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);
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index f357d9a..c0338bf 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -25,9 +25,9 @@ enum actions {
 #define FLUSH_ALL 2
 
 int 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);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 1b1a5f3..8e75504 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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 */
 
 	/*
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
index 2e06beb..c8e78b5 100644
--- a/libmultipath/structs_vec.h
+++ b/libmultipath/structs_vec.h
@@ -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);
diff --git a/multipath/main.c b/multipath/main.c
index 30710ea..4b77023 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 52bcdaa..0ca0807 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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;
diff --git a/multipathd/main.c b/multipathd/main.c
index 8592982..22284f9 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
 
 	/*
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/26] libmultipath: drop 'daemon' configuration setting
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (5 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 06/26] libmultipath: use 'is_daemon' as argument for domap() etc Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap() Hannes Reinecke
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

There 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index ad6aec9..af2374f 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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.
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 2acee25..51afd22 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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;
diff --git a/multipath/main.c b/multipath/main.c
index 4b77023..7c35ce1 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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));
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 0ca0807..eaeaa74 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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;
diff --git a/multipathd/main.c b/multipathd/main.c
index 22284f9..9568ae9 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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");
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (6 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 07/26] libmultipath: drop 'daemon' configuration setting Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid() Hannes Reinecke
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

'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().

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/config.h b/libmultipath/config.h
index 51afd22..715b887 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -24,6 +24,7 @@ enum devtypes {
 };
 
 enum mpath_cmds {
+	CMD_NONE,
 	CMD_CREATE,
 	CMD_DRY_RUN,
 	CMD_LIST_SHORT,
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index d15d898..44b2d2b 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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_r
 			continue;
 		}
 
+		if (cmd == CMD_DRY_RUN)
+			mpp->action = ACT_DRY_RUN;
 		if (mpp->action == ACT_UNDEF)
 			select_action(mpp, curmp, force_reload);
 
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index c0338bf..8d474ea 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -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);
diff --git a/multipath/main.c b/multipath/main.c
index 7c35ce1..e16c6cc 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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);
diff --git a/multipathd/main.c b/multipathd/main.c
index 9568ae9..036872c 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
 
 	/*
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (7 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap() Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 10/26] libmultipath: fallback to checking environment variable in get_udev_uid() Hannes Reinecke
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

This patch adds an 'cmd' argument to get_refwwid(). This allows
store_pathvec() to be simplified and avoids accesses to conf->cmd.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 44b2d2b..8c16e23 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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)
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index 8d474ea..442c956 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -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);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 126a54f..6fc2e8f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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;
 
diff --git a/multipath/main.c b/multipath/main.c
index e16c6cc..bf2fd31 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index eaeaa74..05dcb41 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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",
diff --git a/multipathd/main.c b/multipathd/main.c
index 036872c..6230798 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/26] libmultipath: fallback to checking environment variable in get_udev_uid()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (8 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid() Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 11/26] multipath: make 'cmd' internal to multipath program Hannes Reinecke
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

If 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 6fc2e8f..019faef 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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) {
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 11/26] multipath: make 'cmd' internal to multipath program
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (9 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 10/26] libmultipath: fallback to checking environment variable in get_udev_uid() Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:08 ` [PATCH 12/26] multipath: make 'dev_type' internal to the " Hannes Reinecke
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Only 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/config.h |  1 -
 multipath/main.c      | 73 +++++++++++++++++++++++++--------------------------
 2 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/libmultipath/config.h b/libmultipath/config.h
index 715b887..eed606c 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -97,7 +97,6 @@ struct mpentry {
 
 struct config {
 	int verbosity;
-	enum mpath_cmds cmd;
 	int pgpolicy_flag;
 	int pgpolicy;
 	enum devtypes dev_type;
diff --git a/multipath/main.c b/multipath/main.c
index bf2fd31..bd7da58 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -176,7 +176,7 @@ update_paths (struct multipath * mpp)
 }
 
 static int
-get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)
+get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)
 {
 	int i;
 	struct multipath * mpp;
@@ -198,7 +198,7 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)
 			continue;
 		}
 
-		if (conf->cmd == CMD_VALID_PATH)
+		if (cmd == CMD_VALID_PATH)
 			continue;
 
 		dm_get_map(mpp->alias, &mpp->size, params);
@@ -213,19 +213,19 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)
 		 * If not in "fast list mode", we need to fetch information
 		 * about them
 		 */
-		if (conf->cmd != CMD_LIST_SHORT)
+		if (cmd != CMD_LIST_SHORT)
 			update_paths(mpp);
 
-		if (conf->cmd == CMD_LIST_LONG)
+		if (cmd == CMD_LIST_LONG)
 			mpp->bestpg = select_path_group(mpp);
 
 		disassemble_status(status, mpp);
 
-		if (conf->cmd == CMD_LIST_SHORT ||
-		    conf->cmd == CMD_LIST_LONG)
+		if (cmd == CMD_LIST_SHORT ||
+		    cmd == CMD_LIST_LONG)
 			print_multipath_topology(mpp, conf->verbosity);
 
-		if (conf->cmd == CMD_CREATE)
+		if (cmd == CMD_CREATE)
 			reinstate_paths(mpp);
 	}
 	return 0;
@@ -239,7 +239,7 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)
  *   1: Failure
  */
 static int
-configure (void)
+configure (enum mpath_cmds cmd)
 {
 	vector curmp = NULL;
 	vector pathvec = NULL;
@@ -268,10 +268,10 @@ configure (void)
 	 * if we have a blacklisted device parameter, exit early
 	 */
 	if (dev && conf->dev_type == DEV_DEVNODE &&
-	    conf->cmd != CMD_REMOVE_WWID &&
+	    cmd != CMD_REMOVE_WWID &&
 	    (filter_devnode(conf->blist_devnode,
 			    conf->elist_devnode, dev) > 0)) {
-		if (conf->cmd == CMD_VALID_PATH)
+		if (cmd == CMD_VALID_PATH)
 			printf("%s is not a valid multipath device path\n",
 			       conf->dev);
 		goto out;
@@ -281,17 +281,17 @@ configure (void)
 	 * failing the translation is fatal (by policy)
 	 */
 	if (conf->dev) {
-		int failed = get_refwwid(conf->cmd, conf->dev, conf->dev_type,
+		int failed = get_refwwid(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)
+			if (failed == 2 && cmd == CMD_VALID_PATH)
 				printf("%s is not a valid multipath device path\n", conf->dev);
 			else
 				condlog(3, "scope is nul");
 			goto out;
 		}
-		if (conf->cmd == CMD_REMOVE_WWID) {
+		if (cmd == CMD_REMOVE_WWID) {
 			r = remove_wwid(refwwid);
 			if (r == 0)
 				printf("wwid '%s' removed\n", refwwid);
@@ -302,7 +302,7 @@ configure (void)
 			}
 			goto out;
 		}
-		if (conf->cmd == CMD_ADD_WWID) {
+		if (cmd == CMD_ADD_WWID) {
 			r = remember_wwid(refwwid);
 			if (r == 0)
 				printf("wwid '%s' added\n", refwwid);
@@ -317,7 +317,7 @@ configure (void)
 		 * paths to determine if this path should be multipathed. To
 		 * do this, we put off the check until after discovering all
 		 * the paths */
-		if (conf->cmd == CMD_VALID_PATH &&
+		if (cmd == CMD_VALID_PATH &&
 		    (!conf->find_multipaths || !conf->ignore_wwids)) {
 			if (conf->ignore_wwids ||
 			    check_wwids_file(refwwid, 0) == 0)
@@ -335,10 +335,10 @@ configure (void)
 	if (conf->dev)
 		di_flag = DI_WWID;
 
-	if (conf->cmd == CMD_LIST_LONG)
+	if (cmd == CMD_LIST_LONG)
 		/* extended path info '-ll' */
 		di_flag |= DI_SYSFS | DI_CHECKER;
-	else if (conf->cmd == CMD_LIST_SHORT)
+	else if (cmd == CMD_LIST_SHORT)
 		/* minimum path info '-l' */
 		di_flag |= DI_SYSFS;
 	else
@@ -353,13 +353,13 @@ configure (void)
 
 	get_path_layout(pathvec, 0);
 
-	if (get_dm_mpvec(curmp, pathvec, refwwid))
+	if (get_dm_mpvec(cmd, curmp, pathvec, refwwid))
 		goto out;
 
 	filter_pathvec(pathvec, refwwid);
 
 
-	if (conf->cmd == CMD_VALID_PATH) {
+	if (cmd == CMD_VALID_PATH) {
 		/* This only happens if find_multipaths is and
 		 * ignore_wwids is set.
 		 * If there is currently a multipath device matching
@@ -372,7 +372,7 @@ configure (void)
 		goto out;
 	}
 
-	if (conf->cmd != CMD_CREATE && conf->cmd != CMD_DRY_RUN) {
+	if (cmd != CMD_CREATE && cmd != CMD_DRY_RUN) {
 		r = 0;
 		goto out;
 	}
@@ -381,7 +381,7 @@ configure (void)
 	 * core logic entry point
 	 */
 	r = coalesce_paths(&vecs, NULL, refwwid,
-			   conf->force_reload, conf->cmd);
+			   conf->force_reload, cmd);
 
 out:
 	if (refwwid)
@@ -479,13 +479,12 @@ main (int argc, char *argv[])
 	extern char *optarg;
 	extern int optind;
 	int r = 1;
+	enum mpath_cmds cmd = CMD_CREATE;
 
 	udev = udev_new();
 	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);
@@ -509,11 +508,11 @@ main (int argc, char *argv[])
 			conf->allow_queueing = 1;
 			break;
 		case 'c':
-			conf->cmd = CMD_VALID_PATH;
+			cmd = CMD_VALID_PATH;
 			break;
 		case 'd':
-			if (conf->cmd == CMD_CREATE)
-				conf->cmd = CMD_DRY_RUN;
+			if (cmd == CMD_CREATE)
+				cmd = CMD_DRY_RUN;
 			break;
 		case 'f':
 			conf->remove = FLUSH_ONE;
@@ -523,9 +522,9 @@ main (int argc, char *argv[])
 			break;
 		case 'l':
 			if (optarg && !strncmp(optarg, "l", 1))
-				conf->cmd = CMD_LIST_LONG;
+				cmd = CMD_LIST_LONG;
 			else
-				conf->cmd = CMD_LIST_SHORT;
+				cmd = CMD_LIST_SHORT;
 
 			break;
 		case 'M':
@@ -554,17 +553,17 @@ main (int argc, char *argv[])
 			usage(argv[0]);
 			exit(0);
 		case 'u':
-			conf->cmd = CMD_VALID_PATH;
+			cmd = CMD_VALID_PATH;
 			conf->dev_type = DEV_UEVENT;
 			break;
 		case 'w':
-			conf->cmd = CMD_REMOVE_WWID;
+			cmd = CMD_REMOVE_WWID;
 			break;
 		case 'W':
-			conf->cmd = CMD_RESET_WWIDS;
+			cmd = CMD_RESET_WWIDS;
 			break;
 		case 'a':
-			conf->cmd = CMD_ADD_WWID;
+			cmd = CMD_ADD_WWID;
 			break;
 		case ':':
 			fprintf(stderr, "Missing option argument\n");
@@ -630,12 +629,12 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
-	if (conf->cmd == CMD_VALID_PATH &&
+	if (cmd == CMD_VALID_PATH &&
 	    (!conf->dev || conf->dev_type == DEV_DEVMAP)) {
 		condlog(0, "the -c option requires a path to check");
 		goto out;
 	}
-	if (conf->cmd == CMD_VALID_PATH &&
+	if (cmd == CMD_VALID_PATH &&
 	    conf->dev_type == DEV_UEVENT) {
 		int fd;
 
@@ -647,11 +646,11 @@ main (int argc, char *argv[])
 		}
 		mpath_disconnect(fd);
 	}
-	if (conf->cmd == CMD_REMOVE_WWID && !conf->dev) {
+	if (cmd == CMD_REMOVE_WWID && !conf->dev) {
 		condlog(0, "the -w option requires a device");
 		goto out;
 	}
-	if (conf->cmd == CMD_RESET_WWIDS) {
+	if (cmd == CMD_RESET_WWIDS) {
 		struct multipath * mpp;
 		int i;
 		vector curmp;
@@ -684,7 +683,7 @@ main (int argc, char *argv[])
 		r = dm_flush_maps();
 		goto out;
 	}
-	while ((r = configure()) < 0)
+	while ((r = configure(cmd)) < 0)
 		condlog(3, "restart multipath configuration process");
 
 out:
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 12/26] multipath: make 'dev_type' internal to the multipath program
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (10 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 11/26] multipath: make 'cmd' internal to multipath program Hannes Reinecke
@ 2016-06-20  8:08 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 13/26] multipath: make 'dev' " Hannes Reinecke
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Only 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/config.c |  1 -
 libmultipath/config.h |  1 -
 multipath/main.c      | 29 +++++++++++++++--------------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 6f3c4e8..88a0f09 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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);
diff --git a/libmultipath/config.h b/libmultipath/config.h
index eed606c..06e83dc 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -99,7 +99,6 @@ struct config {
 	int verbosity;
 	int pgpolicy_flag;
 	int pgpolicy;
-	enum devtypes dev_type;
 	int minio;
 	int minio_rq;
 	int checkint;
diff --git a/multipath/main.c b/multipath/main.c
index bd7da58..5b0cb7e 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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:
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 13/26] multipath: make 'dev' internal to the multipath program
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (11 preceding siblings ...)
  2016-06-20  8:08 ` [PATCH 12/26] multipath: make 'dev_type' internal to the " Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 14/26] libmultipath: separate out 'udev' config entry Hannes Reinecke
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Only the multipath program is accessing the config entry 'dev',
so we should be making it a local variable.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/config.c |  3 ---
 libmultipath/config.h |  1 -
 multipath/main.c      | 43 +++++++++++++++++++++++--------------------
 3 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 88a0f09..137ff6a 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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);
 
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 06e83dc..d46b9ce 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -141,7 +141,6 @@ struct config {
 	int uev_wait_timeout;
 	unsigned int version[3];
 
-	char * dev;
 	struct udev * udev;
 	char * multipath_dir;
 	char * selector;
diff --git a/multipath/main.c b/multipath/main.c
index 5b0cb7e..2825c8e 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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, enum devtypes dev_type)
+configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath)
 {
 	vector curmp = NULL;
 	vector pathvec = NULL;
@@ -262,7 +262,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type)
 	vecs.pathvec = pathvec;
 	vecs.mpvec = curmp;
 
-	dev = convert_dev(conf->dev, (dev_type == DEV_DEVNODE));
+	dev = convert_dev(devpath, (dev_type == DEV_DEVNODE));
 
 	/*
 	 * if we have a blacklisted device parameter, exit early
@@ -273,20 +273,20 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type)
 			    conf->elist_devnode, dev) > 0)) {
 		if (cmd == CMD_VALID_PATH)
 			printf("%s is not a valid multipath device path\n",
-			       conf->dev);
+			       devpath);
 		goto out;
 	}
 	/*
 	 * scope limiting must be translated into a wwid
 	 * failing the translation is fatal (by policy)
 	 */
-	if (conf->dev) {
-		int failed = get_refwwid(cmd, conf->dev, dev_type,
+	if (devpath) {
+		int failed = get_refwwid(cmd, devpath, dev_type,
 					 pathvec, &refwwid);
 		if (!refwwid) {
-			condlog(4, "%s: failed to get wwid", conf->dev);
+			condlog(4, "%s: failed to get wwid", devpath);
 			if (failed == 2 && cmd == CMD_VALID_PATH)
-				printf("%s is not a valid multipath device path\n", conf->dev);
+				printf("%s is not a valid multipath device path\n", devpath);
 			else
 				condlog(3, "scope is nul");
 			goto out;
@@ -324,7 +324,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type)
 				r = 0;
 
 			printf("%s %s a valid multipath device path\n",
-			       conf->dev, r == 0 ? "is" : "is not");
+			       devpath, r == 0 ? "is" : "is not");
 			goto out;
 		}
 	}
@@ -332,7 +332,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type)
 	/*
 	 * get a path list
 	 */
-	if (conf->dev)
+	if (devpath)
 		di_flag = DI_WWID;
 
 	if (cmd == CMD_LIST_LONG)
@@ -368,7 +368,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type)
 		if (VECTOR_SIZE(curmp) != 0 || VECTOR_SIZE(pathvec) > 1)
 			r = 0;
 		printf("%s %s a valid multipath device path\n",
-		       conf->dev, r == 0 ? "is" : "is not");
+		       devpath, r == 0 ? "is" : "is not");
 		goto out;
 	}
 
@@ -481,6 +481,7 @@ main (int argc, char *argv[])
 	int r = 1;
 	enum mpath_cmds cmd = CMD_CREATE;
 	enum devtypes dev_type;
+	char *dev = NULL;
 
 	udev = udev_new();
 	logsink = 0;
@@ -592,16 +593,16 @@ main (int argc, char *argv[])
 	dm_udev_set_sync_support(1);
 
 	if (optind < argc) {
-		conf->dev = MALLOC(FILE_NAME_SIZE);
+		dev = MALLOC(FILE_NAME_SIZE);
 
-		if (!conf->dev)
+		if (!dev)
 			goto out;
 
-		strncpy(conf->dev, argv[optind], FILE_NAME_SIZE);
+		strncpy(dev, argv[optind], FILE_NAME_SIZE);
 		if (dev_type != DEV_UEVENT)
-			dev_type = get_dev_type(conf->dev);
+			dev_type = get_dev_type(dev);
 		if (dev_type == DEV_NONE) {
-			condlog(0, "'%s' is not a valid argument\n", conf->dev);
+			condlog(0, "'%s' is not a valid argument\n", dev);
 			goto out;
 		}
 	}
@@ -631,7 +632,7 @@ main (int argc, char *argv[])
 	}
 
 	if (cmd == CMD_VALID_PATH &&
-	    (!conf->dev || dev_type == DEV_DEVMAP)) {
+	    (!dev || dev_type == DEV_DEVMAP)) {
 		condlog(0, "the -c option requires a path to check");
 		goto out;
 	}
@@ -642,12 +643,12 @@ main (int argc, char *argv[])
 		fd = mpath_connect();
 		if (fd == -1) {
 			printf("%s is not a valid multipath device path\n",
-				conf->dev);
+				dev);
 			goto out;
 		}
 		mpath_disconnect(fd);
 	}
-	if (cmd == CMD_REMOVE_WWID && !conf->dev) {
+	if (cmd == CMD_REMOVE_WWID && !dev) {
 		condlog(0, "the -w option requires a device");
 		goto out;
 	}
@@ -674,7 +675,7 @@ main (int argc, char *argv[])
 	}
 	if (conf->remove == FLUSH_ONE) {
 		if (dev_type == DEV_DEVMAP) {
-			r = dm_suspend_and_flush_map(conf->dev);
+			r = dm_suspend_and_flush_map(dev);
 		} else
 			condlog(0, "must provide a map name to remove");
 
@@ -684,7 +685,7 @@ main (int argc, char *argv[])
 		r = dm_flush_maps();
 		goto out;
 	}
-	while ((r = configure(cmd, dev_type)) < 0)
+	while ((r = configure(cmd, dev_type, dev)) < 0)
 		condlog(3, "restart multipath configuration process");
 
 out:
@@ -706,6 +707,8 @@ out_free_config:
 	free_config(conf);
 	conf = NULL;
 	udev_unref(udev);
+	if (dev)
+		FREE(dev);
 #ifdef _DEBUG_
 	dbg_free_final(NULL);
 #endif
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 14/26] libmultipath: separate out 'udev' config entry
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (12 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 13/26] multipath: make 'dev' " Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 15/26] libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo() Hannes Reinecke
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Rather 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index af2374f..dc11d4f 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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;
 	}
diff --git a/libmultipath/config.c b/libmultipath/config.c
index 137ff6a..3e59205 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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);
diff --git a/libmultipath/config.h b/libmultipath/config.h
index d46b9ce..c8f2c32 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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 hwtable, 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);
 
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 8c16e23..9be74fa 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 019faef..d850aba 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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,
diff --git a/libmultipath/print.c b/libmultipath/print.c
index e3c14b6..03c7859 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -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,
diff --git a/multipath/main.c b/multipath/main.c
index 2825c8e..df6a7ca 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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) {
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 05dcb41..c8c712a 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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,
diff --git a/multipathd/main.c b/multipathd/main.c
index 6230798..9a44390 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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) {
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 15/26] libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (13 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 14/26] libmultipath: separate out 'udev' config entry Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 16/26] discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery() Hannes Reinecke
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/configure.c | 2 +-
 libmultipath/discovery.c | 4 ++--
 libmultipath/discovery.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 9be74fa..a0ea2fe 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index d850aba..0bf1bc2 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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;
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 5931bc6..45c8a4a 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 16/26] discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (14 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 15/26] libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo() Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/discovery.c | 28 ++++++++++++++--------------
 libmultipath/discovery.h |  2 +-
 multipathd/main.c        |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 0bf1bc2..e598337 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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;
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 45c8a4a..2619015 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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);
diff --git a/multipathd/main.c b/multipathd/main.c
index 9a44390..fe80d1a 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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);
 
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (15 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 16/26] discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery() Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-07-01 20:25   ` Benjamin Marzinski
  2016-06-20  8:09 ` [PATCH 18/26] checkers: use 'multipath_dir' as argument Hannes Reinecke
                   ` (9 subsequent siblings)
  26 siblings, 1 reply; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

pathinfo() requires access to the entire configuration, not just
hwtable. So don't pretend this is the case.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmpathpersist/mpath_persist.c |  6 +++---
 libmultipath/configure.c        |  8 ++++----
 libmultipath/discovery.c        | 37 ++++++++++++++++++-------------------
 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, 42 insertions(+), 43 deletions(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index dc11d4f..d557da3 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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;
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index a0ea2fe..3e143dd 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index e598337..b32c57e 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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)
 {
 	struct checker * c = &pp->checker;
 	int state;
@@ -1405,8 +1405,8 @@ get_state (struct path * pp, vector hwtable, int daemon)
 	condlog(3, "%s: get_state", pp->dev);
 
 	if (!checker_selected(c)) {
-		if (daemon) {
-			if (pathinfo(pp, hwtable, DI_SYSFS) != PATHINFO_OK) {
+		if (!pp->hwe) {
+			if (pathinfo(pp, conf, DI_SYSFS) != PATHINFO_OK) {
 				condlog(3, "%s: couldn't get sysfs pathinfo",
 					pp->dev);
 				return PATH_UNCHECKED;
@@ -1425,12 +1425,11 @@ get_state (struct path * pp, vector hwtable, int daemon)
 		}
 	}
 	checker_clear_message(c);
-	if (daemon) {
-		if (conf->force_sync == 0)
-			checker_set_async(c);
-		else
-			checker_set_sync(c);
-	}
+	if (conf->force_sync == 0)
+		checker_set_async(c);
+	else
+		checker_set_sync(c);
+
 	if (!conf->checker_timeout &&
 	    sysfs_get_timeout(pp, &(c->timeout)) <= 0)
 		c->timeout = DEF_TIMEOUT;
@@ -1588,7 +1587,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 +1609,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 +1648,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);
 			if (pp->state == PATH_UNCHECKED ||
 			    pp->state == PATH_WILD)
 				goto blank;
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 2619015..cfbc46c 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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 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);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 8e75504..1207a59 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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;
 		}
diff --git a/multipath/main.c b/multipath/main.c
index df6a7ca..ca4c1f5 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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;
 			}
 		}
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index c8c712a..90259ae 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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) {
diff --git a/multipathd/main.c b/multipathd/main.c
index fe80d1a..6c3efb2 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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);
 	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;
 			}
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 18/26] checkers: use 'multipath_dir' as argument
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (16 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 19/26] prio: " Hannes Reinecke
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Pass in the 'multipath_dir' config setting as explicit argument
for init_checkers() and checker_get(). With this we can remove
references to struct config.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index ef1d099..ad7d96c 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -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;
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
index a935b3f..a24b12e 100644
--- a/libmultipath/checkers.h
+++ b/libmultipath/checkers.h
@@ -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 */
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index f803cdc..c1f3d4e 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -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;
diff --git a/multipath/main.c b/multipath/main.c
index ca4c1f5..70412a8 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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;
 	}
diff --git a/multipathd/main.c b/multipathd/main.c
index 6c3efb2..09b96c6 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
 	}
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 19/26] prio: use 'multipath_dir' as argument
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (17 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 18/26] checkers: use 'multipath_dir' as argument Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 20/26] libmultipath: use 'timeout' as argument for getprio() Hannes Reinecke
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Pass in the 'multipath_dir' config setting as explicit argument
for init_prio() and prio_get().

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/prio.c b/libmultipath/prio.c
index fbf3190..c37d1b0 100644
--- a/libmultipath/prio.c
+++ b/libmultipath/prio.c
@@ -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;
diff --git a/libmultipath/prio.h b/libmultipath/prio.h
index 258dee7..ce72a54 100644
--- a/libmultipath/prio.h
+++ b/libmultipath/prio.h
@@ -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 *);
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index c1f3d4e..a97e80f 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -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->hwtable, 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:
 	/*
diff --git a/multipath/main.c b/multipath/main.c
index 70412a8..a6f593f 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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;
 	}
diff --git a/multipathd/main.c b/multipathd/main.c
index 09b96c6..a076f71 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
 	}
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 20/26] libmultipath: use 'timeout' as argument for getprio()
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (18 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 19/26] prio: " Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 21/26] libmultipath: use explicit 'config' argument for configuration file parsing Hannes Reinecke
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Pass in the 'checker_timeout' as explicit argument when calling
getprio().

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index b32c57e..f7d7d1b 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1459,7 +1459,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;
diff --git a/libmultipath/prio.c b/libmultipath/prio.c
index c37d1b0..7fce921 100644
--- a/libmultipath/prio.c
+++ b/libmultipath/prio.c
@@ -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)
diff --git a/libmultipath/prio.h b/libmultipath/prio.h
index ce72a54..7195986 100644
--- a/libmultipath/prio.h
+++ b/libmultipath/prio.h
@@ -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 *);
diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c
index 90dfb71..b6c5176 100644
--- a/libmultipath/prioritizers/alua.c
+++ b/libmultipath/prioritizers/alua.c
@@ -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);
diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c
index 1134fd8..ec8bd22 100644
--- a/libmultipath/prioritizers/alua_rtpg.c
+++ b/libmultipath/prioritizers/alua_rtpg.c
@@ -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;
 	}
diff --git a/libmultipath/prioritizers/alua_rtpg.h b/libmultipath/prioritizers/alua_rtpg.h
index b1b177a..dc16eb7 100644
--- a/libmultipath/prioritizers/alua_rtpg.h
+++ b/libmultipath/prioritizers/alua_rtpg.h
@@ -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__ */
 
diff --git a/libmultipath/prioritizers/emc.c b/libmultipath/prioritizers/emc.c
index e49809c..58640ec 100644
--- a/libmultipath/prioritizers/emc.c
+++ b/libmultipath/prioritizers/emc.c
@@ -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);
 }
diff --git a/libmultipath/prioritizers/hds.c b/libmultipath/prioritizers/hds.c
index 5170626..be00e44 100644
--- a/libmultipath/prioritizers/hds.c
+++ b/libmultipath/prioritizers/hds.c
@@ -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);
 }
diff --git a/libmultipath/prioritizers/hp_sw.c b/libmultipath/prioritizers/hp_sw.c
index 4950cf7..9fbb1ff 100644
--- a/libmultipath/prioritizers/hp_sw.c
+++ b/libmultipath/prioritizers/hp_sw.c
@@ -30,11 +30,11 @@
 #define HP_PATH_FAILED		0x00
 
 #define pp_hp_sw_log(prio, fmt, args...) \
-        condlog(prio, "%s: hp_sw prio: " fmt, dev, ##args)
+	condlog(prio, "%s: hp_sw prio: " fmt, dev, ##args)
 
-int hp_sw_prio(const char *dev, int fd)
+int hp_sw_prio(const char *dev, int fd, unsigned int timeout)
 {
-        unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
+	unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
 	unsigned char sb[128];
 	struct sg_io_hdr io_hdr;
 	int ret = HP_PATH_FAILED;
@@ -46,37 +46,37 @@ int hp_sw_prio(const char *dev, int fd)
 	io_hdr.dxfer_direction = SG_DXFER_NONE;
 	io_hdr.cmdp = turCmdBlk;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(60000);
+	io_hdr.timeout = get_prio_timeout(timeout, 60000);
 	io_hdr.pack_id = 0;
  retry:
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_hp_sw_log(0, "sending tur command failed");
 		goto out;
 	}
-        io_hdr.status &= 0x7e;
-        if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
-            (0 == io_hdr.driver_status)) {
+	io_hdr.status &= 0x7e;
+	if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
+	    (0 == io_hdr.driver_status)) {
 		/* Command completed normally, path is active */
-                ret = HP_PATH_ACTIVE;
+		ret = HP_PATH_ACTIVE;
 	}
 
-        if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
-            (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
-            (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {
-                if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) {
-                        int sense_key, asc, asq;
-                        unsigned char * sense_buffer = io_hdr.sbp;
-                        if (sense_buffer[0] & 0x2) {
-                                sense_key = sense_buffer[1] & 0xf;
+	if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
+	    (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
+	    (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {
+		if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) {
+			int sense_key, asc, asq;
+			unsigned char * sense_buffer = io_hdr.sbp;
+			if (sense_buffer[0] & 0x2) {
+				sense_key = sense_buffer[1] & 0xf;
 				asc = sense_buffer[2];
 				asq = sense_buffer[3];
 			} else {
-                                sense_key = sense_buffer[2] & 0xf;
+				sense_key = sense_buffer[2] & 0xf;
 				asc = sense_buffer[12];
 				asq = sense_buffer[13];
 			}
-                        if(RECOVERED_ERROR == sense_key)
-                                ret = HP_PATH_ACTIVE;
+			if(RECOVERED_ERROR == sense_key)
+				ret = HP_PATH_ACTIVE;
 			if(NOT_READY == sense_key) {
 				if (asc == 0x04 && asq == 0x02) {
 					/* This is a standby path */
@@ -89,13 +89,13 @@ int hp_sw_prio(const char *dev, int fd)
 					goto retry;
 				}
 			}
-                }
-        }
+		}
+	}
 out:
 	return(ret);
 }
 
-int getprio (struct path * pp, char * args)
+int getprio (struct path * pp, char * args, unsigned int timeout)
 {
-	return hp_sw_prio(pp->dev, pp->fd);
+	return hp_sw_prio(pp->dev, pp->fd, timeout);
 }
diff --git a/libmultipath/prioritizers/ontap.c b/libmultipath/prioritizers/ontap.c
index 5e82a17..d6872fe 100644
--- a/libmultipath/prioritizers/ontap.c
+++ b/libmultipath/prioritizers/ontap.c
@@ -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);
 }
diff --git a/libmultipath/prioritizers/rdac.c b/libmultipath/prioritizers/rdac.c
index a210055..bbd73bd 100644
--- a/libmultipath/prioritizers/rdac.c
+++ b/libmultipath/prioritizers/rdac.c
@@ -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);
 }
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index a97e80f..8932e1d 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -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);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 21/26] libmultipath: use explicit 'config' argument for configuration file parsing
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (19 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 20/26] libmultipath: use 'timeout' as argument for getprio() Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 22/26] libmultipath: use (get, put)_multipath_config() accessors Hannes Reinecke
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

When parsing the configuration file we should be passing in
'struct config' as an explicit argument.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index d557da3..1c51397 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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)
 	{
diff --git a/libmultipath/config.c b/libmultipath/config.c
index 3e59205..28e94b9 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 3e143dd..755288f 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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);
 	/*
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index 9920a9b..ed0502a 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -135,21 +135,21 @@ print_yes_no_undef (char *buff, int len, void *ptr)
 
 #define declare_def_handler(option, function)				\
 static int								\
-def_ ## option ## _handler (vector strvec)				\
+def_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	return function (strvec, &conf->option);			\
 }
 
 #define declare_def_snprint(option, function)				\
 static int								\
-snprint_def_ ## option (char * buff, int len, void * data)		\
+snprint_def_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	return function (buff, len, &conf->option);			\
 }
 
 #define declare_def_snprint_defint(option, function, value)		\
 static int								\
-snprint_def_ ## option (char * buff, int len, void * data)		\
+snprint_def_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	int i = value;							\
 	if (!conf->option)						\
@@ -159,7 +159,7 @@ snprint_def_ ## option (char * buff, int len, void * data)		\
 
 #define declare_def_snprint_defstr(option, function, value)		\
 static int								\
-snprint_def_ ## option (char * buff, int len, void * data)		\
+snprint_def_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	char *s = value;						\
 	if (!conf->option)						\
@@ -169,7 +169,7 @@ snprint_def_ ## option (char * buff, int len, void * data)		\
 
 #define declare_hw_handler(option, function)				\
 static int								\
-hw_ ## option ## _handler (vector strvec)				\
+hw_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);		\
 	if (!hwe)							\
@@ -179,7 +179,7 @@ hw_ ## option ## _handler (vector strvec)				\
 
 #define declare_hw_snprint(option, function)				\
 static int								\
-snprint_hw_ ## option (char * buff, int len, void * data)		\
+snprint_hw_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	struct hwentry * hwe = (struct hwentry *)data;			\
 	return function (buff, len, &hwe->option);			\
@@ -187,7 +187,7 @@ snprint_hw_ ## option (char * buff, int len, void * data)		\
 
 #define declare_ovr_handler(option, function)				\
 static int								\
-ovr_ ## option ## _handler (vector strvec)				\
+ovr_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	if (!conf->overrides)						\
 		return 1;						\
@@ -196,14 +196,14 @@ ovr_ ## option ## _handler (vector strvec)				\
 
 #define declare_ovr_snprint(option, function)				\
 static int								\
-snprint_ovr_ ## option (char * buff, int len, void * data)		\
+snprint_ovr_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	return function (buff, len, &conf->overrides->option);		\
 }
 
 #define declare_mp_handler(option, function)				\
 static int								\
-mp_ ## option ## _handler (vector strvec)				\
+mp_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);		\
 	if (!mpe)							\
@@ -213,7 +213,7 @@ mp_ ## option ## _handler (vector strvec)				\
 
 #define declare_mp_snprint(option, function)				\
 static int								\
-snprint_mp_ ## option (char * buff, int len, void * data)		\
+snprint_mp_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	struct mpentry * mpe = (struct mpentry *)data;			\
 	return function (buff, len, &mpe->option);			\
@@ -324,7 +324,8 @@ declare_mp_snprint(minio_rq, print_nonzero)
 
 declare_def_handler(queue_without_daemon, set_yes_no)
 static int
-snprint_def_queue_without_daemon (char * buff, int len, void * data)
+snprint_def_queue_without_daemon (struct config *conf,
+				  char * buff, int len, void * data)
 {
 	switch (conf->queue_without_daemon) {
 	case QUE_NO_DAEMON_OFF:
@@ -403,7 +404,7 @@ declare_def_handler(strict_timing, set_yes_no)
 declare_def_snprint(strict_timing, print_yes_no)
 
 static int
-def_config_dir_handler(vector strvec)
+def_config_dir_handler(struct config *conf, vector strvec)
 {
 	/* this is only valid in the main config file */
 	if (conf->processed_main_config)
@@ -414,14 +415,14 @@ declare_def_snprint(config_dir, print_str)
 
 #define declare_def_attr_handler(option, function)			\
 static int								\
-def_ ## option ## _handler (vector strvec)				\
+def_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	return function (strvec, &conf->option, &conf->attribute_flags);\
 }
 
 #define declare_def_attr_snprint(option, function)			\
 static int								\
-snprint_def_ ## option (char * buff, int len, void * data)		\
+snprint_def_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	return function (buff, len, &conf->option,			\
 			 &conf->attribute_flags);			\
@@ -429,7 +430,7 @@ snprint_def_ ## option (char * buff, int len, void * data)		\
 
 #define declare_mp_attr_handler(option, function)			\
 static int								\
-mp_ ## option ## _handler (vector strvec)				\
+mp_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);		\
 	if (!mpe)							\
@@ -439,7 +440,7 @@ mp_ ## option ## _handler (vector strvec)				\
 
 #define declare_mp_attr_snprint(option, function)			\
 static int								\
-snprint_mp_ ## option (char * buff, int len, void * data)		\
+snprint_mp_ ## option (struct config *conf, char * buff, int len, void * data) \
 {									\
 	struct mpentry * mpe = (struct mpentry *)data;			\
 	return function (buff, len, &mpe->option,			\
@@ -708,7 +709,7 @@ get_sys_max_fds(int *max_fds)
 
 
 static int
-max_fds_handler(vector strvec)
+max_fds_handler(struct config *conf, vector strvec)
 {
 	char * buff;
 	int r = 0, max_fds;
@@ -738,7 +739,7 @@ max_fds_handler(vector strvec)
 }
 
 static int
-snprint_max_fds (char * buff, int len, void * data)
+snprint_max_fds (struct config *conf, char * buff, int len, void * data)
 {
 	int r = 0, max_fds;
 
@@ -898,7 +899,7 @@ declare_mp_handler(no_path_retry, set_no_path_retry)
 declare_mp_snprint(no_path_retry, print_no_path_retry)
 
 static int
-def_log_checker_err_handler(vector strvec)
+def_log_checker_err_handler(struct config *conf, vector strvec)
 {
 	char * buff;
 
@@ -917,7 +918,7 @@ def_log_checker_err_handler(vector strvec)
 }
 
 static int
-snprint_def_log_checker_err (char * buff, int len, void * data)
+snprint_def_log_checker_err (struct config *conf, char * buff, int len, void * data)
 {
 	if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
 		return snprintf(buff, len, "once");
@@ -1050,7 +1051,7 @@ declare_mp_handler(delay_wait_checks, set_delay_checks)
 declare_mp_snprint(delay_wait_checks, print_delay_checks)
 
 static int
-def_uxsock_timeout_handler(vector strvec)
+def_uxsock_timeout_handler(struct config *conf, vector strvec)
 {
 	unsigned int uxsock_timeout;
 	char *buff;
@@ -1073,7 +1074,7 @@ def_uxsock_timeout_handler(vector strvec)
  * blacklist block handlers
  */
 static int
-blacklist_handler(vector strvec)
+blacklist_handler(struct config *conf, vector strvec)
 {
 	if (!conf->blist_devnode)
 		conf->blist_devnode = vector_alloc();
@@ -1092,7 +1093,7 @@ blacklist_handler(vector strvec)
 }
 
 static int
-blacklist_exceptions_handler(vector strvec)
+blacklist_exceptions_handler(struct config *conf, vector strvec)
 {
 	if (!conf->elist_devnode)
 		conf->elist_devnode = vector_alloc();
@@ -1112,7 +1113,7 @@ blacklist_exceptions_handler(vector strvec)
 
 #define declare_ble_handler(option)					\
 static int								\
-ble_ ## option ## _handler (vector strvec)				\
+ble_ ## option ## _handler (struct config *conf, vector strvec)		\
 {									\
 	char * buff;							\
 									\
@@ -1128,7 +1129,7 @@ ble_ ## option ## _handler (vector strvec)				\
 
 #define declare_ble_device_handler(name, option, vend, prod)		\
 static int								\
-ble_ ## option ## _ ## name ## _handler (vector strvec)			\
+ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
 {									\
 	char * buff;							\
 									\
@@ -1150,13 +1151,13 @@ declare_ble_handler(blist_property)
 declare_ble_handler(elist_property)
 
 static int
-snprint_def_uxsock_timeout(char * buff, int len, void * data)
+snprint_def_uxsock_timeout(struct config *conf, char * buff, int len, void * data)
 {
 	return snprintf(buff, len, "%u", conf->uxsock_timeout);
 }
 
 static int
-snprint_ble_simple (char * buff, int len, void * data)
+snprint_ble_simple (struct config *conf, char * buff, int len, void * data)
 {
 	struct blentry * ble = (struct blentry *)data;
 
@@ -1164,13 +1165,13 @@ snprint_ble_simple (char * buff, int len, void * data)
 }
 
 static int
-ble_device_handler(vector strvec)
+ble_device_handler(struct config *conf, vector strvec)
 {
 	return alloc_ble_device(conf->blist_device);
 }
 
 static int
-ble_except_device_handler(vector strvec)
+ble_except_device_handler(struct config *conf, vector strvec)
 {
 	return alloc_ble_device(conf->elist_device);
 }
@@ -1181,7 +1182,7 @@ declare_ble_device_handler(product, blist_device, NULL, buff)
 declare_ble_device_handler(product, elist_device, NULL, buff)
 
 static int
-snprint_bled_vendor (char * buff, int len, void * data)
+snprint_bled_vendor (struct config *conf, char * buff, int len, void * data)
 {
 	struct blentry_device * bled = (struct blentry_device *)data;
 
@@ -1189,7 +1190,7 @@ snprint_bled_vendor (char * buff, int len, void * data)
 }
 
 static int
-snprint_bled_product (char * buff, int len, void * data)
+snprint_bled_product (struct config *conf, char * buff, int len, void * data)
 {
 	struct blentry_device * bled = (struct blentry_device *)data;
 
@@ -1200,7 +1201,7 @@ snprint_bled_product (char * buff, int len, void * data)
  * devices block handlers
  */
 static int
-devices_handler(vector strvec)
+devices_handler(struct config *conf, vector strvec)
 {
 	if (!conf->hwtable)
 		conf->hwtable = vector_alloc();
@@ -1212,7 +1213,7 @@ devices_handler(vector strvec)
 }
 
 static int
-device_handler(vector strvec)
+device_handler(struct config *conf, vector strvec)
 {
 	struct hwentry * hwe;
 
@@ -1249,7 +1250,7 @@ declare_hw_snprint(hwhandler, print_str)
  * overrides handlers
  */
 static int
-overrides_handler(vector strvec)
+overrides_handler(struct config *conf, vector strvec)
 {
 	if (!conf->overrides)
 		conf->overrides = alloc_hwe();
@@ -1266,7 +1267,7 @@ overrides_handler(vector strvec)
  * multipaths block handlers
  */
 static int
-multipaths_handler(vector strvec)
+multipaths_handler(struct config *conf, vector strvec)
 {
 	if (!conf->mptable)
 		conf->mptable = vector_alloc();
@@ -1278,7 +1279,7 @@ multipaths_handler(vector strvec)
 }
 
 static int
-multipath_handler(vector strvec)
+multipath_handler(struct config *conf, vector strvec)
 {
 	struct mpentry * mpe;
 
@@ -1307,7 +1308,7 @@ declare_mp_snprint(alias, print_str)
  */
 
 static int
-deprecated_handler(vector strvec)
+deprecated_handler(struct config *conf, vector strvec)
 {
 	char * buff;
 
@@ -1321,7 +1322,7 @@ deprecated_handler(vector strvec)
 }
 
 static int
-snprint_deprecated (char * buff, int len, void * data)
+snprint_deprecated (struct config *conf, char * buff, int len, void * data)
 {
 	return 0;
 }
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index f7d7d1b..0cdcd77 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1412,7 +1412,7 @@ get_state (struct path * pp, struct config *conf)
 				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;
@@ -1451,8 +1451,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;
@@ -1519,7 +1519,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);
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index e4296ee..96bc872 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -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->print(buff + fwd, len - fwd, data);
+			r = kw->print(conf, buff + fwd, len - fwd, data);
 			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);
 
diff --git a/libmultipath/parser.h b/libmultipath/parser.h
index 70697f4..822b2b4 100644
--- a/libmultipath/parser.h
+++ b/libmultipath/parser.h
@@ -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,
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 03c7859..fe3902f 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -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;
diff --git a/libmultipath/print.h b/libmultipath/print.h
index 72758ad..023f520 100644
--- a/libmultipath/print.h
+++ b/libmultipath/print.h
@@ -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 *);
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index 8932e1d..a1e4b4a 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -82,7 +82,7 @@ do_attr_set(var, mp->mpe, shift, "(LUN setting)")
 do_attr_set(var, conf, shift, "(config file default)")
 
 extern int
-select_mode (struct multipath *mp)
+select_mode (struct config *conf, struct multipath *mp)
 {
 	char *origin;
 
@@ -96,7 +96,7 @@ out:
 }
 
 extern int
-select_uid (struct multipath *mp)
+select_uid (struct config *conf, struct multipath *mp)
 {
 	char *origin;
 
@@ -110,7 +110,7 @@ out:
 }
 
 extern int
-select_gid (struct multipath *mp)
+select_gid (struct config *conf, struct multipath *mp)
 {
 	char *origin;
 
@@ -129,7 +129,7 @@ out:
  * stop at first explicit setting found
  */
 extern int
-select_rr_weight (struct multipath * mp)
+select_rr_weight (struct config *conf, struct multipath * mp)
 {
 	char *origin, buff[13];
 
@@ -145,7 +145,7 @@ out:
 }
 
 extern int
-select_pgfailback (struct multipath * mp)
+select_pgfailback (struct config *conf, struct multipath * mp)
 {
 	char *origin, buff[13];
 
@@ -161,7 +161,7 @@ out:
 }
 
 extern int
-select_pgpolicy (struct multipath * mp)
+select_pgpolicy (struct config *conf, struct multipath * mp)
 {
 	char *origin, buff[POLICY_NAME_SIZE];
 
@@ -183,7 +183,7 @@ out:
 }
 
 extern int
-select_selector (struct multipath * mp)
+select_selector (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -200,7 +200,7 @@ out:
 }
 
 static void
-select_alias_prefix (struct multipath * mp)
+select_alias_prefix (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -214,7 +214,7 @@ out:
 }
 
 static int
-want_user_friendly_names(struct multipath * mp)
+want_user_friendly_names(struct config *conf, struct multipath * mp)
 {
 
 	char *origin;
@@ -237,7 +237,7 @@ out:
 }
 
 extern int
-select_alias (struct multipath * mp)
+select_alias (struct config *conf, struct multipath * mp)
 {
 	char *origin = NULL;
 
@@ -248,10 +248,10 @@ select_alias (struct multipath * mp)
 	}
 
 	mp->alias = NULL;
-	if (!want_user_friendly_names(mp))
+	if (!want_user_friendly_names(conf, mp))
 		goto out;
 
-	select_alias_prefix(mp);
+	select_alias_prefix(conf, mp);
 
 	if (strlen(mp->alias_old) > 0) {
 		mp->alias = use_existing_alias(mp->wwid, conf->bindings_file,
@@ -277,7 +277,7 @@ out:
 }
 
 extern int
-select_features (struct multipath * mp)
+select_features (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -303,7 +303,7 @@ out:
 }
 
 extern int
-select_hwhandler (struct multipath * mp)
+select_hwhandler (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -318,7 +318,7 @@ out:
 }
 
 extern int
-select_checker(struct path *pp)
+select_checker(struct config *conf, struct path *pp)
 {
 	char *origin, *checker_name;
 	struct checker * c = &pp->checker;
@@ -347,7 +347,7 @@ out:
 }
 
 extern int
-select_getuid (struct path * pp)
+select_getuid (struct config *conf, struct path * pp)
 {
 	char *origin;
 
@@ -369,7 +369,7 @@ out:
 }
 
 void
-detect_prio(struct path * pp)
+detect_prio(struct config *conf, struct path * pp)
 {
 	int ret;
 	struct prio *p = &pp->prio;
@@ -387,24 +387,24 @@ detect_prio(struct path * pp)
 	prio_get(conf->multipath_dir, p, PRIO_ALUA, DEFAULT_PRIO_ARGS);
 }
 
-#define set_prio(dir, src, msg)						\
+#define set_prio(dir, src, msg)					\
 do {									\
 	if (src && src->prio_name) {					\
-		prio_get(dir, p, src->prio_name, src->prio_args); \
+		prio_get(dir, p, src->prio_name, src->prio_args);	\
 		origin = msg;						\
 		goto out;						\
 	}								\
 } while(0)
 
 extern int
-select_prio (struct path * pp)
+select_prio (struct config *conf, struct path * pp)
 {
 	char *origin;
 	struct mpentry * mpe;
 	struct prio * p = &pp->prio;
 
 	if (pp->detect_prio == DETECT_PRIO_ON) {
-		detect_prio(pp);
+		detect_prio(conf, pp);
 		if (prio_selected(p)) {
 			origin = "(detected setting)";
 			goto out;
@@ -435,7 +435,7 @@ out:
 }
 
 extern int
-select_no_path_retry(struct multipath *mp)
+select_no_path_retry(struct config *conf, struct multipath *mp)
 {
 	char *origin = NULL;
 	char buff[12];
@@ -464,7 +464,7 @@ out:
 }
 
 int
-select_minio_rq (struct multipath * mp)
+select_minio_rq (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -479,7 +479,7 @@ out:
 }
 
 int
-select_minio_bio (struct multipath * mp)
+select_minio_bio (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 
@@ -494,18 +494,18 @@ out:
 }
 
 extern int
-select_minio (struct multipath * mp)
+select_minio (struct config *conf, struct multipath * mp)
 {
 	unsigned int minv_dmrq[3] = {1, 1, 0};
 
 	if (VERSION_GE(conf->version, minv_dmrq))
-		return select_minio_rq(mp);
+		return select_minio_rq(conf, mp);
 	else
-		return select_minio_bio(mp);
+		return select_minio_bio(conf, mp);
 }
 
 extern int
-select_fast_io_fail(struct multipath *mp)
+select_fast_io_fail(struct config *conf, struct multipath *mp)
 {
 	char *origin, buff[12];
 
@@ -520,7 +520,7 @@ out:
 }
 
 extern int
-select_dev_loss(struct multipath *mp)
+select_dev_loss(struct config *conf, struct multipath *mp)
 {
 	char *origin, buff[12];
 
@@ -536,7 +536,7 @@ out:
 }
 
 extern int
-select_flush_on_last_del(struct multipath *mp)
+select_flush_on_last_del(struct config *conf, struct multipath *mp)
 {
 	char *origin;
 
@@ -554,7 +554,7 @@ out:
 }
 
 extern int
-select_reservation_key (struct multipath * mp)
+select_reservation_key (struct config *conf, struct multipath * mp)
 {
 	char *origin, buff[12];
 
@@ -569,7 +569,7 @@ out:
 }
 
 extern int
-select_retain_hwhandler (struct multipath * mp)
+select_retain_hwhandler (struct config *conf, struct multipath * mp)
 {
 	char *origin;
 	unsigned int minv_dm_retain[3] = {1, 5, 0};
@@ -591,7 +591,7 @@ out:
 }
 
 extern int
-select_detect_prio (struct path * pp)
+select_detect_prio (struct config *conf, struct path * pp)
 {
 	char *origin;
 
@@ -606,7 +606,7 @@ out:
 }
 
 extern int
-select_deferred_remove (struct multipath *mp)
+select_deferred_remove (struct config *conf, struct multipath *mp)
 {
 	char *origin;
 
@@ -632,7 +632,7 @@ out:
 }
 
 extern int
-select_delay_watch_checks(struct multipath *mp)
+select_delay_watch_checks(struct config *conf, struct multipath *mp)
 {
 	char *origin, buff[12];
 
@@ -648,7 +648,7 @@ out:
 }
 
 extern int
-select_delay_wait_checks(struct multipath *mp)
+select_delay_wait_checks(struct config *conf, struct multipath *mp)
 {
 	char *origin, buff[12];
 
diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h
index f9598e7..5941a5f 100644
--- a/libmultipath/propsel.h
+++ b/libmultipath/propsel.h
@@ -1,24 +1,24 @@
-int select_rr_weight (struct multipath * mp);
-int select_pgfailback (struct multipath * mp);
-int select_pgpolicy (struct multipath * mp);
-int select_selector (struct multipath * mp);
-int select_alias (struct multipath * mp);
-int select_features (struct multipath * mp);
-int select_hwhandler (struct multipath * mp);
-int select_checker(struct path *pp);
-int select_getuid (struct path * pp);
-int select_prio (struct path * pp);
-int select_no_path_retry(struct multipath *mp);
-int select_flush_on_last_del(struct multipath *mp);
-int select_minio(struct multipath *mp);
-int select_mode(struct multipath *mp);
-int select_uid(struct multipath *mp);
-int select_gid(struct multipath *mp);
-int select_fast_io_fail(struct multipath *mp);
-int select_dev_loss(struct multipath *mp);
-int select_reservation_key(struct multipath *mp);
-int select_retain_hwhandler (struct multipath * mp);
-int select_detect_prio(struct path * pp);
-int select_deferred_remove(struct multipath *mp);
-int select_delay_watch_checks (struct multipath * mp);
-int select_delay_wait_checks (struct multipath * mp);
+int select_rr_weight (struct config *conf, struct multipath * mp);
+int select_pgfailback (struct config *conf, struct multipath * mp);
+int select_pgpolicy (struct config *conf, struct multipath * mp);
+int select_selector (struct config *conf, struct multipath * mp);
+int select_alias (struct config *conf, struct multipath * mp);
+int select_features (struct config *conf, struct multipath * mp);
+int select_hwhandler (struct config *conf, struct multipath * mp);
+int select_checker(struct config *conf, struct path *pp);
+int select_getuid (struct config *conf, struct path * pp);
+int select_prio (struct config *conf, struct path * pp);
+int select_no_path_retry(struct config *conf, struct multipath *mp);
+int select_flush_on_last_del(struct config *conf, struct multipath *mp);
+int select_minio(struct config *conf, struct multipath *mp);
+int select_mode(struct config *conf, struct multipath *mp);
+int select_uid(struct config *conf, struct multipath *mp);
+int select_gid(struct config *conf, struct multipath *mp);
+int select_fast_io_fail(struct config *conf, struct multipath *mp);
+int select_dev_loss(struct config *conf, struct multipath *mp);
+int select_reservation_key(struct config *conf, struct multipath *mp);
+int select_retain_hwhandler (struct config *conf, struct multipath * mp);
+int select_detect_prio(struct config *conf, struct path * pp);
+int select_deferred_remove(struct config *conf, struct multipath *mp);
+int select_delay_watch_checks (struct config *conf, struct multipath * mp);
+int select_delay_wait_checks (struct config *conf, struct multipath * mp);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 1207a59..11db3ae 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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;
 
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
index c8e78b5..8ef547d 100644
--- a/libmultipath/structs_vec.h
+++ b/libmultipath/structs_vec.h
@@ -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);
diff --git a/libmultipath/waiter.c b/libmultipath/waiter.c
index 6937034..219876b 100644
--- a/libmultipath/waiter.c
+++ b/libmultipath/waiter.c
@@ -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"
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index b80d3bc..5194511 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -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>
diff --git a/multipath/main.c b/multipath/main.c
index a6f593f..0d95572 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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]);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 90259ae..36c77da 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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);
 	}
diff --git a/multipathd/main.c b/multipathd/main.c
index a076f71..d5cab97 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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"
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 22/26] libmultipath: use (get, put)_multipath_config() accessors
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (20 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 21/26] libmultipath: use explicit 'config' argument for configuration file parsing Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 23/26] multipathd: Fixup commandline argument handling Hannes Reinecke
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Use (get,put)_multipath_config() accessors to mark accesses
to the configuration.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 1c51397..c1f811a 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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;
 	}
diff --git a/libmultipath/config.h b/libmultipath/config.h
index c8f2c32..28904ff 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 755288f..90062a5 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -257,6 +257,7 @@ extern int
 setup_map (struct multipath * mpp, char * params, int params_size)
 {
 	struct pathgroup * pgp;
+	struct config *conf;
 	int i;
 
 	/*
@@ -275,6 +276,7 @@ setup_map (struct multipath * mpp, char * params, int params_size)
 	/*
 	 * properties selectors
 	 */
+	conf = get_multipath_config();
 	select_pgfailback(conf, mpp);
 	select_pgpolicy(conf, mpp);
 	select_selector(conf, mpp);
@@ -295,6 +297,7 @@ setup_map (struct multipath * mpp, char * params, int params_size)
 	select_delay_wait_checks(conf, mpp);
 
 	sysfs_set_scsi_tmo(mpp, conf->checkint);
+	put_multipath_config(conf);
 	/*
 	 * assign paths to path groups -- start with no groups and all paths
 	 * in mpp->paths
@@ -582,12 +585,15 @@ extern int
 domap (struct multipath * mpp, char * params, int is_daemon)
 {
 	int r = DOMAP_FAIL;
+	struct config *conf;
 
 	/*
 	 * last chance to quit before touching the devmaps
 	 */
 	if (mpp->action == ACT_DRY_RUN) {
+		conf = get_multipath_config();
 		print_multipath_topology(mpp, conf->verbosity);
+		put_multipath_config(conf);
 		return DOMAP_DRY;
 	}
 
@@ -633,13 +639,17 @@ domap (struct multipath * mpp, char * params, int is_daemon)
 		break;
 
 	case ACT_RENAME:
+		conf = get_multipath_config();
 		r = dm_rename(mpp->alias_old, mpp->alias,
 			      conf->partition_delim);
+		put_multipath_config(conf);
 		break;
 
 	case ACT_FORCERENAME:
+		conf = get_multipath_config();
 		r = dm_rename(mpp->alias_old, mpp->alias,
 			      conf->partition_delim);
+		put_multipath_config(conf);
 		if (r)
 			r = dm_addmap_reload(mpp, params, 0);
 		break;
@@ -671,8 +681,10 @@ domap (struct multipath * mpp, char * params, int is_daemon)
 			if (mpp->action != ACT_CREATE)
 				mpp->action = ACT_NOTHING;
 			else {
+				conf = get_multipath_config();
 				mpp->wait_for_udev = 1;
 				mpp->uev_wait_tick = conf->uev_wait_timeout;
+				put_multipath_config(conf);
 			}
 		}
 		dm_setgeometry(mpp);
@@ -708,6 +720,8 @@ int check_daemon(void)
 	int fd;
 	char *reply;
 	int ret = 0;
+	unsigned int timeout;
+	struct config *conf;
 
 	fd = mpath_connect();
 	if (fd == -1)
@@ -715,7 +729,10 @@ int check_daemon(void)
 
 	if (send_packet(fd, "show daemon") != 0)
 		goto out;
-	if (recv_packet(fd, &reply, conf->uxsock_timeout) != 0)
+	conf = get_multipath_config();
+	timeout = conf->uxsock_timeout;
+	put_multipath_config(conf);
+	if (recv_packet(fd, &reply, timeout) != 0)
 		goto out;
 
 	if (strstr(reply, "shutdown"))
@@ -742,6 +759,8 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 	struct path * pp2;
 	vector curmp = vecs->mpvec;
 	vector pathvec = vecs->pathvec;
+	struct config *conf;
+	int allow_queueing;
 
 	/* ignore refwwid if it's empty */
 	if (refwwid && !strlen(refwwid))
@@ -756,11 +775,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 		/* skip this path for some reason */
 
 		/* 1. if path has no unique id or wwid blacklisted */
+		conf = get_multipath_config();
 		if (strlen(pp1->wwid) == 0 ||
 		    filter_path(conf, pp1) > 0) {
+			put_multipath_config(conf);
 			orphan_path(pp1, "wwid blacklisted");
 			continue;
 		}
+		put_multipath_config(conf);
 
 		/* 2. if path already coalesced */
 		if (pp1->mpp)
@@ -851,7 +873,10 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 		if (r == DOMAP_DRY)
 			continue;
 
-		if (!is_daemon && !conf->allow_queueing && !check_daemon()) {
+		conf = get_multipath_config();
+		allow_queueing = conf->allow_queueing;
+		put_multipath_config(conf);
+		if (!is_daemon && !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 "
@@ -876,8 +901,11 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 			}
 		}
 
-		if (!is_daemon && mpp->action != ACT_NOTHING)
+		if (!is_daemon && mpp->action != ACT_NOTHING) {
+			conf = get_multipath_config();
 			print_multipath_topology(mpp, conf->verbosity);
+			put_multipath_config(conf);
+		}
 
 		if (newmp) {
 			if (mpp->action != ACT_REJECT) {
@@ -933,6 +961,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 	char buff[FILE_NAME_SIZE];
 	char * refwwid = NULL, tmpwwid[WWID_SIZE];
 	int flags = DI_SYSFS | DI_WWID;
+	struct config *conf;
 
 	if (!wwid)
 		return 1;
@@ -959,8 +988,10 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 				condlog(2, "%s: can't get udev device", buff);
 				return 1;
 			}
+			conf = get_multipath_config();
 			ret = store_pathinfo(pathvec, conf, udevice,
 					     flags, &pp);
+			put_multipath_config(conf);
 			udev_device_unref(udevice);
 			if (!pp) {
 				if (ret == 1)
@@ -969,9 +1000,13 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 				return ret;
 			}
 		}
+		conf = get_multipath_config();
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev) > 0) {
+			put_multipath_config(conf);
 			return 2;
+		}
+		put_multipath_config(conf);
 
 		refwwid = pp->wwid;
 		goto out;
@@ -991,8 +1026,10 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 				condlog(2, "%s: can't get udev device", dev);
 				return 1;
 			}
+			conf = get_multipath_config();
 			ret = store_pathinfo(pathvec, conf, udevice,
 					     flags, &pp);
+			put_multipath_config(conf);
 			udev_device_unref(udevice);
 			if (!pp) {
 				if (ret == 1)
@@ -1001,10 +1038,13 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 				return ret;
 			}
 		}
+		conf = get_multipath_config();
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev) > 0) {
+			put_multipath_config(conf);
 			return 2;
-
+		}
+		put_multipath_config(conf);
 		refwwid = pp->wwid;
 		goto out;
 	}
@@ -1016,6 +1056,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 			condlog(2, "%s: can't get udev device", dev);
 			return 1;
 		}
+		conf = get_multipath_config();
 		ret = store_pathinfo(pathvec, conf, udevice,
 				     flags, &pp);
 		udev_device_unref(udevice);
@@ -1023,18 +1064,22 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 			if (ret == 1)
 				condlog(0, "%s: can't store path info",
 					dev);
+			put_multipath_config(conf);
 			return ret;
 		}
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev) > 0) {
+			put_multipath_config(conf);
 			return 2;
-
+		}
+		put_multipath_config(conf);
 		refwwid = pp->wwid;
 		goto out;
 	}
 
 	if (dev_type == DEV_DEVMAP) {
 
+		conf = get_multipath_config();
 		if (((dm_get_uuid(dev, tmpwwid)) == 0) && (strlen(tmpwwid))) {
 			refwwid = tmpwwid;
 			goto check;
@@ -1046,6 +1091,7 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 		if (get_user_friendly_wwid(dev, tmpwwid,
 					   conf->bindings_file) == 0) {
 			refwwid = tmpwwid;
+			put_multipath_config(conf);
 			goto check;
 		}
 
@@ -1063,9 +1109,12 @@ get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 check:
 		if (refwwid && strlen(refwwid)) {
 			if (filter_wwid(conf->blist_wwid, conf->elist_wwid,
-					refwwid, NULL) > 0)
-			return 2;
+					refwwid, NULL) > 0) {
+				put_multipath_config(conf);
+				return 2;
+			}
 		}
+		put_multipath_config(conf);
 	}
 out:
 	if (refwwid && strlen(refwwid)) {
@@ -1085,7 +1134,9 @@ 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) {
+			struct config *conf = get_multipath_config();
 			r = pathinfo(pp, conf, DI_PRIO);
+			put_multipath_config(conf);
 			if (r) {
 				condlog(2, "%s: failed to refresh pathinfo",
 					mpp->alias);
diff --git a/libmultipath/debug.c b/libmultipath/debug.c
index bad78a8..b2e344d 100644
--- a/libmultipath/debug.c
+++ b/libmultipath/debug.c
@@ -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) {
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 0cdcd77..d5215f9 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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);
 	}
@@ -1445,21 +1448,27 @@ get_state (struct path * pp, struct config *conf)
 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;
@@ -1517,9 +1526,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);
@@ -1545,6 +1558,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";
@@ -1554,7 +1569,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";
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index cfbc46c..1af75f1 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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 *);
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index 96bc872..82ce01c 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -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->print(conf, buff + fwd, len - fwd, data);
+			put_multipath_config(conf);
 			if (!r) { /* no output if no value */
 				buff = '\0';
 				return 0;
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 11db3ae..de97b48 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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->hwtable, 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->hwtable, 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);
 }
diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
index 567c93d..a7c3249 100644
--- a/libmultipath/wwids.c
+++ b/libmultipath/wwids.c
@@ -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;
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 5194511..6c1c5e7 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -41,6 +41,17 @@ int construct_transportid(const char * inp, struct transportid transid[], int nu
 
 int 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)
 	{
diff --git a/multipath/main.c b/multipath/main.c
index 0d95572..40b7a76 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 36c77da..84f430c 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -226,12 +226,16 @@ show_config (char ** r, int * len)
 	char * reply;
 	unsigned int maxlen = INITIAL_REPLY_LEN;
 	int again = 1;
+	struct config *conf;
 
 	c = reply = MALLOC(maxlen);
 
+	conf = get_multipath_config();
 	while (again) {
-		if (!reply)
+		if (!reply) {
+			put_multipath_config(conf);
 			return 1;
+		}
 		c = reply;
 		c += snprint_defaults(conf, c, reply + maxlen - c);
 		again = ((c - reply) == maxlen);
@@ -265,6 +269,7 @@ show_config (char ** r, int * len)
 			REALLOC_REPLY(reply, again, maxlen);
 		}
 	}
+	put_multipath_config(conf);
 	*r = reply;
 	*len = (int)(c - reply + 1);
 	return 0;
@@ -621,19 +626,24 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
 	char * param = get_keyparam(v, PATH);
 	struct path *pp;
 	int r;
+	struct config *conf;
 
 	param = convert_dev(param, 1);
 	condlog(2, "%s: add path (operator)", param);
-
+	conf = get_multipath_config();
 	if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
-			   param) > 0)
+			   param) > 0) {
+		put_multipath_config(conf);
 		goto blacklisted;
+	}
 
 	pp = find_path_by_dev(vecs->pathvec, param);
 	if (pp) {
 		condlog(2, "%s: path already in pathvec", param);
-		if (pp->mpp)
+		if (pp->mpp) {
+			put_multipath_config(conf);
 			return 0;
+		}
 	} else {
 		struct udev_device *udevice;
 
@@ -644,6 +654,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
 				   udevice, DI_ALL, &pp);
 		udev_device_unref(udevice);
 		if (!pp) {
+			put_multipath_config(conf);
 			if (r == 2)
 				goto blacklisted;
 			condlog(0, "%s: failed to store path info", param);
@@ -651,6 +662,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
 		}
 		pp->checkint = conf->checkint;
 	}
+	put_multipath_config(conf);
 	return ev_add_path(pp, vecs);
 blacklisted:
 	*reply = strdup("blacklisted\n");
@@ -685,16 +697,20 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
 	char dev_path[PATH_SIZE];
 	char *alias, *refwwid;
 	int rc, count = 0;
+	struct config *conf;
 
 	param = convert_dev(param, 0);
 	condlog(2, "%s: add map (operator)", param);
 
+	conf = get_multipath_config();
 	if (filter_wwid(conf->blist_wwid, conf->elist_wwid, param, NULL) > 0) {
+		put_multipath_config(conf);
 		*reply = strdup("blacklisted\n");
 		*len = strlen(*reply) + 1;
 		condlog(2, "%s: map blacklisted", param);
 		return 1;
 	}
+	put_multipath_config(conf);
 	do {
 		minor = dm_get_minor(param);
 		if (minor < 0)
@@ -880,18 +896,24 @@ cli_resize(void *v, char **reply, int *len, void *data)
 int
 cli_force_no_daemon_q(void * v, char ** reply, int * len, void * data)
 {
+	struct config *conf = get_multipath_config();
+
 	condlog(2, "force queue_without_daemon (operator)");
 	if (conf->queue_without_daemon == QUE_NO_DAEMON_OFF)
 		conf->queue_without_daemon = QUE_NO_DAEMON_FORCE;
+	put_multipath_config(conf);
 	return 0;
 }
 
 int
 cli_restore_no_daemon_q(void * v, char ** reply, int * len, void * data)
 {
+	struct config *conf = get_multipath_config();
+
 	condlog(2, "restore queue_without_daemon (operator)");
 	if (conf->queue_without_daemon == QUE_NO_DAEMON_FORCE)
 		conf->queue_without_daemon = QUE_NO_DAEMON_OFF;
+	put_multipath_config(conf);
 	return 0;
 }
 
@@ -920,8 +942,11 @@ cli_restore_queueing(void *v, char **reply, int *len, void *data)
 		dm_queue_if_no_path(mpp->alias, 1);
 		if (mpp->nr_active > 0)
 			mpp->retry_tick = 0;
-		else
+		else {
+			struct config *conf = get_multipath_config();
 			mpp->retry_tick = mpp->no_path_retry * conf->checkint;
+			put_multipath_config(conf);
+		}
 	}
 	return 0;
 }
@@ -940,8 +965,11 @@ cli_restore_all_queueing(void *v, char **reply, int *len, void *data)
 			dm_queue_if_no_path(mpp->alias, 1);
 			if (mpp->nr_active > 0)
 				mpp->retry_tick = 0;
-			else
+			else {
+				struct config *conf = get_multipath_config();
 				mpp->retry_tick = mpp->no_path_retry * conf->checkint;
+				put_multipath_config(conf);
+			}
 		}
 	}
 	return 0;
@@ -1154,12 +1182,15 @@ show_blacklist (char ** r, int * len)
 	char *reply = NULL;
 	unsigned int maxlen = INITIAL_REPLY_LEN;
 	int again = 1;
+	struct config *conf = get_multipath_config();
 
 	reply = MALLOC(maxlen);
 
 	while (again) {
-		if (!reply)
+		if (!reply) {
+			put_multipath_config(conf);
 			return 1;
+		}
 
 		c = reply;
 		c += snprint_blacklist_report(conf, c, maxlen);
@@ -1169,6 +1200,7 @@ show_blacklist (char ** r, int * len)
 
 	*r = reply;
 	*len = (int)(c - reply + 1);
+	put_multipath_config(conf);
 
 	return 0;
 }
@@ -1188,12 +1220,15 @@ show_devices (char ** r, int * len, struct vectors *vecs)
 	char *reply = NULL;
 	unsigned int maxlen = INITIAL_REPLY_LEN;
 	int again = 1;
+	struct config *conf = get_multipath_config();
 
 	reply = MALLOC(maxlen);
 
 	while (again) {
-		if (!reply)
+		if (!reply) {
+			put_multipath_config(conf);
 			return 1;
+		}
 
 		c = reply;
 		c += snprint_devices(conf, c, maxlen, vecs);
@@ -1203,6 +1238,7 @@ show_devices (char ** r, int * len, struct vectors *vecs)
 
 	*r = reply;
 	*len = (int)(c - reply + 1);
+	put_multipath_config(conf);
 
 	return 0;
 }
diff --git a/multipathd/main.c b/multipathd/main.c
index d5cab97..6771f60 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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)) {
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index 9912e00..abd1486 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -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");
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 23/26] multipathd: Fixup commandline argument handling
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (21 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 22/26] libmultipath: use (get, put)_multipath_config() accessors Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 24/26] multipath: make 'struct config' a local variable Hannes Reinecke
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

multipathd 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 multipathd/main.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 6771f60..1dfc884 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -99,6 +99,9 @@ struct mpath_event_param
 unsigned 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], ' '))
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 24/26] multipath: make 'struct config' a local variable
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (22 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 23/26] multipathd: Fixup commandline argument handling Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 25/26] multipathd: use userspace RCU to access configuration Hannes Reinecke
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Instead 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index c1f811a..b037822 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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();
diff --git a/libmpathpersist/mpath_persist.h b/libmpathpersist/mpath_persist.h
index a5e7868..ef24d64 100644
--- a/libmpathpersist/mpath_persist.h
+++ b/libmpathpersist/mpath_persist.h
@@ -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);
 
 
 /*
diff --git a/libmultipath/config.c b/libmultipath/config.c
index 28e94b9..216ca22 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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;
 }
 
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 28904ff..289403e 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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);
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 6c1c5e7..e4fb39c 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -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;
 }
diff --git a/multipath/main.c b/multipath/main.c
index 40b7a76..2ed3003 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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 ) {
diff --git a/multipathd/main.c b/multipathd/main.c
index 1dfc884..d2b57cf 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -220,6 +220,7 @@ need_switch_pathgroup (struct multipath * mpp, int refresh)
 	struct pathgroup * pgp;
 	struct path * pp;
 	unsigned int i, j;
+	struct config *conf;
 
 	if (!mpp || mpp->pgfailback == -FAILBACK_MANUAL)
 		return 0;
@@ -227,10 +228,15 @@ need_switch_pathgroup (struct multipath * mpp, int refresh)
 	/*
 	 * Refresh path priority values
 	 */
-	if (refresh)
-		vector_foreach_slot (mpp->pg, pgp, i)
-			vector_foreach_slot (pgp->paths, pp, j)
+	if (refresh) {
+		vector_foreach_slot (mpp->pg, pgp, i) {
+			vector_foreach_slot (pgp->paths, pp, j) {
+				conf = get_multipath_config();
 				pathinfo(pp, conf, DI_PRIO);
+				put_multipath_config(conf);
+			}
+		}
+	}
 
 	if (!mpp->pg || VECTOR_SIZE(mpp->paths) == 0)
 		return 0;
@@ -257,8 +263,12 @@ coalesce_maps(struct vectors *vecs, vector nmpv)
 {
 	struct multipath * ompp;
 	vector ompv = vecs->mpvec;
-	unsigned int i;
+	unsigned int i, reassign_maps;
+	struct config *conf;
 
+	conf = get_multipath_config();
+	reassign_maps = conf->reassign_maps;
+	put_multipath_config(conf);
 	vector_foreach_slot (ompv, ompp, i) {
 		condlog(3, "%s: coalesce map", ompp->alias);
 		if (!find_mp_by_wwid(nmpv, ompp->wwid)) {
@@ -288,7 +298,7 @@ coalesce_maps(struct vectors *vecs, vector nmpv)
 				dm_lib_release();
 				condlog(2, "%s devmap removed", ompp->alias);
 			}
-		} else if (conf->reassign_maps) {
+		} else if (reassign_maps) {
 			condlog(3, "%s: Reassign existing device-mapper"
 				" devices", ompp->alias);
 			dm_reassign(ompp->alias);
@@ -448,7 +458,8 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)
 	char * refwwid;
 	struct multipath * mpp;
 	int map_present;
-	int r = 1;
+	int r = 1, delayed_reconfig, reassign_maps;
+	struct config *conf;
 
 	map_present = dm_map_present(alias);
 
@@ -465,9 +476,13 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)
 				/* setup multipathd removed the map */
 				return 1;
 		}
+		conf = get_multipath_config();
+		delayed_reconfig = conf->delayed_reconfig;
+		reassign_maps = conf->reassign_maps;
+		put_multipath_config(conf);
 		if (mpp->wait_for_udev) {
 			mpp->wait_for_udev = 0;
-			if (conf->delayed_reconfig &&
+			if (delayed_reconfig &&
 			    !need_to_delay_reconfig(vecs)) {
 				condlog(2, "reconfigure (delayed)");
 				set_config_state(DAEMON_CONFIGURE);
@@ -479,7 +494,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)
 		 * if we create a multipath mapped device as a result
 		 * of uev_add_path
 		 */
-		if (conf->reassign_maps) {
+		if (reassign_maps) {
 			condlog(3, "%s: Reassign existing device-mapper devices",
 				alias);
 			dm_reassign(alias);
@@ -584,6 +599,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
 {
 	struct path *pp;
 	int ret = 0, i;
+	struct config *conf;
 
 	condlog(2, "%s: add path (uevent)", uev->kernel);
 	if (strstr(uev->kernel, "..") != NULL) {
@@ -607,8 +623,10 @@ 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);
+			conf = get_multipath_config();
 			r = pathinfo(pp, conf,
 				     DI_ALL | DI_BLACKLIST);
+			put_multipath_config(conf);
 			if (r == PATHINFO_OK)
 				ret = ev_add_path(pp, vecs);
 			else if (r == PATHINFO_SKIPPED) {
@@ -632,8 +650,10 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
 	/*
 	 * get path vital state
 	 */
+	conf = get_multipath_config();
 	ret = alloc_path_with_pathinfo(conf, uev->udev,
 				       DI_ALL, &pp);
+	put_multipath_config(conf);
 	if (!pp) {
 		if (ret == PATHINFO_SKIPPED)
 			return 0;
@@ -645,7 +665,9 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
 	pthread_testcancel();
 	ret = store_path(vecs->pathvec, pp);
 	if (!ret) {
+		conf = get_multipath_config();
 		pp->checkint = conf->checkint;
+		put_multipath_config(conf);
 		ret = ev_add_path(pp, vecs);
 	} else {
 		condlog(0, "%s: failed to store path info, "
@@ -1040,6 +1062,7 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 {
 	int r = 0;
 	struct vectors * vecs;
+	struct config *conf;
 
 	vecs = (struct vectors *)trigger_data;
 
@@ -1076,9 +1099,13 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 	/*
 	 * path add/remove event
 	 */
+	conf = get_multipath_config();
 	if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
-			   uev->kernel) > 0)
+			   uev->kernel) > 0) {
+		put_multipath_config(conf);
 		goto out;
+	}
+	put_multipath_config(conf);
 
 	if (!strncmp(uev->action, "add", 3)) {
 		r = uev_add_path(uev, vecs);
@@ -1291,7 +1318,8 @@ missing_uev_wait_tick(struct vectors *vecs)
 {
 	struct multipath * mpp;
 	unsigned int i;
-	int timed_out = 0;
+	int timed_out = 0, delayed_reconfig;
+	struct config *conf;
 
 	vector_foreach_slot (vecs->mpvec, mpp, i) {
 		if (mpp->wait_for_udev && --mpp->uev_wait_tick <= 0) {
@@ -1306,7 +1334,10 @@ missing_uev_wait_tick(struct vectors *vecs)
 		}
 	}
 
-	if (timed_out && conf->delayed_reconfig &&
+	conf = get_multipath_config();
+	delayed_reconfig = conf->delayed_reconfig;
+	put_multipath_config(conf);
+	if (timed_out && delayed_reconfig &&
 	    !need_to_delay_reconfig(vecs)) {
 		condlog(2, "reconfigure (delayed)");
 		set_config_state(DAEMON_CONFIGURE);
@@ -1356,12 +1387,15 @@ int update_prio(struct path *pp, int refresh_all)
 	struct path *pp1;
 	struct pathgroup * pgp;
 	int i, j, changed = 0;
+	struct config *conf;
 
 	if (refresh_all) {
 		vector_foreach_slot (pp->mpp->pg, pgp, i) {
 			vector_foreach_slot (pgp->paths, pp1, j) {
 				oldpriority = pp1->priority;
+				conf = get_multipath_config();
 				pathinfo(pp1, conf, DI_PRIO);
+				put_multipath_config(conf);
 				if (pp1->priority != oldpriority)
 					changed = 1;
 			}
@@ -1369,7 +1403,9 @@ int update_prio(struct path *pp, int refresh_all)
 		return changed;
 	}
 	oldpriority = pp->priority;
+	conf = get_multipath_config();
 	pathinfo(pp, conf, DI_PRIO);
+	put_multipath_config(conf);
 
 	if (pp->priority == oldpriority)
 		return 0;
@@ -1401,6 +1437,8 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	int add_active;
 	int disable_reinstate = 0;
 	int oldchkrstate = pp->chkrstate;
+	int retrigger_tries, checkint;
+	struct config *conf;
 
 	if ((pp->initialized == INIT_OK ||
 	     pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp)
@@ -1411,8 +1449,12 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	if (pp->tick)
 		return 0; /* don't check this path yet */
 
+	conf = get_multipath_config();
+	retrigger_tries = conf->retrigger_tries;
+	checkint = conf->checkint;
+	put_multipath_config(conf);
 	if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV &&
-	    pp->retriggers < conf->retrigger_tries) {
+	    pp->retriggers < retrigger_tries) {
 		condlog(2, "%s: triggering change event to reinitialize",
 			pp->dev);
 		pp->initialized = INIT_REQUESTED_UDEV;
@@ -1426,7 +1468,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	 * provision a next check soonest,
 	 * in case we exit abnormaly from here
 	 */
-	pp->tick = conf->checkint;
+	pp->tick = checkint;
 
 	newstate = path_offline(pp);
 	/*
@@ -1437,24 +1479,30 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	if (newstate == PATH_REMOVED)
 		newstate = PATH_DOWN;
 
-	if (newstate == PATH_UP)
+	if (newstate == PATH_UP) {
+		conf = get_multipath_config();
 		newstate = get_state(pp, conf);
-	else
+		put_multipath_config(conf);
+	} else
 		checker_clear_message(&pp->checker);
 
 	if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) {
 		condlog(2, "%s: unusable path", pp->dev);
+		conf = get_multipath_config();
 		pathinfo(pp, conf, 0);
+		put_multipath_config(conf);
 		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);
+			conf = get_multipath_config();
 			if (pathinfo(pp, conf, DI_ALL) == 0) {
 				ev_add_path(pp, vecs);
 				pp->tick = 1;
 			}
+			put_multipath_config(conf);
 		}
 		return 0;
 	}
@@ -1510,7 +1558,9 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 		 * upon state change, reset the checkint
 		 * to the shortest delay
 		 */
+		conf = get_multipath_config();
 		pp->checkint = conf->checkint;
+		put_multipath_config(conf);
 
 		if (newstate == PATH_DOWN || newstate == PATH_SHAKY) {
 			/*
@@ -1590,16 +1640,20 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 				return 0;
 			}
 		} else {
+			unsigned int max_checkint;
 			LOG_MSG(4, checker_message(&pp->checker));
-			if (pp->checkint != conf->max_checkint) {
+			conf = get_multipath_config();
+			max_checkint = conf->max_checkint;
+			put_multipath_config(conf);
+			if (pp->checkint != max_checkint) {
 				/*
 				 * double the next check delay.
 				 * max at conf->max_checkint
 				 */
-				if (pp->checkint < (conf->max_checkint / 2))
+				if (pp->checkint < (max_checkint / 2))
 					pp->checkint = 2 * pp->checkint;
 				else
-					pp->checkint = conf->max_checkint;
+					pp->checkint = max_checkint;
 
 				condlog(4, "%s: delay next check %is",
 					pp->dev_t, pp->checkint);
@@ -1611,7 +1665,12 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 	}
 	else if (newstate == PATH_DOWN &&
 		 strlen(checker_message(&pp->checker))) {
-		if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
+		int log_checker_err;
+
+		conf = get_multipath_config();
+		log_checker_err = conf->log_checker_err;
+		put_multipath_config(conf);
+		if (log_checker_err == LOG_CHKR_ERR_ONCE)
 			LOG_MSG(3, checker_message(&pp->checker));
 		else
 			LOG_MSG(2, checker_message(&pp->checker));
@@ -1652,6 +1711,7 @@ checkerloop (void *ap)
 	unsigned int i;
 	struct itimerval timer_tick_it;
 	struct timeval last_time;
+	struct config *conf;
 
 	mlockall(MCL_CURRENT | MCL_FUTURE);
 	vecs = (struct vectors *)ap;
@@ -1661,7 +1721,9 @@ checkerloop (void *ap)
 	 * init the path check interval
 	 */
 	vector_foreach_slot (vecs->pathvec, pp, i) {
+		conf = get_multipath_config();
 		pp->checkint = conf->checkint;
+		put_multipath_config(conf);
 	}
 
 	/* Tweak start time for initial path check */
@@ -1697,7 +1759,6 @@ checkerloop (void *ap)
 			condlog(4, "timeout waiting for DAEMON_IDLE");
 			continue;
 		}
-		strict_timing = conf->strict_timing;
 		if (vecs->pathvec) {
 			pthread_cleanup_push(cleanup_lock, &vecs->lock);
 			lock(vecs->lock);
@@ -1733,10 +1794,15 @@ checkerloop (void *ap)
 		    gettimeofday(&end_time, NULL) == 0) {
 			timersub(&end_time, &start_time, &diff_time);
 			if (num_paths) {
+				unsigned int max_checkint;
+
 				condlog(3, "checked %d path%s in %lu.%06lu secs",
 					num_paths, num_paths > 1 ? "s" : "",
 					diff_time.tv_sec, diff_time.tv_usec);
-				if (diff_time.tv_sec > conf->max_checkint)
+				conf = get_multipath_config();
+				max_checkint = conf->max_checkint;
+				put_multipath_config(conf);
+				if (diff_time.tv_sec > max_checkint)
 					condlog(1, "path checkers took longer "
 						"than %lu seconds, consider "
 						"increasing max_polling_interval",
@@ -1745,6 +1811,9 @@ checkerloop (void *ap)
 		}
 
 		post_config_state(DAEMON_IDLE);
+		conf = get_multipath_config();
+		strict_timing = conf->strict_timing;
+		put_multipath_config(conf);
 		if (!strict_timing)
 			sleep(1);
 		else {
@@ -1768,7 +1837,9 @@ checkerloop (void *ap)
 			if (sigwait(&mask, &signo) != 0) {
 				condlog(3, "sigwait failed with error %d",
 					errno);
+				conf = get_multipath_config();
 				conf->strict_timing = 0;
+				put_multipath_config(conf);
 				break;
 			}
 		}
@@ -1783,6 +1854,7 @@ configure (struct vectors * vecs, int start_waiters)
 	struct path * pp;
 	vector mpvec;
 	int i, ret;
+	struct config *conf;
 
 	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc()))
 		return 1;
@@ -1801,6 +1873,7 @@ configure (struct vectors * vecs, int start_waiters)
 		return 1;
 
 	vector_foreach_slot (vecs->pathvec, pp, i){
+		conf = get_multipath_config();
 		if (filter_path(conf, pp) > 0){
 			vector_del_slot(vecs->pathvec, i);
 			free_path(pp);
@@ -1808,6 +1881,7 @@ configure (struct vectors * vecs, int start_waiters)
 		}
 		else
 			pp->checkint = conf->checkint;
+		put_multipath_config(conf);
 	}
 	if (map_discovery(vecs))
 		return 1;
@@ -1876,8 +1950,11 @@ need_to_delay_reconfig(struct vectors * vecs)
 int
 reconfigure (struct vectors * vecs)
 {
-	struct config * old = conf;
-	int retval = 1;
+	struct config * old, *conf;
+
+	conf = load_config(DEFAULT_CONFIGFILE);
+	if (!conf)
+		return 1;
 
 	/*
 	 * free old map and path vectors ... they use old conf state
@@ -1889,29 +1966,27 @@ reconfigure (struct vectors * vecs)
 		free_pathvec(vecs->pathvec, FREE_PATHS);
 
 	vecs->pathvec = NULL;
-	conf = NULL;
 
 	/* Re-read any timezone changes */
 	tzset();
 
-	if (!load_config(DEFAULT_CONFIGFILE)) {
-		dm_drv_version(conf->version, TGT_MPATH);
-		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);
-		retval = 0;
-	} else {
-		conf = old;
-	}
+	dm_drv_version(conf->version, TGT_MPATH);
+	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;
 
-	return retval;
+	old = multipath_conf;
+	multipath_conf = conf;
+
+	configure(vecs, 1);
+
+	free_config(old);
+
+	return 0;
 }
 
 static struct vectors *
@@ -2097,6 +2172,7 @@ child (void * param)
 #endif
 	int rc;
 	int pid_fd = -1;
+	struct config *conf;
 	char *envp;
 
 	mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -2124,7 +2200,8 @@ child (void * param)
 	condlog(2, "--------start up--------");
 	condlog(2, "read " DEFAULT_CONFIGFILE);
 
-	if (load_config(DEFAULT_CONFIGFILE))
+	conf = load_config(DEFAULT_CONFIGFILE);
+	if (!conf)
 		goto failed;
 
 	if (verbosity)
@@ -2390,6 +2467,7 @@ main (int argc, char *argv[])
 	int arg;
 	int err;
 	int foreground = 0;
+	struct config *conf;
 
 	logsink = 1;
 
@@ -2425,7 +2503,8 @@ main (int argc, char *argv[])
 			logsink = -1;
 			break;
 		case 'k':
-			if (load_config(DEFAULT_CONFIGFILE))
+			conf = load_config(DEFAULT_CONFIGFILE);
+			if (!conf)
 				exit(1);
 			if (verbosity)
 				conf->verbosity = verbosity;
@@ -2448,7 +2527,8 @@ main (int argc, char *argv[])
 		char * s = cmd;
 		char * c = s;
 
-		if (load_config(DEFAULT_CONFIGFILE))
+		conf = load_config(DEFAULT_CONFIGFILE);
+		if (!conf)
 			exit(1);
 		if (verbosity)
 			conf->verbosity = verbosity;
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 25/26] multipathd: use userspace RCU to access configuration
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (23 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 24/26] multipath: make 'struct config' a local variable Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-06-20  8:09 ` [PATCH 26/26] libmultipath: Allocate keywords directly Hannes Reinecke
  2016-07-01 20:44 ` [PATCH 00/26] Userspace-RCU for config accesses Benjamin Marzinski
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

As 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/config.h b/libmultipath/config.h
index 289403e..92f2be9 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -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;
diff --git a/libmultipath/waiter.c b/libmultipath/waiter.c
index 219876b..34c0110 100644
--- a/libmultipath/waiter.c
+++ b/libmultipath/waiter.c
@@ -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);
 
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index e4fb39c..5fb831e 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -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;
diff --git a/multipath/main.c b/multipath/main.c
index 2ed3003..719d935 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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)
 {
diff --git a/multipathd/Makefile b/multipathd/Makefile
index 9b0210f..ec977f3 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -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
diff --git a/multipathd/main.c b/multipathd/main.c
index d2b57cf..9682b3e 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -17,6 +17,7 @@
 #include <limits.h>
 #include <linux/oom.h>
 #include <libudev.h>
+#include <urcu.h>
 #ifdef USE_SYSTEMD
 #include <systemd/sd-daemon.h>
 #endif
@@ -206,12 +207,13 @@ int set_config_state(enum daemon_status state)
 
 struct config *get_multipath_config(void)
 {
-	return multipath_conf;
+	rcu_read_lock();
+	return rcu_dereference(multipath_conf);
 }
 
 void put_multipath_config(struct config *conf)
 {
-	/* Noop for now */
+	rcu_read_unlock();
 }
 
 static int
@@ -1124,23 +1126,33 @@ out:
 	return r;
 }
 
+static void *rcu_unregister(void *param)
+{
+	rcu_unregister_thread();
+	return NULL;
+}
+
 static void *
 ueventloop (void * ap)
 {
 	struct udev *udev = ap;
 
+	pthread_cleanup_push(rcu_unregister, NULL);
+	rcu_register_thread();
 	if (uevent_listen(udev))
 		condlog(0, "error starting uevent listener");
-
+	pthread_cleanup_pop(1);
 	return NULL;
 }
 
 static void *
 uevqloop (void * ap)
 {
+	pthread_cleanup_push(rcu_unregister, NULL);
+	rcu_register_thread();
 	if (uevent_dispatch(&uev_trigger, ap))
 		condlog(0, "error starting uevent dispatcher");
-
+	pthread_cleanup_pop(1);
 	return NULL;
 }
 static void *
@@ -1150,7 +1162,8 @@ uxlsnrloop (void * ap)
 		condlog(1, "Failed to init uxsock listener");
 		return NULL;
 	}
-
+	pthread_cleanup_push(rcu_unregister, NULL);
+	rcu_register_thread();
 	set_handler_callback(LIST+PATHS, cli_list_paths);
 	set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt);
 	set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw);
@@ -1200,7 +1213,7 @@ uxlsnrloop (void * ap)
 
 	umask(077);
 	uxsock_listen(&uxsock_trigger, ap);
-
+	pthread_cleanup_pop(1);
 	return NULL;
 }
 
@@ -1713,6 +1726,8 @@ checkerloop (void *ap)
 	struct timeval last_time;
 	struct config *conf;
 
+	pthread_cleanup_push(rcu_unregister, NULL);
+	rcu_register_thread();
 	mlockall(MCL_CURRENT | MCL_FUTURE);
 	vecs = (struct vectors *)ap;
 	condlog(2, "path checkers start up");
@@ -1844,6 +1859,7 @@ checkerloop (void *ap)
 			}
 		}
 	}
+	pthread_cleanup_pop(1);
 	return NULL;
 }
 
@@ -1947,6 +1963,13 @@ need_to_delay_reconfig(struct vectors * vecs)
 	return 0;
 }
 
+void rcu_free_config(struct rcu_head *head)
+{
+	struct config *conf = container_of(head, struct config, rcu);
+
+	free_config(conf);
+}
+
 int
 reconfigure (struct vectors * vecs)
 {
@@ -1979,12 +2002,12 @@ reconfigure (struct vectors * vecs)
 		conf->ignore_new_devs = ignore_new_devs;
 	uxsock_timeout = conf->uxsock_timeout;
 
-	old = multipath_conf;
-	multipath_conf = conf;
+	old = rcu_dereference(multipath_conf);
+	rcu_assign_pointer(multipath_conf, conf);
+	call_rcu(&old->rcu, rcu_free_config);
 
 	configure(vecs, 1);
 
-	free_config(old);
 
 	return 0;
 }
@@ -2177,6 +2200,7 @@ child (void * param)
 
 	mlockall(MCL_CURRENT | MCL_FUTURE);
 	signal_init();
+	rcu_init();
 
 	setup_thread_attr(&misc_attr, 64 * 1024, 1);
 	setup_thread_attr(&uevent_attr, DEFAULT_UEVENT_STACKSIZE * 1024, 1);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 26/26] libmultipath: Allocate keywords directly
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (24 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 25/26] multipathd: use userspace RCU to access configuration Hannes Reinecke
@ 2016-06-20  8:09 ` Hannes Reinecke
  2016-07-01 20:44 ` [PATCH 00/26] Userspace-RCU for config accesses Benjamin Marzinski
  26 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-06-20  8:09 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

There 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.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 216ca22..9a75b4e 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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;
 
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index ed0502a..7b92a91 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -1330,7 +1330,7 @@ snprint_deprecated (struct config *conf, char * buff, int len, void * data)
 #define __deprecated
 
 void
-init_keywords(void)
+init_keywords(vector keywords)
 {
 	install_keyword_root("defaults", NULL);
 	install_keyword("verbosity", &def_verbosity_handler, &snprint_def_verbosity);
diff --git a/libmultipath/dict.h b/libmultipath/dict.h
index 4fdd576..4cd03c5 100644
--- a/libmultipath/dict.h
+++ b/libmultipath/dict.h
@@ -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);
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index 82ce01c..dd955f3 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -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);
 
diff --git a/libmultipath/parser.h b/libmultipath/parser.h
index 822b2b4..519b805 100644
--- a/libmultipath/parser.h
+++ b/libmultipath/parser.h
@@ -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);
 
diff --git a/libmultipath/print.c b/libmultipath/print.c
index fe3902f..196af61 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -1212,19 +1212,19 @@ snprint_multipath_topology_json (char * buff, int len, struct vectors * vecs)
 }
 
 static int
-snprint_hwentry (char * buff, int len, struct hwentry * hwe)
+snprint_hwentry (struct config *conf, char * buff, int len, struct hwentry * hwe)
 {
 	int i;
 	int fwd = 0;
 	struct keyword * kw;
 	struct keyword * rootkw;
 
-	rootkw = find_keyword(NULL, "devices");
+	rootkw = find_keyword(conf->keywords, NULL, "devices");
 
 	if (!rootkw || !rootkw->sub)
 		return 0;
 
-	rootkw = find_keyword(rootkw->sub, "device");
+	rootkw = find_keyword(conf->keywords, rootkw->sub, "device");
 
 	if (!rootkw)
 		return 0;
@@ -1245,14 +1245,14 @@ snprint_hwentry (char * buff, int len, struct hwentry * hwe)
 }
 
 extern int
-snprint_hwtable (char * buff, int len, vector hwtable)
+snprint_hwtable (struct config *conf, char * buff, int len, vector hwtable)
 {
 	int fwd = 0;
 	int i;
 	struct hwentry * hwe;
 	struct keyword * rootkw;
 
-	rootkw = find_keyword(NULL, "devices");
+	rootkw = find_keyword(conf->keywords, NULL, "devices");
 	if (!rootkw)
 		return 0;
 
@@ -1260,7 +1260,7 @@ snprint_hwtable (char * buff, int len, vector hwtable)
 	if (fwd > len)
 		return len;
 	vector_foreach_slot (hwtable, hwe, i) {
-		fwd += snprint_hwentry(buff + fwd, len - fwd, hwe);
+		fwd += snprint_hwentry(conf, buff + fwd, len - fwd, hwe);
 		if (fwd > len)
 			return len;
 	}
@@ -1271,14 +1271,14 @@ snprint_hwtable (char * buff, int len, vector hwtable)
 }
 
 static int
-snprint_mpentry (char * buff, int len, struct mpentry * mpe)
+snprint_mpentry (struct config *conf, char * buff, int len, struct mpentry * mpe)
 {
 	int i;
 	int fwd = 0;
 	struct keyword * kw;
 	struct keyword * rootkw;
 
-	rootkw = find_keyword(NULL, "multipath");
+	rootkw = find_keyword(conf->keywords, NULL, "multipath");
 	if (!rootkw)
 		return 0;
 
@@ -1298,14 +1298,14 @@ snprint_mpentry (char * buff, int len, struct mpentry * mpe)
 }
 
 extern int
-snprint_mptable (char * buff, int len, vector mptable)
+snprint_mptable (struct config *conf, char * buff, int len, vector mptable)
 {
 	int fwd = 0;
 	int i;
 	struct mpentry * mpe;
 	struct keyword * rootkw;
 
-	rootkw = find_keyword(NULL, "multipaths");
+	rootkw = find_keyword(conf->keywords, NULL, "multipaths");
 	if (!rootkw)
 		return 0;
 
@@ -1313,7 +1313,7 @@ snprint_mptable (char * buff, int len, vector mptable)
 	if (fwd > len)
 		return len;
 	vector_foreach_slot (mptable, mpe, i) {
-		fwd += snprint_mpentry(buff + fwd, len - fwd, mpe);
+		fwd += snprint_mpentry(conf, buff + fwd, len - fwd, mpe);
 		if (fwd > len)
 			return len;
 	}
@@ -1324,14 +1324,14 @@ snprint_mptable (char * buff, int len, vector mptable)
 }
 
 extern int
-snprint_overrides (char * buff, int len, struct hwentry *overrides)
+snprint_overrides (struct config *conf, char * buff, int len, struct hwentry *overrides)
 {
 	int fwd = 0;
 	int i;
 	struct keyword *rootkw;
 	struct keyword *kw;
 
-	rootkw = find_keyword(NULL, "overrides");
+	rootkw = find_keyword(conf->keywords, NULL, "overrides");
 	if (!rootkw)
 		return 0;
 
@@ -1361,7 +1361,7 @@ snprint_defaults (struct config *conf, char * buff, int len)
 	struct keyword *rootkw;
 	struct keyword *kw;
 
-	rootkw = find_keyword(NULL, "defaults");
+	rootkw = find_keyword(conf->keywords, NULL, "defaults");
 	if (!rootkw)
 		return 0;
 
@@ -1508,7 +1508,7 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 	struct keyword *rootkw;
 	struct keyword *kw;
 
-	rootkw = find_keyword(NULL, "blacklist");
+	rootkw = find_keyword(conf->keywords, NULL, "blacklist");
 	if (!rootkw)
 		return 0;
 
@@ -1517,7 +1517,7 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 		return len;
 
 	vector_foreach_slot (conf->blist_devnode, ble, i) {
-		kw = find_keyword(rootkw->sub, "devnode");
+		kw = find_keyword(conf->keywords, rootkw->sub, "devnode");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1526,7 +1526,7 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 			return len;
 	}
 	vector_foreach_slot (conf->blist_wwid, ble, i) {
-		kw = find_keyword(rootkw->sub, "wwid");
+		kw = find_keyword(conf->keywords, rootkw->sub, "wwid");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1535,7 +1535,7 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 			return len;
 	}
 	vector_foreach_slot (conf->blist_property, ble, i) {
-		kw = find_keyword(rootkw->sub, "property");
+		kw = find_keyword(conf->keywords, rootkw->sub, "property");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1543,7 +1543,7 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 		if (fwd > len)
 			return len;
 	}
-	rootkw = find_keyword(rootkw->sub, "device");
+	rootkw = find_keyword(conf->keywords, rootkw->sub, "device");
 	if (!rootkw)
 		return 0;
 
@@ -1551,14 +1551,14 @@ snprint_blacklist (struct config *conf, char * buff, int len)
 		fwd += snprintf(buff + fwd, len - fwd, "\tdevice {\n");
 		if (fwd > len)
 			return len;
-		kw = find_keyword(rootkw->sub, "vendor");
+		kw = find_keyword(conf->keywords, rootkw->sub, "vendor");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
 				       kw, bled);
 		if (fwd > len)
 			return len;
-		kw = find_keyword(rootkw->sub, "product");
+		kw = find_keyword(conf->keywords, rootkw->sub, "product");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
@@ -1585,7 +1585,7 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 	struct keyword *rootkw;
 	struct keyword *kw;
 
-	rootkw = find_keyword(NULL, "blacklist_exceptions");
+	rootkw = find_keyword(conf->keywords, NULL, "blacklist_exceptions");
 	if (!rootkw)
 		return 0;
 
@@ -1594,7 +1594,7 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 		return len;
 
 	vector_foreach_slot (conf->elist_devnode, ele, i) {
-		kw = find_keyword(rootkw->sub, "devnode");
+		kw = find_keyword(conf->keywords, rootkw->sub, "devnode");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1603,7 +1603,7 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 			return len;
 	}
 	vector_foreach_slot (conf->elist_wwid, ele, i) {
-		kw = find_keyword(rootkw->sub, "wwid");
+		kw = find_keyword(conf->keywords, rootkw->sub, "wwid");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1612,7 +1612,7 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 			return len;
 	}
 	vector_foreach_slot (conf->elist_property, ele, i) {
-		kw = find_keyword(rootkw->sub, "property");
+		kw = find_keyword(conf->keywords, rootkw->sub, "property");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
@@ -1620,7 +1620,7 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 		if (fwd > len)
 			return len;
 	}
-	rootkw = find_keyword(rootkw->sub, "device");
+	rootkw = find_keyword(conf->keywords, rootkw->sub, "device");
 	if (!rootkw)
 		return 0;
 
@@ -1628,14 +1628,14 @@ snprint_blacklist_except (struct config *conf, char * buff, int len)
 		fwd += snprintf(buff + fwd, len - fwd, "\tdevice {\n");
 		if (fwd > len)
 			return len;
-		kw = find_keyword(rootkw->sub, "vendor");
+		kw = find_keyword(conf->keywords, rootkw->sub, "vendor");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
 				       kw, eled);
 		if (fwd > len)
 			return len;
-		kw = find_keyword(rootkw->sub, "product");
+		kw = find_keyword(conf->keywords, rootkw->sub, "product");
 		if (!kw)
 			return 0;
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
diff --git a/libmultipath/print.h b/libmultipath/print.h
index 023f520..b532f24 100644
--- a/libmultipath/print.h
+++ b/libmultipath/print.h
@@ -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 *);
diff --git a/multipath/main.c b/multipath/main.c
index 719d935..e7e35c0 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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)
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 84f430c..2a54cba 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid()
  2016-06-20  8:08 ` [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid() Hannes Reinecke
@ 2016-07-01 19:48   ` Benjamin Marzinski
  0 siblings, 0 replies; 32+ messages in thread
From: Benjamin Marzinski @ 2016-07-01 19:48 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Hannes Reinecke, Christophe Varoqui

On Mon, Jun 20, 2016 at 10:08:49AM +0200, Hannes Reinecke wrote:
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  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(-)
> 
> diff --git a/libmultipath/config.c b/libmultipath/config.c
> index 8b9e770..00f3e53 100644
> --- a/libmultipath/config.c
> +++ b/libmultipath/config.c
> @@ -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;
>  
> diff --git a/libmultipath/config.h b/libmultipath/config.h
> index 466e31e..2acee25 100644
> --- a/libmultipath/config.h
> +++ b/libmultipath/config.h
> @@ -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 hwtable, char * wwid);
> +char * get_mpe_wwid (vector hwtable, char * alias);

Why do we call this vector hwtable, instead of mptable, since we want to
pass in the mptable?

>  
>  struct hwentry * alloc_hwe (void);
>  struct mpentry * alloc_mpe (void);
> diff --git a/libmultipath/configure.c b/libmultipath/configure.c
> index 8e938c0..a830bcd 100644
> --- a/libmultipath/configure.c
> +++ b/libmultipath/configure.c
> @@ -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->hwtable, dev);

And why are we passing in the hwtable? Shouldn't be be using
conf->mptable?

>  		/*
>  		 * or directly a wwid
> diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
> index 4111fa5..f803cdc 100644
> --- a/libmultipath/propsel.c
> +++ b/libmultipath/propsel.c
> @@ -409,7 +409,7 @@ select_prio (struct path * pp)
>  			goto out;
>  		}
>  	}
> -	mpe = find_mpe(pp->wwid);
> +	mpe = find_mpe(conf->hwtable, pp->wwid);

And here as well.

>  	set_prio(mpe, "(LUN setting)");
>  	set_prio(conf->overrides, "(overrides setting)");
>  	set_prio(pp->hwe, "controller setting)");
> diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
> index 20a7457..b00832e 100644
> --- a/libmultipath/structs_vec.c
> +++ b/libmultipath/structs_vec.c
> @@ -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->hwtable, mpp->wwid);

dido

>  	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->hwtable, pp->wwid);

dido.

>  	mpp->hwe = pp->hwe;
>  
>  	strcpy(mpp->wwid, pp->wwid);

-Ben

> -- 
> 2.6.6

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo()
  2016-06-20  8:09 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke
@ 2016-07-01 20:25   ` Benjamin Marzinski
  2016-07-04  5:49     ` Hannes Reinecke
  0 siblings, 1 reply; 32+ messages in thread
From: Benjamin Marzinski @ 2016-07-01 20:25 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Hannes Reinecke, Christophe Varoqui

On Mon, Jun 20, 2016 at 10:09:04AM +0200, Hannes Reinecke wrote:
> pathinfo() requires access to the entire configuration, not just
> hwtable. So don't pretend this is the case.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  libmpathpersist/mpath_persist.c |  6 +++---
>  libmultipath/configure.c        |  8 ++++----
>  libmultipath/discovery.c        | 37 ++++++++++++++++++-------------------
>  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, 42 insertions(+), 43 deletions(-)
> 

<snip>

> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -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)
>  {
>  	struct checker * c = &pp->checker;
>  	int state;
> @@ -1405,8 +1405,8 @@ get_state (struct path * pp, vector hwtable, int daemon)
>  	condlog(3, "%s: get_state", pp->dev);
>  
>  	if (!checker_selected(c)) {
> -		if (daemon) {
> -			if (pathinfo(pp, hwtable, DI_SYSFS) != PATHINFO_OK) {
> +		if (!pp->hwe) {
> +			if (pathinfo(pp, conf, DI_SYSFS) != PATHINFO_OK) {
>  				condlog(3, "%s: couldn't get sysfs pathinfo",
>  					pp->dev);
>  				return PATH_UNCHECKED;
> @@ -1425,12 +1425,11 @@ get_state (struct path * pp, vector hwtable, int daemon)
>  		}
>  	}
>  	checker_clear_message(c);
> -	if (daemon) {
> -		if (conf->force_sync == 0)
> -			checker_set_async(c);
> -		else
> -			checker_set_sync(c);
> -	}
> +	if (conf->force_sync == 0)
> +		checker_set_async(c);
> +	else
> +		checker_set_sync(c);
> +
>  	if (!conf->checker_timeout &&
>  	    sysfs_get_timeout(pp, &(c->timeout)) <= 0)
>  		c->timeout = DEF_TIMEOUT;

I don't think that this change to get_state is correct. Previously,
we've always had the checker set to synchronous mode when run by the
multipath command.  With this change the checker will now run in async
mode by default.  It should be easy to just overwrite conf->force_sync
when running the multipath command to fix this.

-Ben

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/26] Userspace-RCU for config accesses
  2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
                   ` (25 preceding siblings ...)
  2016-06-20  8:09 ` [PATCH 26/26] libmultipath: Allocate keywords directly Hannes Reinecke
@ 2016-07-01 20:44 ` Benjamin Marzinski
  26 siblings, 0 replies; 32+ messages in thread
From: Benjamin Marzinski @ 2016-07-01 20:44 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Christophe Varoqui

On Mon, Jun 20, 2016 at 10:08:47AM +0200, Hannes Reinecke wrote:
> Hi all,

ACK on all patches besides 2 and 17 (which I've commented on).

-Ben

> 
> 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.
> 
> The patchset can be found at
> 
> github.com:/hreinecke/multipath-tools.git
> branch rcu
> 
> 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              | 121 +++++++------
>  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, 1063 insertions(+), 734 deletions(-)
> 
> -- 
> 2.6.6

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo()
  2016-07-01 20:25   ` Benjamin Marzinski
@ 2016-07-04  5:49     ` Hannes Reinecke
  0 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-07-04  5:49 UTC (permalink / raw)
  To: Benjamin Marzinski; +Cc: dm-devel, Hannes Reinecke, Christophe Varoqui

On 07/01/2016 10:25 PM, Benjamin Marzinski wrote:
> On Mon, Jun 20, 2016 at 10:09:04AM +0200, Hannes Reinecke wrote:
>> pathinfo() requires access to the entire configuration, not just
>> hwtable. So don't pretend this is the case.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.com>
>> ---
>>  libmpathpersist/mpath_persist.c |  6 +++---
>>  libmultipath/configure.c        |  8 ++++----
>>  libmultipath/discovery.c        | 37 ++++++++++++++++++-------------------
>>  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, 42 insertions(+), 43 deletions(-)
>>
> 
> <snip>
> 
>> --- a/libmultipath/discovery.c
>> +++ b/libmultipath/discovery.c
>> @@ -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)
>>  {
>>  	struct checker * c = &pp->checker;
>>  	int state;
>> @@ -1405,8 +1405,8 @@ get_state (struct path * pp, vector hwtable, int daemon)
>>  	condlog(3, "%s: get_state", pp->dev);
>>  
>>  	if (!checker_selected(c)) {
>> -		if (daemon) {
>> -			if (pathinfo(pp, hwtable, DI_SYSFS) != PATHINFO_OK) {
>> +		if (!pp->hwe) {
>> +			if (pathinfo(pp, conf, DI_SYSFS) != PATHINFO_OK) {
>>  				condlog(3, "%s: couldn't get sysfs pathinfo",
>>  					pp->dev);
>>  				return PATH_UNCHECKED;
>> @@ -1425,12 +1425,11 @@ get_state (struct path * pp, vector hwtable, int daemon)
>>  		}
>>  	}
>>  	checker_clear_message(c);
>> -	if (daemon) {
>> -		if (conf->force_sync == 0)
>> -			checker_set_async(c);
>> -		else
>> -			checker_set_sync(c);
>> -	}
>> +	if (conf->force_sync == 0)
>> +		checker_set_async(c);
>> +	else
>> +		checker_set_sync(c);
>> +
>>  	if (!conf->checker_timeout &&
>>  	    sysfs_get_timeout(pp, &(c->timeout)) <= 0)
>>  		c->timeout = DEF_TIMEOUT;
> 
> I don't think that this change to get_state is correct. Previously,
> we've always had the checker set to synchronous mode when run by the
> multipath command.  With this change the checker will now run in async
> mode by default.  It should be easy to just overwrite conf->force_sync
> when running the multipath command to fix this.
> 
Yes, indeed. You are correct.

I will fix this up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo()
  2016-07-04  7:08 [PATCHv2 " Hannes Reinecke
@ 2016-07-04  7:08 ` Hannes Reinecke
  0 siblings, 0 replies; 32+ messages in thread
From: Hannes Reinecke @ 2016-07-04  7:08 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

pathinfo() requires access to the entire configuration, not just
hwtable. So don't pretend this is the case.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 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(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index dc11d4f..d557da3 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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;
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 54fcde2..53d89b0 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -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);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index e598337..ffd26a6 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -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;
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 2619015..fca9637 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 8ddc292..dee6447 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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;
 		}
diff --git a/multipath/main.c b/multipath/main.c
index df6a7ca..ca4c1f5 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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;
 			}
 		}
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index c8c712a..90259ae 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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) {
diff --git a/multipathd/main.c b/multipathd/main.c
index fe80d1a..61ef2e6 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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;
 			}
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2016-07-04  7:08 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
2016-06-20  8:08 ` [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock' Hannes Reinecke
2016-06-20  8:08 ` [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid() Hannes Reinecke
2016-07-01 19:48   ` Benjamin Marzinski
2016-06-20  8:08 ` [PATCH 03/26] config: set 'deferred_remove' defaults at correct call Hannes Reinecke
2016-06-20  8:08 ` [PATCH 04/26] devmapper: explicit config settings Hannes Reinecke
2016-06-20  8:08 ` [PATCH 05/26] dmparser: use 'is_daemon' as argument for disassemble_map() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 06/26] libmultipath: use 'is_daemon' as argument for domap() etc Hannes Reinecke
2016-06-20  8:08 ` [PATCH 07/26] libmultipath: drop 'daemon' configuration setting Hannes Reinecke
2016-06-20  8:08 ` [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 10/26] libmultipath: fallback to checking environment variable in get_udev_uid() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 11/26] multipath: make 'cmd' internal to multipath program Hannes Reinecke
2016-06-20  8:08 ` [PATCH 12/26] multipath: make 'dev_type' internal to the " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 13/26] multipath: make 'dev' " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 14/26] libmultipath: separate out 'udev' config entry Hannes Reinecke
2016-06-20  8:09 ` [PATCH 15/26] libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 16/26] discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke
2016-07-01 20:25   ` Benjamin Marzinski
2016-07-04  5:49     ` Hannes Reinecke
2016-06-20  8:09 ` [PATCH 18/26] checkers: use 'multipath_dir' as argument Hannes Reinecke
2016-06-20  8:09 ` [PATCH 19/26] prio: " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 20/26] libmultipath: use 'timeout' as argument for getprio() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 21/26] libmultipath: use explicit 'config' argument for configuration file parsing Hannes Reinecke
2016-06-20  8:09 ` [PATCH 22/26] libmultipath: use (get, put)_multipath_config() accessors Hannes Reinecke
2016-06-20  8:09 ` [PATCH 23/26] multipathd: Fixup commandline argument handling Hannes Reinecke
2016-06-20  8:09 ` [PATCH 24/26] multipath: make 'struct config' a local variable Hannes Reinecke
2016-06-20  8:09 ` [PATCH 25/26] multipathd: use userspace RCU to access configuration Hannes Reinecke
2016-06-20  8:09 ` [PATCH 26/26] libmultipath: Allocate keywords directly Hannes Reinecke
2016-07-01 20:44 ` [PATCH 00/26] Userspace-RCU for config accesses Benjamin Marzinski
2016-07-04  7:08 [PATCHv2 " Hannes Reinecke
2016-07-04  7:08 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.