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 13/26] multipath: make 'dev' internal to the multipath program
Date: Mon, 20 Jun 2016 10:09:00 +0200 [thread overview]
Message-ID: <1466410153-23896-14-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de>
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
next prev parent reply other threads:[~2016-06-20 8:09 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Hannes Reinecke [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2016-07-04 7:08 [PATCHv2 " Hannes Reinecke
2016-07-04 7:08 ` [PATCH 13/26] multipath: make 'dev' internal to the multipath program 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=1466410153-23896-14-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).