dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@gmail.com>
Cc: Hannes Reinecke <hare@suse.com>, dm-devel@redhat.com
Subject: [PATCH 18/26] checkers: use 'multipath_dir' as argument
Date: Mon,  4 Jul 2016 09:08:38 +0200	[thread overview]
Message-ID: <1467616126-10036-19-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1467616126-10036-1-git-send-email-hare@suse.de>

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 71a0941..c1d9192 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 61ef2e6..5a12007 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

  parent reply	other threads:[~2016-07-04  7:08 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467616126-10036-19-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).