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