All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/15] Fifteen multipath-tools patches
@ 2016-10-21 18:40 Bart Van Assche
  2016-10-21 18:41 ` [PATCH 01/15] libmultipath: Make building against musl-libc again possible Bart Van Assche
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:40 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Hello Christophe,

It would be appreciated if you would consider this patch series for 
inclusion in the multipath-tools repository. The changes in this patch 
series are:
- A build fix for musl-libc.
- A fix for a deadlock during shutdown.
- A bunch of patches that address warnings reported by the sparse
   static analyzer.

Thanks,

Bart.

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

* [PATCH 01/15] libmultipath: Make building against musl-libc again possible
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
@ 2016-10-21 18:41 ` Bart Van Assche
  2016-10-21 18:41 ` [PATCH 02/15] libmultipath: Avoid that thread cancellation causes a hang Bart Van Assche
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:41 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Xose Vazquez Perez

musl-libc does not support PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP.

This patch reverts commit 7884bde302ad ("multipathd: Avoid that a
deadlock is triggered sporadically during shutdown").

Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/uevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 85fd2fb..6247898 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -52,7 +52,7 @@ typedef int (uev_trigger)(struct uevent *, void * trigger_data);
 
 pthread_t uevq_thr;
 LIST_HEAD(uevq);
-pthread_mutex_t uevq_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+pthread_mutex_t uevq_lock = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t *uevq_lockp = &uevq_lock;
 pthread_cond_t uev_cond = PTHREAD_COND_INITIALIZER;
 pthread_cond_t *uev_condp = &uev_cond;
-- 
2.10.1

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

* [PATCH 02/15] libmultipath: Avoid that thread cancellation causes a hang
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
  2016-10-21 18:41 ` [PATCH 01/15] libmultipath: Make building against musl-libc again possible Bart Van Assche
@ 2016-10-21 18:41 ` Bart Van Assche
  2016-10-21 18:42 ` [PATCH 03/15] libmultipath: Remove an incorrect comment Bart Van Assche
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:41 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Apparently uevq_stop() hangs every now and then in pthread_mutex_lock()
if the udev listener thread is canceled. Avoid this hang by removing
code from uevq_stop(). This is safe because uevq_stop() is only called
just before uevent_listen() returns and in that case neither clearing
my_uev_trigger nor signaling uev_condp is needed. Additionally, rename
uevq_stop() into uevent_cleanup() to make clear that its purpose is to
clean up resources and not to stop the uevent listener.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/uevent.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 6247898..0f32dbc 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -124,15 +124,11 @@ service_uevq(struct list_head *tmpq)
 	}
 }
 
-static void uevq_stop(void *arg)
+static void uevent_cleanup(void *arg)
 {
 	struct udev *udev = arg;
 
-	condlog(3, "Stopping uev queue");
-	pthread_mutex_lock(uevq_lockp);
-	my_uev_trigger = NULL;
-	pthread_cond_signal(uev_condp);
-	pthread_mutex_unlock(uevq_lockp);
+	condlog(3, "Releasing uevent_listen() resources");
 	udev_unref(udev);
 }
 
@@ -495,7 +491,7 @@ int uevent_listen(struct udev *udev)
 		return 1;
 	}
 	udev_ref(udev);
-	pthread_cleanup_push(uevq_stop, udev);
+	pthread_cleanup_push(uevent_cleanup, udev);
 
 	monitor = udev_monitor_new_from_netlink(udev, "udev");
 	if (!monitor) {
-- 
2.10.1

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

* [PATCH 03/15] libmultipath: Remove an incorrect comment
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
  2016-10-21 18:41 ` [PATCH 01/15] libmultipath: Make building against musl-libc again possible Bart Van Assche
  2016-10-21 18:41 ` [PATCH 02/15] libmultipath: Avoid that thread cancellation causes a hang Bart Van Assche
@ 2016-10-21 18:42 ` Bart Van Assche
  2016-10-21 18:42 ` [PATCH 04/15] libmultipath: Move setup_thread_attr() from uevent.c into util.c Bart Van Assche
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:42 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

It is easy to see that uevq_lockp is not held while service_uevq()
is called. Since no other code accesses the list that is processed
by this function calling service_uevq() without holding uevq_lockp
is safe. Hence remove the comment about locking above service_uevq().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/uevent.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 0f32dbc..f844294 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -104,9 +104,6 @@ setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
 	}
 }
 
