Commit 198b7660 authored by Mike Miller (OS Dev)'s avatar Mike Miller (OS Dev) Committed by Linus Torvalds

cciss: set rq->errors more correctly in driver

Set rq->errors more correctly in cciss driver.  Previously we had set it
synonymously with the meaning of the last parameter of end_that_last_request
and complete_buffers (the "uptodate" parameter) and had gotten away with it
for all this time because nobody ever looked at rq->errors.
SCSI_IOCTL_SEND_COMMAND looks at rq->errors, so now it matters that it be
right.
Signed-off-by: default avatarStephen M. Cameron <steve.cameron@hp.com>
Signed-off-by: default avatarMike Miller <mike.miller@hp.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 03bbfee5
...@@ -1261,7 +1261,7 @@ static void cciss_softirq_done(struct request *rq) ...@@ -1261,7 +1261,7 @@ static void cciss_softirq_done(struct request *rq)
pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir);
} }
complete_buffers(rq->bio, rq->errors); complete_buffers(rq->bio, (rq->errors == 0));
if (blk_fs_request(rq)) { if (blk_fs_request(rq)) {
const int rw = rq_data_dir(rq); const int rw = rq_data_dir(rq);
...@@ -1275,7 +1275,7 @@ static void cciss_softirq_done(struct request *rq) ...@@ -1275,7 +1275,7 @@ static void cciss_softirq_done(struct request *rq)
add_disk_randomness(rq->rq_disk); add_disk_randomness(rq->rq_disk);
spin_lock_irqsave(&h->lock, flags); spin_lock_irqsave(&h->lock, flags);
end_that_request_last(rq, rq->errors); end_that_request_last(rq, (rq->errors == 0));
cmd_free(h, cmd, 1); cmd_free(h, cmd, 1);
cciss_check_queues(h); cciss_check_queues(h);
spin_unlock_irqrestore(&h->lock, flags); spin_unlock_irqrestore(&h->lock, flags);
...@@ -2366,27 +2366,27 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) ...@@ -2366,27 +2366,27 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c)
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 status = 0; /* 0 means bad, 1 means good. */ int error_count = 1;
if (cmd->err_info->ScsiStatus != 0x02) { /* not check condition? */ if (cmd->err_info->ScsiStatus != 0x02) { /* not 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 status; return error_count;
} }
/* 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))
status = 1; error_count = 0;
if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */ if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */
if (status == 0) if (error_count != 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 status; return error_count;
} }
/* SG_IO or similar, copy sense data back */ /* SG_IO or similar, copy sense data back */
...@@ -2398,7 +2398,7 @@ static inline int evaluate_target_status(CommandList_struct *cmd) ...@@ -2398,7 +2398,7 @@ static inline int evaluate_target_status(CommandList_struct *cmd)
} else } else
cmd->rq->sense_len = 0; cmd->rq->sense_len = 0;
return status; return error_count;
} }
/* 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
...@@ -2408,18 +2408,20 @@ static inline int evaluate_target_status(CommandList_struct *cmd) ...@@ -2408,18 +2408,20 @@ static inline int evaluate_target_status(CommandList_struct *cmd)
static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
int timeout) int timeout)
{ {
int status = 1;
int retry_cmd = 0; int retry_cmd = 0;
struct request *rq = cmd->rq;
rq->errors = 0;
if (timeout) if (timeout)
status = 0; rq->errors = 1;
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;
switch (cmd->err_info->CommandStatus) { switch (cmd->err_info->CommandStatus) {
case CMD_TARGET_STATUS: case CMD_TARGET_STATUS:
status = evaluate_target_status(cmd); rq->errors = evaluate_target_status(cmd);
break; break;
case CMD_DATA_UNDERRUN: case CMD_DATA_UNDERRUN:
if (blk_fs_request(cmd->rq)) { if (blk_fs_request(cmd->rq)) {
...@@ -2438,32 +2440,32 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2438,32 +2440,32 @@ 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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
break; break;
case CMD_UNSOLICITED_ABORT: case CMD_UNSOLICITED_ABORT:
printk(KERN_WARNING "cciss%d: unsolicited " printk(KERN_WARNING "cciss%d: unsolicited "
...@@ -2477,17 +2479,17 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2477,17 +2479,17 @@ 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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
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);
status = 0; rq->errors = 1;
} }
after_error_processing: after_error_processing:
...@@ -2498,7 +2500,6 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, ...@@ -2498,7 +2500,6 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
return; return;
} }
cmd->rq->data_len = 0; cmd->rq->data_len = 0;
cmd->rq->errors = status;
cmd->rq->completion_data = cmd; cmd->rq->completion_data = cmd;
blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE); blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE);
blk_complete_request(cmd->rq); blk_complete_request(cmd->rq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment