Skip to contentSkip to conversation

misc patches

PATCH Superseded Benjamin Marzinski 3 participants 12 messages Feb 11, 2017 – Feb 13, 2017 Device mapper

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

cover misc patches

Here's a couple of minor features bugfixes and cleanups. The biggest change is that the detect_checker option now sets the checker for devices with detected ALUA to TUR. Also, udev wasn't correctly disabling rules for multipath devices that lost their last usable path through a table reload. This was causing lvmetad some problems on failing multipath devices.

Benjamin Marzinski (7):
kpartx: don't keep creating recursive partitions
libmultipath: add detect_checker option
libmultipath: cleanup orphan device states
multipathd: don't update priority of failed paths
multipathd: add messages on delayed path addition
multipathd: allow resetting stats
fix udev rules for failed multipath devices

 kpartx/dos.c                |  2 +-
 libmultipath/config.c       |  3 ++
 libmultipath/config.h       |  2 ++
 libmultipath/defaults.h     |  1 +
 libmultipath/devmapper.c    |  3 +-
 libmultipath/devmapper.h    |  6 ++++
 libmultipath/dict.c         | 10 +++++++
 libmultipath/discovery.c    |  1 +
 libmultipath/hwtable.c      |  1 +
 libmultipath/print.c        |  4 +--
 libmultipath/propsel.c      | 59 +++++++++++++++++++++++++++++++-------
 libmultipath/propsel.h      |  1 +
 libmultipath/structs.h      |  7 +++++
 multipath/11-dm-mpath.rules | 69 +++++++++++++++++++++++++++++++--------------
 multipath/multipath.conf.5  | 18 ++++++++++++
 multipathd/cli.c            |  2 ++
 multipathd/cli_handlers.c   | 44 +++++++++++++++++++++++++++++
 multipathd/cli_handlers.h   |  2 ++
 multipathd/main.c           |  8 +++++-
 19 files changed, 207 insertions(+), 36 deletions(-)
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH 1/7 kpartx: don't keep creating recursive partitions

If the dos partition table is corrupted, kpartx can just keep creating the same partitions until it runs out of partition numbers. This check catches the recursion.

---
 kpartx/dos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kpartx/dos.c +1 -1
