Skip to contentSkip to conversation

SLES resync

PATCH In review Hannes Reinecke 2 participants 16 messages Dec 13, 2013 Device mapper

lore
Share & tools
lore
#0 lore raw

cover SLES resync

Hi Christophe,

here are some more patches which have accumulated in my SLES repository.
Please apply.

Hannes Reinecke (11):
Remove trailing spaces from sysfs attributes
Document 'wwids_file' and 'reservation_key'
libmultipath: Fix typo in retain_attached_hw_handler
multipath: do not print 'path is up' for removed paths
libmultipath: proactively remove path
multipath: do not call tur in sync mode if pthread_cancel fails
multipathd: Update manpage
Reset timezone information on reconfigure
multipathd: Correctly initialize udev context
multipathd: add path when transitioned from 'blocked' state Make 'multipath -t' able to run as normal user

 libmultipath/checkers.c     |  1 +
 libmultipath/checkers.h     |  5 +++++
 libmultipath/checkers/tur.c |  7 +++----
 libmultipath/config.c       |  1 -
 libmultipath/discovery.c    | 17 +++++++++++++----
 libmultipath/log.c          |  1 +
 libmultipath/propsel.c      |  2 +-
 libmultipath/sysfs.c        |  2 +-
 libmultipath/util.c         |  3 ++-
 libmultipath/util.h         |  2 +-
 multipath.conf.annotated    | 17 ++++++++++++++++-
 multipath/main.c            | 22 +++++++++++++---------
 multipathd/main.c           | 35 ++++++++++++++++++++++++++++++-----
 multipathd/multipathd.8     |  6 +++---
 14 files changed, 90 insertions(+), 31 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/11 Remove trailing spaces from sysfs attributes

Some sysfs attributes may contain trailing spaces, which only serve to confuse matters. So strip them before continuing.

---
 libmultipath/discovery.c | 2 +-
 libmultipath/util.c      | 3 ++-
 libmultipath/util.h      | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
libmultipath/discovery.c +1 -1
index d5557d9..d519c02 100644
@@ -164,7 +164,7 @@ sysfs_get_##fname (struct udev_device * udev, char * buff, size_t len)	\
 		return -EINVAL;						\
 	}								\
 	ret = strlcpy(buff, attr, len);					\
-	return ret;							\
+	return strchop(buff);						\
 }
 
 declare_sysfs_get_str(devtype);
libmultipath/util.c +2 -1
index a9f5939..e6fd11d 100644
@@ -10,13 +10,14 @@
 #include "vector.h"
 #include "structs.h"
 
-void
+size_t
 strchop(char *str)
 {
 	int i;
 
 	for (i=strlen(str)-1; i >=0 && isspace(str[i]); --i) ;
 	str[++i] = '\0';
+	return strlen(str);
 }
 
 int
libmultipath/util.h +1 -1
index 44184a1..7b67dff 100644
@@ -1,7 +1,7 @@
 #ifndef _UTIL_H
 #define _UTIL_H
 
-void strchop(char *);
+size_t strchop(char *);
 int basenamecpy (const char * src, char * dst, int);
 int filepresent (char * run);
 int get_word (char * sentence, char ** word);
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 2/11 Document 'wwids_file' and 'reservation_key'

In reply to Hannes Reinecke

Add documentation for 'wwids_file' and 'reservation_key' to multipath.conf.annotated.

---
 multipath.conf.annotated | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
multipath.conf.annotated +16 -1
index a20302c..235e130 100644
@@ -275,7 +275,22 @@
 #	#           the user_friendly_names option.
 #	# values  : <full_pathname>
 #	# default : "/var/lib/multipath/bindings"
-#	bindings_file "/etc/multipath_bindings"
+#	bindings_file "/etc/multipath/bindings"
+#
+#	# name    : wwids_file
+#	# scope   : multipath
+#	# desc    : The location of the wwids file multipath uses to
+#       #           keep track of the created multipath devices.
+#	# values  : <full_pathname>
+#	# default : "/var/lib/multipath/wwids"
+#	wwids_file "/etc/multipath/wwids"
+#
+#	# name    : reservation_key
+#	# scope   : multipath
+#	# desc    : Service action reservation key used by mpathpersist.
+#	# values  : <key>
+#	# default : (null)
+#	reservation_key "mpathkey"
 #
 #}
 #	
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 3/11 libmultipath: Fix typo in retain_attached_hw_handler

In reply to Hannes Reinecke
---
 libmultipath/propsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/propsel.c +1 -1
