@@ -139,6 +139,14 @@ struct checker * add_checker (char * name)
if (!c->free)
goto out;
+ c->repair = (void (*)(struct checker *)) dlsym(c->handle,
+ "libcheck_repair");
+ errstr = dlerror();
+ if (errstr != NULL)
+ condlog(0, "A dynamic linking error occurred: (%s)", errstr);
+ if (!c->repair)
+ goto out;
+
c->fd = 0;
c->sync = 1;
list_add(&c->node, &checkers);
@@ -204,6 +212,20 @@ void checker_put (struct checker * dst)
free_checker(src);
}
+void checker_repair (struct checker * c)
+{
+ if (!c)
+ return;
+
+ c->message[0] = '\0';
+ if (c->disable) {
+ MSG(c, "checker disabled");
+ return;
+ }
+
+ c->repair(c);
+}
+
int checker_check (struct checker * c)
{
int r;
@@ -268,6 +290,7 @@ void checker_get (struct checker * dst, char * name)
dst->sync = src->sync;
strncpy(dst->name, src->name, CHECKER_NAME_LEN);
strncpy(dst->message, src->message, CHECKER_MSG_LEN);
+ dst->repair = src->repair;
dst->check = src->check;
dst->init = src->init;
dst->free = src->free;
@@ -113,6 +113,9 @@ struct checker {
multipath-wide. Use MALLOC if
you want to stuff data in. */
int (*check)(struct checker *);
+ void (*repair)(struct checker *); /* called if check returns
+ PATH_DOWN to bring path into
+ usable state */
int (*init)(struct checker *); /* to allocate the context */
void (*free)(struct checker *); /* to free the context */
};
@@ -132,6 +135,7 @@ void checker_set_async (struct checker *);
void checker_set_fd (struct checker *, int);
void checker_enable (struct checker *);
void checker_disable (struct checker *);
+void checker_repair (struct checker *);
int checker_check (struct checker *);
int checker_selected (struct checker *);
char * checker_name (struct checker *);
@@ -63,6 +63,11 @@ void libcheck_free (struct checker * c)
return;
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
extern int
libcheck_check (struct checker * c)
{
@@ -118,6 +118,11 @@ void libcheck_free (struct checker * c)
free(ct);
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
static int
check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
{
@@ -91,6 +91,11 @@ void libcheck_free (struct checker * c)
free(c->context);
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
int libcheck_check (struct checker * c)
{
unsigned char sense_buffer[128] = { 0, };
@@ -44,6 +44,11 @@ void libcheck_free (struct checker * c)
return;
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
static int
do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
void *resp, int mx_resp_len, int noisy, unsigned int timeout)
@@ -139,6 +139,11 @@ void libcheck_free (struct checker * c)
return;
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
static int
do_inq(int sg_fd, unsigned int pg_op, void *resp, int mx_resp_len,
unsigned int timeout)
@@ -23,6 +23,11 @@ void libcheck_free (struct checker * c)
return;
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
int libcheck_check (struct checker * c)
{
unsigned char buf[4096];
@@ -97,6 +97,11 @@ void libcheck_free (struct checker * c)
return;
}
+void libcheck_repair (struct checker * c)
+{
+ return;
+}
+
#define TUR_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args);
int
@@ -1635,6 +1635,14 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
return 1;
}
+void repair_path(struct vectors * vecs, struct path * pp)
+{
+ if (pp->state != PATH_DOWN)
+ return;
+
+ checker_repair(&pp->checker);
+}
+
static void *
checkerloop (void *ap)
{
@@ -1665,6 +1673,7 @@ checkerloop (void *ap)
while (1) {
struct timeval diff_time, start_time, end_time;
int num_paths = 0, ticks = 0, signo, strict_timing, rc = 0;
+ int checked;
sigset_t mask;
if (gettimeofday(&start_time, NULL) != 0)
@@ -1695,7 +1704,10 @@ checkerloop (void *ap)
lock(vecs->lock);
pthread_testcancel();
vector_foreach_slot (vecs->pathvec, pp, i) {
- num_paths += check_path(vecs, pp, ticks);
+ checked = check_path(vecs, pp, ticks);
+ if (checked)
+ repair_path(vecs, pp);
+ num_paths += checked;
}
lock_cleanup_pop(vecs->lock);
}
This patch adds a callback which can be used to repair a path if check() has determined it is in the PATH_DOWN state. The next patch that adds rbd checker support which will use this to handle the case where a rbd device is blacklisted. Signed-off-by: Mike Christie <mchristi@redhat.com> --- libmultipath/checkers.c | 23 +++++++++++++++++++++++ libmultipath/checkers.h | 4 ++++ libmultipath/checkers/cciss_tur.c | 5 +++++ libmultipath/checkers/directio.c | 5 +++++ libmultipath/checkers/emc_clariion.c | 5 +++++ libmultipath/checkers/hp_sw.c | 5 +++++ libmultipath/checkers/rdac.c | 5 +++++ libmultipath/checkers/readsector0.c | 5 +++++ libmultipath/checkers/tur.c | 5 +++++ multipathd/main.c | 14 +++++++++++++- 10 files changed, 75 insertions(+), 1 deletion(-)