Search
j0ke.net Open Build Service
>
Projects
>
GFS
>
multipath-tools
> multipath-tools-retry-sg_read
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File multipath-tools-retry-sg_read of Package multipath-tools
commit f0aa11f03cf7dfd9973a0f5df833283916639f0b Author: Hannes Reinecke <hare@suse.de> Date: Mon Mar 17 14:29:36 2008 +0100 Improve sense code scanning in sg_read() and tur sg_read and tur should be able to scan all sense data, as we might need to retry a UNIT ATTENTION. References: 343019,329922 Signed-off-by: Hannes Reinecke <hare@suse.de> diff --git a/libcheckers/libsg.c b/libcheckers/libsg.c index 9171b10..4cb7ecc 100644 --- a/libcheckers/libsg.c +++ b/libcheckers/libsg.c @@ -72,10 +72,21 @@ retry: (0 == io_hdr.driver_status)) { return PATH_UP; } else { + int key = 0; + + if (io_hdr.sb_len_wr > 3) { + if (sbb[0] == 0x72 || sbb[0] == 0x73) + key = sbb[1] & 0x0f; + else if (io_hdr.sb_len_wr > 13 && + ((sbb[0] & 0x7f) == 0x70 || + (sbb[0] & 0x7f) == 0x71)) + key = sbb[2] & 0x0f; + } + /* * Retry if UNIT_ATTENTION check condition. */ - if ((sbb[2]&0xf) == 6) { + if (key == 0x6) { if (--retry_count) goto retry; } diff --git a/libcheckers/tur.c b/libcheckers/tur.c index e79bc0a..6022590 100644 --- a/libcheckers/tur.c +++ b/libcheckers/tur.c @@ -41,26 +41,48 @@ extern int tur (struct checker * c) { struct sg_io_hdr io_hdr; - unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 }; - unsigned char sense_buffer[32]; + unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 }; + unsigned char sense_buffer[32]; + int retry_tur = 5; - memset(&io_hdr, 0, sizeof (struct sg_io_hdr)); - io_hdr.interface_id = 'S'; - io_hdr.cmd_len = sizeof (turCmdBlk); - io_hdr.mx_sb_len = sizeof (sense_buffer); - io_hdr.dxfer_direction = SG_DXFER_NONE; - io_hdr.cmdp = turCmdBlk; - io_hdr.sbp = sense_buffer; - io_hdr.timeout = DEF_TIMEOUT; - io_hdr.pack_id = 0; - if (ioctl(c->fd, SG_IO, &io_hdr) < 0) { + retry: + memset(&io_hdr, 0, sizeof (struct sg_io_hdr)); + io_hdr.interface_id = 'S'; + io_hdr.cmd_len = sizeof (turCmdBlk); + io_hdr.mx_sb_len = sizeof (sense_buffer); + io_hdr.dxfer_direction = SG_DXFER_NONE; + io_hdr.cmdp = turCmdBlk; + io_hdr.sbp = sense_buffer; + io_hdr.timeout = DEF_TIMEOUT; + io_hdr.pack_id = 0; + if (ioctl(c->fd, SG_IO, &io_hdr) < 0) { MSG(c, MSG_TUR_DOWN); - return PATH_DOWN; - } - if (io_hdr.info & SG_INFO_OK_MASK) { + return PATH_DOWN; + } + if (io_hdr.info & SG_INFO_OK_MASK) { + int key = 0, asc, ascq; + + if (io_hdr.sb_len_wr > 3) { + if (io_hdr.sbp[0] == 0x72 || io_hdr.sbp[0] == 0x73) { + key = io_hdr.sbp[1] & 0x0f; + asc = io_hdr.sbp[2]; + ascq = io_hdr.sbp[3]; + } else if (io_hdr.sb_len_wr > 13 && + ((io_hdr.sbp[0] & 0x7f) == 0x70 || + (io_hdr.sbp[0] & 0x7f) == 0x71)) { + key = io_hdr.sbp[2] & 0x0f; + asc = io_hdr.sbp[12]; + ascq = io_hdr.sbp[13]; + } + } + if (key == 0x6) { + /* Unit Attention, retry */ + if (--retry_tur) + goto retry; + } MSG(c, MSG_TUR_DOWN); - return PATH_DOWN; - } + return PATH_DOWN; + } MSG(c, MSG_TUR_UP); - return PATH_UP; + return PATH_UP; }