-/*
- * Called with uevq_lockp held
- */
 void
 service_uevq(struct list_head *tmpq)
 {
-- 
2.10.1

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

* [PATCH 04/15] libmultipath: Move setup_thread_attr() from uevent.c into util.c
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (2 preceding siblings ...)
  2016-10-21 18:42 ` [PATCH 03/15] libmultipath: Remove an incorrect comment Bart Van Assche
@ 2016-10-21 18:42 ` Bart Van Assche
  2016-10-21 18:43 ` [PATCH 05/15] libmultipath: Fix POLLIN checks Bart Van Assche
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:42 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

The setup_thread_attr() is not called by any code in source file
uevent.c. Hence move that function to source file util.c.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/checkers/rbd.c |  2 +-
 libmultipath/checkers/tur.c |  2 +-
 libmultipath/uevent.c       | 25 -------------------------
 libmultipath/uevent.h       |  1 -
 libmultipath/util.c         | 25 +++++++++++++++++++++++--
 libmultipath/util.h         |  1 +
 6 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
index c920cbb..f60914e 100644
--- a/libmultipath/checkers/rbd.c
+++ b/libmultipath/checkers/rbd.c
@@ -26,7 +26,7 @@
 #include "checkers.h"
 
 #include "../libmultipath/debug.h"
-#include "../libmultipath/uevent.h"
+#include "../libmultipath/util.h"
 #include "../libmultipath/time-util.h"
 
 struct rbd_checker_context;
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
index 81206e4..92200aa 100644
--- a/libmultipath/checkers/tur.c
+++ b/libmultipath/checkers/tur.c
@@ -19,7 +19,7 @@
 
 #include "../libmultipath/debug.h"
 #include "../libmultipath/sg_include.h"
-#include "../libmultipath/uevent.h"
+#include "../libmultipath/util.h"
 #include "../libmultipath/time-util.h"
 #include "../libmultipath/util.h"
 
diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index f844294..7bc5837 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -37,7 +37,6 @@
 #include <linux/types.h>
 #include <linux/netlink.h>
 #include <pthread.h>
-#include <limits.h>
 #include <sys/mman.h>
 #include <libudev.h>
 #include <errno.h>
@@ -81,30 +80,6 @@ struct uevent * alloc_uevent (void)
 }
 
 void
-setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
-{
-	if (pthread_attr_init(attr)) {
-		fprintf(stderr, "can't initialize thread attr: %s\n",
-			strerror(errno));
-		exit(1);
-	}
-	if (stacksize < PTHREAD_STACK_MIN)
-		stacksize = PTHREAD_STACK_MIN;
-
-	if (pthread_attr_setstacksize(attr, stacksize)) {
-		fprintf(stderr, "can't set thread stack size to %lu: %s\n",
-			(unsigned long)stacksize, strerror(errno));
-		exit(1);
-	}
-	if (detached && pthread_attr_setdetachstate(attr,
-						    PTHREAD_CREATE_DETACHED)) {
-		fprintf(stderr, "can't set thread to detached: %s\n",
-			strerror(errno));
-		exit(1);
-	}
-}
-
-void
 service_uevq(struct list_head *tmpq)
 {
 	struct uevent *uev, *tmp;
diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h
index e5fdfcc..9d22dcd 100644
--- a/libmultipath/uevent.h
+++ b/libmultipath/uevent.h
@@ -27,7 +27,6 @@ struct uevent {
 };
 
 int is_uevent_busy(void);
-void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
 
 int uevent_listen(struct udev *udev);
 int uevent_dispatch(int (*store_uev)(struct uevent *, void * trigger_data),
diff --git a/libmultipath/util.c b/libmultipath/util.c
index ac0d1b2..0a136b4 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -1,7 +1,10 @@
-#include <string.h>
+#include <assert.h>
 #include <ctype.h>
-#include <sys/types.h>
+#include <limits.h>
+#include <pthread.h>
+#include <string.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include "debug.h"
@@ -258,3 +261,21 @@ dev_t parse_devt(const char *dev_t)
 
 	return makedev(maj, min);
 }
+
+void
+setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
+{
+	int ret;
+
+	ret = pthread_attr_init(attr);
+	assert(ret == 0);
+	if (stacksize < PTHREAD_STACK_MIN)
+		stacksize = PTHREAD_STACK_MIN;
+	ret = pthread_attr_setstacksize(attr, stacksize);
+	assert(ret == 0);
+	if (detached) {
+		ret = pthread_attr_setdetachstate(attr,
+						  PTHREAD_CREATE_DETACHED);
+		assert(ret == 0);
+	}
+}
diff --git a/libmultipath/util.h b/libmultipath/util.h
index 8861085..f3b37ee 100644
--- a/libmultipath/util.h
+++ b/libmultipath/util.h
@@ -12,6 +12,7 @@ size_t strlcat(char *dst, const char *src, size_t size);
 int devt2devname (char *, int, char *);
 dev_t parse_devt(const char *dev_t);
 char *convert_dev(char *dev, int is_path_device);
+void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
 
 #define safe_sprintf(var, format, args...)	\
 	snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
-- 
2.10.1

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

* [PATCH 05/15] libmultipath: Fix POLLIN checks
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (3 preceding siblings ...)
  2016-10-21 18:42 ` [PATCH 04/15] libmultipath: Move setup_thread_attr() from uevent.c into util.c Bart Van Assche
@ 2016-10-21 18:43 ` Bart Van Assche
  2016-10-21 18:43 ` [PATCH 06/15] libmultipath: Remove an unused function Bart Van Assche
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:43 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Instead of testing (pfd.revents == 0) & 1, test whether
(pfd.revents & 1) == 0.

This has been detected by the sparse static analyzer.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmpathcmd/mpath_cmd.c | 2 +-
 libmultipath/uxsock.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
index 667a2dc..d9c5790 100644
--- a/libmpathcmd/mpath_cmd.c
+++ b/libmpathcmd/mpath_cmd.c
@@ -31,7 +31,7 @@ static ssize_t read_all(int fd, void *buf, size_t len, unsigned int timeout)
 			if (errno == EINTR)
 				continue;
 			return -1;
-		} else if (!pfd.revents & POLLIN)
+		} else if (!(pfd.revents & POLLIN))
 			continue;
 		n = recv(fd, buf, len, 0);
 		if (n < 0) {
diff --git a/libmultipath/uxsock.c b/libmultipath/uxsock.c
index 880257f..b158a56 100644
--- a/libmultipath/uxsock.c
+++ b/libmultipath/uxsock.c
@@ -116,7 +116,7 @@ ssize_t read_all(int fd, void *buf, size_t len, unsigned int timeout)
 			if (errno == EINTR)
 				continue;
 			return -errno;
-		} else if (!pfd.revents & POLLIN)
+		} else if (!(pfd.revents & POLLIN))
 			continue;
 		n = read(fd, buf, len);
 		if (n < 0) {
-- 
2.10.1

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

* [PATCH 06/15] libmultipath: Remove an unused function
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (4 preceding siblings ...)
  2016-10-21 18:43 ` [PATCH 05/15] libmultipath: Fix POLLIN checks Bart Van Assche
@ 2016-10-21 18:43 ` Bart Van Assche
  2016-10-24 10:50   ` Germano Percossi
  2016-10-21 18:43 ` [PATCH 07/15] libmpathpersist: " Bart Van Assche
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:43 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

The function snprint_config() is not used. Hence remove it.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/print.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 9aa41ad..09e4a2e 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -1745,12 +1745,6 @@ snprint_devices (struct config *conf, char * buff, int len, struct vectors *vecs
 	return fwd;
 }
 
-extern int
-snprint_config (char * buff, int len)
-{
-	return 0;
-}
-
 /*
  * stdout printing helpers
  */
-- 
2.10.1

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

* [PATCH 07/15] libmpathpersist: Remove an unused function
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (5 preceding siblings ...)
  2016-10-21 18:43 ` [PATCH 06/15] libmultipath: Remove an unused function Bart Van Assche
@ 2016-10-21 18:43 ` Bart Van Assche
  2016-10-21 18:44 ` [PATCH 08/15] libmultipath: Remove an unused variable Bart Van Assche
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:43 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmpathpersist/mpath_persist.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 7501651..edd4246 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -414,17 +414,6 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)
 	return MPATH_PR_SUCCESS ;
 }
 
-void * mpath_prin_pthread_fn (void *p)
-{
-	int ret;
-	struct prin_param * pparam = (struct prin_param *)p;
-
-	ret = prin_do_scsi_ioctl(pparam->dev, pparam->rq_servact,
-				 pparam->resp,  pparam->noisy);
-	pparam->status = ret;
-	pthread_exit(NULL);
-}
-
 int mpath_send_prin_activepath (char * dev, int rq_servact,
 				struct prin_resp * resp, int noisy)
 {
-- 
2.10.1

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

* [PATCH 08/15] libmultipath: Remove an unused variable
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (6 preceding siblings ...)
  2016-10-21 18:43 ` [PATCH 07/15] libmpathpersist: " Bart Van Assche
@ 2016-10-21 18:44 ` Bart Van Assche
  2016-10-21 18:44 ` [PATCH 09/15] libmultipath/checkers/rbd: Use unsigned int for one-bit bitfields Bart Van Assche
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:44 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/uevent.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 7bc5837..19b910f 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -49,7 +49,6 @@
 
 typedef int (uev_trigger)(struct uevent *, void * trigger_data);
 
-pthread_t uevq_thr;
 LIST_HEAD(uevq);
 pthread_mutex_t uevq_lock = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t *uevq_lockp = &uevq_lock;
-- 
2.10.1

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

* [PATCH 09/15] libmultipath/checkers/rbd: Use unsigned int for one-bit bitfields
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (7 preceding siblings ...)
  2016-10-21 18:44 ` [PATCH 08/15] libmultipath: Remove an unused variable Bart Van Assche
@ 2016-10-21 18:44 ` Bart Van Assche
  2016-10-21 18:44 ` [PATCH 10/15] libmultipath: Move the definition of a global variable from .h to .c Bart Van Assche
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:44 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Avoid that this bitfield is sign-extended. Detected by sparse.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/checkers/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
index f60914e..745e240 100644
--- a/libmultipath/checkers/rbd.c
+++ b/libmultipath/checkers/rbd.c
@@ -46,7 +46,7 @@ struct rbd_checker_context {
 	char *username;
 	int remapped;
 	int blacklisted;
-	int lock_on_read:1;
+	unsigned lock_on_read:1;
 
 	rados_t cluster;
 
-- 
2.10.1

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

* [PATCH 10/15] libmultipath: Move the definition of a global variable from .h to .c
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (8 preceding siblings ...)
  2016-10-21 18:44 ` [PATCH 09/15] libmultipath/checkers/rbd: Use unsigned int for one-bit bitfields Bart Van Assche
@ 2016-10-21 18:44 ` Bart Van Assche
  2016-10-21 18:45 ` [PATCH 11/15] libmpathpersist: " Bart Van Assche
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:44 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

This change does not change the semantics of the code but makes
it easier for sparse to analyze the source code.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/log.c | 2 ++
 libmultipath/log.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libmultipath/log.c b/libmultipath/log.c
index ab92e2a..debd36d 100644
--- a/libmultipath/log.c
+++ b/libmultipath/log.c
@@ -15,6 +15,8 @@
 
 #define ALIGN(len, s) (((len)+(s)-1)/(s)*(s))
 
+struct logarea* la;
+
 #if LOGDBG
 static void dump_logarea (void)
 {
diff --git a/libmultipath/log.h b/libmultipath/log.h
index 984f047..6551b5c 100644
--- a/libmultipath/log.h
+++ b/libmultipath/log.h
@@ -29,7 +29,7 @@ struct logarea {
 	char * buff;
 };
 
-struct logarea * la;
+extern struct logarea* la;
 
 int log_init (char * progname, int size);
 void log_close (void);
-- 
2.10.1

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

* [PATCH 11/15] libmpathpersist: Move the definition of a global variable from .h to .c
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (9 preceding siblings ...)
  2016-10-21 18:44 ` [PATCH 10/15] libmultipath: Move the definition of a global variable from .h to .c Bart Van Assche
@ 2016-10-21 18:45 ` Bart Van Assche
  2016-10-21 18:45 ` [PATCH 12/15] Use NULL instead of 0 where a pointer is expected Bart Van Assche
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:45 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmpathpersist/mpath_persist.c | 1 +
 libmpathpersist/mpathpr.h       | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index edd4246..6cc6dbc 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -35,6 +35,7 @@
 #define __STDC_FORMAT_MACROS 1
 
 struct udev *udev;
+struct config *conf;
 
 struct config *
 mpath_lib_init (struct udev *udev)
diff --git a/libmpathpersist/mpathpr.h b/libmpathpersist/mpathpr.h
index cd58201..056c547 100644
--- a/libmpathpersist/mpathpr.h
+++ b/libmpathpersist/mpathpr.h
@@ -26,7 +26,7 @@ struct threadinfo {
 };
 
 
-struct config * conf;
+extern struct config *conf;
 
 
 int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int noisy);
-- 
2.10.1

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

* [PATCH 12/15] Use NULL instead of 0 where a pointer is expected
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (10 preceding siblings ...)
  2016-10-21 18:45 ` [PATCH 11/15] libmpathpersist: " Bart Van Assche
@ 2016-10-21 18:45 ` Bart Van Assche
  2016-10-21 18:46 ` [PATCH 13/15] libmultipath/prioritizers: Make getprio() prototypes consistent Bart Van Assche
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:45 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

This was detected by sparse.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 kpartx/lopart.c             |  2 +-
 libmultipath/checkers/rbd.c |  2 +-
 mpathpersist/main.h         | 48 ++++++++++++++++++++++-----------------------
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/kpartx/lopart.c b/kpartx/lopart.c
index 0ab1688..4502fad 100644
--- a/kpartx/lopart.c
+++ b/kpartx/lopart.c
@@ -228,7 +228,7 @@ find_unused_loop_device (void)
 				"       maybe /dev/loop# has the wrong major number?");
 	} else
 		fprintf(stderr, "mount: could not find any free loop device");
