This patch (as1360b) fixes a small bug in scsi_error_handler(): If for any reason the scsi_autopm_get_host() call should fail, the thread's state doesn't get set back to TASK_INTERRUPTIBLE. The routine will run through its main loop an extra time instead of going straight to sleep. Rather than adding yet another set_current_state() call, the patch shrinks the scsi_error_handler() routine by moving an existing set_current_state() call inside the loop where it really ought to be, removing two other calls in the process. Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> CC: stable@xxxxxxxxxx --- Index: usb-2.6/drivers/scsi/scsi_error.c =================================================================== --- usb-2.6.orig/drivers/scsi/scsi_error.c +++ usb-2.6/drivers/scsi/scsi_error.c @@ -1744,21 +1744,22 @@ int scsi_error_handler(void *data) { struct Scsi_Host *shost = data; - /* - * We use TASK_INTERRUPTIBLE so that the thread is not - * counted against the load average as a running process. - * We never actually get interrupted because kthread_run - * disables signal delivery for the created thread. - */ - set_current_state(TASK_INTERRUPTIBLE); - while (!kthread_should_stop()) { + for (;;) { + /* + * We use TASK_INTERRUPTIBLE so that the thread is not + * counted against the load average as a running process. + * We never actually get interrupted because kthread_run + * disables signal delivery for the created thread. + */ + set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_stop()) + break; if ((shost->host_failed == 0 && shost->host_eh_scheduled == 0) || shost->host_failed != shost->host_busy) { SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d sleeping\n", shost->host_no)); schedule(); - set_current_state(TASK_INTERRUPTIBLE); continue; } @@ -1794,7 +1795,6 @@ int scsi_error_handler(void *data) */ scsi_restart_operations(shost); scsi_autopm_put_host(shost); - set_current_state(TASK_INTERRUPTIBLE); } __set_current_state(TASK_RUNNING); -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html