forked from pool/multipath-tools
492 lines
13 KiB
Plaintext
492 lines
13 KiB
Plaintext
From 09345f745f894b261bccef694bcd36d79095d2b6 Mon Sep 17 00:00:00 2001
|
|
From: Hannes Reinecke <hare@suse.de>
|
|
Date: Tue, 29 Apr 2008 16:17:56 +0200
|
|
Subject: [PATCH] Remove DEAMON defines
|
|
|
|
We're now building just one multipath.so library, so any
|
|
DAEMON defines are pointless. And we should be setting
|
|
the correct dlopen path during compilation.
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
---
|
|
libmultipath/Makefile | 13 ++++++-------
|
|
libmultipath/checkers.c | 3 ++-
|
|
libmultipath/configure.c | 26 +++++++++++++-------------
|
|
libmultipath/debug.c | 8 +-------
|
|
libmultipath/debug.h | 10 +---------
|
|
libmultipath/devmapper.c | 12 ++----------
|
|
libmultipath/discovery.c | 11 +----------
|
|
libmultipath/dmparser.c | 4 +---
|
|
libmultipath/prio.c | 17 +++++++++--------
|
|
libmultipath/structs.c | 4 +---
|
|
libmultipath/structs_vec.c | 11 +++++------
|
|
libmultipath/structs_vec.h | 2 --
|
|
libmultipath/uxsock.c | 10 ++++------
|
|
libmultipath/waiter.h | 3 ---
|
|
multipath/Makefile | 2 +-
|
|
multipath/main.c | 2 ++
|
|
multipathd/Makefile | 2 +-
|
|
multipathd/main.c | 2 ++
|
|
18 files changed, 52 insertions(+), 90 deletions(-)
|
|
|
|
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
|
|
index 16bd978..55721e8 100644
|
|
--- a/libmultipath/Makefile
|
|
+++ b/libmultipath/Makefile
|
|
@@ -11,23 +11,22 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \
|
|
structs.o discovery.o propsel.o dict.o \
|
|
pgpolicies.o debug.o regex.o defaults.o uevent.o \
|
|
switchgroup.o uxsock.o print.o alias.o log_pthread.o \
|
|
- log.o configure.o structs_vec.o sysfs.o prio.o checkers.o
|
|
+ log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
|
|
+ lock.o waiter.o
|
|
|
|
-#ifeq ($(strip $(DAEMON)),1)
|
|
- OBJS += lock.o waiter.o
|
|
- CFLAGS += -DDAEMON
|
|
-#endif
|
|
|
|
-LIBDM_API_FLUSH = $(shell objdump -T /lib/libdevmapper.so.* | grep -c dm_task_no_flush)
|
|
+LIBDM_API_FLUSH = $(shell if test -d /lib64 ; then objdump -T /lib64/libdevmapper.so* ; else objdump -T /lib/libdevmapper.so.* ; fi | grep -c dm_task_no_flush)
|
|
|
|
ifeq ($(strip $(LIBDM_API_FLUSH)),1)
|
|
CFLAGS += -DLIBDM_API_FLUSH
|
|
endif
|
|
|
|
+CFLAGS += -DLIBMULTIPATH=\"$(libdir)\"
|
|
+
|
|
all: $(LIBS)
|
|
|
|
$(LIBS): $(OBJS)
|
|
- $(CC) $(SHARED_FLAGS) $(CFLAGS) -o $@ $(OBJS)
|
|
+ $(CC) $(SHARED_FLAGS) $(CFLAGS) -o $@ $(OBJS)
|
|
|
|
install:
|
|
$(INSTALL_PROGRAM) -o root -g root -m 755 -d $(libdir)
|
|
diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
|
|
index ff606d0..ce9dd86 100644
|
|
--- a/libmultipath/checkers.c
|
|
+++ b/libmultipath/checkers.c
|
|
@@ -61,7 +61,8 @@ struct checker * add_checker (char * name)
|
|
c = alloc_checker();
|
|
if (!c)
|
|
return NULL;
|
|
- snprintf(libname, LIB_CHECKER_NAMELEN, "libcheck%s.so", name);
|
|
+ snprintf(libname, LIB_CHECKER_NAMELEN, "%s/libcheck%s.so",
|
|
+ LIBMULTIPATH, name);
|
|
condlog(3, "loading %s checker", libname);
|
|
handle = dlopen(libname, RTLD_NOW);
|
|
errstr = dlerror();
|
|
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
|
|
index df31cdd..8fdc9f2 100644
|
|
--- a/libmultipath/configure.c
|
|
+++ b/libmultipath/configure.c
|
|
@@ -367,19 +367,19 @@ domap (struct multipath * mpp)
|
|
* DM_DEVICE_CREATE, DM_DEVICE_RENAME, or DM_DEVICE_RELOAD
|
|
* succeeded
|
|
*/
|
|
-#ifndef DAEMON
|
|
- dm_switchgroup(mpp->alias, mpp->bestpg);
|
|
- if (mpp->action != ACT_NOTHING)
|
|
- print_multipath_topology(mpp, conf->verbosity);
|
|
-#else
|
|
- mpp->stat_map_loads++;
|
|
- condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
|
|
- mpp->size, DEFAULT_TARGET, mpp->params);
|
|
- /*
|
|
- * Required action is over, reset for the stateful daemon
|
|
- */
|
|
- mpp->action = ACT_NOTHING;
|
|
-#endif
|
|
+ if (!mpp->waiter) {
|
|
+ dm_switchgroup(mpp->alias, mpp->bestpg);
|
|
+ if (mpp->action != ACT_NOTHING)
|
|
+ print_multipath_topology(mpp, conf->verbosity);
|
|
+ } else {
|
|
+ mpp->stat_map_loads++;
|
|
+ condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
|
|
+ mpp->size, DEFAULT_TARGET, mpp->params);
|
|
+ /*
|
|
+ * Required action is over, reset for the stateful daemon
|
|
+ */
|
|
+ mpp->action = ACT_NOTHING;
|
|
+ }
|
|
return DOMAP_OK;
|
|
}
|
|
return DOMAP_FAIL;
|
|
diff --git a/libmultipath/debug.c b/libmultipath/debug.c
|
|
index 05dfb06..d30517d 100644
|
|
--- a/libmultipath/debug.c
|
|
+++ b/libmultipath/debug.c
|
|
@@ -5,11 +5,9 @@
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
|
|
-#if DAEMON
|
|
#include "log_pthread.h"
|
|
#include <sys/types.h>
|
|
#include <time.h>
|
|
-#endif
|
|
|
|
#include "vector.h"
|
|
#include "config.h"
|
|
@@ -23,12 +21,11 @@ void dlog (int sink, int prio, const char * fmt, ...)
|
|
thres = (conf) ? conf->verbosity : 0;
|
|
|
|
if (prio <= thres) {
|
|
-#if DAEMON
|
|
if (!sink) {
|
|
time_t t = time(NULL);
|
|
struct tm *tb = localtime(&t);
|
|
char buff[16];
|
|
-
|
|
+
|
|
strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb);
|
|
buff[sizeof(buff)-1] = '\0';
|
|
|
|
@@ -37,9 +34,6 @@ void dlog (int sink, int prio, const char * fmt, ...)
|
|
}
|
|
else
|
|
log_safe(prio + 3, fmt, ap);
|
|
-#else
|
|
- vfprintf(stdout, fmt, ap);
|
|
-#endif
|
|
}
|
|
va_end(ap);
|
|
}
|
|
diff --git a/libmultipath/debug.h b/libmultipath/debug.h
|
|
index 082fff1..c6120c1 100644
|
|
--- a/libmultipath/debug.h
|
|
+++ b/libmultipath/debug.h
|
|
@@ -1,21 +1,13 @@
|
|
void dlog (int sink, int prio, const char * fmt, ...)
|
|
__attribute__((format(printf, 3, 4)));
|
|
|
|
-#if DAEMON
|
|
|
|
#include <pthread.h>
|
|
#include <stdarg.h>
|
|
|
|
#include "log_pthread.h"
|
|
|
|
-int logsink;
|
|
+extern int logsink;
|
|
|
|
#define condlog(prio, fmt, args...) \
|
|
dlog(logsink, prio, fmt "\n", ##args)
|
|
-
|
|
-#else /* DAEMON */
|
|
-
|
|
-#define condlog(prio, fmt, args...) \
|
|
- dlog(0, prio, fmt "\n", ##args)
|
|
-
|
|
-#endif /* DAEMON */
|
|
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
|
|
index f21d3ab..cc01486 100644
|
|
--- a/libmultipath/devmapper.c
|
|
+++ b/libmultipath/devmapper.c
|
|
@@ -22,11 +22,9 @@
|
|
#include "devmapper.h"
|
|
#include "config.h"
|
|
|
|
-#if DAEMON
|
|
#include "log_pthread.h"
|
|
#include <sys/types.h>
|
|
#include <time.h>
|
|
-#endif
|
|
|
|
#define MAX_WAIT 5
|
|
#define LOOPS_PER_SEC 5
|
|
@@ -47,8 +45,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...)
|
|
if (thres <= 3 || level > thres)
|
|
return;
|
|
|
|
- va_start(ap, f);
|
|
-#if DAEMON
|
|
+ va_start(ap, f);
|
|
if (!logsink) {
|
|
time_t t = time(NULL);
|
|
struct tm *tb = localtime(&t);
|
|
@@ -65,12 +62,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...)
|
|
condlog(level, "libdevmapper: %s(%i): ", file, line);
|
|
log_safe(level + 3, f, ap);
|
|
}
|
|
-#else
|
|
- fprintf(stdout, "libdevmapper: %s(%i): ", file, line);
|
|
- vfprintf(stdout, f, ap);
|
|
- fprintf(stdout, "\n");
|
|
-#endif
|
|
- va_end(ap);
|
|
+ va_end(ap);
|
|
|
|
return;
|
|
}
|
|
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
|
index 8cfb53f..7baa9e7 100644
|
|
--- a/libmultipath/discovery.c
|
|
+++ b/libmultipath/discovery.c
|
|
@@ -716,10 +716,6 @@ pathinfo (struct path *pp, vector hwtable, int mask)
|
|
if (mask & DI_WWID && !strlen(pp->wwid))
|
|
get_uid(pp);
|
|
|
|
-#ifndef DAEMON
|
|
- close(pp->fd);
|
|
- pp->fd = -1;
|
|
-#endif
|
|
return 0;
|
|
|
|
blank:
|
|
@@ -728,11 +724,6 @@ blank:
|
|
*/
|
|
memset(pp->wwid, 0, WWID_SIZE);
|
|
pp->state = PATH_DOWN;
|
|
-#ifndef DAEMON
|
|
- if (pp->fd > 0){
|
|
- close(pp->fd);
|
|
- pp->fd = -1;
|
|
- }
|
|
-#endif
|
|
+
|
|
return 0;
|
|
}
|
|
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
|
|
index fe7d986..1ef22fb 100644
|
|
--- a/libmultipath/dmparser.c
|
|
+++ b/libmultipath/dmparser.c
|
|
@@ -277,10 +277,8 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
|
|
|
|
strncpy(pp->dev_t, word, BLK_DEV_SIZE);
|
|
|
|
-#ifndef DAEMON
|
|
- if (store_path(pathvec, pp))
|
|
+ if (mpp->waiter && store_path(pathvec, pp))
|
|
goto out;
|
|
-#endif
|
|
}
|
|
FREE(word);
|
|
|
|
diff --git a/libmultipath/prio.c b/libmultipath/prio.c
|
|
index 617fc19..4d6d840 100644
|
|
--- a/libmultipath/prio.c
|
|
+++ b/libmultipath/prio.c
|
|
@@ -28,18 +28,18 @@ void free_prio (struct prio * p)
|
|
|
|
void cleanup_prio(void)
|
|
{
|
|
- struct prio * prio_loop;
|
|
- struct prio * prio_temp;
|
|
+ struct prio * prio_loop;
|
|
+ struct prio * prio_temp;
|
|
|
|
- list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
|
|
- list_del(&prio_loop->node);
|
|
- free(prio_loop);
|
|
- }
|
|
+ list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
|
|
+ list_del(&prio_loop->node);
|
|
+ free(prio_loop);
|
|
+ }
|
|
}
|
|
|
|
struct prio * prio_lookup (char * name)
|
|
{
|
|
- struct prio * p;
|
|
+ struct prio * p;
|
|
|
|
list_for_each_entry(p, &prioritizers, node) {
|
|
if (!strncmp(name, p->name, PRIO_NAME_LEN))
|
|
@@ -61,7 +61,8 @@ struct prio * add_prio (char * name)
|
|
p = alloc_prio();
|
|
if (!p)
|
|
return NULL;
|
|
- snprintf(libname, LIB_PRIO_NAMELEN, "libprio%s.so", name);
|
|
+ snprintf(libname, LIB_PRIO_NAMELEN, "%s/libprio%s.so",
|
|
+ LIBMULTIPATH, name);
|
|
condlog(3, "loading %s prioritizer", libname);
|
|
handle = dlopen(libname, RTLD_NOW);
|
|
errstr = dlerror();
|
|
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
|
|
index 11f3061..082d53f 100644
|
|
--- a/libmultipath/structs.c
|
|
+++ b/libmultipath/structs.c
|
|
@@ -170,14 +170,12 @@ free_multipath (struct multipath * mpp, int free_paths)
|
|
|
|
if (mpp->dmi)
|
|
FREE(mpp->dmi);
|
|
-
|
|
-#if DAEMON
|
|
+
|
|
/*
|
|
* better own vecs->lock here
|
|
*/
|
|
if (mpp->waiter)
|
|
((struct event_thread *)mpp->waiter)->mpp = NULL;
|
|
-#endif
|
|
|
|
free_pathvec(mpp->paths, free_paths);
|
|
free_pgvec(mpp->pg, free_paths);
|
|
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
|
|
index f4d69bb..6757eb9 100644
|
|
--- a/libmultipath/structs_vec.c
|
|
+++ b/libmultipath/structs_vec.c
|
|
@@ -62,7 +62,7 @@ adopt_paths (vector pathvec, struct multipath * mpp)
|
|
condlog(3, "%s: ownership set to %s",
|
|
pp->dev, mpp->alias);
|
|
pp->mpp = mpp;
|
|
-
|
|
+
|
|
if (!mpp->paths && !(mpp->paths = vector_alloc()))
|
|
return 1;
|
|
|
|
@@ -294,18 +294,17 @@ retry:
|
|
char new_alias[WWID_SIZE];
|
|
|
|
/*
|
|
- * detect an external rename of the multipath device
|
|
+ * detect an external rename of the multipath device
|
|
*/
|
|
if (dm_get_name(mpp->wwid, DEFAULT_TARGET, new_alias)) {
|
|
condlog(3, "%s multipath mapped device name has "
|
|
"changed from %s to %s", mpp->wwid,
|
|
mpp->alias, new_alias);
|
|
strcpy(mpp->alias, new_alias);
|
|
-#if DAEMON
|
|
- if (mpp->waiter)
|
|
+
|
|
+ if (mpp->waiter)
|
|
strncpy(((struct event_thread *)mpp->waiter)->mapname,
|
|
new_alias, WWID_SIZE);
|
|
-#endif
|
|
goto retry;
|
|
}
|
|
condlog(0, "%s: failed to setup multipath", mpp->alias);
|
|
@@ -341,7 +340,7 @@ add_map_without_path (struct vectors * vecs,
|
|
|
|
if (adopt_paths(vecs->pathvec, mpp))
|
|
goto out;
|
|
-
|
|
+
|
|
if (!vector_alloc_slot(vecs->mpvec))
|
|
goto out;
|
|
|
|
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
|
|
index b8a416f..19a2387 100644
|
|
--- a/libmultipath/structs_vec.h
|
|
+++ b/libmultipath/structs_vec.h
|
|
@@ -2,9 +2,7 @@
|
|
#define _STRUCTS_VEC_H
|
|
|
|
struct vectors {
|
|
-#if DAEMON
|
|
pthread_mutex_t *lock;
|
|
-#endif
|
|
vector pathvec;
|
|
vector mpvec;
|
|
};
|
|
diff --git a/libmultipath/uxsock.c b/libmultipath/uxsock.c
|
|
index cdc3dbc..a070943 100644
|
|
--- a/libmultipath/uxsock.c
|
|
+++ b/libmultipath/uxsock.c
|
|
@@ -129,23 +129,21 @@ size_t read_all(int fd, void *buf, size_t len)
|
|
int send_packet(int fd, const char *buf, size_t len)
|
|
{
|
|
int ret = 0;
|
|
-#ifdef DAEMON
|
|
sigset_t set, old;
|
|
|
|
/* Block SIGPIPE */
|
|
sigemptyset(&set);
|
|
sigaddset(&set, SIGPIPE);
|
|
pthread_sigmask(SIG_BLOCK, &set, &old);
|
|
-#endif
|
|
- if (write_all(fd, &len, sizeof(len)) != sizeof(len))
|
|
+
|
|
+ if (write_all(fd, &len, sizeof(len)) != sizeof(len))
|
|
ret = -1;
|
|
if (!ret && write_all(fd, buf, len) != len)
|
|
- ret = -1;
|
|
+ ret = -1;
|
|
|
|
-#ifdef DAEMON
|
|
/* And unblock it again */
|
|
pthread_sigmask(SIG_SETMASK, &old, NULL);
|
|
-#endif
|
|
+
|
|
return ret;
|
|
}
|
|
|
|
diff --git a/libmultipath/waiter.h b/libmultipath/waiter.h
|
|
index 0223924..468ce5f 100644
|
|
--- a/libmultipath/waiter.h
|
|
+++ b/libmultipath/waiter.h
|
|
@@ -1,8 +1,6 @@
|
|
#ifndef _WAITER_H
|
|
#define _WAITER_H
|
|
|
|
-#if DAEMON
|
|
-
|
|
struct event_thread {
|
|
struct dm_task *dmt;
|
|
pthread_t thread;
|
|
@@ -19,5 +17,4 @@ int start_waiter_thread (struct multipath *mpp, struct vectors *vecs);
|
|
int waiteventloop (struct event_thread *waiter);
|
|
void *waitevent (void *et);
|
|
|
|
-#endif /* DAEMON */
|
|
#endif /* _WAITER_H */
|
|
diff --git a/multipath/Makefile b/multipath/Makefile
|
|
index 71df431..bb44e3e 100644
|
|
--- a/multipath/Makefile
|
|
+++ b/multipath/Makefile
|
|
@@ -7,7 +7,7 @@ include ../Makefile.inc
|
|
OBJS = main.o
|
|
|
|
CFLAGS += -I$(multipathdir) -Wl,-rpath,$(libdir)
|
|
-LDFLAGS += -laio -ldevmapper -lpthread \
|
|
+LDFLAGS += -laio -ldevmapper -lpthread -ldl \
|
|
-lmultipath -L$(multipathdir)
|
|
|
|
EXEC = multipath
|
|
diff --git a/multipath/main.c b/multipath/main.c
|
|
index b6ea6fd..c071cac 100644
|
|
--- a/multipath/main.c
|
|
+++ b/multipath/main.c
|
|
@@ -49,6 +49,8 @@
|
|
#include <pgpolicies.h>
|
|
#include <version.h>
|
|
|
|
+int logsink;
|
|
+
|
|
static int
|
|
filter_pathvec (vector pathvec, char * refwwid)
|
|
{
|
|
diff --git a/multipathd/Makefile b/multipathd/Makefile
|
|
index 6beb993..dd223c4 100644
|
|
--- a/multipathd/Makefile
|
|
+++ b/multipathd/Makefile
|
|
@@ -5,7 +5,7 @@ include ../Makefile.inc
|
|
#
|
|
# basic flags setting
|
|
#
|
|
-CFLAGS += -DDAEMON -I$(multipathdir) -Wl,-rpath,$(libdir)
|
|
+CFLAGS += -I$(multipathdir) -Wl,-rpath,$(libdir)
|
|
LDFLAGS += -lpthread -ldevmapper -lreadline -lncurses -laio \
|
|
-lmultipath -L$(multipathdir)
|
|
|
|
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
index 385521c..2b1fd86 100644
|
|
--- a/multipathd/main.c
|
|
+++ b/multipathd/main.c
|
|
@@ -65,6 +65,8 @@
|
|
pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER;
|
|
pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
+int logsink;
|
|
+
|
|
/*
|
|
* global copy of vecs for use in sig handlers
|
|
*/
|
|
--
|
|
1.5.2.4
|
|
|