index 64b27b6..4985152 100644
@@ -46,7 +46,7 @@ read_extended_partition(int fd, struct partition *ep, int en,
 		for (i=0; i<2; i++) {
 			memcpy(&p, bp + 0x1be + i * sizeof (p), sizeof (p));
 			if (is_extended(p.sys_type)) {
-				if (p.nr_sects && !moretodo) {
+				if (p.start_sect && p.nr_sects && !moretodo) {
 					next = start + sector_size_mul * le32_to_cpu(p.start_sect);
 					moretodo = 1;
 				}
Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH 2/7 libmultipath: add detect_checker option

In reply to Benjamin Marzinski

This patch adds a detect_checker option that works just like the detect_prio option. It currently only detects ALUA devices, and if it finds ALUA support, it sets the priortizier to TUR. This is useful for devices like the VNX2, where it should be using the TUR checker when in ALUA mode (or so I have been told). It is set on by default just like detect_prio and retain_attached_hw_handler.

---
 libmultipath/config.c      |  3 +++
 libmultipath/config.h      |  2 ++
 libmultipath/defaults.h    |  1 +
 libmultipath/dict.c        | 10 ++++++++
 libmultipath/discovery.c   |  1 +
 libmultipath/hwtable.c     |  1 +
 libmultipath/propsel.c     | 59 ++++++++++++++++++++++++++++++++++++++--------
 libmultipath/propsel.h     |  1 +
 libmultipath/structs.h     |  7 ++++++
 multipath/multipath.conf.5 | 18 ++++++++++++++
 10 files changed, 93 insertions(+), 10 deletions(-)
libmultipath/config.c +3 -0
index 15ddbd8..68a1692 100644
@@ -343,6 +343,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
 	merge_num(user_friendly_names);
 	merge_num(retain_hwhandler);
 	merge_num(detect_prio);
+	merge_num(detect_checker);
 	merge_num(deferred_remove);
 	merge_num(delay_watch_checks);
 	merge_num(delay_wait_checks);
@@ -420,6 +421,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe)
 	hwe->user_friendly_names = dhwe->user_friendly_names;
 	hwe->retain_hwhandler = dhwe->retain_hwhandler;
 	hwe->detect_prio = dhwe->detect_prio;
+	hwe->detect_checker = dhwe->detect_checker;
 
 	if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
 		goto out;
@@ -607,6 +609,7 @@ load_config (char * file)
 	conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
 	conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
 	conf->detect_prio = DEFAULT_DETECT_PRIO;
+	conf->detect_checker = DEFAULT_DETECT_CHECKER;
 	conf->force_sync = DEFAULT_FORCE_SYNC;
 	conf->partition_delim = DEFAULT_PARTITION_DELIM;
 	conf->processed_main_config = 0;
libmultipath/config.h +2 -0
index 9670020..4a785ca 100644
@@ -62,6 +62,7 @@ struct hwentry {
 	int user_friendly_names;
 	int retain_hwhandler;
 	int detect_prio;
+	int detect_checker;
 	int deferred_remove;
 	int delay_watch_checks;
 	int delay_wait_checks;
@@ -133,6 +134,7 @@ struct config {
 	int reassign_maps;
 	int retain_hwhandler;
 	int detect_prio;
+	int detect_checker;
 	int force_sync;
 	int deferred_remove;
 	int processed_main_config;
libmultipath/defaults.h +1 -0
index b9b0a37..1e5a527 100644
@@ -22,6 +22,7 @@
 #define DEFAULT_DEV_LOSS_TMO	600
 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_ON
 #define DEFAULT_DETECT_PRIO	DETECT_PRIO_ON
+#define DEFAULT_DETECT_CHECKER	DETECT_CHECKER_ON
 #define DEFAULT_DEFERRED_REMOVE	DEFERRED_REMOVE_OFF
 #define DEFAULT_DELAY_CHECKS	DELAY_CHECKS_OFF
 #define DEFAULT_UEVENT_STACKSIZE 256
libmultipath/dict.c +10 -0
index dc21846..53f78ea 100644
@@ -379,6 +379,13 @@ declare_ovr_snprint(detect_prio, print_yes_no_undef)
 declare_hw_handler(detect_prio, set_yes_no_undef)
 declare_hw_snprint(detect_prio, print_yes_no_undef)
 
+declare_def_handler(detect_checker, set_yes_no_undef)
+declare_def_snprint_defint(detect_checker, print_yes_no_undef, YNU_NO)
+declare_ovr_handler(detect_checker, set_yes_no_undef)
+declare_ovr_snprint(detect_checker, print_yes_no_undef)
+declare_hw_handler(detect_checker, set_yes_no_undef)
+declare_hw_snprint(detect_checker, print_yes_no_undef)
+
 declare_def_handler(force_sync, set_yes_no)
 declare_def_snprint(force_sync, print_yes_no)
 
@@ -1397,6 +1404,7 @@ init_keywords(vector keywords)
 	install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
 	install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler);
 	install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
+	install_keyword("detect_checker", &def_detect_checker_handler, &snprint_def_detect_checker);
 	install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);
 	install_keyword("strict_timing", &def_strict_timing_handler, &snprint_def_strict_timing);
 	install_keyword("deferred_remove", &def_deferred_remove_handler, &snprint_def_deferred_remove);
@@ -1483,6 +1491,7 @@ init_keywords(vector keywords)
 	install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names);
 	install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler);
 	install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio);
+	install_keyword("detect_checker", &hw_detect_checker_handler, &snprint_hw_detect_checker);
 	install_keyword("deferred_remove", &hw_deferred_remove_handler, &snprint_hw_deferred_remove);
 	install_keyword("delay_watch_checks", &hw_delay_watch_checks_handler, &snprint_hw_delay_watch_checks);
 	install_keyword("delay_wait_checks", &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks);
@@ -1512,6 +1521,7 @@ init_keywords(vector keywords)
 	install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names);
 	install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler);
 	install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio);