-	return 0;
+	return NULL;
 }
 
 extern int
diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
index 745e240..481d860 100644
--- a/libmultipath/checkers/rbd.c
+++ b/libmultipath/checkers/rbd.c
@@ -464,7 +464,7 @@ static int rbd_rm_blacklist(struct rbd_checker_context *ct)
 	cmd[1] = NULL;
 
 	ret = rados_mon_command(ct->cluster, (const char **)cmd, 1, "", 0,
-				NULL, 0, &stat, &stat_len);
+				NULL, NULL, &stat, &stat_len);
 	if (ret < 0) {
 		condlog(1, "rbd%d: repair failed to remove blacklist for %s %d",
 			ct->rbd_bus_id, ct->client_addr, ret);
diff --git a/mpathpersist/main.h b/mpathpersist/main.h
index 7c31262..5c0e089 100644
--- a/mpathpersist/main.h
+++ b/mpathpersist/main.h
@@ -1,28 +1,28 @@
 static struct option long_options[] = {
-	{"verbose", 1, 0, 'v'},
-	{"clear", 0, 0, 'C'},
-	{"device", 1, 0, 'd'},
-	{"help", 0, 0, 'h'},
-	{"hex", 0, 0, 'H'},
-	{"in", 0, 0, 'i'},
-	{"out", 0, 0, 'o'},
-	{"param-aptpl", 0, 0, 'Z'},
-	{"param-rk", 1, 0, 'K'},
-	{"param-sark", 1, 0, 'S'},
-	{"preempt", 0, 0, 'P'},
-	{"preempt-abort", 0, 0, 'A'},
-	{"prout-type", 1, 0, 'T'},
-	{"read-full-status", 0, 0, 's'},
-	{"read-keys", 0, 0, 'k'},
-	{"read-reservation", 0, 0, 'r'},
-	{"register", 0, 0, 'G'},
-	{"register-ignore", 0, 0, 'I'},
-	{"release", 0, 0, 'L'},
-	{"report-capabilities", 0, 0, 'c'},
-	{"reserve", 0, 0, 'R'},
-	{"transport-id", 1, 0, 'X'},
-	{"alloc-length", 1, 0, 'l'},
-	{0, 0, 0, 0}
+	{"verbose", 1, NULL, 'v'},
+	{"clear", 0, NULL, 'C'},
+	{"device", 1, NULL, 'd'},
+	{"help", 0, NULL, 'h'},
+	{"hex", 0, NULL, 'H'},
+	{"in", 0, NULL, 'i'},
+	{"out", 0, NULL, 'o'},
+	{"param-aptpl", 0, NULL, 'Z'},
+	{"param-rk", 1, NULL, 'K'},
+	{"param-sark", 1, NULL, 'S'},
+	{"preempt", 0, NULL, 'P'},
+	{"preempt-abort", 0, NULL, 'A'},
+	{"prout-type", 1, NULL, 'T'},
+	{"read-full-status", 0, NULL, 's'},
+	{"read-keys", 0, NULL, 'k'},
+	{"read-reservation", 0, NULL, 'r'},
+	{"register", 0, NULL, 'G'},
+	{"register-ignore", 0, NULL, 'I'},
+	{"release", 0, NULL, 'L'},
+	{"report-capabilities", 0, NULL, 'c'},
+	{"reserve", 0, NULL, 'R'},
+	{"transport-id", 1, NULL, 'X'},
+	{"alloc-length", 1, NULL, 'l'},
+	{NULL, 0, NULL, 0}
 };
 
 static void usage(void);
-- 
2.10.1

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

* [PATCH 13/15] libmultipath/prioritizers: Make getprio() prototypes consistent
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (11 preceding siblings ...)
  2016-10-21 18:45 ` [PATCH 12/15] Use NULL instead of 0 where a pointer is expected Bart Van Assche
@ 2016-10-21 18:46 ` Bart Van Assche
  2016-10-21 18:46 ` [PATCH 14/15] libmultipath/checkers: Make the compiler check the checker function prototypes Bart Van Assche
  2016-10-21 18:46 ` [PATCH 15/15] kpartx: Move the declaration of a global variable from .c to .h Bart Van Assche
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:46 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Additionally, ensure that the compiler checks the getprio()
prototype.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/prio.h                      | 3 +++
 libmultipath/prioritizers/const.c        | 2 +-
 libmultipath/prioritizers/datacore.c     | 2 +-
 libmultipath/prioritizers/iet.c          | 2 +-
 libmultipath/prioritizers/random.c       | 2 +-
 libmultipath/prioritizers/weightedpath.c | 2 +-
 6 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libmultipath/prio.h b/libmultipath/prio.h
index 261105b..0193c52 100644
--- a/libmultipath/prio.h
+++ b/libmultipath/prio.h
@@ -64,4 +64,7 @@ char * prio_name (struct prio *);
 char * prio_args (struct prio *);
 int prio_set_args (struct prio *, char *);
 
+/* The only function exported by prioritizer dynamic libraries (.so) */
+int getprio(struct path *, char *, unsigned int);
+
 #endif /* _PRIO_H */
diff --git a/libmultipath/prioritizers/const.c b/libmultipath/prioritizers/const.c
index 9d9d003..aad6927 100644
--- a/libmultipath/prioritizers/const.c
+++ b/libmultipath/prioritizers/const.c
@@ -2,7 +2,7 @@
 
 #include "prio.h"
 
-int getprio (struct path * pp, char * args)
+int getprio(struct path * pp, char * args, unsigned int timeout)
 {
 	return 1;
 }
diff --git a/libmultipath/prioritizers/datacore.c b/libmultipath/prioritizers/datacore.c
index 050a94c..36465ac 100644
--- a/libmultipath/prioritizers/datacore.c
+++ b/libmultipath/prioritizers/datacore.c
@@ -106,7 +106,7 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 	return 0;
 }
 
