|
|
50e627 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
50e627 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
50e627 |
Date: Wed, 24 Feb 2021 00:33:22 -0600
|
|
|
50e627 |
Subject: [PATCH] multipathd: add recheck_wwid option to verify the path wwid
|
|
|
50e627 |
|
|
|
50e627 |
There are cases where the wwid of a path changes due to LUN remapping
|
|
|
50e627 |
without triggering uevent for the changed path. Multipathd has no method
|
|
|
50e627 |
for trying to catch these cases, and corruption has resulted because of
|
|
|
50e627 |
it.
|
|
|
50e627 |
|
|
|
50e627 |
In order to have a better chance at catching these cases, multipath now
|
|
|
50e627 |
has a recheck_wwid option. If this is set to "yes", when a failed path
|
|
|
50e627 |
has become active again, multipathd will recheck its wwid. If multipathd
|
|
|
50e627 |
notices that a path's wwid has changed, it will remove and re-add the
|
|
|
50e627 |
path, just like the existing wwid checking code for change events does.
|
|
|
50e627 |
In cases where the no uevent occurs, both the udev database entry and
|
|
|
50e627 |
sysfs will have the old wwid, so the only way to get a current wwid is
|
|
|
50e627 |
to ask the device directly. Currently multipath only has code to
|
|
|
50e627 |
directly get the wwid for scsi devices, so this option only effects scsi
|
|
|
50e627 |
devices, and they must be configured to be able to use the uid_fallback
|
|
|
50e627 |
methods. To make sure both the sysfs and udev database values are
|
|
|
50e627 |
updated, multipathd triggers a both a rescan of the device and a udev
|
|
|
50e627 |
add event.
|
|
|
50e627 |
|
|
|
50e627 |
Co-developed-by: Chongyun Wu <wucy11@chinatelecom.cn>
|
|
|
50e627 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
50e627 |
Reviewed-by: Martin Wilck <mwilck@suse.com>Reviewed-by: Martin Wilck <mwilck@suse.com>
|
|
|
50e627 |
---
|
|
|
50e627 |
libmultipath/config.c | 2 +
|
|
|
50e627 |
libmultipath/config.h | 2 +
|
|
|
50e627 |
libmultipath/configure.c | 4 +-
|
|
|
50e627 |
libmultipath/configure.h | 2 +
|
|
|
50e627 |
libmultipath/defaults.h | 1 +
|
|
|
50e627 |
libmultipath/dict.c | 11 ++++++
|
|
|
50e627 |
libmultipath/discovery.c | 3 +-
|
|
|
50e627 |
libmultipath/discovery.h | 1 +
|
|
|
50e627 |
libmultipath/propsel.c | 21 ++++++++++
|
|
|
50e627 |
libmultipath/propsel.h | 1 +
|
|
|
50e627 |
libmultipath/structs.h | 7 ++++
|
|
|
50e627 |
multipath/multipath.conf.5 | 14 +++++++
|
|
|
50e627 |
multipathd/cli_handlers.c | 9 +++++
|
|
|
50e627 |
multipathd/main.c | 78 ++++++++++++++++++++++++++++++++++++++
|
|
|
50e627 |
multipathd/main.h | 2 +
|
|
|
50e627 |
15 files changed, 155 insertions(+), 3 deletions(-)
|
|
|
50e627 |
|
|
|
50e627 |
diff --git a/libmultipath/config.c b/libmultipath/config.c
|
|
|
50e627 |
index dd645f17..abbddaf1 100644
|
|
|
50e627 |
--- a/libmultipath/config.c
|
|
|
50e627 |
+++ b/libmultipath/config.c
|
|
|
50e627 |
@@ -371,6 +371,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
|
|
|
50e627 |
merge_num(max_sectors_kb);
|
|
|
50e627 |
merge_num(ghost_delay);
|
|
|
50e627 |
merge_num(all_tg_pt);
|
|
|
50e627 |
+ merge_num(recheck_wwid);
|
|
|
50e627 |
merge_num(vpd_vendor_id);
|
|
|
50e627 |
merge_num(san_path_err_threshold);
|
|
|
50e627 |
merge_num(san_path_err_forget_rate);
|
|
|
50e627 |
@@ -762,6 +763,7 @@ load_config (char * file)
|
|
|
50e627 |
conf->remove_retries = 0;
|
|
|
50e627 |
conf->ghost_delay = DEFAULT_GHOST_DELAY;
|
|
|
50e627 |
conf->all_tg_pt = DEFAULT_ALL_TG_PT;
|
|
|
50e627 |
+ conf->recheck_wwid = DEFAULT_RECHECK_WWID;
|
|
|
50e627 |
/*
|
|
|
50e627 |
* preload default hwtable
|
|
|
50e627 |
*/
|
|
|
50e627 |
diff --git a/libmultipath/config.h b/libmultipath/config.h
|
|
|
50e627 |
index a22c1b4e..e2e3f143 100644
|
|
|
50e627 |
--- a/libmultipath/config.h
|
|
|
50e627 |
+++ b/libmultipath/config.h
|
|
|
50e627 |
@@ -84,6 +84,7 @@ struct hwentry {
|
|
|
50e627 |
int ghost_delay;
|
|
|
50e627 |
int all_tg_pt;
|
|
|
50e627 |
int vpd_vendor_id;
|
|
|
50e627 |
+ int recheck_wwid;
|
|
|
50e627 |
char * bl_product;
|
|
|
50e627 |
};
|
|
|
50e627 |
|
|
|
50e627 |
@@ -188,6 +189,7 @@ struct config {
|
|
|
50e627 |
int skip_delegate;
|
|
|
50e627 |
unsigned int version[3];
|
|
|
50e627 |
unsigned int sequence_nr;
|
|
|
50e627 |
+ int recheck_wwid;
|
|
|
50e627 |
|
|
|
50e627 |
char * multipath_dir;
|
|
|
50e627 |
char * selector;
|
|
|
50e627 |
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
|
|
|
50e627 |
index a6893d8d..f24d9283 100644
|
|
|
50e627 |
--- a/libmultipath/configure.c
|
|
|
50e627 |
+++ b/libmultipath/configure.c
|
|
|
50e627 |
@@ -506,8 +506,8 @@ trigger_udev_change(const struct multipath *mpp)
|
|
|
50e627 |
udev_device_unref(udd);
|
|
|
50e627 |
}
|
|
|
50e627 |
|
|
|
50e627 |
-static void trigger_partitions_udev_change(struct udev_device *dev,
|
|
|
50e627 |
- const char *action, int len)
|
|
|
50e627 |
+void trigger_partitions_udev_change(struct udev_device *dev,
|
|
|
50e627 |
+ const char *action, int len)
|
|
|
50e627 |
{
|
|
|
50e627 |
struct udev_enumerate *part_enum;
|
|
|
50e627 |
struct udev_list_entry *item;
|
|
|
50e627 |
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
|
|
|
50e627 |
index 0e33bf40..81090dd4 100644
|
|
|
50e627 |
--- a/libmultipath/configure.h
|
|
|
50e627 |
+++ b/libmultipath/configure.h
|
|
|
50e627 |
@@ -57,3 +57,5 @@ int get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
|
|
|
50e627 |
int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon);
|
|
|
50e627 |
struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
|
|
|
50e627 |
void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath);
|
|
|
50e627 |
+void trigger_partitions_udev_change(struct udev_device *dev, const char *action,
|
|
|
50e627 |
+ int len);
|
|
|
50e627 |
diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
|
|
|
50e627 |
index 52fe05b9..f1cb000d 100644
|
|
|
50e627 |
--- a/libmultipath/defaults.h
|
|
|
50e627 |
+++ b/libmultipath/defaults.h
|
|
|
50e627 |
@@ -50,6 +50,7 @@
|
|
|
50e627 |
#define DEFAULT_FIND_MULTIPATHS_TIMEOUT -10
|
|
|
50e627 |
#define DEFAULT_UNKNOWN_FIND_MULTIPATHS_TIMEOUT 1
|
|
|
50e627 |
#define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF
|
|
|
50e627 |
+#define DEFAULT_RECHECK_WWID RECHECK_WWID_OFF
|
|
|
50e627 |
/* Enable all foreign libraries by default */
|
|
|
50e627 |
#define DEFAULT_ENABLE_FOREIGN ""
|
|
|
50e627 |
|
|
|
50e627 |
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
|
|
|
50e627 |
index 8fd91d8c..13698b76 100644
|
|
|
50e627 |
--- a/libmultipath/dict.c
|
|
|
50e627 |
+++ b/libmultipath/dict.c
|
|
|
50e627 |
@@ -1413,6 +1413,14 @@ declare_hw_snprint(all_tg_pt, print_yes_no_undef)
|
|
|
50e627 |
declare_def_handler(marginal_pathgroups, set_yes_no)
|
|
|
50e627 |
declare_def_snprint(marginal_pathgroups, print_yes_no)
|
|
|
50e627 |
|
|
|
50e627 |
+declare_def_handler(recheck_wwid, set_yes_no_undef)
|
|
|
50e627 |
+declare_def_snprint_defint(recheck_wwid, print_yes_no_undef, DEFAULT_RECHECK_WWID)
|
|
|
50e627 |
+declare_ovr_handler(recheck_wwid, set_yes_no_undef)
|
|
|
50e627 |
+declare_ovr_snprint(recheck_wwid, print_yes_no_undef)
|
|
|
50e627 |
+declare_hw_handler(recheck_wwid, set_yes_no_undef)
|
|
|
50e627 |
+declare_hw_snprint(recheck_wwid, print_yes_no_undef)
|
|
|
50e627 |
+
|
|
|
50e627 |
+
|
|
|
50e627 |
static int
|
|
|
50e627 |
def_uxsock_timeout_handler(struct config *conf, vector strvec)
|
|
|
50e627 |
{
|
|
|
50e627 |
@@ -1824,6 +1832,7 @@ init_keywords(vector keywords)
|
|
|
50e627 |
install_keyword("enable_foreign", &def_enable_foreign_handler,
|
|
|
50e627 |
&snprint_def_enable_foreign);
|
|
|
50e627 |
install_keyword("marginal_pathgroups", &def_marginal_pathgroups_handler, &snprint_def_marginal_pathgroups);
|
|
|
50e627 |
+ install_keyword("recheck_wwid", &def_recheck_wwid_handler, &snprint_def_recheck_wwid);
|
|
|
50e627 |
__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
|
|
|
50e627 |
__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
|
|
|
50e627 |
__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
|
|
|
50e627 |
@@ -1913,6 +1922,7 @@ init_keywords(vector keywords)
|
|
|
50e627 |
install_keyword("ghost_delay", &hw_ghost_delay_handler, &snprint_hw_ghost_delay);
|
|
|
50e627 |
install_keyword("all_tg_pt", &hw_all_tg_pt_handler, &snprint_hw_all_tg_pt);
|
|
|
50e627 |
install_keyword("vpd_vendor", &hw_vpd_vendor_handler, &snprint_hw_vpd_vendor);
|
|
|
50e627 |
+ install_keyword("recheck_wwid", &hw_recheck_wwid_handler, &snprint_hw_recheck_wwid);
|
|
|
50e627 |
install_sublevel_end();
|
|
|
50e627 |
|
|
|
50e627 |
install_keyword_root("overrides", &overrides_handler);
|
|
|
50e627 |
@@ -1954,6 +1964,7 @@ init_keywords(vector keywords)
|
|
|
50e627 |
install_keyword("max_sectors_kb", &ovr_max_sectors_kb_handler, &snprint_ovr_max_sectors_kb);
|
|
|
50e627 |
install_keyword("ghost_delay", &ovr_ghost_delay_handler, &snprint_ovr_ghost_delay);
|
|
|
50e627 |
install_keyword("all_tg_pt", &ovr_all_tg_pt_handler, &snprint_ovr_all_tg_pt);
|
|
|
50e627 |
+ install_keyword("recheck_wwid", &ovr_recheck_wwid_handler, &snprint_ovr_recheck_wwid);
|
|
|
50e627 |
|
|
|
50e627 |
install_keyword_root("multipaths", &multipaths_handler);
|
|
|
50e627 |
install_keyword_multi("multipath", &multipath_handler, NULL);
|
|
|
50e627 |
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
|
|
50e627 |
index 126a70b3..bc267609 100644
|
|
|
50e627 |
--- a/libmultipath/discovery.c
|
|
|
50e627 |
+++ b/libmultipath/discovery.c
|
|
|
50e627 |
@@ -2040,7 +2040,7 @@ static ssize_t uid_fallback(struct path *pp, int path_state,
|
|
|
50e627 |
return len;
|
|
|
50e627 |
}
|
|
|
50e627 |
|
|
|
50e627 |
-static bool has_uid_fallback(struct path *pp)
|
|
|
50e627 |
+bool has_uid_fallback(struct path *pp)
|
|
|
50e627 |
{
|
|
|
50e627 |
/*
|
|
|
50e627 |
* Falling back to direct WWID determination is dangerous
|
|
|
50e627 |
@@ -2072,6 +2072,7 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev,
|
|
|
50e627 |
conf = get_multipath_config();
|
|
|
50e627 |
pthread_cleanup_push(put_multipath_config, conf);
|
|
|
50e627 |
select_getuid(conf, pp);
|
|
|
50e627 |
+ select_recheck_wwid(conf, pp);
|
|
|
50e627 |
pthread_cleanup_pop(1);
|
|
|
50e627 |
}
|
|
|
50e627 |
|
|
|
50e627 |
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
|
|
|
50e627 |
index d3193daf..a5446b4d 100644
|
|
|
50e627 |
--- a/libmultipath/discovery.h
|
|
|
50e627 |
+++ b/libmultipath/discovery.h
|
|
|
50e627 |
@@ -54,6 +54,7 @@ ssize_t sysfs_get_inquiry(struct udev_device *udev,
|
|
|
50e627 |
unsigned char *buff, size_t len);
|
|
|
50e627 |
int sysfs_get_asymmetric_access_state(struct path *pp,
|
|
|
50e627 |
char *buff, int buflen);
|
|
|
50e627 |
+bool has_uid_fallback(struct path *pp);
|
|
|
50e627 |
int get_uid(struct path * pp, int path_state, struct udev_device *udev,
|
|
|
50e627 |
int allow_fallback);
|
|
|
50e627 |
bool is_vpd_page_supported(int fd, int pg);
|
|
|
50e627 |
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
|
|
|
50e627 |
index 1150cfe8..127b3370 100644
|
|
|
50e627 |
--- a/libmultipath/propsel.c
|
|
|
50e627 |
+++ b/libmultipath/propsel.c
|
|
|
50e627 |
@@ -581,6 +581,27 @@ out:
|
|
|
50e627 |
return 0;
|
|
|
50e627 |
}
|
|
|
50e627 |
|
|
|
50e627 |
+/* must be called after select_getuid */
|
|
|
50e627 |
+int select_recheck_wwid(struct config *conf, struct path * pp)
|
|
|
50e627 |
+{
|
|
|
50e627 |
+ const char *origin;
|
|
|
50e627 |
+
|
|
|
50e627 |
+ pp_set_ovr(recheck_wwid);
|
|
|
50e627 |
+ pp_set_hwe(recheck_wwid);
|
|
|
50e627 |
+ pp_set_conf(recheck_wwid);
|
|
|
50e627 |
+ pp_set_default(recheck_wwid, DEFAULT_RECHECK_WWID);
|
|
|
50e627 |
+out:
|
|
|
50e627 |
+ if (pp->recheck_wwid == RECHECK_WWID_ON &&
|
|
|
50e627 |
+ (pp->bus != SYSFS_BUS_SCSI || pp->getuid != NULL ||
|
|
|
50e627 |
+ !has_uid_fallback(pp))) {
|
|
|
50e627 |
+ pp->recheck_wwid = RECHECK_WWID_OFF;
|
|
|
50e627 |
+ origin = "(setting: unsupported by device type/config)";
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+ condlog(3, "%s: recheck_wwid = %i %s", pp->dev, pp->recheck_wwid,
|
|
|
50e627 |
+ origin);
|
|
|
50e627 |
+ return 0;
|
|
|
50e627 |
+}
|
|
|
50e627 |
+
|
|
|
50e627 |
void
|
|
|
50e627 |
detect_prio(struct config *conf, struct path * pp)
|
|
|
50e627 |
{
|
|
|
50e627 |
diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h
|
|
|
50e627 |
index a68bacf0..72a7e33c 100644
|
|
|
50e627 |
--- a/libmultipath/propsel.h
|
|
|
50e627 |
+++ b/libmultipath/propsel.h
|
|
|
50e627 |
@@ -7,6 +7,7 @@ int select_features (struct config *conf, struct multipath * mp);
|
|
|
50e627 |
int select_hwhandler (struct config *conf, struct multipath * mp);
|
|
|
50e627 |
int select_checker(struct config *conf, struct path *pp);
|
|
|
50e627 |
int select_getuid (struct config *conf, struct path * pp);
|
|
|
50e627 |
+int select_recheck_wwid(struct config *conf, struct path * pp);
|
|
|
50e627 |
int select_prio (struct config *conf, struct path * pp);
|
|
|
50e627 |
int select_find_multipaths_timeout(struct config *conf, struct path *pp);
|
|
|
50e627 |
int select_no_path_retry(struct config *conf, struct multipath *mp);
|
|
|
50e627 |
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
|
|
|
50e627 |
index 65542dea..a5dbad5b 100644
|
|
|
50e627 |
--- a/libmultipath/structs.h
|
|
|
50e627 |
+++ b/libmultipath/structs.h
|
|
|
50e627 |
@@ -252,6 +252,12 @@ enum eh_deadline_states {
|
|
|
50e627 |
EH_DEADLINE_ZERO = UOZ_ZERO,
|
|
|
50e627 |
};
|
|
|
50e627 |
|
|
|
50e627 |
+enum recheck_wwid_states {
|
|
|
50e627 |
+ RECHECK_WWID_UNDEF = YNU_UNDEF,
|
|
|
50e627 |
+ RECHECK_WWID_OFF = YNU_NO,
|
|
|
50e627 |
+ RECHECK_WWID_ON = YNU_YES,
|
|
|
50e627 |
+};
|
|
|
50e627 |
+
|
|
|
50e627 |
struct vpd_vendor_page {
|
|
|
50e627 |
int pg;
|
|
|
50e627 |
const char *name;
|
|
|
50e627 |
@@ -326,6 +332,7 @@ struct path {
|
|
|
50e627 |
int find_multipaths_timeout;
|
|
|
50e627 |
int marginal;
|
|
|
50e627 |
int vpd_vendor_id;
|
|
|
50e627 |
+ int recheck_wwid;
|
|
|
50e627 |
/* configlet pointers */
|
|
|
50e627 |
vector hwe;
|
|
|
50e627 |
struct gen_path generic_path;
|
|
|
50e627 |
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
|
|
|
50e627 |
index a5686090..6da15aad 100644
|
|
|
50e627 |
--- a/multipath/multipath.conf.5
|
|
|
50e627 |
+++ b/multipath/multipath.conf.5
|
|
|
50e627 |
@@ -1256,6 +1256,20 @@ The default is: \fB\(dq\(dq\fR (the empty regular expression)
|
|
|
50e627 |
.RE
|
|
|
50e627 |
.
|
|
|
50e627 |
.
|
|
|
50e627 |
+.TP
|
|
|
50e627 |
+.B recheck_wwid
|
|
|
50e627 |
+If set to \fIyes\fR, when a failed path is restored, its wwid is rechecked. If
|
|
|
50e627 |
+the wwid has changed, the path is removed from the current multipath device,
|
|
|
50e627 |
+and re-added as a new path. Multipathd will also recheck a path's wwid if it is
|
|
|
50e627 |
+manually re-added. This option only works for SCSI devices that are configured
|
|
|
50e627 |
+to use the default uid_attribute, \fIID_SERIAL\fR, or sysfs for getting their
|
|
|
50e627 |
+wwid.
|
|
|
50e627 |
+.RS
|
|
|
50e627 |
+.TP
|
|
|
50e627 |
+The default is \fBno\fR
|
|
|
50e627 |
+.RE
|
|
|
50e627 |
+.
|
|
|
50e627 |
+.
|
|
|
50e627 |
|
|
|
50e627 |
.
|
|
|
50e627 |
.\" ----------------------------------------------------------------------------
|
|
|
50e627 |
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
|
|
|
50e627 |
index 782bb003..8b4bd187 100644
|
|
|
50e627 |
--- a/multipathd/cli_handlers.c
|
|
|
50e627 |
+++ b/multipathd/cli_handlers.c
|
|
|
50e627 |
@@ -715,6 +715,15 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
|
|
|
50e627 |
pp = find_path_by_dev(vecs->pathvec, param);
|
|
|
50e627 |
if (pp) {
|
|
|
50e627 |
condlog(2, "%s: path already in pathvec", param);
|
|
|
50e627 |
+
|
|
|
50e627 |
+ if (pp->recheck_wwid == RECHECK_WWID_ON &&
|
|
|
50e627 |
+ check_path_wwid_change(pp)) {
|
|
|
50e627 |
+ condlog(0, "%s: wwid changed. Removing device",
|
|
|
50e627 |
+ pp->dev);
|
|
|
50e627 |
+ handle_path_wwid_change(pp, vecs);
|
|
|
50e627 |
+ return 1;
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+
|
|
|
50e627 |
if (pp->mpp)
|
|
|
50e627 |
return 0;
|
|
|
50e627 |
} else {
|
|
|
50e627 |
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
|
50e627 |
index cc1aeea2..1fbc31eb 100644
|
|
|
50e627 |
--- a/multipathd/main.c
|
|
|
50e627 |
+++ b/multipathd/main.c
|
|
|
50e627 |
@@ -822,6 +822,73 @@ ev_remove_map (char * devname, char * alias, int minor, struct vectors * vecs)
|
|
|
50e627 |
return flush_map(mpp, vecs, 0);
|
|
|
50e627 |
}
|
|
|
50e627 |
|
|
|
50e627 |
+static void
|
|
|
50e627 |
+rescan_path(struct udev_device *parent)
|
|
|
50e627 |
+{
|
|
|
50e627 |
+ while(parent) {
|
|
|
50e627 |
+ const char *subsys = udev_device_get_subsystem(parent);
|
|
|
50e627 |
+ if (subsys && !strncmp(subsys, "scsi", 4))
|
|
|
50e627 |
+ break;
|
|
|
50e627 |
+ parent = udev_device_get_parent(parent);
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+ if (parent)
|
|
|
50e627 |
+ sysfs_attr_set_value(parent, "rescan", "1", strlen("1"));
|
|
|
50e627 |
+}
|
|
|
50e627 |
+
|
|
|
50e627 |
+void
|
|
|
50e627 |
+handle_path_wwid_change(struct path *pp, struct vectors *vecs)
|
|
|
50e627 |
+{
|
|
|
50e627 |
+ struct udev_device *udd;
|
|
|
50e627 |
+
|
|
|
50e627 |
+ if (!pp || !pp->udev)
|
|
|
50e627 |
+ return;
|
|
|
50e627 |
+
|
|
|
50e627 |
+ udd = udev_device_ref(pp->udev);
|
|
|
50e627 |
+ if (ev_remove_path(pp, vecs, 1) != 0 && pp->mpp) {
|
|
|
50e627 |
+ pp->dmstate = PSTATE_FAILED;
|
|
|
50e627 |
+ dm_fail_path(pp->mpp->alias, pp->dev_t);
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+ rescan_path(udd);
|
|
|
50e627 |
+ sysfs_attr_set_value(udd, "uevent", "add", strlen("add"));
|
|
|
50e627 |
+ trigger_partitions_udev_change(udd, "add", strlen("add"));
|
|
|
50e627 |
+ udev_device_unref(udd);
|
|
|
50e627 |
+}
|
|
|
50e627 |
+
|
|
|
50e627 |
+bool
|
|
|
50e627 |
+check_path_wwid_change(struct path *pp)
|
|
|
50e627 |
+{
|
|
|
50e627 |
+ char wwid[WWID_SIZE];
|
|
|
50e627 |
+ int len = 0;
|
|
|
50e627 |
+ size_t i;
|
|
|
50e627 |
+
|
|
|
50e627 |
+ if (!strlen(pp->wwid))
|
|
|
50e627 |
+ return false;
|
|
|
50e627 |
+
|
|
|
50e627 |
+ /* Get the real fresh device wwid by sgio. sysfs still has old
|
|
|
50e627 |
+ * data, so only get_vpd_sgio will work to get the new wwid */
|
|
|
50e627 |
+ len = get_vpd_sgio(pp->fd, 0x83, 0, wwid, WWID_SIZE);
|
|
|
50e627 |
+
|
|
|
50e627 |
+ if (len <= 0) {
|
|
|
50e627 |
+ condlog(2, "%s: failed to check wwid by sgio: len = %d",
|
|
|
50e627 |
+ pp->dev, len);
|
|
|
50e627 |
+ return false;
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+
|
|
|
50e627 |
+ /*Strip any trailing blanks */
|
|
|
50e627 |
+ for (i = strlen(pp->wwid); i > 0 && pp->wwid[i-1] == ' '; i--);
|
|
|
50e627 |
+ /* no-op */
|
|
|
50e627 |
+ pp->wwid[i] = '\0';
|
|
|
50e627 |
+ condlog(4, "%s: Got wwid %s by sgio", pp->dev, wwid);
|
|
|
50e627 |
+
|
|
|
50e627 |
+ if (strncmp(wwid, pp->wwid, WWID_SIZE)) {
|
|
|
50e627 |
+ condlog(0, "%s: wwid '%s' doesn't match wwid '%s' from device",
|
|
|
50e627 |
+ pp->dev, pp->wwid, wwid);
|
|
|
50e627 |
+ return true;
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+
|
|
|
50e627 |
+ return false;
|
|
|
50e627 |
+}
|
|
|
50e627 |
+
|
|
|
50e627 |
static int
|
|
|
50e627 |
uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map)
|
|
|
50e627 |
{
|
|
|
50e627 |
@@ -1241,6 +1308,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
|
|
|
50e627 |
condlog(0, "%s: path wwid changed from '%s' to '%s'",
|
|
|
50e627 |
uev->kernel, wwid, pp->wwid);
|
|
|
50e627 |
ev_remove_path(pp, vecs, 1);
|
|
|
50e627 |
+ rescan_path(uev->udev);
|
|
|
50e627 |
needs_reinit = 1;
|
|
|
50e627 |
goto out;
|
|
|
50e627 |
} else {
|
|
|
50e627 |
@@ -2101,6 +2169,16 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
|
|
|
50e627 |
return 0;
|
|
|
50e627 |
set_no_path_retry(pp->mpp);
|
|
|
50e627 |
|
|
|
50e627 |
+ if (pp->recheck_wwid == RECHECK_WWID_ON &&
|
|
|
50e627 |
+ (newstate == PATH_UP || newstate == PATH_GHOST) &&
|
|
|
50e627 |
+ ((pp->state != PATH_UP && pp->state != PATH_GHOST) ||
|
|
|
50e627 |
+ pp->dmstate == PSTATE_FAILED) &&
|
|
|
50e627 |
+ check_path_wwid_change(pp)) {
|
|
|
50e627 |
+ condlog(0, "%s: path wwid change detected. Removing", pp->dev);
|
|
|
50e627 |
+ handle_path_wwid_change(pp, vecs);
|
|
|
50e627 |
+ return 0;
|
|
|
50e627 |
+ }
|
|
|
50e627 |
+
|
|
|
50e627 |
if ((newstate == PATH_UP || newstate == PATH_GHOST) &&
|
|
|
50e627 |
(san_path_check_enabled(pp->mpp) ||
|
|
|
50e627 |
marginal_path_check_enabled(pp->mpp))) {
|
|
|
50e627 |
diff --git a/multipathd/main.h b/multipathd/main.h
|
|
|
50e627 |
index 5dff17e5..8f0028a9 100644
|
|
|
50e627 |
--- a/multipathd/main.h
|
|
|
50e627 |
+++ b/multipathd/main.h
|
|
|
50e627 |
@@ -49,4 +49,6 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset);
|
|
|
50e627 |
int update_path_groups(struct multipath *mpp, struct vectors *vecs,
|
|
|
50e627 |
int refresh);
|
|
|
50e627 |
|
|
|
50e627 |
+void handle_path_wwid_change(struct path *pp, struct vectors *vecs);
|
|
|
50e627 |
+bool check_path_wwid_change(struct path *pp);
|
|
|
50e627 |
#endif /* MAIN_H */
|
|
|
50e627 |
--
|
|
|
50e627 |
2.17.2
|
|
|
50e627 |
|