@@ -14,6 +14,7 @@
#include "checkers.h"
#include "../libmultipath/sg_include.h"
+#include "../libmultipath/debug.h"
#define SENSE_BUFF_LEN 32
@@ -50,6 +51,7 @@
int res;
int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88};
int sz_ind;
+ int retry_count = 3;
memset(rdCmd, 0, cdbsz);
sz_ind = 1;
@@ -75,6 +77,8 @@
if (diop && *diop)
io_hdr.flags |= SG_FLAG_DIRECT_IO;
+retry:
+ memset(senseBuff, 0, SENSE_BUFF_LEN);
while (((res = ioctl(sg_fd, SG_IO, &io_hdr)) < 0) && (EINTR == errno));
if (res < 0) {
@@ -89,6 +93,24 @@
(0 == io_hdr.driver_status)) {
return PATH_UP;
} else {
+ int key = 0;
+
+ if (io_hdr.sb_len_wr > 3) {
+ if (senseBuff[0] == 0x72 || senseBuff[0] == 0x73)
+ key = senseBuff[1] & 0x0f;
+ else if (io_hdr.sb_len_wr > 13 &&
+ ((senseBuff[0] & 0x7f) == 0x70 ||
+ (senseBuff[0] & 0x7f) == 0x71))
+ key = senseBuff[2] & 0x0f;
+ }
+
+ /*
+ * Retry if UNIT_ATTENTION check condition.
+ */
+ if (key == 0x6) {
+ if (--retry_count)
+ goto retry;
+ }
return PATH_DOWN;
}
}