提交 1a614f50 编写于 作者: S Steve Cameron 提交者: Linus Torvalds

cciss: fix error reporting for SG_IO

This fixes a problem with the way cciss was filling out the "errors" field
of the request structure upon completion of requests.  Previously, it just
put a 1 or a 0 in there and used the negation of this as the uptodate
parameter to one of the functions in the block layer, being a block device.
 For the SG_IO ioctl, this was not sufficient, and we noticed that, for
example, sg_turs from sg3_utils did not correctly detect problems due to
cciss having set rq->errors incorrectly.
Signed-off-by: NStephen M. Cameron <steve.cameron@hp.com>
Acked-by: NMike Miller <mike.miller@hp.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 7fdfd406
...@@ -2365,30 +2365,55 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) ...@@ -2365,30 +2365,55 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c)
start_io(h); start_io(h);
} }
static inline unsigned int make_status_bytes(unsigned int scsi_status_byte,
unsigned int msg_byte, unsigned int host_byte,
unsigned int driver_byte)
{
/* inverse of macros in scsi.h */
return (scsi_status_byte & 0xff) |
((msg_byte & 0xff) << 8) |
((host_byte & 0xff) << 16) |
((driver_byte & 0xff) << 24);
}
static inline int evaluate_target_status(CommandList_struct *cmd) static inline int evaluate_target_status(CommandList_struct *cmd)
{ {
unsigned char sense_key; unsigned char sense_key;
int error_count = 1; unsigned char status_byte, msg_byte, host_byte, driver_byte;
int error_value;
/* If we get in here, it means we got "target status", that is, scsi status */
status_byte = cmd->err_info->ScsiStatus;
driver_byte = DRIVER_OK;
msg_byte = cmd->err_info->CommandStatus; /* correct? seems too device specific */
if (blk_pc_request(cmd->rq))
host_byte = DID_PASSTHROUGH;
else
host_byte = DID_OK;
error_value = make_status_bytes(status_byte, msg_byte,
host_byte, driver_byte);
if (cmd->err_info->ScsiStatus != 0x02) { /* not check condition? */ if (cmd->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) {
if (!blk_pc_request(cmd->rq)) if (!blk_pc_request(cmd->rq))
printk(KERN_WARNING "cciss: cmd %p " printk(KERN_WARNING "cciss: cmd %p "
"has SCSI Status 0x%x\n", "has SCSI Status 0x%x\n",
cmd, cmd->err_info->ScsiStatus); cmd, cmd->err_info->ScsiStatus);
return error_count; return error_value;
} }
/* check the sense key */ /* check the sense key */
sense_key = 0xf & cmd->err_info->SenseInfo[2]; sense_key = 0xf & cmd->err_info->SenseInfo[2];
/* no status or recovered error */ /* no status or recovered error */
if ((sense_key == 0x0) || (sense_key == 0x1)) if (((sense_key == 0x0) || (sense_key == 0x1)) && !blk_pc_request(cmd->rq))
error_count = 0; error_value = 0;
if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */ if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */
if (error_count != 0) if (error_value != 0)
printk(KERN_WARNING "cciss: cmd %p has CHECK CONDITION" printk(KERN_WARNING "cciss: cmd %p has CHECK CONDITION"
" sense key = 0x%x\n", cmd, sense_key); " sense key = 0x%x\n", cmd, sense_key);
return error_count; return error_value;
} }
/* SG_IO or similar, copy sense data back */ /* SG_IO or similar, copy sense data back */
...@@ -2400,7 +2425,7 @@ static inline int evaluate_target_status(CommandList_struct *cmd) ...@@ -2400,7 +2425,7 @@ static inline int evaluate_target_status(CommandList_struct *cmd)
} else } else
cmd->rq->sense_len = 0; cmd->rq->sense_len = 0;
return error_count; return error_value;
} }
/* checks the status of the job and calls complete buffers to mark all /* checks the status of the job and calls complete buffers to mark all
...@@ -2416,7 +2441,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2416,7 +2441,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
rq->errors = 0; rq->errors = 0;
if (timeout) if (timeout)
rq->errors = 1; rq->errors = make_status_bytes(0, 0, 0, DRIVER_TIMEOUT);
if (cmd->err_info->CommandStatus == 0) /* no error has occurred */ if (cmd->err_info->CommandStatus == 0) /* no error has occurred */
goto after_error_processing; goto after_error_processing;
...@@ -2442,32 +2467,44 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2442,32 +2467,44 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
case CMD_INVALID: case CMD_INVALID:
printk(KERN_WARNING "cciss: cmd %p is " printk(KERN_WARNING "cciss: cmd %p is "
"reported invalid\n", cmd); "reported invalid\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
case CMD_PROTOCOL_ERR: case CMD_PROTOCOL_ERR:
printk(KERN_WARNING "cciss: cmd %p has " printk(KERN_WARNING "cciss: cmd %p has "
"protocol error \n", cmd); "protocol error \n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
case CMD_HARDWARE_ERR: case CMD_HARDWARE_ERR:
printk(KERN_WARNING "cciss: cmd %p had " printk(KERN_WARNING "cciss: cmd %p had "
" hardware error\n", cmd); " hardware error\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
case CMD_CONNECTION_LOST: case CMD_CONNECTION_LOST:
printk(KERN_WARNING "cciss: cmd %p had " printk(KERN_WARNING "cciss: cmd %p had "
"connection lost\n", cmd); "connection lost\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
case CMD_ABORTED: case CMD_ABORTED:
printk(KERN_WARNING "cciss: cmd %p was " printk(KERN_WARNING "cciss: cmd %p was "
"aborted\n", cmd); "aborted\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ABORT);
break; break;
case CMD_ABORT_FAILED: case CMD_ABORT_FAILED:
printk(KERN_WARNING "cciss: cmd %p reports " printk(KERN_WARNING "cciss: cmd %p reports "
"abort failed\n", cmd); "abort failed\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
case CMD_UNSOLICITED_ABORT: case CMD_UNSOLICITED_ABORT:
printk(KERN_WARNING "cciss%d: unsolicited " printk(KERN_WARNING "cciss%d: unsolicited "
...@@ -2481,17 +2518,23 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2481,17 +2518,23 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
printk(KERN_WARNING printk(KERN_WARNING
"cciss%d: %p retried too " "cciss%d: %p retried too "
"many times\n", h->ctlr, cmd); "many times\n", h->ctlr, cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ABORT);
break; break;
case CMD_TIMEOUT: case CMD_TIMEOUT:
printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd); printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
break; break;
default: default:
printk(KERN_WARNING "cciss: cmd %p returned " printk(KERN_WARNING "cciss: cmd %p returned "
"unknown status %x\n", cmd, "unknown status %x\n", cmd,
cmd->err_info->CommandStatus); cmd->err_info->CommandStatus);
rq->errors = 1; rq->errors = make_status_bytes(SAM_STAT_GOOD,
cmd->err_info->CommandStatus, DRIVER_OK,
blk_pc_request(cmd->rq) ? DID_PASSTHROUGH : DID_ERROR);
} }
after_error_processing: after_error_processing:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册