[SCSI] libsas: fix timeout vs completion race

Until we have told the lldd to forget a task a timed out operation can
return from the hardware at any time.  Since completion frees the task
we need to make sure that no tasks run their normal completion handler
once eh has decided to manage the task.  Similar to
ata_scsi_cmd_error_handler() freeze completions to let eh judge the
outcome of the race.

Task collector mode is problematic because it presents a situation where
a task can be timed out and aborted before the lldd has even seen it.
For this case we need to guarantee that a task that an lldd has been
told to forget does not get queued after the lldd says "never seen it".
With sas_scsi_timed_out we achieve this with the ->task_queue_flush
mutex, rather than adding more time.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:
Dan Williams 2011-11-28 11:29:20 -08:00 committed by James Bottomley
parent a3a142524a
commit 9095a64a9a
5 changed files with 68 additions and 83 deletions

View file

@ -178,6 +178,7 @@ enum {
};
struct domain_device {
spinlock_t done_lock;
enum sas_dev_type dev_type;
enum sas_linkrate linkrate;
@ -321,6 +322,7 @@ struct asd_sas_phy {
struct scsi_core {
struct Scsi_Host *shost;
struct mutex task_queue_flush;
spinlock_t task_queue_lock;
struct list_head task_queue;
int task_queue_size;
@ -337,6 +339,7 @@ enum sas_ha_state {
SAS_HA_REGISTERED,
SAS_HA_DRAINING,
SAS_HA_ATA_EH_ACTIVE,
SAS_HA_FROZEN,
};
struct sas_ha_struct {