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