--- orig/drivers/scsi/scsi_error.c Thu Sep 26 00:05:50 2002 +++ linux-rpc/drivers/scsi/scsi_error.c Thu Sep 26 00:16:01 2002 @@ -1519,43 +1519,47 @@ /* * Next, see if we need to request sense information. if so, * then get it now, so we have a better idea of what to do. - * FIXME(eric) this has the unfortunate side effect that if a host - * adapter does not automatically request sense information, that we end - * up shutting it down before we request it. All hosts should be doing this - * anyways, so for now all I have to say is tough noogies if you end up in here. - * On second thought, this is probably a good idea. We *really* want to give - * authors an incentive to automatically request this. + * FIXME(eric) this has the unfortunate side effect that if a + * host adapter does not automatically request sense information, + * that we end up shutting it down before we request it. All + * hosts should be doing this anyways, so for now all I have + * to say is tough noogies if you end up in here. On second + * thought, this is probably a good idea. We *really* want + * to give authors an incentive to automatically request this. */ - SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we need to request sense\n")); + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Checking to see if we need to request sense\n")); for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) { - if (SCpnt->state != SCSI_STATE_FAILED || scsi_sense_valid(SCpnt)) { + if (SCpnt->state != SCSI_STATE_FAILED || scsi_sense_valid(SCpnt)) continue; - } - SCSI_LOG_ERROR_RECOVERY(2, printk("scsi_unjam_host: Requesting sense for %d\n", - SCpnt->target)); + + SCSI_LOG_ERROR_RECOVERY(2, + printk("scsi_unjam_host: Requesting sense for %d\n", + SCpnt->target)); rtn = scsi_request_sense(SCpnt); - if (rtn != SUCCESS) { + if (rtn != SUCCESS) continue; - } - SCSI_LOG_ERROR_RECOVERY(3, printk("Sense requested for %p - result %x\n", - SCpnt, SCpnt->result)); + + SCSI_LOG_ERROR_RECOVERY(3, + printk("Sense requested for %p - result %x\n", + SCpnt, SCpnt->result)); SCSI_LOG_ERROR_RECOVERY(3, print_sense("bh", SCpnt)); result = scsi_decide_disposition(SCpnt); /* - * If the result was normal, then just pass it along to the - * upper level. + * If the result was normal, then just pass + * it along to the upper level. */ if (result == SUCCESS) { SCpnt->host->host_failed--; scsi_eh_finish_command(done, SCpnt); } - if (result != NEEDS_RETRY) { + if (result != NEEDS_RETRY) continue; - } + /* * We only come in here if we want to retry a * command. The test to see whether the command @@ -1565,9 +1569,9 @@ */ SCpnt->state = NEEDS_RETRY; rtn = scsi_eh_retry_command(SCpnt); - if (rtn != SUCCESS) { + if (rtn != SUCCESS) continue; - } + /* * We eventually hand this one back to the top level. */ @@ -1586,8 +1590,8 @@ int timed_out; /* - * Go through the list of commands and figure out where we stand and how bad things - * really are. + * Go through the list of commands and figure out where we + * stand and how bad things really are. */ numfailed = 0; timed_out = 0; @@ -1597,51 +1601,55 @@ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) { if (SCpnt->state == SCSI_STATE_FAILED) { - SCSI_LOG_ERROR_RECOVERY(5, printk("Command to ID %d failed\n", - SCpnt->target)); + SCSI_LOG_ERROR_RECOVERY(5, + printk("Command to ID %d failed\n", + SCpnt->target)); numfailed++; device_error++; } if (SCpnt->state == SCSI_STATE_TIMEOUT) { - SCSI_LOG_ERROR_RECOVERY(5, printk("Command to ID %d timedout\n", - SCpnt->target)); + SCSI_LOG_ERROR_RECOVERY(5, + printk("Command to ID %d timedout\n", + SCpnt->target)); timed_out++; device_error++; } } - if (device_error > 0) { + if (device_error > 0) devices_failed++; - } } - SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d+%d commands on %d devices require eh work\n", - numfailed, timed_out, devices_failed)); + SCSI_LOG_ERROR_RECOVERY(2, + printk("Total of %d+%d commands on %d devices require eh work\n", + numfailed, timed_out, devices_failed)); } static void scsi_unjam_abort(struct Scsi_Host *host, Scsi_Cmnd **done) { Scsi_Device *SDpnt; - Scsi_Cmnd *SCloop; + Scsi_Cmnd *SCpnt; int rtn; /* - * Next, try and see whether or not it makes sense to try and abort - * the running command. This only works out to be the case if we have - * one command that has timed out. If the command simply failed, it - * makes no sense to try and abort the command, since as far as the - * host adapter is concerned, it isn't running. + * Next, try and see whether or not it makes sense to try and + * abort the running command. This only works out to be the + * case if we have one command that has timed out. If the + * command simply failed, it makes no sense to try and abort + * the command, since as far as the host adapter is concerned, + * it isn't running. */ - SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we want to try abort\n")); + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Checking to see if we want to try abort\n")); for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { - for (SCloop = SDpnt->device_queue; SCloop; SCloop = SCloop->next) { - if (SCloop->state != SCSI_STATE_TIMEOUT) { + for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) { + if (SCpnt->state != SCSI_STATE_TIMEOUT) continue; - } - rtn = scsi_try_to_abort_command(SCloop, ABORT_TIMEOUT); + + rtn = scsi_try_to_abort_command(SCpnt, ABORT_TIMEOUT); if (rtn == SUCCESS) - scsi_eh_test_and_retry(SCloop, done); + scsi_eh_test_and_retry(SCpnt, done); } } } @@ -1649,32 +1657,32 @@ static void scsi_unjam_device_reset(struct Scsi_Host *host, Scsi_Cmnd **done) { Scsi_Device *SDpnt; - Scsi_Cmnd *SCloop; + Scsi_Cmnd *SCpnt; int rtn; /* * Either the abort wasn't appropriate, or it didn't succeed. - * Now try a bus device reset. Still, look to see whether we have - * multiple devices that are jammed or not - if we have multiple devices, - * it makes no sense to try BUS_DEVICE_RESET - we really would need - * to try a BUS_RESET instead. + * Now try a bus device reset. Still, look to see whether we + * have multiple devices that are jammed or not - if we have + * multiple devices, it makes no sense to try BUS_DEVICE_RESET + * - we really would need to try a BUS_RESET instead. * - * Does this make sense - should we try BDR on each device individually? - * Yes, definitely. + * Does this make sense - should we try BDR on each device + * individually? Yes, definitely. */ - SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we want to try BDR\n")); + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Checking to see if we want to try BDR\n")); for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { - SCloop = scsi_eh_find_failed_command(SDpnt); - if (SCloop == NULL) { + SCpnt = scsi_eh_find_failed_command(SDpnt); + if (SCpnt == NULL) continue; - } /* * OK, we have a device that is having problems. * Try and send a bus device reset to it. */ - rtn = scsi_try_bus_device_reset(SCloop, RESET_TIMEOUT); + rtn = scsi_try_bus_device_reset(SCpnt, RESET_TIMEOUT); /* * A successful bus device reset causes all commands @@ -1700,11 +1708,12 @@ int rtn, channel, max_channel = 0; /* - * If we ended up here, we have serious problems. The only thing left - * to try is a full bus reset. If someone has grabbed the bus and isn't - * letting go, then perhaps this will help. + * If we ended up here, we have serious problems. The only thing + * left to try is a full bus reset. If someone has grabbed the + * bus and isn't letting go, then perhaps this will help. */ - SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Try hard bus reset\n")); + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Try hard bus reset\n")); /* * Find the maximum channel number for this host. @@ -1766,8 +1775,8 @@ * through to the 'take device offline' case. * * FIXME(eric) - It is possible that the command completed - * *after* the error recovery procedure started, and if this - * is the case, we are worrying about nothing here. + * *after* the error recovery procedure started, and if + * this is the case, we are worrying about nothing here. * * FIXME(rmk) - This should be bounded; we shouldn't wait * for an infinite amount of time for any device. @@ -1815,7 +1824,9 @@ * so we can try to talk to other devices. */ scsi_try_bus_reset(SCpnt); - scsi_eh_set_device_offline(SDpnt, done, "not ready or command retry failed after bus reset"); + scsi_eh_set_device_offline(SDpnt, done, + "not ready or command retry " + "failed after bus reset"); } } } @@ -1823,27 +1834,30 @@ static void scsi_unjam_host_reset(struct Scsi_Host *host, Scsi_Cmnd **done) { - Scsi_Device *SDpnt, *SDloop; + Scsi_Device *SDpnt; Scsi_Cmnd *SCpnt; Scsi_Cmnd *failed_command = NULL; int rtn, soft_reset; /* - * If we ended up here, we have serious problems. The only thing left - * to try is a full host reset - perhaps the firmware on the device - * crashed, or something like that. + * If we ended up here, we have serious problems. The only thing + * left to try is a full host reset - perhaps the firmware on the + * device crashed, or something like that. * - * It is assumed that a succesful host reset will cause *all* information - * about the command to be flushed from both the host adapter *and* the - * device. + * It is assumed that a succesful host reset will cause *all* + * information about the command to be flushed from both the host + * adapter *and* the device. * - * FIXME(eric) - it isn't clear that devices that implement the soft reset - * option can ever be cleared except via cycling the power. The problem is - * that sending the host reset command will cause the host to forget - * about the pending command, but the device won't forget. For now, we - * skip the host reset option if any of the failed devices are configured - * to use the soft reset option. + * FIXME(eric) - it isn't clear that devices that implement the + * soft reset option can ever be cleared except via cycling the + * power. The problem is that sending the host reset command will + * cause the host to forget about the pending command, but the + * device won't forget. For now, we skip the host reset option + * if any of the failed devices are configured to use the soft + * reset option. */ + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Try host reset\n")); try_again: failed_command = NULL; @@ -1873,6 +1887,9 @@ * * FIXME(eric) - right now we will just end up falling * through to the 'take device offline' case. + * + * FIXME(rmk) - This should be bounded; we shouldn't wait + * for an infinite amount of time for any device. */ if (soft_reset) { SCSI_LOG_ERROR_RECOVERY(3, @@ -1888,7 +1905,8 @@ goto try_again; } - SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Try hard host reset\n")); + SCSI_LOG_ERROR_RECOVERY(3, + printk("scsi_unjam_host: Try hard host reset\n")); /* * FIXME(eric) - we need to obtain a valid SCpnt to perform this call. @@ -1896,19 +1914,19 @@ rtn = scsi_try_host_reset(failed_command); if (rtn == SUCCESS) { /* - * FIXME(eric) we assume that all commands are flushed from the - * controller. We should get a DID_RESET for all of the commands - * that were pending. We should ignore these so that we can - * guarantee that we are in a consistent state. + * FIXME(eric) we assume that all commands are flushed from + * the controller. We should get a DID_RESET for all of the + * commands that were pending. We should ignore these so + * that we can guarantee that we are in a consistent state. * - * I believe this to be the case right now, but this needs to be - * tested. + * I believe this to be the case right now, but this needs + * to be tested. */ - for (SDloop = host->host_queue; SDloop; SDloop = SDloop->next) { - rtn = scsi_eh_restart_device(SDloop, done); + for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) { + rtn = scsi_eh_restart_device(SDpnt, done); if (rtn != SUCCESS) { - SCpnt = scsi_eh_find_failed_command(SDloop); + SCpnt = scsi_eh_find_failed_command(SDpnt); /* * This device failed again. Since a host @@ -1919,7 +1937,9 @@ * so we can try to talk to other devices. */ scsi_try_host_reset(SCpnt); - scsi_eh_set_device_offline(SDloop, done, "not ready or command retry failed after host reset"); + scsi_eh_set_device_offline(SDpnt, done, + "not ready or command retry " + "failed after host reset"); } } } @@ -1930,19 +1950,20 @@ Scsi_Device *SDpnt; /* - * If the HOST RESET failed, then for now we assume that the entire host - * adapter is too hosed to be of any use. For our purposes, however, it is - * easier to simply take the devices offline that correspond to commands - * that failed. + * If the HOST RESET failed, then for now we assume that the + * entire host adapter is too hosed to be of any use. For our + * purposes, however, it is easier to simply take the devices + * offline that correspond to commands that failed. */ - SCSI_LOG_ERROR_RECOVERY(1, printk("scsi_unjam_host: Take device offline\n")); + SCSI_LOG_ERROR_RECOVERY(1, + printk("scsi_unjam_host: Take device offline\n")); for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) - scsi_eh_set_device_offline(SDpnt, done, "command error recover failed"); + scsi_eh_set_device_offline(SDpnt, done, + "command error recover failed"); - if (host->host_failed != 0) { + if (host->host_failed != 0) panic("scsi_unjam_host: Miscount of number of failed commands.\n"); - } SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Returning\n")); }