index f092227..5fe72af 100644
@@ -680,7 +680,7 @@ select_retain_hwhandler (struct multipath * mp)
 
 	if (!VERSION_GE(conf->version, minv_dm_retain)) {
 		mp->retain_hwhandler = RETAIN_HWHANDLER_OFF;
-		condlog(3, "%s: retain_attached_hw_hander disabled (requires kernel version >= 1.5.0)", mp->alias);
+		condlog(3, "%s: retain_attached_hw_handler disabled (requires kernel version >= 1.5.0)", mp->alias);
 		return 0;
 	}
 
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH 4/11 multipath: do not print 'path is up' for removed paths

In reply to Hannes Reinecke

When a path is removed the previous checker message is still kept in the checker context, and will be printed upon each check. This causes multipath to print out
'path is up'
even though it already has been removed from sysfs.

---
 multipathd/main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
multipathd/main.c +7 -2
index 91d7bfc..2633da9 100644
@@ -1124,6 +1124,8 @@ check_path (struct vectors * vecs, struct path * pp)
 	newstate = path_offline(pp);
 	if (newstate == PATH_UP)
 		newstate = get_state(pp, 1);
+	else
+		checker_clear_message(&pp->checker);
 
 	if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) {
 		condlog(2, "%s: unusable path", pp->dev);
@@ -1150,7 +1152,9 @@ check_path (struct vectors * vecs, struct path * pp)
 	if (newstate != pp->state) {
 		int oldstate = pp->state;
 		pp->state = newstate;
-		LOG_MSG(1, checker_message(&pp->checker));
+
+		if (strlen(checker_message(&pp->checker)))
+			LOG_MSG(1, checker_message(&pp->checker));
 
 		/*
 		 * upon state change, reset the checkint
@@ -1232,7 +1236,8 @@ check_path (struct vectors * vecs, struct path * pp)
 			pp->tick = pp->checkint;
 		}
 	}
-	else if (newstate == PATH_DOWN) {
+	else if (newstate == PATH_DOWN &&
+		 strlen(checker_message(&pp->checker))) {
 		if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
 			LOG_MSG(3, checker_message(&pp->checker));
 		else
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH 5/11 libmultipath: proactively remove path

In reply to Hannes Reinecke

When path_offline() detects a removed path we really do not need to wait for any uevent to arrive, but can remove the path straightaway.

---
 libmultipath/checkers.c  |  1 +
 libmultipath/checkers.h  |  5 +++++
 libmultipath/discovery.c | 15 ++++++++++++---
 libmultipath/sysfs.c     |  2 +-
 multipathd/main.c        |  5 +++++
 5 files changed, 24 insertions(+), 4 deletions(-)
libmultipath/checkers.c +1 -0
index 47f5c68..4a4cd7c 100644
@@ -18,6 +18,7 @@ char *checker_state_names[] = {
       "ghost",
       "pending",
       "timeout",
+      "removed",
 };
 
 static LIST_HEAD(checkers);
libmultipath/checkers.h +5 -0
index 1b6c22d..e62b52f 100644
@@ -50,6 +50,10 @@
  * PATH_TIMEOUT:
  * - Use: Only tur checker
  * - Description: Command timed out
+ *
+ * PATH REMOVED:
+ * - Use: All checkers
+ * - Description: Device has been removed from the system
  */
 enum path_check_state {
 	PATH_WILD,
@@ -60,6 +64,7 @@ enum path_check_state {
 	PATH_GHOST,
 	PATH_PENDING,
 	PATH_TIMEOUT,
+	PATH_REMOVED,
 	PATH_MAX_STATE
 };
 
libmultipath/discovery.c +12 -3
index d519c02..ccd3b62 100644
@@ -839,6 +839,7 @@ path_offline (struct path * pp)
 {
 	struct udev_device * parent;
 	char buff[SCSI_STATE_SIZE];
+	int err;
 
 	if (pp->bus != SYSFS_BUS_SCSI)
 		return PATH_UP;
@@ -853,12 +854,18 @@ path_offline (struct path * pp)
 
 	if (!parent) {
 		condlog(1, "%s: failed to get sysfs information", pp->dev);
-		return PATH_DOWN;
+		return PATH_REMOVED;
 	}
 
 	memset(buff, 0x0, SCSI_STATE_SIZE);
-	if (sysfs_attr_get_value(parent, "state", buff, SCSI_STATE_SIZE) <= 0)
-		return PATH_DOWN;
+	err = sysfs_attr_get_value(parent, "state", buff, SCSI_STATE_SIZE);
+	if (err <= 0) {
+		if (err == -ENXIO)
+			return PATH_REMOVED;
+		else
+			return PATH_DOWN;
+	}
+
 
 	condlog(3, "%s: path state = %s", pp->dev, buff);
 
@@ -1084,6 +1091,8 @@ pathinfo (struct path *pp, vector hwtable, int mask)
 	}
 
 	path_state = path_offline(pp);
+	if (path_state == PATH_REMOVED)
+		goto blank;
 
 	/*
 	 * fetch info not available through sysfs
libmultipath/sysfs.c +1 -1
index 8ba27d4..e5834f9 100644
@@ -59,7 +59,7 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
 	condlog(4, "open '%s'", devpath);
 	if (stat(devpath, &statbuf) != 0) {
 		condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
-		return -errno;
+		return -ENXIO;
 	}
 
 	/* skip directories */
multipathd/main.c +5 -0
index 2633da9..96564f8 100644
@@ -1122,6 +1122,11 @@ check_path (struct vectors * vecs, struct path * pp)
 	pp->tick = conf->checkint;
 
 	newstate = path_offline(pp);
+	if (newstate == PATH_REMOVED) {
+		condlog(2, "%s: remove path (checker)", pp->dev);
+		ev_remove_path(pp, vecs);
+		return;
+	}
 	if (newstate == PATH_UP)
 		newstate = get_state(pp, 1);
 	else
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH 6/11 multipath: do not call tur in sync mode if pthread_cancel fails

In reply to Hannes Reinecke

When pthread_cancel fails the thread is stuck, most likely during I/O submission. So it would be pointless to call the tur checker in sync mode here, as this would be stuck, too. Hence we should rather return 'PATH_TIMEOUT' and hope the situation resolves itself over time.

---
 libmultipath/checkers/tur.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
libmultipath/checkers/tur.c +3 -4
index b76dcec..bd7372d 100644
@@ -298,7 +298,6 @@ libcheck_check (struct checker * c)
 				ct->running = 0;
 				MSG(c, MSG_TUR_TIMEOUT);
 				tur_status = PATH_TIMEOUT;
-				ct->state = PATH_UNCHECKED;
 			} else {
 				condlog(3, "%d:%d: tur checker not finished",
 					TUR_DEVT(ct));
@@ -317,9 +316,9 @@ libcheck_check (struct checker * c)
 		if (ct->thread) {
 			/* pthread cancel failed. continue in sync mode */
 			pthread_mutex_unlock(&ct->lock);
-			condlog(3, "%d:%d: tur thread not responding, "
-				"using sync mode", TUR_DEVT(ct));
-			return tur_check(c->fd, c->timeout, c->message);
+			condlog(3, "%d:%d: tur thread not responding",
+				TUR_DEVT(ct));
+			return PATH_TIMEOUT;
 		}
 		/* Start new TUR checker */
 		ct->state = PATH_UNCHECKED;
Signature · 1 line
1.8.1.4
#8 lore raw

PATCH 7/11 multipathd: Update manpage

In reply to Hannes Reinecke

Some aliases for CLI command arguments were missing from the manpage.

---
 multipathd/multipathd.8 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
multipathd/multipathd.8 +3 -3
index ccc5f54..17bf650 100644
@@ -83,16 +83,16 @@ Add a path to the list of monitored paths. $path is as listed in /sys/block (e.g
 .B remove|del path $path
 Stop monitoring a path. $path is as listed in /sys/block (e.g. sda).
 .TP
-.B add map $map
+.B add map|multipath $map
 Add a multipath device to the list of monitored devices. $map can either be a device-mapper device as listed in /sys/block (e.g. dm-0) or it can be the alias for the multipath device (e.g. mpath1) or the uid of the multipath device (e.g. 36005076303ffc56200000000000010aa). 
 .TP
-.B remove|del map $map
+.B remove|del map|multipath $map
 Stop monitoring a multipath device.
 .TP
 .B resize map|multipath $map
 Resizes map $map to the given size
 .TP 
-.B switch|switchgroup map $map group $group
+.B switch|switchgroup map|multipath $map group $group
 Force a multipath device to switch to a specific path group. $group is the path group index, starting with 1.
 .TP
 .B reconfigure
Signature · 1 line
1.8.1.4
#9 lore raw

PATCH 8/11 Reset timezone information on reconfigure

In reply to Hannes Reinecke

Whenever 'reconfigure' is called we need to re-initialize the timezone information as it might have been changed in the meantime.

References: bnc#830511

---
 libmultipath/log.c | 1 +
 multipathd/main.c  | 3 +++
 2 files changed, 4 insertions(+)
libmultipath/log.c +1 -0
index 37c7cd7..74702d8 100644
@@ -99,6 +99,7 @@ void log_close (void)
 void log_reset (char *program_name)
 {
 	closelog();
+	tzset();
 	openlog(program_name, 0, LOG_DAEMON);
 }
 
multipathd/main.c +3 -0
index 96564f8..1a1aa2d 100644
@@ -1416,6 +1416,9 @@ reconfigure (struct vectors * vecs)
 	vecs->pathvec = NULL;
 	conf = NULL;
 
+	/* Re-read any timezone changes */
+	tzset();
+
 	if (!load_config(DEFAULT_CONFIGFILE, udev)) {
 		conf->verbosity = old->verbosity;
 		conf->daemon = 1;
Signature · 1 line
1.8.1.4
#11 lore raw

PATCH 9/11 multipathd: Correctly initialize udev context

In reply to Hannes Reinecke

The udev context is passed as argument to ueventloop(), so we should be using that instead of the global variable.

---
 multipathd/main.c | 2 ++
 1 file changed, 2 insertions(+)
multipathd/main.c +2 -0
index 1a1aa2d..7058147 100644
@@ -836,6 +836,8 @@ out:
 static void *
 ueventloop (void * ap)
 {
+	struct udev *udev = ap;
+
 	if (uevent_listen(udev))
 		condlog(0, "error starting uevent listener");
 
Signature · 1 line
1.8.1.4
#12 lore raw

PATCH 10/11 multipathd: add path when transitioned from 'blocked' state

In reply to Hannes Reinecke

When a path is discovered in 'blocked' state it won't be added to the path list as we cannot get the path uuid.
And any further check will fail here as the uuid won't be recovered. So add a check in checkerloop() to re-add the path if it gets out of a 'blocked' state.

---
 multipathd/main.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
multipathd/main.c +11 -3
index 7058147..cc5cf67 100644
@@ -1111,9 +1111,6 @@ check_path (struct vectors * vecs, struct path * pp)
 	int chkr_new_path_up = 0;
 	int oldchkrstate = pp->chkrstate;
 
-	if (!pp->mpp)
-		return;
-
 	if (pp->tick && --pp->tick)
 		return; /* don't check this path yet */
 
@@ -1139,6 +1136,17 @@ check_path (struct vectors * vecs, struct path * pp)
 		pathinfo(pp, conf->hwtable, 0);
 		return;
 	}
+	if (!pp->mpp) {
+		if (!strlen(pp->wwid) &&
+		    (newstate == PATH_UP || newstate == PATH_GHOST)) {
+			condlog(2, "%s: add missing path", pp->dev);
+			if (pathinfo(pp, conf->hwtable, DI_ALL) == 0) {
+				ev_add_path(pp, vecs);
+				pp->tick = 1;
+			}
+		}
+		return;
+	}
 	/*
 	 * Async IO in flight. Keep the previous path state
 	 * and reschedule as soon as possible
Signature · 1 line
1.8.1.4
#14 lore raw

PATCH 11/11 Make 'multipath -t' able to run as normal user

In reply to Hannes Reinecke

'multipath -t' should be run as normal user, as we might be needing it to update the default configuration.

---
 libmultipath/config.c |  1 -
 multipath/main.c      | 22 +++++++++++++---------
 multipathd/main.c     |  2 ++
 3 files changed, 15 insertions(+), 10 deletions(-)
libmultipath/config.c +0 -1
index 9b7adda..e13c307 100644
@@ -543,7 +543,6 @@ load_config (char * file, struct udev *udev)
 		conf->verbosity = DEFAULT_VERBOSITY;
 
 	conf->udev = udev;
-	dm_drv_version(conf->version, TGT_MPATH);
 	conf->dev_type = DEV_NONE;
 	conf->minio = DEFAULT_MINIO;
 	conf->minio_rq = DEFAULT_MINIO_RQ;
multipath/main.c +13 -9
index 842a787..c351507 100644
@@ -447,16 +447,8 @@ main (int argc, char *argv[])
 	extern int optind;
 	int r = 1;
 
-	if (getuid() != 0) {
-		fprintf(stderr, "need to be root\n");
-		exit(1);
-	}
-
 	udev = udev_new();
 
-	if (dm_prereq())
-		exit(1);
-
 	if (load_config(DEFAULT_CONFIGFILE, udev))
 		exit(1);
 
@@ -521,7 +513,7 @@ main (int argc, char *argv[])
 			break;
 		case 't':
 			r = dump_config();
-			goto out;
+			goto out_free_config;
 		case 'h':
 			usage(argv[0]);
 			exit(0);
@@ -544,6 +536,16 @@ main (int argc, char *argv[])
 			exit(1);
 		}
 	}
+
+	if (getuid() != 0) {
+		fprintf(stderr, "need to be root\n");
+		exit(1);
+	}
+
+	if (dm_prereq())
+		exit(1);
+	dm_drv_version(conf->version, TGT_MPATH);
+
 	if (optind < argc) {
 		conf->dev = MALLOC(FILE_NAME_SIZE);
 
@@ -630,6 +632,8 @@ out:
 
 	cleanup_prio();
 	cleanup_checkers();
+
+out_free_config:
 	/*
 	 * Freeing config must be done after dm_lib_exit(), because
 	 * the logging function (dm_write_log()), which is called there,
multipathd/main.c +2 -0
index cc5cf67..7f59c6d 100644
@@ -1430,6 +1430,7 @@ reconfigure (struct vectors * vecs)
 	tzset();
 
 	if (!load_config(DEFAULT_CONFIGFILE, udev)) {
+		dm_drv_version(conf->version, TGT_MPATH);
 		conf->verbosity = old->verbosity;
 		conf->daemon = 1;
 		configure(vecs, 1);
@@ -1634,6 +1635,7 @@ child (void * param)
 	if (load_config(DEFAULT_CONFIGFILE, udev))
 		exit(1);
 
+	dm_drv_version(conf->version, TGT_MPATH);
 	if (init_checkers()) {
 		condlog(0, "failed to initialize checkers");
 		exit(1);
Signature · 1 line
1.8.1.4
#15 lore raw
In reply to Hannes Reinecke
Quoted 6 lines · Hannes Reinecke

Hi Christophe,

here are some more patches which have accumulated in my SLES repository.
Please apply.

And with that I don't have patches pending anymore, so now would be a good time to cut a new version.

(Provided those patches will be applied, of course :-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
#13 lore raw

Re: [PATCH 10/11] multipathd: add path when transitioned from 'blocked' state

In reply to Hannes Reinecke

Hannes,

I merged the patchset.

Can you post a patch to set return values to the multipathd/main.c::patch_check() exit points where it is not present. This 11/12 patch adds one, and the "proactive path removal" patch adds the other.
This requirement was introduced by your earlier "check timing" patch.

Thanks,
Christophe Varoqui

Quoted 51 lines · Hannes Reinecke

When a path is discovered in 'blocked' state it won't be added to the path list as we cannot get the path uuid.
And any further check will fail here as the uuid won't be recovered. So add a check in checkerloop() to re-add the path if it gets out of a 'blocked' state.

---
 multipathd/main.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
multipathd/main.c +11 -4
index 7058147..cc5cf67 100644
@@ -1111,9 +1111,6 @@ check_path (struct vectors * vecs, struct path * pp)
        int chkr_new_path_up = 0;
        int oldchkrstate = pp->chkrstate;
 
-       if (!pp->mpp)
-               return;
-
        if (pp->tick && --pp->tick)
                return; /* don't check this path yet */
 
@@ -1139,6 +1136,17 @@ check_path (struct vectors * vecs, struct path * pp)
                pathinfo(pp, conf->hwtable, 0);
                return;
        }
+       if (!pp->mpp) {
+               if (!strlen(pp->wwid) &&
+                   (newstate == PATH_UP || newstate == PATH_GHOST)) {
+                       condlog(2, "%s: add missing path", pp->dev);
+                       if (pathinfo(pp, conf->hwtable, DI_ALL) == 0) {
+                               ev_add_path(pp, vecs);
+                               pp->tick = 1;
+                       }
+               }
+               return;
+       }
        /*
         * Async IO in flight. Keep the previous path state
         * and reschedule as soon as possible
--

1.8.1.4

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#10 lore raw

Re: [PATCH 08/11] Reset timezone information on reconfigure

In reply to Hannes Reinecke

Hannes,

FYI, related to your latest patchset,

commit dd205886ed2d41bb8e2602cb9771be403a99cd27

Author: Christophe Varoqui <[email protected]>
Date:   Fri Dec 13 23:20:40 2013 +0100

Add missing includes to support tzget() usage

libmultipath/log.c +1 -0
index 74702d8..ab92e2a 100644
@@ -8,6 +8,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <syslog.h>
+#include <time.h>
 
 #include "memory.h"
 #include "log.h"
multipathd/main.c +1 -0
index 37a9bc2..fd70b70 100644
@@ -22,6 +22,7 @@
 #endif
 #include <semaphore.h>
 #include <mpath_persist.h>
+#include <time.h>
 
 /*
  * libcheckers

Best regards,
Christophe Varoqui

Quoted 46 lines · Hannes Reinecke

Whenever 'reconfigure' is called we need to re-initialize the timezone information as it might have been changed in the meantime.

References: bnc#830511

---
 libmultipath/log.c | 1 +
 multipathd/main.c  | 3 +++
 2 files changed, 4 insertions(+)
libmultipath/log.c +1 -0
index 37c7cd7..74702d8 100644
@@ -99,6 +99,7 @@ void log_close (void)
 void log_reset (char *program_name)
 {
        closelog();
+       tzset();
        openlog(program_name, 0, LOG_DAEMON);
 }
 
multipathd/main.c +3 -1
index 96564f8..1a1aa2d 100644
@@ -1416,6 +1416,9 @@ reconfigure (struct vectors * vecs)
        vecs->pathvec = NULL;
        conf = NULL;
 
+       /* Re-read any timezone changes */
+       tzset();
+
        if (!load_config(DEFAULT_CONFIGFILE, udev)) {
                conf->verbosity = old->verbosity;
                conf->daemon = 1;
--

1.8.1.4

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#2 lore raw

Re: [PATCH 01/11] Remove trailing spaces from sysfs attributes

In reply to Hannes Reinecke

Hannes,

FYI, related to this patch,

commit 3e7763345a31e81318b70d7af68902984312f624

Author: Christophe Varoqui <[email protected]>
Date:   Fri Dec 13 23:10:27 2013 +0100

[libmultipath] Fix a compilation warning

Now that we chop the sysfs attribute strings, the size returned by strlcpy is not used anymore. Remove the variable to tame the compiler warning.

libmultipath/discovery.c +0 -0
index ccd3b62..b7470f8 100644
@@ -143,7 +143,6 @@ path_discovery (vector pathvec, struct config * conf,

int flag)
extern ssize_t \
sysfs_get_##fname (struct udev_device * udev, char * buff, size_t len) \

 {                                                                      \
-       ssize_t ret;                                                    \
        const char * attr;                                              \
        const char * devname;                                           \
                                                                        \
@@ -163,7 +162,7 @@ sysfs_get_##fname (struct udev_device * udev, char *
buff, size_t len)      \
                        devname, #fname);                               \
                return -EINVAL;                                         \
        }                                                               \
-       ret = strlcpy(buff, attr, len);                                 \
+       strlcpy(buff, attr, len);                                       \
        return strchop(buff);                                           \

}

Best regards,
Christophe Varoqui

Quoted 65 lines · Hannes Reinecke

Some sysfs attributes may contain trailing spaces, which only serve to confuse matters. So strip them before continuing.

---
 libmultipath/discovery.c | 2 +-
 libmultipath/util.c      | 3 ++-
 libmultipath/util.h      | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
libmultipath/discovery.c +1 -1
index d5557d9..d519c02 100644
@@ -164,7 +164,7 @@ sysfs_get_##fname (struct udev_device * udev, char *
 buff, size_t len)      \
                return -EINVAL;                                         \
        }                                                               \
        ret = strlcpy(buff, attr, len);                                 \
-       return ret;                                                     \
+       return strchop(buff);                                           \
 }
 

declare_sysfs_get_str(devtype);

libmultipath/util.c +2 -1
index a9f5939..e6fd11d 100644
@@ -10,13 +10,14 @@
 #include "vector.h"
 #include "structs.h"
 
-void
+size_t
 strchop(char *str)
 {
        int i;
 
        for (i=strlen(str)-1; i >=0 && isspace(str[i]); --i) ;
        str[++i] = '\0';
+       return strlen(str);
 }
 
 int
libmultipath/util.h +1 -2
index 44184a1..7b67dff 100644
@@ -1,7 +1,7 @@
 #ifndef _UTIL_H
 #define _UTIL_H
 
-void strchop(char *);
+size_t strchop(char *);
 int basenamecpy (const char * src, char * dst, int);
 int filepresent (char * run);
 int get_word (char * sentence, char ** word);
--

1.8.1.4

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel