The current protocol for scheduling the SCSI error handler explicitly is as follows: 1. The LLD registers a transport layer that defines a eh_strategy_handler. 2. The LLD observes an error, sets variables that indicate the nature of the error and calls scsi_schedule_eh(). Currently only the ATA core and libsas use scsi_schedule_eh(). 3. scsi_schedule_eh() increments host_eh_scheduled. 4. The SCSI error handling thread wakes up and invokes eh_strategy_handler. 5. After all errors have been handled and before the eh_strategy_handler implementation returns, host_eh_scheduled is cleared. This must be done in such a way that all errors that happened while the error handler was running are either handled or result in rerunning the error handler. Making LLDs responsible for clearing host_eh_scheduled is error prone. Hence clear host_eh_scheduled from inside the SCSI error handler. A side effect of this patch is that if scsi_schedule_eh() is called while the SCSI error handler is active that it will be reactivated immediately. Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Ming Lei <ming.lei@xxxxxxxxxx> Cc: John Garry <john.garry@xxxxxxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- drivers/scsi/scsi_error.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index c6cd5a8e5c85..665cc44d8877 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2242,6 +2242,13 @@ int scsi_error_handler(void *data) continue; } + /* + * Clear host_eh_scheduled before handling any errors such that + * calling scsi_schedule_eh() while errors are being handled + * causes the error handler to be rerun. + */ + shost->host_eh_scheduled = 0; + if (shost->transportt->eh_strategy_handler) shost->transportt->eh_strategy_handler(shost); else