public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@us.ibm.com>
To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: alexisb@us.ibm.com
Subject: [PATCH 04/15] libsas: Don't give scsi_cmnds to the EH if they never made it to the SAS LLDD or have already returned
Date: Fri, 17 Nov 2006 13:07:49 -0800	[thread overview]
Message-ID: <20061117210749.17052.56317.stgit@localhost.localdomain> (raw)
In-Reply-To: <20061117210737.17052.67041.stgit@localhost.localdomain>


On a system with many SAS targets, it appears possible that a scsi_cmnd
can time out without ever making it to the SAS LLDD or at the same time
that a completion is occurring.  In both of these cases, telling the
LLDD to abort the sas_task makes no sense because the LLDD won't know
about the sas_task; what we really want to do is to increase the timer.
Note that this involves creating another sas_task bit to indicate
whether or not the task has been sent to the LLDD; I could have
implemented this by slightly redefining SAS_TASK_STATE_PENDING, but
this way seems cleaner.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 drivers/scsi/aic94xx/aic94xx_task.c |    9 +++++++++
 drivers/scsi/aic94xx/aic94xx_tmf.c  |    4 +++-
 drivers/scsi/libsas/sas_ata.c       |    1 -
 drivers/scsi/libsas/sas_scsi_host.c |    7 +++++++
 include/scsi/libsas.h               |    1 +
 5 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 9840708..466b492 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -349,6 +349,7 @@ Again:
 
 	spin_lock_irqsave(&task->task_state_lock, flags);
 	task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