-int getprio (struct path * pp, char * args)
+int getprio(struct path * pp, char * args, unsigned int timeout)
 {
 	return datacore_prio(pp->dev, pp->fd, args);
 }
diff --git a/libmultipath/prioritizers/iet.c b/libmultipath/prioritizers/iet.c
index aa852a0..a4ea61e 100644
--- a/libmultipath/prioritizers/iet.c
+++ b/libmultipath/prioritizers/iet.c
@@ -138,7 +138,7 @@ int iet_prio(const char *dev, char * args)
 	return 10;
 }
 
-int getprio(struct path * pp, char * args)
+int getprio(struct path * pp, char * args, unsigned int timeout)
 {
 	return iet_prio(pp->dev, args);
 }
diff --git a/libmultipath/prioritizers/random.c b/libmultipath/prioritizers/random.c
index c3ea3ac..4a27123 100644
--- a/libmultipath/prioritizers/random.c
+++ b/libmultipath/prioritizers/random.c
@@ -5,7 +5,7 @@
 
 #include "prio.h"
 
-int getprio (struct path * pp, char * args)
+int getprio(struct path * pp, char * args, unsigned int timeout)
 {
 	struct timeval tv;
 
diff --git a/libmultipath/prioritizers/weightedpath.c b/libmultipath/prioritizers/weightedpath.c
index a62b86e..34a43a8 100644
--- a/libmultipath/prioritizers/weightedpath.c
+++ b/libmultipath/prioritizers/weightedpath.c
@@ -151,7 +151,7 @@ int prio_path_weight(struct path *pp, char *prio_args)
 	return priority;
 }
 
