|
|
adbba0 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
adbba0 |
From: Muneendra Kumar <muneendra.kumar@broadcom.com>
|
|
|
adbba0 |
Date: Wed, 9 Feb 2022 19:28:10 -0800
|
|
|
adbba0 |
Subject: [PATCH] multipathd: handle fpin events
|
|
|
adbba0 |
|
|
|
adbba0 |
This patch incorporates the functionality to handle
|
|
|
adbba0 |
FPIN ELS events present as part of FCTransport daemon
|
|
|
adbba0 |
(available in EPEL8) into the multipathd. This helps us to
|
|
|
adbba0 |
reduce the response time to react and take the necessary actions
|
|
|
adbba0 |
on receiving the FPIN events.
|
|
|
adbba0 |
|
|
|
adbba0 |
This patch currently support FPIN-Li Events.
|
|
|
adbba0 |
|
|
|
adbba0 |
It adds a new thread to listen for ELS frames from driver and on
|
|
|
adbba0 |
receiving the frame payload, push the payload to a list and notify the
|
|
|
adbba0 |
fpin_els_li_consumer thread to process it.Once consumer thread is
|
|
|
adbba0 |
notified, it returns to listen for more ELS frames from driver.
|
|
|
adbba0 |
|
|
|
adbba0 |
The consumer thread process the ELS frames and moves the devices paths
|
|
|
adbba0 |
which are affected due to link integrity to marginal path groups.
|
|
|
adbba0 |
This also sets the associated portstate to marginal.
|
|
|
adbba0 |
The paths which are set to marginal path group will be unset
|
|
|
adbba0 |
on receiving the RSCN events
|
|
|
adbba0 |
|
|
|
adbba0 |
[ MW: minor fixup for 32bit compilation ]
|
|
|
adbba0 |
|
|
|
adbba0 |
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
|
|
|
adbba0 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
adbba0 |
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
|
|
adbba0 |
Reviewed-by: Martin Wilck <mwilck@suse.com>
|
|
|
adbba0 |
---
|
|
|
adbba0 |
Makefile.inc | 13 +
|
|
|
adbba0 |
libmultipath/Makefile | 5 +
|
|
|
adbba0 |
libmultipath/dict.c | 56 +++-
|
|
|
adbba0 |
libmultipath/propsel.c | 47 +++-
|
|
|
adbba0 |
libmultipath/structs.h | 7 +
|
|
|
adbba0 |
multipath/multipath.conf.5 | 19 +-
|
|
|
adbba0 |
multipathd/Makefile | 10 +
|
|
|
adbba0 |
multipathd/fpin.h | 20 ++
|
|
|
adbba0 |
multipathd/fpin_handlers.c | 541 +++++++++++++++++++++++++++++++++++++
|
|
|
adbba0 |
multipathd/main.c | 35 ++-
|
|
|
adbba0 |
10 files changed, 738 insertions(+), 15 deletions(-)
|
|
|
adbba0 |
create mode 100644 multipathd/fpin.h
|
|
|
adbba0 |
create mode 100644 multipathd/fpin_handlers.c
|
|
|
adbba0 |
|
|
|
adbba0 |
diff --git a/Makefile.inc b/Makefile.inc
|
|
|
adbba0 |
index 220009e0..25c16f4e 100644
|
|
|
adbba0 |
--- a/Makefile.inc
|
|
|
adbba0 |
+++ b/Makefile.inc
|
|
|
adbba0 |
@@ -146,6 +146,19 @@ check_file = $(shell \
|
|
|
adbba0 |
echo "$$found" \
|
|
|
adbba0 |
)
|
|
|
adbba0 |
|
|
|
adbba0 |
+# Check whether a file contains a variable with name $1 in header file $2
|
|
|
adbba0 |
+check_var = $(shell \
|
|
|
adbba0 |
+ if grep -Eq "(^|[[:blank:]])$1([[:blank:]]|=|$$)" "$2"; then \
|
|
|
adbba0 |
+ found=1; \
|
|
|
adbba0 |
+ status="yes"; \
|
|
|
adbba0 |
+ else \
|
|
|
adbba0 |
+ found=0; \
|
|
|
adbba0 |
+ status="no"; \
|
|
|
adbba0 |
+ fi; \
|
|
|
adbba0 |
+ echo 1>&2 "Checking for .. $1 in $2 ... $$status"; \
|
|
|
adbba0 |
+ echo "$$found" \
|
|
|
adbba0 |
+ )
|
|
|
adbba0 |
+
|
|
|
adbba0 |
%.o: %.c
|
|
|
adbba0 |
@echo building $@ because of $?
|
|
|
adbba0 |
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
adbba0 |
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
|
|
|
adbba0 |
index ad690a49..49f71dfa 100644
|
|
|
adbba0 |
--- a/libmultipath/Makefile
|
|
|
adbba0 |
+++ b/libmultipath/Makefile
|
|
|
adbba0 |
@@ -40,6 +40,11 @@ ifneq ($(call check_func,dm_hold_control_dev,/usr/include/libdevmapper.h),0)
|
|
|
adbba0 |
CFLAGS += -DLIBDM_API_HOLD_CONTROL
|
|
|
adbba0 |
endif
|
|
|
adbba0 |
|
|
|
adbba0 |
+ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,/usr/include/scsi/fc/fc_els.h),0)
|
|
|
adbba0 |
+ CFLAGS += -DFPIN_EVENT_HANDLER
|
|
|
adbba0 |
+endif
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
OBJS = memory.o parser.o vector.o devmapper.o callout.o \
|
|
|
adbba0 |
hwtable.o blacklist.o util.o dmparser.o config.o \
|
|
|
adbba0 |
structs.o discovery.o propsel.o dict.o \
|
|
|
adbba0 |
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
|
|
|
adbba0 |
index 8321ec1e..d7cd94a5 100644
|
|
|
adbba0 |
--- a/libmultipath/dict.c
|
|
|
adbba0 |
+++ b/libmultipath/dict.c
|
|
|
adbba0 |
@@ -579,6 +579,59 @@ snprint_def_find_multipaths(struct config *conf, char *buff, int len,
|
|
|
adbba0 |
find_multipaths_optvals[conf->find_multipaths]);
|
|
|
adbba0 |
}
|
|
|
adbba0 |
|
|
|
adbba0 |
+static const char * const marginal_pathgroups_optvals[] = {
|
|
|
adbba0 |
+ [MARGINAL_PATHGROUP_OFF] = "off",
|
|
|
adbba0 |
+ [MARGINAL_PATHGROUP_ON] = "on",
|
|
|
adbba0 |
+#ifdef FPIN_EVENT_HANDLER
|
|
|
adbba0 |
+ [MARGINAL_PATHGROUP_FPIN] = "fpin",
|
|
|
adbba0 |
+#endif
|
|
|
adbba0 |
+};
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+def_marginal_pathgroups_handler(struct config *conf, vector strvec,
|
|
|
adbba0 |
+ const char *file, int line_nr)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ char *buff;
|
|
|
adbba0 |
+ unsigned int i;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ buff = set_value(strvec);
|
|
|
adbba0 |
+ if (!buff)
|
|
|
adbba0 |
+ return 1;
|
|
|
adbba0 |
+ for (i = MARGINAL_PATHGROUP_OFF;
|
|
|
adbba0 |
+ i < ARRAY_SIZE(marginal_pathgroups_optvals); i++) {
|
|
|
adbba0 |
+ if (marginal_pathgroups_optvals[i] != NULL &&
|
|
|
adbba0 |
+ !strcmp(buff, marginal_pathgroups_optvals[i])) {
|
|
|
adbba0 |
+ conf->marginal_pathgroups = i;
|
|
|
adbba0 |
+ break;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (i >= ARRAY_SIZE(marginal_pathgroups_optvals)) {
|
|
|
adbba0 |
+ if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0)
|
|
|
adbba0 |
+ conf->marginal_pathgroups = MARGINAL_PATHGROUP_OFF;
|
|
|
adbba0 |
+ else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
|
|
|
adbba0 |
+ conf->marginal_pathgroups = MARGINAL_PATHGROUP_ON;
|
|
|
adbba0 |
+ /* This can only be true if FPIN_EVENT_HANDLER isn't defined,
|
|
|
adbba0 |
+ * otherwise this check will have already happened above */
|
|
|
adbba0 |
+ else if (strcmp(buff, "fpin") == 0)
|
|
|
adbba0 |
+ condlog(1, "%s line %d, support for \"fpin\" is not compiled in for marginal_pathgroups", file, line_nr);
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ condlog(1, "%s line %d, invalid value for marginal_pathgroups: \"%s\"",
|
|
|
adbba0 |
+ file, line_nr, buff);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ free(buff);
|
|
|
adbba0 |
+ return 0;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+snprint_def_marginal_pathgroups(struct config *conf, char *buff, int len,
|
|
|
adbba0 |
+ const void *data)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ return snprintf(buff, len, "\"%s\"",
|
|
|
adbba0 |
+ marginal_pathgroups_optvals[conf->marginal_pathgroups]);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
declare_def_handler(selector, set_str)
|
|
|
adbba0 |
declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)
|
|
|
adbba0 |
declare_hw_handler(selector, set_str)
|
|
|
adbba0 |
@@ -1596,9 +1649,6 @@ declare_ovr_snprint(all_tg_pt, print_yes_no_undef)
|
|
|
adbba0 |
declare_hw_handler(all_tg_pt, set_yes_no_undef)
|
|
|
adbba0 |
declare_hw_snprint(all_tg_pt, print_yes_no_undef)
|
|
|
adbba0 |
|
|
|
adbba0 |
-declare_def_handler(marginal_pathgroups, set_yes_no)
|
|
|
adbba0 |
-declare_def_snprint(marginal_pathgroups, print_yes_no)
|
|
|
adbba0 |
-
|
|
|
adbba0 |
declare_def_handler(recheck_wwid, set_yes_no_undef)
|
|
|
adbba0 |
declare_def_snprint_defint(recheck_wwid, print_yes_no_undef, DEFAULT_RECHECK_WWID)
|
|
|
adbba0 |
declare_ovr_handler(recheck_wwid, set_yes_no_undef)
|
|
|
adbba0 |
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
|
|
|
adbba0 |
index 209c1d67..be79902f 100644
|
|
|
adbba0 |
--- a/libmultipath/propsel.c
|
|
|
adbba0 |
+++ b/libmultipath/propsel.c
|
|
|
adbba0 |
@@ -85,6 +85,8 @@ static const char cmdline_origin[] =
|
|
|
adbba0 |
"(setting: multipath command line [-p] flag)";
|
|
|
adbba0 |
static const char autodetect_origin[] =
|
|
|
adbba0 |
"(setting: storage device autodetected)";
|
|
|
adbba0 |
+static const char fpin_marginal_path_origin[] =
|
|
|
adbba0 |
+ "(setting: overridden by marginal_path_fpin)";
|
|
|
adbba0 |
static const char marginal_path_origin[] =
|
|
|
adbba0 |
"(setting: implied by marginal_path check)";
|
|
|
adbba0 |
static const char delay_watch_origin[] =
|
|
|
adbba0 |
@@ -1052,9 +1054,12 @@ int select_san_path_err_threshold(struct config *conf, struct multipath *mp)
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
- if (marginal_path_check_enabled(mp)) {
|
|
|
adbba0 |
+ if (marginal_path_check_enabled(mp) || (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)) {
|
|
|
adbba0 |
mp->san_path_err_threshold = NU_NO;
|
|
|
adbba0 |
- origin = marginal_path_origin;
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ origin = marginal_path_origin;
|
|
|
adbba0 |
goto out;
|
|
|
adbba0 |
}
|
|
|
adbba0 |
mp_set_mpe(san_path_err_threshold);
|
|
|
adbba0 |
@@ -1075,9 +1080,12 @@ int select_san_path_err_forget_rate(struct config *conf, struct multipath *mp)
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
- if (marginal_path_check_enabled(mp)) {
|
|
|
adbba0 |
+ if (marginal_path_check_enabled(mp) || (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)) {
|
|
|
adbba0 |
mp->san_path_err_forget_rate = NU_NO;
|
|
|
adbba0 |
- origin = marginal_path_origin;
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ origin = marginal_path_origin;
|
|
|
adbba0 |
goto out;
|
|
|
adbba0 |
}
|
|
|
adbba0 |
mp_set_mpe(san_path_err_forget_rate);
|
|
|
adbba0 |
@@ -1099,9 +1107,12 @@ int select_san_path_err_recovery_time(struct config *conf, struct multipath *mp)
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
- if (marginal_path_check_enabled(mp)) {
|
|
|
adbba0 |
+ if (marginal_path_check_enabled(mp) || (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)) {
|
|
|
adbba0 |
mp->san_path_err_recovery_time = NU_NO;
|
|
|
adbba0 |
- origin = marginal_path_origin;
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ origin = marginal_path_origin;
|
|
|
adbba0 |
goto out;
|
|
|
adbba0 |
}
|
|
|
adbba0 |
mp_set_mpe(san_path_err_recovery_time);
|
|
|
adbba0 |
@@ -1123,6 +1134,12 @@ int select_marginal_path_err_sample_time(struct config *conf, struct multipath *
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN) {
|
|
|
adbba0 |
+ mp->marginal_path_err_sample_time = NU_NO;
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ goto out;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
mp_set_mpe(marginal_path_err_sample_time);
|
|
|
adbba0 |
mp_set_ovr(marginal_path_err_sample_time);
|
|
|
adbba0 |
mp_set_hwe(marginal_path_err_sample_time);
|
|
|
adbba0 |
@@ -1141,6 +1158,12 @@ int select_marginal_path_err_rate_threshold(struct config *conf, struct multipat
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN) {
|
|
|
adbba0 |
+ mp->marginal_path_err_rate_threshold = NU_NO;
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ goto out;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
mp_set_mpe(marginal_path_err_rate_threshold);
|
|
|
adbba0 |
mp_set_ovr(marginal_path_err_rate_threshold);
|
|
|
adbba0 |
mp_set_hwe(marginal_path_err_rate_threshold);
|
|
|
adbba0 |
@@ -1159,6 +1182,12 @@ int select_marginal_path_err_recheck_gap_time(struct config *conf, struct multip
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN) {
|
|
|
adbba0 |
+ mp->marginal_path_err_recheck_gap_time = NU_NO;
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ goto out;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
mp_set_mpe(marginal_path_err_recheck_gap_time);
|
|
|
adbba0 |
mp_set_ovr(marginal_path_err_recheck_gap_time);
|
|
|
adbba0 |
mp_set_hwe(marginal_path_err_recheck_gap_time);
|
|
|
adbba0 |
@@ -1177,6 +1206,12 @@ int select_marginal_path_double_failed_time(struct config *conf, struct multipat
|
|
|
adbba0 |
const char *origin;
|
|
|
adbba0 |
char buff[12];
|
|
|
adbba0 |
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN) {
|
|
|
adbba0 |
+ mp->marginal_path_double_failed_time = NU_NO;
|
|
|
adbba0 |
+ origin = fpin_marginal_path_origin;
|
|
|
adbba0 |
+ goto out;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
mp_set_mpe(marginal_path_double_failed_time);
|
|
|
adbba0 |
mp_set_ovr(marginal_path_double_failed_time);
|
|
|
adbba0 |
mp_set_hwe(marginal_path_double_failed_time);
|
|
|
adbba0 |
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
|
|
|
adbba0 |
index 875e726e..3ed5cfc1 100644
|
|
|
adbba0 |
--- a/libmultipath/structs.h
|
|
|
adbba0 |
+++ b/libmultipath/structs.h
|
|
|
adbba0 |
@@ -128,6 +128,12 @@ enum find_multipaths_states {
|
|
|
adbba0 |
__FIND_MULTIPATHS_LAST,
|
|
|
adbba0 |
};
|
|
|
adbba0 |
|
|
|
adbba0 |
+enum marginal_pathgroups_mode {
|
|
|
adbba0 |
+ MARGINAL_PATHGROUP_OFF = YN_NO,
|
|
|
adbba0 |
+ MARGINAL_PATHGROUP_ON = YN_YES,
|
|
|
adbba0 |
+ MARGINAL_PATHGROUP_FPIN,
|
|
|
adbba0 |
+};
|
|
|
adbba0 |
+
|
|
|
adbba0 |
enum flush_states {
|
|
|
adbba0 |
FLUSH_UNDEF = YNU_UNDEF,
|
|
|
adbba0 |
FLUSH_DISABLED = YNU_NO,
|
|
|
adbba0 |
@@ -429,6 +435,7 @@ struct multipath {
|
|
|
adbba0 |
unsigned char prflag;
|
|
|
adbba0 |
int all_tg_pt;
|
|
|
adbba0 |
struct gen_multipath generic_mp;
|
|
|
adbba0 |
+ bool fpin_must_reload;
|
|
|
adbba0 |
};
|
|
|
adbba0 |
|
|
|
adbba0 |
static inline int marginal_path_check_enabled(const struct multipath *mpp)
|
|
|
adbba0 |
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
|
|
|
adbba0 |
index abbc89af..805b7a5e 100644
|
|
|
adbba0 |
--- a/multipath/multipath.conf.5
|
|
|
adbba0 |
+++ b/multipath/multipath.conf.5
|
|
|
adbba0 |
@@ -1063,20 +1063,26 @@ The default is: \fBno\fR
|
|
|
adbba0 |
.
|
|
|
adbba0 |
.TP
|
|
|
adbba0 |
.B marginal_pathgroups
|
|
|
adbba0 |
-If set to \fIno\fR, the \fIdelay_*_checks\fR, \fImarginal_path_*\fR, and
|
|
|
adbba0 |
+If set to \fIoff\fR, the \fIdelay_*_checks\fR, \fImarginal_path_*\fR, and
|
|
|
adbba0 |
\fIsan_path_err_*\fR options will keep marginal, or \(dqshaky\(dq, paths from
|
|
|
adbba0 |
being reinstated until they have been monitored for some time. This can cause
|
|
|
adbba0 |
situations where all non-marginal paths are down, and no paths are usable
|
|
|
adbba0 |
until multipathd detects this and reinstates a marginal path. If the multipath
|
|
|
adbba0 |
device is not configured to queue IO in this case, it can cause IO errors to
|
|
|
adbba0 |
occur, even though there are marginal paths available. However, if this
|
|
|
adbba0 |
-option is set to \fIyes\fR, when one of the marginal path detecting methods
|
|
|
adbba0 |
+option is set to \fIon\fR, when one of the marginal path detecting methods
|
|
|
adbba0 |
determines that a path is marginal, it will be reinstated and placed in a
|
|
|
adbba0 |
seperate pathgroup that will only be used after all the non-marginal pathgroups
|
|
|
adbba0 |
have been tried first. This prevents the possibility of IO errors occuring
|
|
|
adbba0 |
while marginal paths are still usable. After the path has been monitored
|
|
|
adbba0 |
for the configured time, and is declared healthy, it will be returned to its
|
|
|
adbba0 |
-normal pathgroup. See "Shaky paths detection" below for more information.
|
|
|
adbba0 |
+normal pathgroup.
|
|
|
adbba0 |
+However if this option is set to \fIfpin\fR multipathd will receive fpin
|
|
|
adbba0 |
+notifications, set path states to "marginal" accordingly, and regroup paths
|
|
|
adbba0 |
+as described for "marginal_pathgroups yes". This option can't be used in combination
|
|
|
adbba0 |
+with other options for "Shaky path detection" (see below).If it is set to fpin,
|
|
|
adbba0 |
+marginal_path_xyz and san_path_err_xyz parameters are implicitly set to 0.
|
|
|
adbba0 |
+See "Shaky paths detection" below for more information.
|
|
|
adbba0 |
.RS
|
|
|
adbba0 |
.TP
|
|
|
adbba0 |
The default is: \fBno\fR
|
|
|
adbba0 |
@@ -1852,6 +1858,13 @@ increase and the threshold is never reached. Ticks are the time between
|
|
|
adbba0 |
path checks by multipathd, which is variable and controlled by the
|
|
|
adbba0 |
\fIpolling_interval\fR and \fImax_polling_interval\fR parameters.
|
|
|
adbba0 |
.
|
|
|
adbba0 |
+.TP
|
|
|
adbba0 |
+.B \(dqFPIN \(dq failure tracking
|
|
|
adbba0 |
+Fibre channel fabrics can notify hosts about fabric-level issues such
|
|
|
adbba0 |
+as integrity failures or congestion with so-called Fabric Performance
|
|
|
adbba0 |
+Impact Notifications (FPINs).On receiving the fpin notifications through ELS
|
|
|
adbba0 |
+multipathd will move the affected path and port states to marginal.
|
|
|
adbba0 |
+.
|
|
|
adbba0 |
.RS 8
|
|
|
adbba0 |
.LP
|
|
|
adbba0 |
This method is \fBdeprecated\fR in favor of the \(dqmarginal_path\(dq failure
|
|
|
adbba0 |
diff --git a/multipathd/Makefile b/multipathd/Makefile
|
|
|
adbba0 |
index 8d901178..835edd93 100644
|
|
|
adbba0 |
--- a/multipathd/Makefile
|
|
|
adbba0 |
+++ b/multipathd/Makefile
|
|
|
adbba0 |
@@ -1,5 +1,9 @@
|
|
|
adbba0 |
include ../Makefile.inc
|
|
|
adbba0 |
|
|
|
adbba0 |
+ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,/usr/include/scsi/fc/fc_els.h),0)
|
|
|
adbba0 |
+ CFLAGS += -DFPIN_EVENT_HANDLER
|
|
|
adbba0 |
+ FPIN_SUPPORT = 1
|
|
|
adbba0 |
+endif
|
|
|
adbba0 |
#
|
|
|
adbba0 |
# debugging stuff
|
|
|
adbba0 |
#
|
|
|
adbba0 |
@@ -28,6 +32,12 @@ endif
|
|
|
adbba0 |
OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \
|
|
|
adbba0 |
dmevents.o
|
|
|
adbba0 |
|
|
|
adbba0 |
+ifeq ($(FPIN_SUPPORT),1)
|
|
|
adbba0 |
+OBJS += fpin_handlers.o
|
|
|
adbba0 |
+endif
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
EXEC = multipathd
|
|
|
adbba0 |
|
|
|
adbba0 |
all : $(EXEC)
|
|
|
adbba0 |
diff --git a/multipathd/fpin.h b/multipathd/fpin.h
|
|
|
adbba0 |
new file mode 100644
|
|
|
adbba0 |
index 00000000..bfcc1ce2
|
|
|
adbba0 |
--- /dev/null
|
|
|
adbba0 |
+++ b/multipathd/fpin.h
|
|
|
adbba0 |
@@ -0,0 +1,20 @@
|
|
|
adbba0 |
+#ifndef __FPIN_H__
|
|
|
adbba0 |
+#define __FPIN_H__
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#ifdef FPIN_EVENT_HANDLER
|
|
|
adbba0 |
+void *fpin_fabric_notification_receiver(void *unused);
|
|
|
adbba0 |
+void *fpin_els_li_consumer(void *data);
|
|
|
adbba0 |
+void fpin_clean_marginal_dev_list(__attribute__((unused)) void *arg);
|
|
|
adbba0 |
+#else
|
|
|
adbba0 |
+static void *fpin_fabric_notification_receiver(__attribute__((unused))void *unused)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ return NULL;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+static void *fpin_els_li_consumer(__attribute__((unused))void *data)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ return NULL;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+/* fpin_clean_marginal_dev_list() is never called */
|
|
|
adbba0 |
+#endif
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#endif
|
|
|
adbba0 |
diff --git a/multipathd/fpin_handlers.c b/multipathd/fpin_handlers.c
|
|
|
adbba0 |
new file mode 100644
|
|
|
adbba0 |
index 00000000..b14366d7
|
|
|
adbba0 |
--- /dev/null
|
|
|
adbba0 |
+++ b/multipathd/fpin_handlers.c
|
|
|
adbba0 |
@@ -0,0 +1,541 @@
|
|
|
adbba0 |
+#include <errno.h>
|
|
|
adbba0 |
+#include <unistd.h>
|
|
|
adbba0 |
+#include <sys/types.h>
|
|
|
adbba0 |
+#include <sys/socket.h>
|
|
|
adbba0 |
+#include <libudev.h>
|
|
|
adbba0 |
+#include <stdint.h>
|
|
|
adbba0 |
+#include <scsi/scsi_netlink_fc.h>
|
|
|
adbba0 |
+#include <scsi/fc/fc_els.h>
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#include "parser.h"
|
|
|
adbba0 |
+#include "vector.h"
|
|
|
adbba0 |
+#include "structs.h"
|
|
|
adbba0 |
+#include "structs_vec.h"
|
|
|
adbba0 |
+#include "main.h"
|
|
|
adbba0 |
+#include "debug.h"
|
|
|
adbba0 |
+#include "util.h"
|
|
|
adbba0 |
+#include "sysfs.h"
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#include "fpin.h"
|
|
|
adbba0 |
+#include "devmapper.h"
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static pthread_cond_t fpin_li_cond = PTHREAD_COND_INITIALIZER;
|
|
|
adbba0 |
+static pthread_mutex_t fpin_li_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
adbba0 |
+static pthread_mutex_t fpin_li_marginal_dev_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static LIST_HEAD(els_marginal_list_head);
|
|
|
adbba0 |
+static LIST_HEAD(fpin_li_marginal_dev_list_head);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#define DEF_RX_BUF_SIZE 4096
|
|
|
adbba0 |
+#define DEV_NAME_LEN 128
|
|
|
adbba0 |
+#define FCH_EVT_LINKUP 0x2
|
|
|
adbba0 |
+#define FCH_EVT_LINK_FPIN 0x501
|
|
|
adbba0 |
+#define FCH_EVT_RSCN 0x5
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+#define list_first_entry(ptr, type, member) \
|
|
|
adbba0 |
+ list_entry((ptr)->next, type, member)
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/* max ELS frame Size */
|
|
|
adbba0 |
+#define FC_PAYLOAD_MAXLEN 2048
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+struct els_marginal_list {
|
|
|
adbba0 |
+ uint32_t event_code;
|
|
|
adbba0 |
+ uint16_t host_num;
|
|
|
adbba0 |
+ uint16_t length;
|
|
|
adbba0 |
+ char payload[FC_PAYLOAD_MAXLEN];
|
|
|
adbba0 |
+ struct list_head node;
|
|
|
adbba0 |
+};
|
|
|
adbba0 |
+/* Structure to store the marginal devices info */
|
|
|
adbba0 |
+struct marginal_dev_list {
|
|
|
adbba0 |
+ char dev_t[BLK_DEV_SIZE];
|
|
|
adbba0 |
+ uint32_t host_num;
|
|
|
adbba0 |
+ struct list_head node;
|
|
|
adbba0 |
+};
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static void _udev_device_unref(void *p)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ udev_device_unref(p);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*set/unset the path state to marginal*/
|
|
|
adbba0 |
+static int fpin_set_pathstate(struct path *pp, bool set)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ const char *action = set ? "set" : "unset";
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (!pp || !pp->mpp || !pp->mpp->alias)
|
|
|
adbba0 |
+ return -1;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ condlog(3, "\n%s: %s marginal path %s (fpin)",
|
|
|
adbba0 |
+ action, pp->mpp->alias, pp->dev_t);
|
|
|
adbba0 |
+ pp->marginal = set;
|
|
|
adbba0 |
+ pp->mpp->fpin_must_reload = true;
|
|
|
adbba0 |
+ return 0;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/* This will unset marginal state of a device*/
|
|
|
adbba0 |
+static void fpin_path_unsetmarginal(char *devname, struct vectors *vecs)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct path *pp;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pp = find_path_by_dev(vecs->pathvec, devname);
|
|
|
adbba0 |
+ if (!pp)
|
|
|
adbba0 |
+ pp = find_path_by_devt(vecs->pathvec, devname);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ fpin_set_pathstate(pp, false);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*This will set the marginal state of a device*/
|
|
|
adbba0 |
+static int fpin_path_setmarginal(struct path *pp)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ return fpin_set_pathstate(pp, true);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/* Unsets all the devices in the list from marginal state */
|
|
|
adbba0 |
+static void
|
|
|
adbba0 |
+fpin_unset_marginal_dev(uint32_t host_num, struct vectors *vecs)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct marginal_dev_list *tmp_marg = NULL;
|
|
|
adbba0 |
+ struct marginal_dev_list *marg = NULL;
|
|
|
adbba0 |
+ struct multipath *mpp;
|
|
|
adbba0 |
+ int ret = 0;
|
|
|
adbba0 |
+ int i;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(cleanup_lock, &vecs->lock);
|
|
|
adbba0 |
+ lock(&vecs->lock);
|
|
|
adbba0 |
+ pthread_testcancel();
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+ pthread_cleanup_push(cleanup_mutex, &fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+ pthread_testcancel();
|
|
|
adbba0 |
+ if (list_empty(&fpin_li_marginal_dev_list_head)) {
|
|
|
adbba0 |
+ condlog(4, "Marginal List is empty\n");
|
|
|
adbba0 |
+ goto empty;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ list_for_each_entry_safe(marg, tmp_marg, &fpin_li_marginal_dev_list_head, node) {
|
|
|
adbba0 |
+ if (marg->host_num != host_num)
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ condlog(4, " unsetting marginal dev: is %s %d\n",
|
|
|
adbba0 |
+ tmp_marg->dev_t, tmp_marg->host_num);
|
|
|
adbba0 |
+ fpin_path_unsetmarginal(marg->dev_t, vecs);
|
|
|
adbba0 |
+ list_del(&marg->node);
|
|
|
adbba0 |
+ free(marg);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+empty:
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ /* walk backwards because update_path_groups() can remove mpp */
|
|
|
adbba0 |
+ vector_foreach_slot_backwards(vecs->mpvec, mpp, i) {
|
|
|
adbba0 |
+ if (mpp->fpin_must_reload) {
|
|
|
adbba0 |
+ ret = update_path_groups(mpp, vecs, 0);
|
|
|
adbba0 |
+ if (ret == 2)
|
|
|
adbba0 |
+ condlog(2, "map removed during reload");
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ mpp->fpin_must_reload = false;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * On Receiving the frame from HBA driver, insert the frame into link
|
|
|
adbba0 |
+ * integrity frame list which will be picked up later by consumer thread for
|
|
|
adbba0 |
+ * processing.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+fpin_els_add_li_frame(struct fc_nl_event *fc_event)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct els_marginal_list *els_mrg = NULL;
|
|
|
adbba0 |
+ int ret = 0;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (fc_event->event_datalen > FC_PAYLOAD_MAXLEN)
|
|
|
adbba0 |
+ return -EINVAL;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_mutex);
|
|
|
adbba0 |
+ pthread_cleanup_push(cleanup_mutex, &fpin_li_mutex);
|
|
|
adbba0 |
+ pthread_testcancel();
|
|
|
adbba0 |
+ els_mrg = calloc(1, sizeof(struct els_marginal_list));
|
|
|
adbba0 |
+ if (els_mrg != NULL) {
|
|
|
adbba0 |
+ els_mrg->host_num = fc_event->host_no;
|
|
|
adbba0 |
+ els_mrg->event_code = fc_event->event_code;
|
|
|
adbba0 |
+ els_mrg->length = fc_event->event_datalen;
|
|
|
adbba0 |
+ memcpy(els_mrg->payload, &(fc_event->event_data), fc_event->event_datalen);
|
|
|
adbba0 |
+ list_add_tail(&els_mrg->node, &els_marginal_list_head);
|
|
|
adbba0 |
+ pthread_cond_signal(&fpin_li_cond);
|
|
|
adbba0 |
+ } else
|
|
|
adbba0 |
+ ret = -ENOMEM;
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ return ret;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*Sets the rport port_state to marginal*/
|
|
|
adbba0 |
+static void fpin_set_rport_marginal(struct udev_device *rport_dev)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ sysfs_attr_set_value(rport_dev, "port_state",
|
|
|
adbba0 |
+ "Marginal", strlen("Marginal"));
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*Add the marginal devices info into the list*/
|
|
|
adbba0 |
+static void
|
|
|
adbba0 |
+fpin_add_marginal_dev_info(uint32_t host_num, char *devname)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct marginal_dev_list *newdev = NULL;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ newdev = calloc(1, sizeof(struct marginal_dev_list));
|
|
|
adbba0 |
+ if (newdev != NULL) {
|
|
|
adbba0 |
+ newdev->host_num = host_num;
|
|
|
adbba0 |
+ strlcpy(newdev->dev_t, devname, BLK_DEV_SIZE);
|
|
|
adbba0 |
+ condlog(4, "\n%s hostno %d devname %s\n", __func__,
|
|
|
adbba0 |
+ host_num, newdev->dev_t);
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+ list_add_tail(&(newdev->node),
|
|
|
adbba0 |
+ &fpin_li_marginal_dev_list_head);
|
|
|
adbba0 |
+ pthread_mutex_unlock(&fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * This function goes through the vecs->pathvec, and for
|
|
|
adbba0 |
+ * each path, check that the host number,
|
|
|
adbba0 |
+ * the target WWPN associated with the path matches
|
|
|
adbba0 |
+ * with the els wwpn and sets the path and port state to
|
|
|
adbba0 |
+ * Marginal
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+static int fpin_chk_wwn_setpath_marginal(uint16_t host_num, struct vectors *vecs,
|
|
|
adbba0 |
+ uint64_t els_wwpn)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct path *pp;
|
|
|
adbba0 |
+ struct multipath *mpp;
|
|
|
adbba0 |
+ int i, k;
|
|
|
adbba0 |
+ char rport_id[42];
|
|
|
adbba0 |
+ const char *value = NULL;
|
|
|
adbba0 |
+ struct udev_device *rport_dev = NULL;
|
|
|
adbba0 |
+ uint64_t wwpn;
|
|
|
adbba0 |
+ int ret = 0;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(cleanup_lock, &vecs->lock);
|
|
|
adbba0 |
+ lock(&vecs->lock);
|
|
|
adbba0 |
+ pthread_testcancel();
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ vector_foreach_slot(vecs->pathvec, pp, k) {
|
|
|
adbba0 |
+ /* Checks the host number and also for the SCSI FCP */
|
|
|
adbba0 |
+ if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP || host_num != pp->sg_id.host_no)
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ sprintf(rport_id, "rport-%d:%d-%d",
|
|
|
adbba0 |
+ pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
|
|
|
adbba0 |
+ rport_dev = udev_device_new_from_subsystem_sysname(udev,
|
|
|
adbba0 |
+ "fc_remote_ports", rport_id);
|
|
|
adbba0 |
+ if (!rport_dev) {
|
|
|
adbba0 |
+ condlog(2, "%s: No fc_remote_port device for '%s'", pp->dev,
|
|
|
adbba0 |
+ rport_id);
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ pthread_cleanup_push(_udev_device_unref, rport_dev);
|
|
|
adbba0 |
+ value = udev_device_get_sysattr_value(rport_dev, "port_name");
|
|
|
adbba0 |
+ if (!value)
|
|
|
adbba0 |
+ goto unref;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (value)
|
|
|
adbba0 |
+ wwpn = strtol(value, NULL, 16);
|
|
|
adbba0 |
+ /*
|
|
|
adbba0 |
+ * If the port wwpn matches sets the path and port state
|
|
|
adbba0 |
+ * to marginal
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+ if (wwpn == els_wwpn) {
|
|
|
adbba0 |
+ ret = fpin_path_setmarginal(pp);
|
|
|
adbba0 |
+ if (ret < 0)
|
|
|
adbba0 |
+ goto unref;
|
|
|
adbba0 |
+ fpin_set_rport_marginal(rport_dev);
|
|
|
adbba0 |
+ fpin_add_marginal_dev_info(host_num, pp->dev);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+unref:
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ /* walk backwards because update_path_groups() can remove mpp */
|
|
|
adbba0 |
+ vector_foreach_slot_backwards(vecs->mpvec, mpp, i) {
|
|
|
adbba0 |
+ if (mpp->fpin_must_reload) {
|
|
|
adbba0 |
+ ret = update_path_groups(mpp, vecs, 0);
|
|
|
adbba0 |
+ if (ret == 2)
|
|
|
adbba0 |
+ condlog(2, "map removed during reload");
|
|
|
adbba0 |
+ else
|
|
|
adbba0 |
+ mpp->fpin_must_reload = false;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ return ret;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * This function loops around all the impacted wwns received as part of els
|
|
|
adbba0 |
+ * frame and sets the associated path and port states to marginal.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+fpin_parse_li_els_setpath_marginal(uint16_t host_num, struct fc_tlv_desc *tlv,
|
|
|
adbba0 |
+ struct vectors *vecs)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ uint32_t wwn_count = 0, iter = 0;
|
|
|
adbba0 |
+ uint64_t wwpn;
|
|
|
adbba0 |
+ struct fc_fn_li_desc *li_desc = (struct fc_fn_li_desc *)tlv;
|
|
|
adbba0 |
+ int count = 0;
|
|
|
adbba0 |
+ int ret = 0;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ /* Update the wwn to list */
|
|
|
adbba0 |
+ wwn_count = be32_to_cpu(li_desc->pname_count);
|
|
|
adbba0 |
+ condlog(4, "Got wwn count as %d\n", wwn_count);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ for (iter = 0; iter < wwn_count; iter++) {
|
|
|
adbba0 |
+ wwpn = be64_to_cpu(li_desc->pname_list[iter]);
|
|
|
adbba0 |
+ ret = fpin_chk_wwn_setpath_marginal(host_num, vecs, wwpn);
|
|
|
adbba0 |
+ if (ret < 0)
|
|
|
adbba0 |
+ condlog(2, "failed to set the path marginal associated with wwpn: 0x%" PRIx64 "\n", wwpn);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ count++;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ return count;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * This function process the ELS frame received from HBA driver,
|
|
|
adbba0 |
+ * and sets the path associated with the port wwn to marginal
|
|
|
adbba0 |
+ * and also set the port state to marginal.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+fpin_process_els_frame(uint16_t host_num, char *fc_payload, struct vectors *vecs)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ int count = -1;
|
|
|
adbba0 |
+ struct fc_els_fpin *fpin = (struct fc_els_fpin *)fc_payload;
|
|
|
adbba0 |
+ struct fc_tlv_desc *tlv;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0];
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ /*
|
|
|
adbba0 |
+ * Parse the els frame and set the affected paths and port
|
|
|
adbba0 |
+ * state to marginal
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+ count = fpin_parse_li_els_setpath_marginal(host_num, tlv, vecs);
|
|
|
adbba0 |
+ if (count <= 0)
|
|
|
adbba0 |
+ condlog(4, "Could not find any WWNs, ret = %d\n",
|
|
|
adbba0 |
+ count);
|
|
|
adbba0 |
+ return count;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * This function process the FPIN ELS frame received from HBA driver,
|
|
|
adbba0 |
+ * and push the frame to appropriate frame list. Currently we have only FPIN
|
|
|
adbba0 |
+ * LI frame list.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+static int
|
|
|
adbba0 |
+fpin_handle_els_frame(struct fc_nl_event *fc_event)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ int ret = -1;
|
|
|
adbba0 |
+ uint32_t els_cmd;
|
|
|
adbba0 |
+ struct fc_els_fpin *fpin = (struct fc_els_fpin *)&fc_event->event_data;
|
|
|
adbba0 |
+ struct fc_tlv_desc *tlv;
|
|
|
adbba0 |
+ uint32_t dtag;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ els_cmd = (uint32_t)fc_event->event_data;
|
|
|
adbba0 |
+ tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0];
|
|
|
adbba0 |
+ dtag = be32_to_cpu(tlv->desc_tag);
|
|
|
adbba0 |
+ condlog(4, "Got CMD in add as 0x%x fpin_cmd 0x%x dtag 0x%x\n",
|
|
|
adbba0 |
+ els_cmd, fpin->fpin_cmd, dtag);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if ((fc_event->event_code == FCH_EVT_LINK_FPIN) ||
|
|
|
adbba0 |
+ (fc_event->event_code == FCH_EVT_LINKUP) ||
|
|
|
adbba0 |
+ (fc_event->event_code == FCH_EVT_RSCN)) {
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (els_cmd == ELS_FPIN) {
|
|
|
adbba0 |
+ /*
|
|
|
adbba0 |
+ * Check the type of fpin by checking the tag info
|
|
|
adbba0 |
+ * At present we are supporting only LI events
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+ if (dtag == ELS_DTAG_LNK_INTEGRITY) {
|
|
|
adbba0 |
+ /*Push the Payload to FPIN frame queue. */
|
|
|
adbba0 |
+ ret = fpin_els_add_li_frame(fc_event);
|
|
|
adbba0 |
+ if (ret != 0)
|
|
|
adbba0 |
+ condlog(0, "Failed to process LI frame with error %d\n",
|
|
|
adbba0 |
+ ret);
|
|
|
adbba0 |
+ } else {
|
|
|
adbba0 |
+ condlog(4, "Unsupported FPIN received 0x%x\n", dtag);
|
|
|
adbba0 |
+ return ret;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ } else {
|
|
|
adbba0 |
+ /*Push the Payload to FPIN frame queue. */
|
|
|
adbba0 |
+ ret = fpin_els_add_li_frame(fc_event);
|
|
|
adbba0 |
+ if (ret != 0)
|
|
|
adbba0 |
+ condlog(0, "Failed to process Linkup/RSCN event with error %d evnt %d\n",
|
|
|
adbba0 |
+ ret, fc_event->event_code);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ } else
|
|
|
adbba0 |
+ condlog(4, "Invalid command received: 0x%x\n", els_cmd);
|
|
|
adbba0 |
+ return ret;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*cleans the global marginal dev list*/
|
|
|
adbba0 |
+void fpin_clean_marginal_dev_list(__attribute__((unused)) void *arg)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct marginal_dev_list *tmp_marg = NULL;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+ while (!list_empty(&fpin_li_marginal_dev_list_head)) {
|
|
|
adbba0 |
+ tmp_marg = list_first_entry(&fpin_li_marginal_dev_list_head,
|
|
|
adbba0 |
+ struct marginal_dev_list, node);
|
|
|
adbba0 |
+ list_del(&tmp_marg->node);
|
|
|
adbba0 |
+ free(tmp_marg);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ pthread_mutex_unlock(&fpin_li_marginal_dev_mutex);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/* Cleans the global els marginal list */
|
|
|
adbba0 |
+static void fpin_clean_els_marginal_list(void *arg)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct list_head *head = (struct list_head *)arg;
|
|
|
adbba0 |
+ struct els_marginal_list *els_marg;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ while (!list_empty(head)) {
|
|
|
adbba0 |
+ els_marg = list_first_entry(head, struct els_marginal_list,
|
|
|
adbba0 |
+ node);
|
|
|
adbba0 |
+ list_del(&els_marg->node);
|
|
|
adbba0 |
+ free(els_marg);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static void rcu_unregister(__attribute__((unused)) void *param)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ rcu_unregister_thread();
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * This is the FPIN ELS consumer thread. The thread sleeps on pthread cond
|
|
|
adbba0 |
+ * variable unless notified by fpin_fabric_notification_receiver thread.
|
|
|
adbba0 |
+ * This thread is only to process FPIN-LI ELS frames. A new thread and frame
|
|
|
adbba0 |
+ * list will be added if any more ELS frames types are to be supported.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+void *fpin_els_li_consumer(void *data)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ struct list_head marginal_list_head;
|
|
|
adbba0 |
+ int ret = 0;
|
|
|
adbba0 |
+ uint16_t host_num;
|
|
|
adbba0 |
+ struct els_marginal_list *els_marg;
|
|
|
adbba0 |
+ uint32_t event_code;
|
|
|
adbba0 |
+ struct vectors *vecs = (struct vectors *)data;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(rcu_unregister, NULL);
|
|
|
adbba0 |
+ rcu_register_thread();
|
|
|
adbba0 |
+ pthread_cleanup_push(fpin_clean_marginal_dev_list, NULL);
|
|
|
adbba0 |
+ INIT_LIST_HEAD(&marginal_list_head);
|
|
|
adbba0 |
+ pthread_cleanup_push(fpin_clean_els_marginal_list,
|
|
|
adbba0 |
+ (void *)&marginal_list_head);
|
|
|
adbba0 |
+ for ( ; ; ) {
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_mutex);
|
|
|
adbba0 |
+ pthread_cleanup_push(cleanup_mutex, &fpin_li_mutex);
|
|
|
adbba0 |
+ pthread_testcancel();
|
|
|
adbba0 |
+ while (list_empty(&els_marginal_list_head))
|
|
|
adbba0 |
+ pthread_cond_wait(&fpin_li_cond, &fpin_li_mutex);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if (!list_empty(&els_marginal_list_head)) {
|
|
|
adbba0 |
+ condlog(4, "Invoke List splice tail\n");
|
|
|
adbba0 |
+ list_splice_tail_init(&els_marginal_list_head, &marginal_list_head);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ while (!list_empty(&marginal_list_head)) {
|
|
|
adbba0 |
+ els_marg = list_first_entry(&marginal_list_head,
|
|
|
adbba0 |
+ struct els_marginal_list, node);
|
|
|
adbba0 |
+ host_num = els_marg->host_num;
|
|
|
adbba0 |
+ event_code = els_marg->event_code;
|
|
|
adbba0 |
+ /* Now finally process FPIN LI ELS Frame */
|
|
|
adbba0 |
+ condlog(4, "Got a new Payload buffer, processing it\n");
|
|
|
adbba0 |
+ if ((event_code == FCH_EVT_LINKUP) || (event_code == FCH_EVT_RSCN))
|
|
|
adbba0 |
+ fpin_unset_marginal_dev(host_num, vecs);
|
|
|
adbba0 |
+ else {
|
|
|
adbba0 |
+ ret = fpin_process_els_frame(host_num, els_marg->payload, vecs);
|
|
|
adbba0 |
+ if (ret <= 0)
|
|
|
adbba0 |
+ condlog(0, "ELS frame processing failed with ret %d\n", ret);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ list_del(&els_marg->node);
|
|
|
adbba0 |
+ free(els_marg);
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ return NULL;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+static void receiver_cleanup_list(__attribute__((unused)) void *arg)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ pthread_mutex_lock(&fpin_li_mutex);
|
|
|
adbba0 |
+ fpin_clean_els_marginal_list(&els_marginal_list_head);
|
|
|
adbba0 |
+ pthread_mutex_unlock(&fpin_li_mutex);
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+/*
|
|
|
adbba0 |
+ * Listen for ELS frames from driver. on receiving the frame payload,
|
|
|
adbba0 |
+ * push the payload to a list, and notify the fpin_els_li_consumer thread to
|
|
|
adbba0 |
+ * process it. Once consumer thread is notified, return to listen for more ELS
|
|
|
adbba0 |
+ * frames from driver.
|
|
|
adbba0 |
+ */
|
|
|
adbba0 |
+void *fpin_fabric_notification_receiver(__attribute__((unused))void *unused)
|
|
|
adbba0 |
+{
|
|
|
adbba0 |
+ int ret;
|
|
|
adbba0 |
+ long fd;
|
|
|
adbba0 |
+ uint32_t els_cmd;
|
|
|
adbba0 |
+ struct fc_nl_event *fc_event = NULL;
|
|
|
adbba0 |
+ struct sockaddr_nl fc_local;
|
|
|
adbba0 |
+ unsigned char buf[DEF_RX_BUF_SIZE] __attribute__((aligned(sizeof(uint64_t))));
|
|
|
adbba0 |
+ size_t plen = 0;
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(rcu_unregister, NULL);
|
|
|
adbba0 |
+ rcu_register_thread();
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(receiver_cleanup_list, NULL);
|
|
|
adbba0 |
+ fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_SCSITRANSPORT);
|
|
|
adbba0 |
+ if (fd < 0) {
|
|
|
adbba0 |
+ condlog(0, "fc socket error %ld", fd);
|
|
|
adbba0 |
+ return NULL;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ pthread_cleanup_push(close_fd, (void *)fd);
|
|
|
adbba0 |
+ memset(&fc_local, 0, sizeof(fc_local));
|
|
|
adbba0 |
+ fc_local.nl_family = AF_NETLINK;
|
|
|
adbba0 |
+ fc_local.nl_groups = ~0;
|
|
|
adbba0 |
+ fc_local.nl_pid = getpid();
|
|
|
adbba0 |
+ ret = bind(fd, (struct sockaddr *)&fc_local, sizeof(fc_local));
|
|
|
adbba0 |
+ if (ret == -1) {
|
|
|
adbba0 |
+ condlog(0, "fc socket bind error %d\n", ret);
|
|
|
adbba0 |
+ goto out;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ for ( ; ; ) {
|
|
|
adbba0 |
+ condlog(4, "Waiting for ELS...\n");
|
|
|
adbba0 |
+ ret = read(fd, buf, DEF_RX_BUF_SIZE);
|
|
|
adbba0 |
+ if (ret < 0) {
|
|
|
adbba0 |
+ condlog(0, "failed to read the els frame (%d)", ret);
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ condlog(4, "Got a new request %d\n", ret);
|
|
|
adbba0 |
+ if (!NLMSG_OK((struct nlmsghdr *)buf, (unsigned int)ret)) {
|
|
|
adbba0 |
+ condlog(0, "bad els frame read (%d)", ret);
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ /* Push the frame to appropriate frame list */
|
|
|
adbba0 |
+ plen = NLMSG_PAYLOAD((struct nlmsghdr *)buf, 0);
|
|
|
adbba0 |
+ fc_event = (struct fc_nl_event *)NLMSG_DATA(buf);
|
|
|
adbba0 |
+ if (plen < sizeof(*fc_event)) {
|
|
|
adbba0 |
+ condlog(0, "too short (%d) to be an FC event", ret);
|
|
|
adbba0 |
+ continue;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ els_cmd = (uint32_t)fc_event->event_data;
|
|
|
adbba0 |
+ condlog(4, "Got host no as %d, event 0x%x, len %d evntnum %d evntcode %d\n",
|
|
|
adbba0 |
+ fc_event->host_no, els_cmd, fc_event->event_datalen,
|
|
|
adbba0 |
+ fc_event->event_num, fc_event->event_code);
|
|
|
adbba0 |
+ fpin_handle_els_frame(fc_event);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+out:
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ pthread_cleanup_pop(1);
|
|
|
adbba0 |
+ return NULL;
|
|
|
adbba0 |
+}
|
|
|
adbba0 |
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
|
adbba0 |
index eeded52b..4cf5bc41 100644
|
|
|
adbba0 |
--- a/multipathd/main.c
|
|
|
adbba0 |
+++ b/multipathd/main.c
|
|
|
adbba0 |
@@ -16,6 +16,7 @@
|
|
|
adbba0 |
#include <linux/oom.h>
|
|
|
adbba0 |
#include <libudev.h>
|
|
|
adbba0 |
#include <urcu.h>
|
|
|
adbba0 |
+#include "fpin.h"
|
|
|
adbba0 |
#ifdef USE_SYSTEMD
|
|
|
adbba0 |
#include <systemd/sd-daemon.h>
|
|
|
adbba0 |
#endif
|
|
|
adbba0 |
@@ -2704,7 +2705,9 @@ reconfigure (struct vectors * vecs)
|
|
|
adbba0 |
conf->sequence_nr = old->sequence_nr + 1;
|
|
|
adbba0 |
rcu_assign_pointer(multipath_conf, conf);
|
|
|
adbba0 |
call_rcu(&old->rcu, rcu_free_config);
|
|
|
adbba0 |
-
|
|
|
adbba0 |
+#ifdef FPIN_EVENT_HANDLER
|
|
|
adbba0 |
+ fpin_clean_marginal_dev_list(NULL);
|
|
|
adbba0 |
+#endif
|
|
|
adbba0 |
configure(vecs);
|
|
|
adbba0 |
|
|
|
adbba0 |
|
|
|
adbba0 |
@@ -2878,7 +2881,8 @@ set_oom_adj (void)
|
|
|
adbba0 |
static int
|
|
|
adbba0 |
child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
{
|
|
|
adbba0 |
- pthread_t check_thr, uevent_thr, uxlsnr_thr, uevq_thr, dmevent_thr;
|
|
|
adbba0 |
+ pthread_t check_thr, uevent_thr, uxlsnr_thr, uevq_thr, dmevent_thr,
|
|
|
adbba0 |
+ fpin_thr, fpin_consumer_thr;
|
|
|
adbba0 |
pthread_attr_t log_attr, misc_attr, uevent_attr;
|
|
|
adbba0 |
struct vectors * vecs;
|
|
|
adbba0 |
struct multipath * mpp;
|
|
|
adbba0 |
@@ -2892,6 +2896,7 @@ child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
char *envp;
|
|
|
adbba0 |
int queue_without_daemon;
|
|
|
adbba0 |
enum daemon_status state;
|
|
|
adbba0 |
+ int fpin_marginal_paths = 0;
|
|
|
adbba0 |
|
|
|
adbba0 |
mlockall(MCL_CURRENT | MCL_FUTURE);
|
|
|
adbba0 |
signal_init();
|
|
|
adbba0 |
@@ -2959,7 +2964,10 @@ child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
|
|
|
adbba0 |
setscheduler();
|
|
|
adbba0 |
set_oom_adj();
|
|
|
adbba0 |
-
|
|
|
adbba0 |
+#ifdef FPIN_EVENT_HANDLER
|
|
|
adbba0 |
+ if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)
|
|
|
adbba0 |
+ fpin_marginal_paths = 1;
|
|
|
adbba0 |
+#endif
|
|
|
adbba0 |
/*
|
|
|
adbba0 |
* Startup done, invalidate configuration
|
|
|
adbba0 |
*/
|
|
|
adbba0 |
@@ -3020,6 +3028,19 @@ child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
condlog(0, "failed to create uevent dispatcher: %d", rc);
|
|
|
adbba0 |
goto failed;
|
|
|
adbba0 |
}
|
|
|
adbba0 |
+ if (fpin_marginal_paths) {
|
|
|
adbba0 |
+ if ((rc = pthread_create(&fpin_thr, &misc_attr,
|
|
|
adbba0 |
+ fpin_fabric_notification_receiver, NULL))) {
|
|
|
adbba0 |
+ condlog(0, "failed to create the fpin receiver thread: %d", rc);
|
|
|
adbba0 |
+ goto failed;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+
|
|
|
adbba0 |
+ if ((rc = pthread_create(&fpin_consumer_thr,
|
|
|
adbba0 |
+ &misc_attr, fpin_els_li_consumer, vecs))) {
|
|
|
adbba0 |
+ condlog(0, "failed to create the fpin consumer thread thread: %d", rc);
|
|
|
adbba0 |
+ goto failed;
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
pthread_attr_destroy(&misc_attr);
|
|
|
adbba0 |
|
|
|
adbba0 |
while (1) {
|
|
|
adbba0 |
@@ -3070,6 +3091,10 @@ child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
pthread_cancel(uevq_thr);
|
|
|
adbba0 |
if (poll_dmevents)
|
|
|
adbba0 |
pthread_cancel(dmevent_thr);
|
|
|
adbba0 |
+ if (fpin_marginal_paths) {
|
|
|
adbba0 |
+ pthread_cancel(fpin_thr);
|
|
|
adbba0 |
+ pthread_cancel(fpin_consumer_thr);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
|
|
|
adbba0 |
pthread_join(check_thr, NULL);
|
|
|
adbba0 |
pthread_join(uevent_thr, NULL);
|
|
|
adbba0 |
@@ -3077,6 +3102,10 @@ child (__attribute__((unused)) void *param)
|
|
|
adbba0 |
pthread_join(uevq_thr, NULL);
|
|
|
adbba0 |
if (poll_dmevents)
|
|
|
adbba0 |
pthread_join(dmevent_thr, NULL);
|
|
|
adbba0 |
+ if (fpin_marginal_paths) {
|
|
|
adbba0 |
+ pthread_join(fpin_thr, NULL);
|
|
|
adbba0 |
+ pthread_join(fpin_consumer_thr, NULL);
|
|
|
adbba0 |
+ }
|
|
|
adbba0 |
|
|
|
adbba0 |
stop_io_err_stat_thread();
|
|
|
adbba0 |
|