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 04/26] devmapper: explicit config settings
Date: Mon, 20 Jun 2016 10:08:51 +0200 [thread overview]
Message-ID: <1466410153-23896-5-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de>
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
next prev parent reply other threads:[~2016-06-20 8:08 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 ` Hannes Reinecke [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2016-07-04 7:08 [PATCHv2 " Hannes Reinecke
2016-07-04 7:08 ` [PATCH 04/26] devmapper: explicit config settings 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-5-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).