--- orig/drivers/scsi/scsi_error.c Wed Sep 25 14:59:31 2002 +++ linux-rpc/drivers/scsi/scsi_error.c Wed Sep 25 14:54:37 2002 @@ -49,6 +49,13 @@ */ #define SHUTDOWN_SIGS (sigmask(SIGHUP)) +/* + * The number of times we retry a REQUEST SENSE and TEST UNIT READY + * respectively. This is arbitary. + */ +#define SENSE_RETRIES 5 +#define TUR_RETRIES 5 + #ifdef DEBUG #define SENSE_TIMEOUT SCSI_TIMEOUT #define ABORT_TIMEOUT SCSI_TIMEOUT @@ -385,10 +392,12 @@ */ STATIC int scsi_eh_retry_command(Scsi_Cmnd * SCpnt) { + int tries = 0; + do { scsi_setup_cmd_retry(SCpnt); scsi_send_eh_cmnd(SCpnt, SCpnt->timeout_per_command); - } while (SCpnt->eh_state == NEEDS_RETRY); + } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < SCpnt->allowed); /* * Hey, we are done. Let's look to see what happened. @@ -415,7 +424,7 @@ static unsigned char generic_sense[6] = {REQUEST_SENSE, 0, 0, 0, 255, 0}; unsigned char scsi_result0[256], *scsi_result = NULL; - int saved_result; + int saved_result, tries; ASSERT_LOCK(&io_request_lock, 0); @@ -429,6 +438,7 @@ saved_result = SCpnt->result; + tries = 0; do { memcpy((void *) SCpnt->cmnd, (void *) generic_sense, sizeof(generic_sense)); @@ -459,7 +469,7 @@ * is in process of becoming ready", we need to * retry this command. */ - } while (SCpnt->eh_state == NEEDS_RETRY); + } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < SENSE_RETRIES); /* Last chance to have valid sense data */ if (!scsi_sense_valid(SCpnt)) @@ -493,6 +503,7 @@ { static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; + int tries = 0; do { memcpy((void *) SCpnt->cmnd, (void *) tur_command, @@ -521,7 +532,7 @@ * is in process of becoming ready", we need to * retry this command. */ - } while (SCpnt->eh_state == NEEDS_RETRY); + } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < TUR_RETRIES); /* * When we eventually call scsi_finish, we really wish to complete