2.4 SCSI error handling fixes
PATCH 1/4 2.4 SCSI error handling fixes
I've been chasing a few SCSI problems today, and here's 4 patches to address the issues I found. These patches are against 2.4.19.
My main aim here was to solve the bad behaviour with a medium error. Some problems were found in my HBA driver, but some were found in the error handling code.
Problems found were:
a) retrying a command with stale or invalid command information. (Patches 1 and 2)
b) reporting the wrong command on IO error.
(Patch 3)
c) drives behaving badly in error condition, reporting success without data transfer.
(Patch 4)
Results of investigation into these issues can be found at in my lkml messages at:
http://marc.theaimsgroup.com/?l=linux-kernel&m=103184937214222&w=2
Patch 4 is the one I'm least happy about; we shouldn't unconditionally set the FUA bit in READ10 commands. It seems that we need to set this bit only after receiving an error, and only when we try to read the remaining blocks which we believe are good.
Patch 1: scsi_eh_retry_command
drivers/scsi/scsi.c +4 -8
@@ -1330,14 +1330,10 @@*/ int scsi_retry_command (Scsi_Cmnd * SCpnt) { -memcpy ((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd, -sizeof (SCpnt->data_cmnd)); - SCpnt->request_buffer = SCpnt->buffer; - SCpnt->request_bufflen = SCpnt->bufflen; - SCpnt->use_sg = SCpnt->old_use_sg; - SCpnt->cmd_len = SCpnt->old_cmd_len; - SCpnt->sc_data_direction = SCpnt->sc_old_data_direction; - SCpnt->underflow = SCpnt->old_underflow; +/* +* Restore the SCSI command state. +*/ +scsi_setup_cmd_retry (SCpnt);/* * Zero the sense information from the last time we tried
drivers/scsi/scsi.h +1 -0
@@ -474,6 +474,7 @@ int sectors);extern struct Scsi_Device_Template *scsi_get_request_dev (struct request *);extern int scsi_init_cmd_errh (Scsi_Cmnd * SCpnt); +extern void scsi_setup_cmd_retry (Scsi_Cmnd *SCpnt);extern int scsi_insert_special_cmd (Scsi_Cmnd * SCpnt,int );extern void scsi_io_completion (Scsi_Cmnd * SCpnt,int good_sectors,int block_sectors);
drivers/scsi/scsi_error.c +1 -9
@@ -385,15 +385,7 @@*/ STATIC int scsi_eh_retry_command(Scsi_Cmnd * SCpnt) { -memcpy ((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd, -sizeof (SCpnt->data_cmnd)); - SCpnt->request_buffer = SCpnt->buffer; - SCpnt->request_bufflen = SCpnt->bufflen; - SCpnt->use_sg = SCpnt->old_use_sg; - SCpnt->cmd_len = SCpnt->old_cmd_len; - SCpnt->sc_data_direction = SCpnt->sc_old_data_direction; - SCpnt->underflow = SCpnt->old_underflow; - +scsi_setup_cmd_retry (SCpnt);scsi_send_eh_cmnd (SCpnt, SCpnt->timeout_per_command);/*
drivers/scsi/scsi_lib.c +24 -0
@@ -208,6 +208,30 @@ }/* +* Function: scsi_setup_cmd_retry() +* +* Purpose: Restore the command state for a retry +* +* Arguments: SCpnt - command to be restored +* +* Returns: Nothing +* +* Notes: Immediately prior to retrying a command, we need +* to restore certain fields that we saved above. +*/ +void scsi_setup_cmd_retry (Scsi_Cmnd *SCpnt) +{ +memcpy ((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd, +sizeof (SCpnt->data_cmnd)); + SCpnt->request_buffer = SCpnt->buffer; + SCpnt->request_bufflen = SCpnt->bufflen; + SCpnt->use_sg = SCpnt->old_use_sg; + SCpnt->cmd_len = SCpnt->old_cmd_len; + SCpnt->sc_data_direction = SCpnt->sc_old_data_direction; + SCpnt->underflow = SCpnt->old_underflow; +} + +/* * Function: scsi_queue_next_request() * * Purpose: Handle post-processing of completed commands.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html