---
libmultipath/checkers/emc_clariion.c | 79 ++++++++++++----------------
1 file changed, 33 insertions(+), 46 deletions(-)
diff --git a/libmultipath/checkers/emc_clariion.c
b/libmultipath/checkers/emc_clariion.c
index 24a386c..2c9d4fd 100644
--- a/libmultipath/checkers/emc_clariion.c
+++ b/libmultipath/checkers/emc_clariion.c
@@ -1,8 +1,6 @@
/*
* Copyright (c) 2004, 2005 Lars Marowsky-Bree
*/
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -14,8 +12,8 @@
#include "sg_include.h"
#include "libsg.h"
#include "checkers.h"
+#include "async_checker.h"
#include "debug.h"
-#include "util.h"
#define INQUIRY_CMD 0x12
#define INQUIRY_CMDLEN 6
@@ -33,19 +31,17 @@
* simple read test would return 02/04/03 instead
* of 05/25/01 sensekey/ASC/ASCQ data.
*/
-#define IS_INACTIVE_SNAP(mpctx) \
- (!mpctx || IS_INVALID_MPCONTEXT(*mpctx) ? 0 : mpctx->long_val)
+#define IS_INACTIVE_SNAP(mpctx) \
+ (IS_INVALID_MPCONTEXT(mpctx) ? 0 : mpctx.long_val)
#define SET_INACTIVE_SNAP(mpctx) \
do { \
- if (mpctx) \
- mpctx->long_val = 1; \
+ mpctx.long_val = 1; \
} while (0);
#define CLR_INACTIVE_SNAP(mpctx) \
do { \
- if (mpctx) \
- mpctx->long_val = 0; \
+ mpctx.long_val = 0; \
} while (0);
enum {
@@ -86,7 +82,9 @@ struct emc_clariion_checker_LU_context {
int inactive_snap;
};
-void hexadecimal_to_ascii(char * wwn, char *wwnstr)
+int async_context_size = sizeof(struct emc_clariion_checker_path_context);
+
+static void hexadecimal_to_ascii(char *wwn, char *wwnstr)
{
int i,j, nbl;
@@ -99,33 +97,22 @@ void hexadecimal_to_ascii(char * wwn, char *wwnstr)
wwnstr[32]=0;
}
-int libcheck_init (struct checker * c)
+int async_init(struct runner_data *rdata)
{
- /*
- * Allocate and initialize the path specific context.
- */
- c->context = calloc(1, sizeof(struct
emc_clariion_checker_path_context));
- if (!c->context)
- return 1;
- ((struct emc_clariion_checker_path_context *)c->context)->wwn_set = 0;
+ ((struct emc_clariion_checker_path_context
*)rdata->checker_ctx)->wwn_set = 0;
return 0;
}
-void libcheck_free(struct checker *c)
-{
- free(c->context);
-}
-
-int libcheck_check(struct checker *c, union checker_mpcontext *mpctx)
+int libcheck_async_func(struct runner_data *rdata)
{
unsigned char sense_buffer[128] = { 0, };
unsigned char sb[SENSE_BUFF_LEN] = { 0, }, *sbb;
unsigned char inqCmdBlk[INQUIRY_CMDLEN] = {INQUIRY_CMD, 1, 0xC0, 0,
sizeof(sense_buffer), 0};
struct sg_io_hdr io_hdr;
- struct emc_clariion_checker_path_context * ct =
- (struct emc_clariion_checker_path_context *)c->context;
+ struct emc_clariion_checker_path_context *ct =
+ (struct emc_clariion_checker_path_context *)rdata->checker_ctx;
char wwnstr[33];
int ret;
int retry_emc = 5;
@@ -142,14 +129,14 @@ retry:
io_hdr.dxferp = sense_buffer;
io_hdr.cmdp = inqCmdBlk;
io_hdr.sbp = sb;
- io_hdr.timeout = c->timeout * 1000;
+ io_hdr.timeout = rdata->timeout * 1000;
io_hdr.pack_id = 0;
- if (ioctl(c->fd, SG_IO, &io_hdr) < 0) {
+ if (ioctl(rdata->fd, SG_IO, &io_hdr) < 0) {
if (errno == ENOTTY) {
- c->msgid = CHECKER_MSGID_UNSUPPORTED;
+ rdata->msgid = CHECKER_MSGID_UNSUPPORTED;
return PATH_WILD;
}
- c->msgid = MSG_CLARIION_QUERY_FAILED;
+ rdata->msgid = MSG_CLARIION_QUERY_FAILED;
return PATH_DOWN;
}
@@ -181,12 +168,12 @@ retry:
sense_key = sbp[2] & 0xf;
if (sense_key == ILLEGAL_REQUEST) {
- c->msgid = CHECKER_MSGID_UNSUPPORTED;
+ rdata->msgid = CHECKER_MSGID_UNSUPPORTED;
return PATH_WILD;
} else if (sense_key != RECOVERED_ERROR) {
condlog(1, "emc_clariion_checker: INQUIRY
failed with sense key %02x",
sense_key);
- c->msgid = MSG_CLARIION_QUERY_ERROR;
+ rdata->msgid = MSG_CLARIION_QUERY_ERROR;
return PATH_DOWN;
}
}
@@ -195,13 +182,13 @@ retry:
if (io_hdr.info & SG_INFO_OK_MASK) {
condlog(1, "emc_clariion_checker: INQUIRY failed without sense,
status %02x",
io_hdr.status);
- c->msgid = MSG_CLARIION_QUERY_ERROR;
+ rdata->msgid = MSG_CLARIION_QUERY_ERROR;
return PATH_DOWN;
}
if (/* Verify the code page - right page & revision */
sense_buffer[1] != 0xc0 || sense_buffer[9] != 0x00) {
- c->msgid = MSG_CLARIION_UNIT_REPORT;
+ rdata->msgid = MSG_CLARIION_UNIT_REPORT;
return PATH_DOWN;
}
@@ -215,19 +202,19 @@ retry:
((sense_buffer[28] & 0x07) != 0x06))
/* Arraycommpath should be set to 1 */
|| (sense_buffer[30] & 0x04) != 0x04) {
- c->msgid = MSG_CLARIION_PATH_CONFIG;
+ rdata->msgid = MSG_CLARIION_PATH_CONFIG;
return PATH_DOWN;
}
if ( /* LUN operations should indicate normal operations */
sense_buffer[48] != 0x00) {
- c->msgid = MSG_CLARIION_PATH_NOT_AVAIL;
+ rdata->msgid = MSG_CLARIION_PATH_NOT_AVAIL;
return PATH_SHAKY;
}
if ( /* LUN should at least be bound somewhere and not be LUNZ */
sense_buffer[4] == 0x00) {
- c->msgid = MSG_CLARIION_LUN_UNBOUND;
+ rdata->msgid = MSG_CLARIION_LUN_UNBOUND;
return PATH_DOWN;
}
@@ -238,7 +225,7 @@ retry:
*/
if (ct->wwn_set) {
if (memcmp(ct->wwn, &sense_buffer[10], 16) != 0) {
- c->msgid = MSG_CLARIION_WWN_CHANGED;
+ rdata->msgid = MSG_CLARIION_WWN_CHANGED;
return PATH_DOWN;
}
} else {
@@ -253,8 +240,8 @@ retry:
unsigned char buf[4096];
memset(buf, 0, 4096);
- ret = sg_read(c->fd, &buf[0], 4096,
- sbb = &sb[0], SENSE_BUFF_LEN, c->timeout);
+ ret = sg_read(rdata->fd, &buf[0], 4096, sbb = &sb[0],
+ SENSE_BUFF_LEN, rdata->timeout);
if (ret == PATH_DOWN) {
hexadecimal_to_ascii(ct->wwn, wwnstr);
@@ -269,7 +256,7 @@ retry:
* passive paths which will return
* 02/04/03 not 05/25/01 on read.
*/
- SET_INACTIVE_SNAP(mpctx);
+ SET_INACTIVE_SNAP(rdata->mpc);
condlog(3, "emc_clariion_checker: Active "
"path to inactive snapshot WWN %s.",
wwnstr);
@@ -278,26 +265,26 @@ retry:
"error for WWN %s. Sense data are "
"0x%x/0x%x/0x%x.", wwnstr,
sbb[2]&0xf, sbb[12], sbb[13]);
- c->msgid = MSG_CLARIION_READ_ERROR;
+ rdata->msgid = MSG_CLARIION_READ_ERROR;
}
} else {
- c->msgid = MSG_CLARIION_PASSIVE_GOOD;
+ rdata->msgid = MSG_CLARIION_PASSIVE_GOOD;
/*
* Remove the path from the set of paths to inactive
* snapshot LUs if it was in this list since the
* snapshot is no longer inactive.
*/
- CLR_INACTIVE_SNAP(mpctx);
+ CLR_INACTIVE_SNAP(rdata->mpc);
}
} else {
- if (IS_INACTIVE_SNAP(mpctx)) {
+ if (IS_INACTIVE_SNAP(rdata->mpc)) {
hexadecimal_to_ascii(ct->wwn, wwnstr);
condlog(3, "emc_clariion_checker: Passive "
"path to inactive snapshot WWN %s.",
wwnstr);
ret = PATH_DOWN;
} else {
- c->msgid = MSG_CLARIION_PASSIVE_GOOD;
+ rdata->msgid = MSG_CLARIION_PASSIVE_GOOD;
ret = PATH_UP; /* not ghost */
}
}
--
2.54.0