+	install_keyword("detect_checker", &ovr_detect_checker_handler, &snprint_ovr_detect_checker);
 	install_keyword("deferred_remove", &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);
 	install_keyword("delay_watch_checks", &ovr_delay_watch_checks_handler, &snprint_ovr_delay_watch_checks);
 	install_keyword("delay_wait_checks", &ovr_delay_wait_checks_handler, &snprint_ovr_delay_wait_checks);
libmultipath/discovery.c +1 -0
index d1aec31..f38ae3c 100644
@@ -1489,6 +1489,7 @@ get_state (struct path * pp, struct config *conf, int daemon)
 				return PATH_UNCHECKED;
 			}
 		}
+		select_detect_checker(conf, pp);
 		select_checker(conf, pp);
 		if (!checker_selected(c)) {
 			condlog(3, "%s: No checker selected", pp->dev);
libmultipath/hwtable.c +1 -0
index f5a5f7b..6e7c453 100644
@@ -1112,6 +1112,7 @@ static struct hwentry default_hw[] = {
 		.dev_loss      = 600,
 		.retain_hwhandler = RETAIN_HWHANDLER_ON,
 		.detect_prio   = DETECT_PRIO_ON,
+		.detect_checker = DETECT_CHECKER_ON,
 		.deferred_remove = DEFERRED_REMOVE_OFF,
 		.delay_watch_checks = DELAY_CHECKS_OFF,
 		.delay_wait_checks = DELAY_CHECKS_OFF,
libmultipath/propsel.c +49 -10

86 lines not on this page · raw message

libmultipath/propsel.h +1 -0
index ad98fa5..8bf3c6a 100644
@@ -19,6 +19,7 @@ int select_dev_loss(struct config *conf, struct multipath *mp);
 int select_reservation_key(struct config *conf, struct multipath *mp);
 int select_retain_hwhandler (struct config *conf, struct multipath * mp);
 int select_detect_prio(struct config *conf, struct path * pp);
+int select_detect_checker(struct config *conf, struct path * pp);
 int select_deferred_remove(struct config *conf, struct multipath *mp);
 int select_delay_watch_checks (struct config *conf, struct multipath * mp);
 int select_delay_wait_checks (struct config *conf, struct multipath * mp);
libmultipath/structs.h +7 -0
index 396f69d..99d5184 100644
@@ -121,6 +121,12 @@ enum detect_prio_states {
 	DETECT_PRIO_ON = YNU_YES,
 };
 
+enum detect_checker_states {
+	DETECT_CHECKER_UNDEF = YNU_UNDEF,
+	DETECT_CHECKER_OFF = YNU_NO,
+	DETECT_CHECKER_ON = YNU_YES,
+};
+
 enum deferred_remove_states {
 	DEFERRED_REMOVE_UNDEF = YNU_UNDEF,
 	DEFERRED_REMOVE_OFF = YNU_NO,
@@ -210,6 +216,7 @@ struct path {
 	int priority;
 	int pgindex;
 	int detect_prio;
+	int detect_checker;
 	int watch_checks;
 	int wait_checks;
 	int tpgs;
multipath/multipath.conf.5 +18 -0
index 36589f5..2eef4b0 100644
@@ -683,6 +683,20 @@ The default is: \fByes\fR
 .
 .
 .TP
+.B detect_checker
+if set to
+.I yes
+, multipath will try to detect if the device supports SCSI-3 ALUA. If so, the
+device will automatically use the \fItur\fR checker. If set to
+.I no
+, the checker will be selected as usual.
+.RS
+.TP
+The default is: \fByes\fR
+.RE
+.
+.
+.TP
 .B force_sync
 If set to
 .I yes
@@ -1126,6 +1140,8 @@ section:
 .TP
 .B detect_prio
 .TP
+.B detect_checker
+.TP
 .B deferred_remove
 .TP
 .B delay_watch_checks
@@ -1190,6 +1206,8 @@ the values are taken from the \fIdevices\fR or \fIdefaults\fR sections:
 .TP
 .B detect_prio
 .TP
+.B detect_checker
+.TP
 .B deferred_remove
 .TP
 .B delay_watch_checks
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH 2/7] libmultipath: add detect_checker option

Quoted 163 lines · Benjamin Marzinski

This patch adds a detect_checker option that works just like the detect_prio option. It currently only detects ALUA devices, and if it finds ALUA support, it sets the priortizier to TUR. This is useful for devices like the VNX2, where it should be using the TUR checker when in ALUA mode (or so I have been told). It is set on by default just like detect_prio and retain_attached_hw_handler.

---
 libmultipath/config.c      |  3 +++
 libmultipath/config.h      |  2 ++
 libmultipath/defaults.h    |  1 +
 libmultipath/dict.c        | 10 ++++++++
 libmultipath/discovery.c   |  1 +
 libmultipath/hwtable.c     |  1 +
 libmultipath/propsel.c     | 59 ++++++++++++++++++++++++++++++++++++++--------
 libmultipath/propsel.h     |  1 +
 libmultipath/structs.h     |  7 ++++++
 multipath/multipath.conf.5 | 18 ++++++++++++++
 10 files changed, 93 insertions(+), 10 deletions(-)
libmultipath/config.c +3 -0
index 15ddbd8..68a1692 100644
@@ -343,6 +343,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
 	merge_num(user_friendly_names);
 	merge_num(retain_hwhandler);
 	merge_num(detect_prio);
+	merge_num(detect_checker);
 	merge_num(deferred_remove);
 	merge_num(delay_watch_checks);
 	merge_num(delay_wait_checks);
@@ -420,6 +421,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe)
 	hwe->user_friendly_names = dhwe->user_friendly_names;
 	hwe->retain_hwhandler = dhwe->retain_hwhandler;
 	hwe->detect_prio = dhwe->detect_prio;
+	hwe->detect_checker = dhwe->detect_checker;
 
 	if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
 		goto out;
@@ -607,6 +609,7 @@ load_config (char * file)
 	conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
 	conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
 	conf->detect_prio = DEFAULT_DETECT_PRIO;
+	conf->detect_checker = DEFAULT_DETECT_CHECKER;
 	conf->force_sync = DEFAULT_FORCE_SYNC;
 	conf->partition_delim = DEFAULT_PARTITION_DELIM;
 	conf->processed_main_config = 0;
libmultipath/config.h +2 -0
index 9670020..4a785ca 100644
@@ -62,6 +62,7 @@ struct hwentry {
 	int user_friendly_names;
 	int retain_hwhandler;
 	int detect_prio;
+	int detect_checker;
 	int deferred_remove;
 	int delay_watch_checks;
 	int delay_wait_checks;
@@ -133,6 +134,7 @@ struct config {
 	int reassign_maps;
 	int retain_hwhandler;
 	int detect_prio;
+	int detect_checker;
 	int force_sync;
 	int deferred_remove;
 	int processed_main_config;
libmultipath/defaults.h +1 -0
index b9b0a37..1e5a527 100644
@@ -22,6 +22,7 @@
 #define DEFAULT_DEV_LOSS_TMO	600
 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_ON
 #define DEFAULT_DETECT_PRIO	DETECT_PRIO_ON
+#define DEFAULT_DETECT_CHECKER	DETECT_CHECKER_ON
 #define DEFAULT_DEFERRED_REMOVE	DEFERRED_REMOVE_OFF
 #define DEFAULT_DELAY_CHECKS	DELAY_CHECKS_OFF
 #define DEFAULT_UEVENT_STACKSIZE 256
libmultipath/dict.c +10 -0
index dc21846..53f78ea 100644
@@ -379,6 +379,13 @@ declare_ovr_snprint(detect_prio, print_yes_no_undef)
 declare_hw_handler(detect_prio, set_yes_no_undef)
 declare_hw_snprint(detect_prio, print_yes_no_undef)
 
+declare_def_handler(detect_checker, set_yes_no_undef)
+declare_def_snprint_defint(detect_checker, print_yes_no_undef, YNU_NO)
+declare_ovr_handler(detect_checker, set_yes_no_undef)
+declare_ovr_snprint(detect_checker, print_yes_no_undef)
+declare_hw_handler(detect_checker, set_yes_no_undef)
+declare_hw_snprint(detect_checker, print_yes_no_undef)
+
 declare_def_handler(force_sync, set_yes_no)
 declare_def_snprint(force_sync, print_yes_no)
 
@@ -1397,6 +1404,7 @@ init_keywords(vector keywords)
 	install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
 	install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler);
 	install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
+	install_keyword("detect_checker", &def_detect_checker_handler, &snprint_def_detect_checker);
 	install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);
 	install_keyword("strict_timing", &def_strict_timing_handler, &snprint_def_strict_timing);
 	install_keyword("deferred_remove", &def_deferred_remove_handler, &snprint_def_deferred_remove);
@@ -1483,6 +1491,7 @@ init_keywords(vector keywords)
 	install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names);
 	install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler);
 	install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio);
+	install_keyword("detect_checker", &hw_detect_checker_handler, &snprint_hw_detect_checker);
 	install_keyword("deferred_remove", &hw_deferred_remove_handler, &snprint_hw_deferred_remove);
 	install_keyword("delay_watch_checks", &hw_delay_watch_checks_handler, &snprint_hw_delay_watch_checks);
 	install_keyword("delay_wait_checks", &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks);
@@ -1512,6 +1521,7 @@ init_keywords(vector keywords)
 	install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names);
 	install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler);
 	install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio);
+	install_keyword("detect_checker", &ovr_detect_checker_handler, &snprint_ovr_detect_checker);
 	install_keyword("deferred_remove", &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);
 	install_keyword("delay_watch_checks", &ovr_delay_watch_checks_handler, &snprint_ovr_delay_watch_checks);
 	install_keyword("delay_wait_checks", &ovr_delay_wait_checks_handler, &snprint_ovr_delay_wait_checks);
libmultipath/discovery.c +1 -0
index d1aec31..f38ae3c 100644
@@ -1489,6 +1489,7 @@ get_state (struct path * pp, struct config *conf, int daemon)
 				return PATH_UNCHECKED;
 			}
 		}
+		select_detect_checker(conf, pp);
 		select_checker(conf, pp);
 		if (!checker_selected(c)) {
 			condlog(3, "%s: No checker selected", pp->dev);
libmultipath/hwtable.c +1 -0
index f5a5f7b..6e7c453 100644
@@ -1112,6 +1112,7 @@ static struct hwentry default_hw[] = {
 		.dev_loss      = 600,
 		.retain_hwhandler = RETAIN_HWHANDLER_ON,
 		.detect_prio   = DETECT_PRIO_ON,
+		.detect_checker = DETECT_CHECKER_ON,
 		.deferred_remove = DEFERRED_REMOVE_OFF,
 		.delay_watch_checks = DELAY_CHECKS_OFF,
 		.delay_wait_checks = DELAY_CHECKS_OFF,
libmultipath/propsel.c +8 -0
index c0bc616..546f735 100644
@@ -307,11 +307,44 @@ out:
 	return 0;
 }
 
+int
+detect_alua(struct config *conf, struct path * pp)
+{
+	int ret;
+	int tpgs = 0;
+	unsigned int timeout = conf->checker_timeout;
+
+	if ((tpgs = get_target_port_group_support(pp->fd, timeout)) <= 0)

libmultipath/propsel.c out: · line 327

Quoted 10 lines
libmultipath/propsel.c +10 -0
+		return 0;
+	pp->tpgs = tpgs;
+	ret = get_target_port_group(pp, timeout);
+	if (ret < 0)
+		return 0;
+	if (get_asymmetric_access_state(pp->fd, ret, timeout) < 0)
+		return 0;
+	return 1;
+}
+

Isn't it about time to move the ALUA detection into the path detection proper, and make it an additional attribute to struct path?

More and more things start to look for it, and it really feel stupid to do the ALUA detection over and over again.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
author maintainer
#4 lore raw

Re: [PATCH 2/7] libmultipath: add detect_checker option

Quoted 8 lines · Hannes Reinecke
Quoted 7 lines · Benjamin Marzinski

This patch adds a detect_checker option that works just like the detect_prio option. It currently only detects ALUA devices, and if it finds ALUA support, it sets the priortizier to TUR. This is useful for devices like the VNX2, where it should be using the TUR checker when in ALUA mode (or so I have been told). It is set on by default just like detect_prio and retain_attached_hw_handler.

Quoted 5 lines

Isn't it about time to move the ALUA detection into the path detection proper, and make it an additional attribute to struct path?

More and more things start to look for it, and it really feel stupid to do the ALUA detection over and over again.

Sure. I can change that.

-Ben

Quoted 10 lines

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
author maintainer
#5 lore raw

PATCH 3/7 libmultipath: cleanup orphan device states

In reply to Benjamin Marzinski

After a path device is orphaned, multipathd stops checking its state. However, multipathd show state still shows its old state. It should display "undef unknown" instead.

---
 libmultipath/print.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libmultipath/print.c +2 -2
index 5b03383..00a3626 100644
@@ -392,7 +392,7 @@ snprint_dev_t (char * buff, size_t len, struct path * pp)
 static int
 snprint_offline (char * buff, size_t len, struct path * pp)
 {
-	if (!pp)
+	if (!pp || !pp->mpp)
 		return snprintf(buff, len, "unknown");
 	else if (pp->offline)
 		return snprintf(buff, len, "offline");
@@ -403,7 +403,7 @@ snprint_offline (char * buff, size_t len, struct path * pp)
 static int
 snprint_chk_state (char * buff, size_t len, struct path * pp)
 {
-	if (!pp)
+	if (!pp || !pp->mpp)
 		return snprintf(buff, len, "undef");
 
 	switch (pp->state) {
Signature · 1 line
1.8.3.1
author maintainer
#6 lore raw

PATCH 4/7 multipathd: don't update priority of failed paths

In reply to Benjamin Marzinski

Multipathd shouldn't be updating the priority of failed paths in the checkerloop. The current avoids this in almost all cases, but not all. Close the loophole.

---
 multipathd/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
multipathd/main.c +2 -1
index adc3258..5480e96 100644
@@ -1457,7 +1457,8 @@ int update_prio(struct path *pp, int refresh_all)
 	}
 	oldpriority = pp->priority;
 	conf = get_multipath_config();
-	pathinfo(pp, conf, DI_PRIO);
+	if (pp->state != PATH_DOWN)
+		pathinfo(pp, conf, DI_PRIO);
 	put_multipath_config(conf);
 
 	if (pp->priority == oldpriority)
Signature · 1 line
1.8.3.1
author maintainer
#7 lore raw

PATCH 5/7 multipathd: add messages on delayed path addition

In reply to Benjamin Marzinski

When multipath delays adding a path because the device is waiting for udev to finish initialization, it now logs a message, so the users know what happened to the path.

---
 multipathd/main.c | 3 +++
 1 file changed, 3 insertions(+)
multipathd/main.c +3 -0
index 5480e96..33b7ad6 100644
@@ -485,6 +485,8 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)
 
 	if (mpp) {
 		if (mpp->wait_for_udev > 1) {
+			condlog(2, "%s: performing delayed actions",
+				mpp->alias);
 			if (update_map(mpp, vecs))
 				/* setup multipathd removed the map */
 				return 1;
@@ -719,6 +721,7 @@ ev_add_path (struct path * pp, struct vectors * vecs)
 	    (pathcount(mpp, PATH_UP) > 0 ||
 	     (pathcount(mpp, PATH_GHOST) > 0 && pp->tpgs != TPGS_IMPLICIT))) {
 		/* if wait_for_udev is set and valid paths exist */
+		condlog(2, "%s: delaying path addition until %s is fully initialized", pp->dev, mpp->alias);
 		mpp->wait_for_udev = 2;
 		orphan_path(pp, "waiting for create to complete");
 		return 0;
Signature · 1 line
1.8.3.1
author maintainer
#8 lore raw

PATCH 6/7 multipathd: allow resetting stats

In reply to Benjamin Marzinski

This patch adds two multipathd interactive commands:

multipathd reset maps stats

and

multipathd reset map <map> stats

to reset the statistics that are shown with the "show stats" commands.

---
 multipathd/cli.c          |  2 ++
 multipathd/cli_handlers.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 multipathd/cli_handlers.h |  2 ++
 multipathd/main.c         |  2 ++
 4 files changed, 50 insertions(+)
multipathd/cli.c +2 -0
index 50161be..32d4976 100644
@@ -547,6 +547,8 @@ cli_init (void) {
 	add_handler(LIST+BLACKLIST, NULL);
 	add_handler(LIST+DEVICES, NULL);
 	add_handler(LIST+WILDCARDS, NULL);
+	add_handler(RESET+MAPS+STATS, NULL);
+	add_handler(RESET+MAP+STATS, NULL);
 	add_handler(ADD+PATH, NULL);
 	add_handler(DEL+PATH, NULL);
 	add_handler(ADD+MAP, NULL);
multipathd/cli_handlers.c +44 -0

56 lines not on this page · raw message

multipathd/cli_handlers.h +2 -0
index 19e003d..f4d02cc 100644
@@ -19,6 +19,8 @@ int cli_list_config (void * v, char ** reply, int * len, void * data);
 int cli_list_blacklist (void * v, char ** reply, int * len, void * data);
 int cli_list_devices (void * v, char ** reply, int * len, void * data);
 int cli_list_wildcards (void * v, char ** reply, int * len, void * data);
+int cli_reset_maps_stats (void * v, char ** reply, int * len, void * data);
+int cli_reset_map_stats (void * v, char ** reply, int * len, void * data);
 int cli_add_path (void * v, char ** reply, int * len, void * data);
 int cli_del_path (void * v, char ** reply, int * len, void * data);
 int cli_add_map (void * v, char ** reply, int * len, void * data);
multipathd/main.c +2 -0
index 33b7ad6..aa6c72e 100644
@@ -1228,6 +1228,8 @@ uxlsnrloop (void * ap)
 	set_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
 	set_handler_callback(LIST+DEVICES, cli_list_devices);
 	set_handler_callback(LIST+WILDCARDS, cli_list_wildcards);
+	set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats);
+	set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats);
 	set_handler_callback(ADD+PATH, cli_add_path);
 	set_handler_callback(DEL+PATH, cli_del_path);
 	set_handler_callback(ADD+MAP, cli_add_map);
Signature · 1 line
1.8.3.1
author maintainer
#9 lore raw

PATCH 7/7 fix udev rules for failed multipath devices

In reply to Benjamin Marzinski

11-dm-mpath.rules was only correctly dealing with the case where the multipath device was unusable because the last path had failed. If instead, the last working path was removed from the device on a table reload, it was not correctly marking the device as unusable. One problem with fixing this is that when the device table is reloaded, device-mapper doesn't know if the path devices are usable or not. To deal with this, multipath now flags reloads with no usable paths with DM_SUBSYSTEM_UDEV_FLAG2.

11-dm-mpath.rules now checks for both PATH_FAILED events and reloads with no valid paths. and disables the other rules.

Cc Peter Rajnoha <[email protected]>
Cc Hannes Reinecke <[email protected]>
---
 libmultipath/devmapper.c    |  3 +-
 libmultipath/devmapper.h    |  6 ++++
 multipath/11-dm-mpath.rules | 69 +++++++++++++++++++++++++++++++--------------
 3 files changed, 56 insertions(+), 22 deletions(-)
libmultipath/devmapper.c +2 -1
index 4f8ef13..1b43c44 100644
@@ -373,7 +373,8 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush)
 	int r;
 	uint16_t udev_flags = (flush ? 0 : MPATH_UDEV_RELOAD_FLAG) |
 			      ((mpp->skip_kpartx == SKIP_KPARTX_ON)?
-			       MPATH_UDEV_NO_KPARTX_FLAG : 0);
+			       MPATH_UDEV_NO_KPARTX_FLAG : 0) |
+			      ((mpp->nr_active)? 0 : MPATH_UDEV_NO_PATHS_FLAG);
 
 	/*
 	 * DM_DEVICE_RELOAD cannot wait on a cookie, as
libmultipath/devmapper.h +6 -0
index 411177d..3ea4329 100644
@@ -18,6 +18,12 @@
 #define MPATH_UDEV_NO_KPARTX_FLAG 0
 #endif
 
+#ifdef DM_SUBSYSTEM_UDEV_FLAG2
+#define MPATH_UDEV_NO_PATHS_FLAG DM_SUBSYSTEM_UDEV_FLAG2
+#else
+#define MPATH_UDEV_NO_PATHS_FLAG 0
+#endif
+
 void dm_init(int verbosity);
 int dm_prereq (void);
 int dm_drv_version (unsigned int * version, char * str);
multipath/11-dm-mpath.rules +48 -21

87 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#10 lore raw

Re: [PATCH 7/7] fix udev rules for failed multipath devices

Quoted 15 lines · Benjamin Marzinski
multipath/11-dm-mpath.rules +7 -0
index 5559af3..b253433 100644
@@ -2,39 +2,66 @@ ACTION!="add|change", GOTO="mpath_end"
 ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end"
 ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end"
 
+IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
+IMPORT{db}="MPATH_DEVICE_READY"
+
+# If this uevent didn't come from dm, don't try to update the
+# device state
+ENV{DM_ACTIVATION}!="1", DM_ACTION!="?*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import"
+

...

multipath/11-dm-mpath.rules ACTION!="add|change", GOTO="mpath_end" · line 32

Quoted 4 lines
multipath/11-dm-mpath.rules +4 -0
+# This event is either a PATH_REINSTATED or a table reload where
+# there are active paths. Mark the device ready
+ENV{MPATH_DEVICE_READY}=""
+

If we're doing coldplug (the "udevadm trigger --action=add" or "echo add

Quoted 1 line

/sys/block/<devname>/uevent"), I think this will drop any existing

MPATH_DEVICE_READY="0" here. Thing is that the ENV{DM_ACTIVATION}="1" is also set for the coldplug case which generates spurious events, not only for uevents coming from DM directly.

What we can do though is that we can check for DM_COOKIE and DM_ACTION="PATH_*" variable existence in which case the uevent surely comes from DM/mpath driver directly from kernel, so we can rule out the coldplug case with spurious events.

Signature · 1 line
Peter
author maintainer
#11 lore raw

Re: [PATCH 7/7] fix udev rules for failed multipath devices

Quoted 26 lines · Peter Rajnoha
Quoted 15 lines · Benjamin Marzinski
multipath/11-dm-mpath.rules +7 -0
index 5559af3..b253433 100644
@@ -2,39 +2,66 @@ ACTION!="add|change", GOTO="mpath_end"
 ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end"
 ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end"
 
+IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
+IMPORT{db}="MPATH_DEVICE_READY"
+
+# If this uevent didn't come from dm, don't try to update the
+# device state
+ENV{DM_ACTIVATION}!="1", DM_ACTION!="?*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import"
+

...

multipath/11-dm-mpath.rules ACTION!="add|change", GOTO="mpath_end" · line 32

Quoted 4 lines
multipath/11-dm-mpath.rules +4 -0
+# This event is either a PATH_REINSTATED or a table reload where
+# there are active paths. Mark the device ready
+ENV{MPATH_DEVICE_READY}=""
+

If we're doing coldplug (the "udevadm trigger --action=add" or "echo add

Quoted 1 line

/sys/block/<devname>/uevent"), I think this will drop any existing

Quoted 8 lines

MPATH_DEVICE_READY="0" here. Thing is that the ENV{DM_ACTIVATION}="1" is also set for the coldplug case which generates spurious events, not only for uevents coming from DM directly.

What we can do though is that we can check for DM_COOKIE and DM_ACTION="PATH_*" variable existence in which case the uevent surely comes from DM/mpath driver directly from kernel, so we can rule out the coldplug case with spurious events.

You're right. I'll change this.

Thanks.
-Ben

Quoted 3 lines
Signature · 2 lines
-- 
Peter