From c8115c03bacd91af26da3bb0b6d0fa634e33ce57 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Sat, 11 Aug 2007 10:41:31 +0200 Subject: [PATCH] [multipathd] fail/reinstate CLI commands disable/enable path checker The "fail path X" CLI command was an interesting debug tool, showing the checkers automatically reinstating the failed path. But some fun spoilers want to use the thing to prepare cable unplugs and other maintenance ops. So make the command also care about diabling and enabling the checker to inhibit auto-reinstates. --- libcheckers/checkers.c | 14 +++++++++++++- libcheckers/checkers.h | 9 ++++++--- multipathd/cli_handlers.c | 10 +++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/libcheckers/checkers.c b/libcheckers/checkers.c index d7728a5..f07d537 100644 --- a/libcheckers/checkers.c +++ b/libcheckers/checkers.c @@ -71,7 +71,7 @@ static struct checker checkers[] = { .init = readsector0_init, .free = readsector0_free }, - {0, 1, "", "", NULL, NULL, NULL, NULL}, + {0, 1, 0, "", "", NULL, NULL, NULL, NULL}, }; void checker_set_fd (struct checker * c, int fd) @@ -89,6 +89,16 @@ void checker_set_async (struct checker * c) c->sync = 0; } +void checker_enable (struct checker * c) +{ + c->disable = 0; +} + +void checker_disable (struct checker * c) +{ + c->disable = 1; +} + struct checker * checker_lookup (char * name) { struct checker * c = &checkers[0]; @@ -118,6 +128,8 @@ int checker_check (struct checker * c) { int r; + if (c->disable) + return PATH_UNCHECKED; if (c->fd <= 0) { MSG(c, "no usable fd"); return PATH_WILD; diff --git a/libcheckers/checkers.h b/libcheckers/checkers.h index 9b270eb..3ce643b 100644 --- a/libcheckers/checkers.h +++ b/libcheckers/checkers.h @@ -87,6 +87,7 @@ struct checker { int fd; int sync; + int disable; char name[CHECKER_NAME_LEN]; char message[CHECKER_MSG_LEN]; /* comm with callers */ void * context; /* store for persistent data */ @@ -101,10 +102,12 @@ struct checker { int checker_init (struct checker *, void **); void checker_put (struct checker *); -void checker_reset (struct checker * c); -void checker_set_sync (struct checker * c); -void checker_set_async (struct checker * c); +void checker_reset (struct checker *); +void checker_set_sync (struct checker *); +void checker_set_async (struct checker *); void checker_set_fd (struct checker *, int); +void checker_enable (struct checker *); +void checker_disable (struct checker *); struct checker * checker_lookup (char *); int checker_check (struct checker *); int checker_selected (struct checker *); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 7bae02a..f71dca0 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -431,6 +431,7 @@ cli_reinstate(void * v, char ** reply, int * len, void * data) condlog(2, "%s: reinstate path %s (operator)", pp->mpp->alias, pp->dev_t); + checker_enable(&pp->checker); return dm_reinstate_path(pp->mpp->alias, pp->dev_t); } @@ -440,6 +441,7 @@ cli_fail(void * v, char ** reply, int * len, void * data) struct vectors * vecs = (struct vectors *)data; char * param = get_keyparam(v, PATH); struct path * pp; + int r; pp = find_path_by_dev(vecs->pathvec, param); @@ -452,7 +454,13 @@ cli_fail(void * v, char ** reply, int * len, void * data) condlog(2, "%s: fail path %s (operator)", pp->mpp->alias, pp->dev_t); - return dm_fail_path(pp->mpp->alias, pp->dev_t); + r = dm_fail_path(pp->mpp->alias, pp->dev_t); + /* + * Suspend path checking to avoid auto-reinstating the path + */ + if (!r) + checker_disable(&pp->checker); + return r; } int -- 2.7.4