-int getprio(struct path *pp, char *args)
+int getprio(struct path *pp, char *args, unsigned int timeout)
 {
 	return prio_path_weight(pp, args);
 }
-- 
2.10.1

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

* [PATCH 14/15] libmultipath/checkers: Make the compiler check the checker function prototypes
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (12 preceding siblings ...)
  2016-10-21 18:46 ` [PATCH 13/15] libmultipath/prioritizers: Make getprio() prototypes consistent Bart Van Assche
@ 2016-10-21 18:46 ` Bart Van Assche
  2016-10-21 18:46 ` [PATCH 15/15] kpartx: Move the declaration of a global variable from .c to .h Bart Van Assche
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:46 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/checkers.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
index 4fb97c9..fedc330 100644
--- a/libmultipath/checkers.h
+++ b/libmultipath/checkers.h
@@ -142,4 +142,10 @@ char * checker_message (struct checker *);
 void checker_clear_message (struct checker *c);
 void checker_get (char *, struct checker *, char *);
 
+/* Functions exported by path checker dynamic libraries (.so) */
+int libcheck_check(struct checker *);
+int libcheck_init(struct checker *);
+void libcheck_free(struct checker *);
+void libcheck_repair(struct checker *);
+
 #endif /* _CHECKERS_H */
-- 
2.10.1

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

* [PATCH 15/15] kpartx: Move the declaration of a global variable from .c to .h
  2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
                   ` (13 preceding siblings ...)
  2016-10-21 18:46 ` [PATCH 14/15] libmultipath/checkers: Make the compiler check the checker function prototypes Bart Van Assche
@ 2016-10-21 18:46 ` Bart Van Assche
  14 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-21 18:46 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 kpartx/gpt.c    | 1 -
 kpartx/kpartx.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kpartx/gpt.c b/kpartx/gpt.c