+	task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
 	task->task_state_flags |= SAS_TASK_STATE_DONE;
 	if (unlikely((task->task_state_flags & SAS_TASK_STATE_ABORTED))) {
 		spin_unlock_irqrestore(&task->task_state_lock, flags);
@@ -556,6 +557,7 @@ int asd_execute_task(struct sas_task *ta
 	struct sas_task *t = task;
 	struct asd_ascb *ascb = NULL, *a;
 	struct asd_ha_struct *asd_ha = task->dev->port->ha->lldd_ha;
+	unsigned long flags;
 
 	res = asd_can_queue(asd_ha, num);
 	if (res)
@@ -601,9 +603,16 @@ int asd_execute_task(struct sas_task *ta
 	}
 	list_del_init(&alist);
 
+	spin_lock_irqsave(&task->task_state_lock, flags);
+	task->task_state_flags |= SAS_TASK_AT_INITIATOR;
+	spin_unlock_irqrestore(&task->task_state_lock, flags);
+
 	res = asd_post_ascb_list(asd_ha, ascb, num);
 	if (unlikely(res)) {
 		a = NULL;
+		spin_lock_irqsave(&task->task_state_lock, flags);
+		task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
+		spin_unlock_irqrestore(&task->task_state_lock, flags);
 		__list_add(&alist, ascb->list.prev, &ascb->list);
 		goto out_err_unmap;
 	}
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index 6123438..686cea1 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -345,7 +345,7 @@ static inline int asd_clear_nexus(struct
 int asd_abort_task(struct sas_task *task)
 {
 	struct asd_ascb *tascb = task->lldd_task;
-	struct asd_ha_struct *asd_ha = tascb->ha;
+	struct asd_ha_struct *asd_ha;
 	int res = 1;
 	unsigned long flags;
 	struct asd_ascb *ascb = NULL;
@@ -360,6 +360,8 @@ int asd_abort_task(struct sas_task *task
 	}
 	spin_unlock_irqrestore(&task->task_state_lock, flags);
 
+	asd_ha = tascb->ha;
+
 	ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL);
 	if (!ascb)
 		return -ENOMEM;
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index de42b5b..f92f035 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -161,7 +161,6 @@ static unsigned int sas_ata_qc_issue(str
 	task->data_dir = qc->dma_dir;
 	task->scatter = qc->__sg;
 	task->ata_task.retry_count = 1;
-	task->task_state_flags = SAS_TASK_STATE_PENDING;
 
 	switch (qc->tf.protocol) {
 	case ATA_PROT_NCQ:
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 5c6e6f2..7cc7a1e 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -550,6 +550,13 @@ enum scsi_eh_timer_return sas_scsi_timed
 			    cmd, task);
 		return EH_HANDLED;
 	}
+	if (!(task->task_state_flags & SAS_TASK_AT_INITIATOR)) {
+		spin_unlock_irqrestore(&task->task_state_lock, flags);
+		SAS_DPRINTK("command 0x%p, task 0x%p, not at initiator: "
+			    "EH_RESET_TIMER\n",
+			    cmd, task);
+		return EH_RESET_TIMER;
+	}
 	task->task_state_flags |= SAS_TASK_STATE_ABORTED;
 	spin_unlock_irqrestore(&task->task_state_lock, flags);
 
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 921db78..d2ec1be 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -546,6 +546,7 @@ #define SAS_TASK_STATE_PENDING      1
 #define SAS_TASK_STATE_DONE         2
 #define SAS_TASK_STATE_ABORTED      4
 #define SAS_TASK_INITIATOR_ABORTED  8
+#define SAS_TASK_AT_INITIATOR       16
 
 static inline struct sas_task *sas_alloc_task(gfp_t flags)
 {

  parent reply	other threads:[~2006-11-17 21:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17 21:07 [PATCH 00/15] Roll-up of my libsas, aic94xx and sas_ata patches Darrick J. Wong
2006-11-17 21:07 ` [PATCH 01/15] aic94xx: Handle REQ_DEVICE_RESET Darrick J. Wong
2006-11-17 21:07 ` [PATCH 02/15] libsas: Clean up rphys/port dev list after a discovery error Darrick J. Wong
2006-11-17 21:07 ` [PATCH 03/15] aic94xx: Delete ascb timers when freeing queues Darrick J. Wong
2006-11-17 21:07 ` Darrick J. Wong [this message]
2006-11-25  6:58   ` [PATCH v2] libsas: Don't give scsi_cmnds to the EH if they never made it to the SAS LLDD or have already returned Darrick J. Wong
2006-11-25 19:02     ` James Bottomley
2006-11-17 21:07 ` [PATCH 05/15] libsas: Add a sysfs knob to enable/disable a phy Darrick J. Wong
2006-11-17 21:07 ` [PATCH 06/15] sas_ata: Require CONFIG_ATA in Kconfig Darrick J. Wong
2006-11-17 21:08 ` [PATCH 07/15] sas_ata: Satisfy libata qc function locking requirements Darrick J. Wong
2006-11-17 21:08 ` [PATCH 08/15] sas_ata: sas_ata_qc_issue should return AC_ERR_* Darrick J. Wong
2006-11-17 21:08 ` [PATCH 09/15] sas_ata: ata_post_internal should abort the sas_task Darrick J. Wong
2006-11-17 21:08 ` [PATCH 10/15] aic94xx: Don't call pci_map_sg for already-mapped scatterlists Darrick J. Wong
2006-11-17 21:08 ` [PATCH 11/15] sas_ata: Don't copy aic94xx's sactive to ata_port Darrick J. Wong
2006-11-17 21:08 ` [PATCH 12/15] sas_ata: Implement sata phy control Darrick J. Wong
2006-11-17 21:08 ` [PATCH 13/15] sas_ata: Implement a libata error handler Darrick J. Wong
2006-11-17 21:08 ` [PATCH 14/15] libsas: Provide a generic SATL registration function Darrick J. Wong
2006-11-17 21:08 ` [PATCH 15/15] sas_ata: Make this a module separate from libsas Darrick J. Wong
2006-11-21  1:16 ` [PATCH 00/15] Roll-up of my libsas, aic94xx and sas_ata patches Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061117210749.17052.56317.stgit@localhost.localdomain \
    --to=djwong@us.ibm.com \
    --cc=alexisb@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox