Blame SOURCES/0191-RHBZ-1169168-disable-changed-paths.patch

4728c8
---
4728c8
 libmultipath/config.c      |    1 +
4728c8
 libmultipath/config.h      |    1 +
4728c8
 libmultipath/dict.c        |   33 +++++++++++++++++++++++++++++++++
4728c8
 libmultipath/discovery.c   |   11 ++++++-----
4728c8
 libmultipath/discovery.h   |    1 +
4728c8
 libmultipath/structs.h     |    1 +
4728c8
 multipath/multipath.conf.5 |    6 ++++++
4728c8
 multipathd/main.c          |   26 ++++++++++++++++++++++++++
4728c8
 8 files changed, 75 insertions(+), 5 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/discovery.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/discovery.c
4728c8
+++ multipath-tools-130222/libmultipath/discovery.c
4728c8
@@ -1155,8 +1155,8 @@ free_dev:
4728c8
 	return ret;
4728c8
 }
4728c8
 
4728c8
-static int
4728c8
-get_uid (struct path * pp)
4728c8
+int
4728c8
+get_uid (struct path * pp, struct udev_device *udev)
4728c8
 {
4728c8
 	char *c;
4728c8
 	const char *value;
4728c8
@@ -1165,7 +1165,7 @@ get_uid (struct path * pp)
4728c8
 	if (!pp->uid_attribute)
4728c8
 		select_getuid(pp);
4728c8
 
4728c8
-	if (!pp->udev) {
4728c8
+	if (!udev) {
4728c8
 		condlog(1, "%s: no udev information", pp->dev);
4728c8
 		return 1;
4728c8
 	}
4728c8
@@ -1180,7 +1180,7 @@ get_uid (struct path * pp)
4728c8
 			pp->tick = conf->retrigger_delay;
4728c8
 		}
4728c8
 	} else {
4728c8
-		value = udev_device_get_property_value(pp->udev,
4728c8
+		value = udev_device_get_property_value(udev,
4728c8
 						       pp->uid_attribute);
4728c8
 		if ((!value || strlen(value) == 0) &&
4728c8
 		     conf->cmd == CMD_VALID_PATH)
4728c8
@@ -1194,6 +1194,7 @@ get_uid (struct path * pp)
4728c8
 				len = strlen(value);
4728c8
 			}
4728c8
 			strncpy(pp->wwid, value, len);
4728c8
+			condlog(4, "%s: got wwid of '%s'", pp->dev, pp->wwid);
4728c8
 			pp->missing_udev_info = INFO_OK;
4728c8
 			pp->tick = 0;
4728c8
 		} else {
4728c8
@@ -1282,7 +1283,7 @@ pathinfo (struct path *pp, vector hwtabl
4728c8
 	}
4728c8
 
4728c8
 	if ((mask & DI_WWID) && !strlen(pp->wwid))
4728c8
-		get_uid(pp);
4728c8
+		get_uid(pp, pp->udev);
4728c8
 	if (mask & DI_BLACKLIST && mask & DI_WWID) {
4728c8
 		if (filter_wwid(conf->blist_wwid, conf->elist_wwid,
4728c8
 				pp->wwid) > 0) {
4728c8
Index: multipath-tools-130222/libmultipath/discovery.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/discovery.h
4728c8
+++ multipath-tools-130222/libmultipath/discovery.h
4728c8
@@ -44,6 +44,7 @@ int sysfs_set_scsi_tmo (struct multipath
4728c8
 int sysfs_get_timeout(struct path *pp, unsigned int *timeout);
4728c8
 int sysfs_get_host_pci_name(struct path *pp, char *pci_name);
4728c8
 int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address);
4728c8
+int get_uid (struct path * pp, struct udev_device *udev);
4728c8
 
4728c8
 /*
4728c8
  * discovery bitmask
4728c8
Index: multipath-tools-130222/libmultipath/structs.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/structs.h
4728c8
+++ multipath-tools-130222/libmultipath/structs.h
4728c8
@@ -209,6 +209,7 @@ struct path {
4728c8
 	int fd;
4728c8
 	int missing_udev_info;
4728c8
 	int retriggers;
4728c8
+	int wwid_changed;
4728c8
 
4728c8
 	/* configlet pointers */
4728c8
 	struct hwentry * hwe;
4728c8
Index: multipath-tools-130222/multipathd/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipathd/main.c
4728c8
+++ multipath-tools-130222/multipathd/main.c
4728c8
@@ -784,6 +784,26 @@ uev_update_path (struct uevent *uev, str
4728c8
 	if (pp->missing_udev_info == INFO_REQUESTED)
4728c8
 		return uev_add_path(uev, vecs);
4728c8
 
4728c8
+	if (conf->disable_changed_wwids &&
4728c8
+	    (strlen(pp->wwid) || pp->wwid_changed)) {
4728c8
+		char wwid[WWID_SIZE];
4728c8
+
4728c8
+		strcpy(wwid, pp->wwid);
4728c8
+		get_uid(pp, uev->udev);
4728c8
+		if (strcmp(wwid, pp->wwid) != 0) {
4728c8
+			condlog(0, "%s: path wwid changed from '%s' to '%s'. disallowing", uev->kernel, wwid, pp->wwid);
4728c8
+			strcpy(pp->wwid, wwid);
4728c8
+			if (!pp->wwid_changed) {
4728c8
+				pp->wwid_changed = 1;
4728c8
+				pp->tick = 1;
4728c8
+				dm_fail_path(pp->mpp->alias, pp->dev_t);
4728c8
+			}
4728c8
+		}
4728c8
+		else {
4728c8
+			pp->wwid_changed = 0;
4728c8
+		}
4728c8
+	}
4728c8
+
4728c8
 	/* reinit the prio values on change event, in case something is
4728c8
 	 * different */
4728c8
 	prio_init(&pp->prio);
4728c8
@@ -1284,6 +1304,12 @@ check_path (struct vectors * vecs, struc
4728c8
 	else
4728c8
 		checker_clear_message(&pp->checker);
4728c8
 
4728c8
+	if (pp->wwid_changed) {
4728c8
+		condlog(2, "%s: path wwid has changed. Refusing to use",
4728c8
+			pp->dev);
4728c8
+		newstate = PATH_DOWN;
4728c8
+	}
4728c8
+
4728c8
 	if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) {
4728c8
 		condlog(2, "%s: unusable path", pp->dev);
4728c8
 		pathinfo(pp, conf->hwtable, 0);
4728c8
Index: multipath-tools-130222/libmultipath/config.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.c
4728c8
+++ multipath-tools-130222/libmultipath/config.c
4728c8
@@ -681,6 +681,7 @@ load_config (char * file, struct udev *u
4728c8
 	conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
4728c8
 	conf->skip_kpartx = DEFAULT_SKIP_KPARTX;
4728c8
 	conf->remove_retries = 0;
4728c8
+	conf->disable_changed_wwids = 0;
4728c8
 
4728c8
 	/*
4728c8
 	 * preload default hwtable
4728c8
Index: multipath-tools-130222/libmultipath/config.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.h
4728c8
+++ multipath-tools-130222/libmultipath/config.h
4728c8
@@ -147,6 +147,7 @@ struct config {
4728c8
 	int uev_wait_timeout;
4728c8
 	int skip_kpartx;
4728c8
 	int remove_retries;
4728c8
+	int disable_changed_wwids;
4728c8
 	unsigned int version[3];
4728c8
 
4728c8
 	char * dev;
4728c8
Index: multipath-tools-130222/libmultipath/dict.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/dict.c
4728c8
+++ multipath-tools-130222/libmultipath/dict.c
4728c8
@@ -953,6 +953,29 @@ def_remove_retries_handler(vector strvec
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+static int
4728c8
+def_disable_changed_wwids_handler(vector strvec)
4728c8
+{
4728c8
+	char * buff;
4728c8
+
4728c8
+	buff = set_value(strvec);
4728c8
+
4728c8
+	if (!buff)
4728c8
+		return 1;
4728c8
+
4728c8
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4728c8
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
4728c8
+		conf->disable_changed_wwids = 0;
4728c8
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4728c8
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
4728c8
+		conf->disable_changed_wwids = 1;
4728c8
+	else
4728c8
+		conf->disable_changed_wwids = 0;
4728c8
+
4728c8
+	FREE(buff);
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 /*
4728c8
  * blacklist block handlers
4728c8
  */
4728c8
@@ -3429,6 +3452,15 @@ snprint_def_remove_retries (char * buff,
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
+snprint_def_disable_changed_wwids(char * buff, int len, void * data)
4728c8
+{
4728c8
+	if (conf->disable_changed_wwids == 1)
4728c8
+		return snprintf(buff, len, "yes");
4728c8
+	else
4728c8
+		return snprintf(buff, len, "no");
4728c8
+}
4728c8
+
4728c8
+static int
4728c8
 snprint_ble_simple (char * buff, int len, void * data)
4728c8
 {
4728c8
 	struct blentry * ble = (struct blentry *)data;
4728c8
@@ -3508,6 +3540,7 @@ init_keywords(void)
4728c8
 	install_keyword("missing_uev_wait_timeout", &def_uev_wait_timeout_handler, &snprint_def_uev_wait_timeout);
4728c8
 	install_keyword("new_bindings_in_boot", &def_new_bindings_in_boot_handler, &snprint_def_new_bindings_in_boot);
4728c8
 	install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries);
4728c8
+	install_keyword("disable_changed_wwids", &def_disable_changed_wwids_handler, &snprint_def_disable_changed_wwids);
4728c8
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
4728c8
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
4728c8
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
4728c8
Index: multipath-tools-130222/multipath/multipath.conf.5
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipath/multipath.conf.5
4728c8
+++ multipath-tools-130222/multipath/multipath.conf.5
4728c8
@@ -557,6 +557,12 @@ regular filesystem, the device will be r
4728c8
 default is
4728c8
 .I no
4728c8
 .TP
4728c8
+.B disable_changed_wwids
4728c8
+If set to \fIyes\fR, multipathd will check the path wwid on change events, and
4728c8
+if it has changed from the wwid of the multipath device, multipathd will
4728c8
+disable access to the path until the wwid changes back. The default is
4728c8
+.I no
4728c8
+.TP
4728c8
 .B remove_retries
4728c8
 This sets how may times multipath will retry removing a device that is in-use.
4728c8
 Between each attempt, multipath will sleep 1 second. The default is