index 3511886..6ef20f9 100644
--- a/kpartx/gpt.c
+++ b/kpartx/gpt.c
@@ -504,7 +504,6 @@ compare_gpts(gpt_header *pgpt, gpt_header *agpt, uint64_t lastlba)
 static int
 find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes)
 {
-	extern int force_gpt;
 	int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
 	gpt_header *pgpt = NULL, *agpt = NULL;
 	gpt_entry *pptes = NULL, *aptes = NULL;
diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h
index a55c211..52920e4 100644
--- a/kpartx/kpartx.h
+++ b/kpartx/kpartx.h
@@ -39,6 +39,8 @@ struct slice {
 
 typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
 
+extern int force_gpt;
+
 extern ptreader read_dos_pt;
 extern ptreader read_bsd_pt;
 extern ptreader read_solaris_pt;
-- 
2.10.1

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

* Re: [PATCH 06/15] libmultipath: Remove an unused function
  2016-10-21 18:43 ` [PATCH 06/15] libmultipath: Remove an unused function Bart Van Assche
@ 2016-10-24 10:50   ` Germano Percossi
  2016-10-24 14:26     ` Bart Van Assche
  0 siblings, 1 reply; 20+ messages in thread
From: Germano Percossi @ 2016-10-24 10:50 UTC (permalink / raw)
  To: dm-devel

Removing functions packaged in a library just because they are
not used in multipath does not seem fine, in general.
They could still be used by third party.

Germano

On 10/21/2016 07:43 PM, Bart Van Assche wrote:
> The function snprint_config() is not used. Hence remove it.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> ---
>  libmultipath/print.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/libmultipath/print.c b/libmultipath/print.c
> index 9aa41ad..09e4a2e 100644
> --- a/libmultipath/print.c
> +++ b/libmultipath/print.c
> @@ -1745,12 +1745,6 @@ snprint_devices (struct config *conf, char * buff, int len, struct vectors *vecs
>  	return fwd;
>  }
>  
> -extern int
> -snprint_config (char * buff, int len)
> -{
> -	return 0;
> -}
> -
>  /*
>   * stdout printing helpers
>   */
> 

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

* Re: [PATCH 06/15] libmultipath: Remove an unused function
  2016-10-24 10:50   ` Germano Percossi
@ 2016-10-24 14:26     ` Bart Van Assche
  2016-10-24 14:55       ` Germano Percossi
  0 siblings, 1 reply; 20+ messages in thread
From: Bart Van Assche @ 2016-10-24 14:26 UTC (permalink / raw)
  To: Germano Percossi, dm-devel

On 10/24/16 03:50, Germano Percossi wrote:
> On 10/21/2016 07:43 PM, Bart Van Assche wrote:
>> The function snprint_config() is not used. Hence remove it.
>>
>> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
>> ---
>>  libmultipath/print.c | 6 ------
>>  1 file changed, 6 deletions(-)
>>
>> diff --git a/libmultipath/print.c b/libmultipath/print.c
>> index 9aa41ad..09e4a2e 100644
>> --- a/libmultipath/print.c
>> +++ b/libmultipath/print.c
>> @@ -1745,12 +1745,6 @@ snprint_devices (struct config *conf, char * buff, int len, struct vectors *vecs
>>  	return fwd;
>>  }
>>
>> -extern int
>> -snprint_config (char * buff, int len)
>> -{
>> -	return 0;
>> -}
>> -
>>  /*
>>   * stdout printing helpers
>>   */
>
 > Removing functions packaged in a library just because they are
 > not used in multipath does not seem fine, in general.
 > They could still be used by third party.

Hello Germano,

The snprint_config() function has never been declared in any 
multipath-tools header file so if someone would want to use this 
function without triggering a compiler warning they would have to add 
something like "extern int snprint_config (char * buff, int len)" to 
their source code. Because of this reason and also because of the empty 
implementation I think that is unlikely that any project is using this 
function.

Bart.

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

* Re: [PATCH 06/15] libmultipath: Remove an unused function
  2016-10-24 14:26     ` Bart Van Assche
@ 2016-10-24 14:55       ` Germano Percossi
  2016-10-24 16:02         ` Bart Van Assche
  0 siblings, 1 reply; 20+ messages in thread
From: Germano Percossi @ 2016-10-24 14:55 UTC (permalink / raw)
  To: Bart Van Assche, dm-devel

Sorry, my reply was meant for mpath_prin_pthread_fn patch but,
I guess, given the lack of a declaration in a header file,
your answer will be the same.

Germano

On 10/24/2016 03:26 PM, Bart Van Assche wrote:
> On 10/24/16 03:50, Germano Percossi wrote:
>> On 10/21/2016 07:43 PM, Bart Van Assche wrote:
>>> The function snprint_config() is not used. Hence remove it.
>>>
>>> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
>>> ---
>>>  libmultipath/print.c | 6 ------
>>>  1 file changed, 6 deletions(-)
>>>
>>> diff --git a/libmultipath/print.c b/libmultipath/print.c
>>> index 9aa41ad..09e4a2e 100644
>>> --- a/libmultipath/print.c
>>> +++ b/libmultipath/print.c
>>> @@ -1745,12 +1745,6 @@ snprint_devices (struct config *conf, char *
>>> buff, int len, struct vectors *vecs
>>>      return fwd;
>>>  }
>>>
>>> -extern int
>>> -snprint_config (char * buff, int len)
>>> -{
>>> -    return 0;
>>> -}
>>> -
>>>  /*
>>>   * stdout printing helpers
>>>   */
>>
>> Removing functions packaged in a library just because they are
>> not used in multipath does not seem fine, in general.
>> They could still be used by third party.
> 
> Hello Germano,
> 
> The snprint_config() function has never been declared in any
> multipath-tools header file so if someone would want to use this
> function without triggering a compiler warning they would have to add
> something like "extern int snprint_config (char * buff, int len)" to
> their source code. Because of this reason and also because of the empty
> implementation I think that is unlikely that any project is using this
> function.
> 
> Bart.
> 

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

* Re: [PATCH 06/15] libmultipath: Remove an unused function
  2016-10-24 14:55       ` Germano Percossi
@ 2016-10-24 16:02         ` Bart Van Assche
  0 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2016-10-24 16:02 UTC (permalink / raw)
  To: Germano Percossi, dm-devel

On 10/24/2016 07:55 AM, Germano Percossi wrote:
> Sorry, my reply was meant for mpath_prin_pthread_fn patch but,
> I guess, given the lack of a declaration in a header file,
> your answer will be the same.

Hello Germano,

Inspection of the git log -p output learned me that also 
mpath_prin_pthread_fn() was never declared in any multipath-tools header 
file.

Bart.

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

end of thread, other threads:[~2016-10-24 16:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21 18:40 [PATCH 0/15] Fifteen multipath-tools patches Bart Van Assche
2016-10-21 18:41 ` [PATCH 01/15] libmultipath: Make building against musl-libc again possible Bart Van Assche
2016-10-21 18:41 ` [PATCH 02/15] libmultipath: Avoid that thread cancellation causes a hang Bart Van Assche
2016-10-21 18:42 ` [PATCH 03/15] libmultipath: Remove an incorrect comment Bart Van Assche
2016-10-21 18:42 ` [PATCH 04/15] libmultipath: Move setup_thread_attr() from uevent.c into util.c Bart Van Assche
2016-10-21 18:43 ` [PATCH 05/15] libmultipath: Fix POLLIN checks Bart Van Assche
2016-10-21 18:43 ` [PATCH 06/15] libmultipath: Remove an unused function Bart Van Assche
2016-10-24 10:50   ` Germano Percossi
2016-10-24 14:26     ` Bart Van Assche
2016-10-24 14:55       ` Germano Percossi
2016-10-24 16:02         ` Bart Van Assche
2016-10-21 18:43 ` [PATCH 07/15] libmpathpersist: " Bart Van Assche
2016-10-21 18:44 ` [PATCH 08/15] libmultipath: Remove an unused variable Bart Van Assche
2016-10-21 18:44 ` [PATCH 09/15] libmultipath/checkers/rbd: Use unsigned int for one-bit bitfields Bart Van Assche
2016-10-21 18:44 ` [PATCH 10/15] libmultipath: Move the definition of a global variable from .h to .c Bart Van Assche
2016-10-21 18:45 ` [PATCH 11/15] libmpathpersist: " Bart Van Assche
2016-10-21 18:45 ` [PATCH 12/15] Use NULL instead of 0 where a pointer is expected Bart Van Assche
2016-10-21 18:46 ` [PATCH 13/15] libmultipath/prioritizers: Make getprio() prototypes consistent Bart Van Assche
2016-10-21 18:46 ` [PATCH 14/15] libmultipath/checkers: Make the compiler check the checker function prototypes Bart Van Assche
2016-10-21 18:46 ` [PATCH 15/15] kpartx: Move the declaration of a global variable from .c to .h Bart Van Assche

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.