|
|
c896fb |
From 1073621a7a63ca4e9a00baedd8edc51e5381eb95 Mon Sep 17 00:00:00 2001
|
|
|
c896fb |
From: Mike Christie <mchristi@redhat.com>
|
|
|
c896fb |
Date: Tue, 9 Aug 2016 13:46:11 -0500
|
|
|
c896fb |
Subject: [PATCH 03/11] multipath-tools: add checker callout to repair path
|
|
|
c896fb |
|
|
|
c896fb |
For BZ 1348372 from upstream commit:
|
|
|
c896fb |
|
|
|
c896fb |
commit 015f87b16a7797a17afd514aec46e65c2a1a2f73
|
|
|
c896fb |
Author: Mike Christie <mchristi@redhat.com>
|
|
|
c896fb |
Date: Mon Aug 8 07:01:48 2016 -0500
|
|
|
c896fb |
|
|
|
c896fb |
multipath-tools: add checker callout to repair path
|
|
|
c896fb |
|
|
|
c896fb |
This patch adds a callback which can be used to repair a path
|
|
|
c896fb |
if check() has determined it is in the PATH_DOWN state.
|
|
|
c896fb |
|
|
|
c896fb |
The next patch that adds rbd checker support which will use this to
|
|
|
c896fb |
handle the case where a rbd device is blacklisted.
|
|
|
c896fb |
|
|
|
c896fb |
--------
|
|
|
c896fb |
|
|
|
c896fb |
Porting notes:
|
|
|
c896fb |
checkerloop difference due to different path tracking.
|
|
|
c896fb |
|
|
|
c896fb |
Signed-off-by: Mike Christie <mchristi@redhat.com>
|
|
|
c896fb |
---
|
|
|
c896fb |
libmultipath/checkers.c | 23 +++++++++++++++++++++++
|
|
|
c896fb |
libmultipath/checkers.h | 4 ++++
|
|
|
c896fb |
libmultipath/checkers/cciss_tur.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/directio.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/emc_clariion.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/hp_sw.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/rdac.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/readsector0.c | 5 +++++
|
|
|
c896fb |
libmultipath/checkers/tur.c | 5 +++++
|
|
|
c896fb |
multipathd/main.c | 9 +++++++++
|
|
|
c896fb |
10 files changed, 71 insertions(+)
|
|
|
c896fb |
|
|
|
c896fb |
diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
|
|
|
c896fb |
index 7f9db2d..fa7d8b7 100644
|
|
|
c896fb |
--- a/libmultipath/checkers.c
|
|
|
c896fb |
+++ b/libmultipath/checkers.c
|
|
|
c896fb |
@@ -137,6 +137,14 @@ struct checker * add_checker (char * name)
|
|
|
c896fb |
if (!c->free)
|
|
|
c896fb |
goto out;
|
|
|
c896fb |
|
|
|
c896fb |
+ c->repair = (void (*)(struct checker *)) dlsym(c->handle,
|
|
|
c896fb |
+ "libcheck_repair");
|
|
|
c896fb |
+ errstr = dlerror();
|
|
|
c896fb |
+ if (errstr != NULL)
|
|
|
c896fb |
+ condlog(0, "A dynamic linking error occurred: (%s)", errstr);
|
|
|
c896fb |
+ if (!c->repair)
|
|
|
c896fb |
+ goto out;
|
|
|
c896fb |
+
|
|
|
c896fb |
c->fd = 0;
|
|
|
c896fb |
c->sync = 1;
|
|
|
c896fb |
list_add(&c->node, &checkers);
|
|
|
c896fb |
@@ -202,6 +210,20 @@ void checker_put (struct checker * dst)
|
|
|
c896fb |
free_checker(src);
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void checker_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ if (!c)
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+
|
|
|
c896fb |
+ c->message[0] = '\0';
|
|
|
c896fb |
+ if (c->disable) {
|
|
|
c896fb |
+ MSG(c, "checker disabled");
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+ }
|
|
|
c896fb |
+
|
|
|
c896fb |
+ c->repair(c);
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
int checker_check (struct checker * c)
|
|
|
c896fb |
{
|
|
|
c896fb |
int r;
|
|
|
c896fb |
@@ -266,6 +288,7 @@ void checker_get (struct checker * dst, char * name)
|
|
|
c896fb |
dst->sync = src->sync;
|
|
|
c896fb |
strncpy(dst->name, src->name, CHECKER_NAME_LEN);
|
|
|
c896fb |
strncpy(dst->message, src->message, CHECKER_MSG_LEN);
|
|
|
c896fb |
+ dst->repair = src->repair;
|
|
|
c896fb |
dst->check = src->check;
|
|
|
c896fb |
dst->init = src->init;
|
|
|
c896fb |
dst->free = src->free;
|
|
|
c896fb |
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
|
|
|
c896fb |
index 735bb25..ad3b9e4 100644
|
|
|
c896fb |
--- a/libmultipath/checkers.h
|
|
|
c896fb |
+++ b/libmultipath/checkers.h
|
|
|
c896fb |
@@ -106,6 +106,9 @@ struct checker {
|
|
|
c896fb |
multipath-wide. Use MALLOC if
|
|
|
c896fb |
you want to stuff data in. */
|
|
|
c896fb |
int (*check)(struct checker *);
|
|
|
c896fb |
+ void (*repair)(struct checker *); /* called if check returns
|
|
|
c896fb |
+ PATH_DOWN to bring path into
|
|
|
c896fb |
+ usable state */
|
|
|
c896fb |
int (*init)(struct checker *); /* to allocate the context */
|
|
|
c896fb |
void (*free)(struct checker *); /* to free the context */
|
|
|
c896fb |
};
|
|
|
c896fb |
@@ -125,6 +128,7 @@ void checker_set_async (struct checker *);
|
|
|
c896fb |
void checker_set_fd (struct checker *, int);
|
|
|
c896fb |
void checker_enable (struct checker *);
|
|
|
c896fb |
void checker_disable (struct checker *);
|
|
|
c896fb |
+void checker_repair (struct checker *);
|
|
|
c896fb |
int checker_check (struct checker *);
|
|
|
c896fb |
int checker_selected (struct checker *);
|
|
|
c896fb |
char * checker_name (struct checker *);
|
|
|
c896fb |
diff --git a/libmultipath/checkers/cciss_tur.c b/libmultipath/checkers/cciss_tur.c
|
|
|
c896fb |
index 4c26901..7e4eb81 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/cciss_tur.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/cciss_tur.c
|
|
|
c896fb |
@@ -63,6 +63,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
return;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
extern int
|
|
|
c896fb |
libcheck_check (struct checker * c)
|
|
|
c896fb |
{
|
|
|
c896fb |
diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c
|
|
|
c896fb |
index 46fe6a7..1a997ed 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/directio.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/directio.c
|
|
|
c896fb |
@@ -116,6 +116,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
free(ct);
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
static int
|
|
|
c896fb |
check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
|
|
|
c896fb |
{
|
|
|
c896fb |
diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c
|
|
|
c896fb |
index b42d267..43b5025 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/emc_clariion.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/emc_clariion.c
|
|
|
c896fb |
@@ -90,6 +90,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
free(c->context);
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
int libcheck_check (struct checker * c)
|
|
|
c896fb |
{
|
|
|
c896fb |
unsigned char sense_buffer[128] = { 0, };
|
|
|
c896fb |
diff --git a/libmultipath/checkers/hp_sw.c b/libmultipath/checkers/hp_sw.c
|
|
|
c896fb |
index b50ac0c..857ac5e 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/hp_sw.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/hp_sw.c
|
|
|
c896fb |
@@ -44,6 +44,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
return;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
static int
|
|
|
c896fb |
do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
|
|
|
c896fb |
void *resp, int mx_resp_len, int noisy, unsigned int timeout)
|
|
|
c896fb |
diff --git a/libmultipath/checkers/rdac.c b/libmultipath/checkers/rdac.c
|
|
|
c896fb |
index f0e0af3..5469e61 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/rdac.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/rdac.c
|
|
|
c896fb |
@@ -139,6 +139,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
return;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
static int
|
|
|
c896fb |
do_inq(int sg_fd, unsigned int pg_op, void *resp, int mx_resp_len,
|
|
|
c896fb |
unsigned int timeout)
|
|
|
c896fb |
diff --git a/libmultipath/checkers/readsector0.c b/libmultipath/checkers/readsector0.c
|
|
|
c896fb |
index 0550fb6..b3ed1f3 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/readsector0.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/readsector0.c
|
|
|
c896fb |
@@ -23,6 +23,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
return;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
int libcheck_check (struct checker * c)
|
|
|
c896fb |
{
|
|
|
c896fb |
unsigned char buf[4096];
|
|
|
c896fb |
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
|
|
|
c896fb |
index 1e5b039..91f1458 100644
|
|
|
c896fb |
--- a/libmultipath/checkers/tur.c
|
|
|
c896fb |
+++ b/libmultipath/checkers/tur.c
|
|
|
c896fb |
@@ -187,6 +187,11 @@ void libcheck_free (struct checker * c)
|
|
|
c896fb |
return;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void libcheck_repair (struct checker * c)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
#define TUR_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args);
|
|
|
c896fb |
|
|
|
c896fb |
int
|
|
|
c896fb |
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
|
c896fb |
index 8808c88..d26fd22 100644
|
|
|
c896fb |
--- a/multipathd/main.c
|
|
|
c896fb |
+++ b/multipathd/main.c
|
|
|
c896fb |
@@ -1455,6 +1455,14 @@ check_path (struct vectors * vecs, struct path * pp)
|
|
|
c896fb |
}
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+void repair_path(struct vectors * vecs, struct path * pp)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ if (pp->state != PATH_DOWN)
|
|
|
c896fb |
+ return;
|
|
|
c896fb |
+
|
|
|
c896fb |
+ checker_repair(&pp->checker);
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
static void *
|
|
|
c896fb |
checkerloop (void *ap)
|
|
|
c896fb |
{
|
|
|
c896fb |
@@ -1483,6 +1491,7 @@ checkerloop (void *ap)
|
|
|
c896fb |
if (vecs->pathvec) {
|
|
|
c896fb |
vector_foreach_slot (vecs->pathvec, pp, i) {
|
|
|
c896fb |
check_path(vecs, pp);
|
|
|
c896fb |
+ repair_path(vecs, pp);
|
|
|
c896fb |
}
|
|
|
c896fb |
}
|
|
|
c896fb |
if (vecs->mpvec) {
|
|
|
c896fb |
--
|
|
|
c896fb |
1.8.3.1
|
|
|
c896fb |
|