diff mbox

libsas: Disable asynchronous aborts for SATA devices

Message ID 1515512632-115483-1-git-send-email-hare@suse.de (mailing list archive)
State Superseded
Headers show

Commit Message

Hannes Reinecke Jan. 9, 2018, 3:43 p.m. UTC
Handling CD-ROM devices from libsas is decidedly odd, as libata
relies on SCSI EH to be started to figure out that no medium is
present.
So we cannot do asynchronous aborts for SATA devices.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/libsas/sas_scsi_host.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Jan. 10, 2018, 8:15 a.m. UTC | #1
Looks fine to me for 4.15 and -stable:

Reviewed-by: Christoph Hellwig <hch@lst.de>

But we really need to fix this properly in the long run.
Yves-Alexis Perez Jan. 10, 2018, 8:27 a.m. UTC | #2
On Tue, 2018-01-09 at 16:43 +0100, Hannes Reinecke wrote:
> Handling CD-ROM devices from libsas is decidedly odd, as libata
> relies on SCSI EH to be started to figure out that no medium is
> present.
> So we cannot do asynchronous aborts for SATA devices.

The box boots fine with this change, thanks!

Tested-by: Yves-Alexis Perez <corsac@debian.org>
Hannes Reinecke Jan. 10, 2018, 8:51 a.m. UTC | #3
On 01/10/2018 09:15 AM, Christoph Hellwig wrote:
> Looks fine to me for 4.15 and -stable:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> But we really need to fix this properly in the long run.
> 
Looked into it, but I'm not sure if we can due to the fundamental
differences between SCSI and libata EH.

And there really is no way on how we can do async aborts on SATA; as
soon as we're submitting NCQ commands _all_ commands will be aborted on
error and we have to pick up the pieces.

We might be handling things a tad better than now (we're always punting
the abort to a workqueue, only to figure out from the workqueue function
that we should've invoked SCSI EH proper).
But I can't really see a better way here.

Cheers,

Hannes
Martin K. Petersen Jan. 10, 2018, 9:40 p.m. UTC | #4
Hannes,

> Handling CD-ROM devices from libsas is decidedly odd, as libata relies
> on SCSI EH to be started to figure out that no medium is present.  So
> we cannot do asynchronous aborts for SATA devices.

Applied to 4.15/scsi-fixes. Thank you!
diff mbox

Patch

diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 6267272..6de9681 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -487,15 +487,28 @@  static int sas_queue_reset(struct domain_device *dev, int reset_type,
 
 int sas_eh_abort_handler(struct scsi_cmnd *cmd)
 {
-	int res;
+	int res = TMF_RESP_FUNC_FAILED;
 	struct sas_task *task = TO_SAS_TASK(cmd);
 	struct Scsi_Host *host = cmd->device->host;
+	struct domain_device *dev = cmd_to_domain_dev(cmd);
 	struct sas_internal *i = to_sas_internal(host->transportt);
+	unsigned long flags;
 
 	if (!i->dft->lldd_abort_task)
 		return FAILED;
 
-	res = i->dft->lldd_abort_task(task);
+	spin_lock_irqsave(host->host_lock, flags);
+	/* We cannot do async aborts for SATA devices */
+	if (dev_is_sata(dev) && !host->host_eh_scheduled) {
+		spin_unlock_irqrestore(host->host_lock, flags);
+		return FAILED;
+	}
+	spin_unlock_irqrestore(host->host_lock, flags);
+
+	if (task)
+		res = i->dft->lldd_abort_task(task);
+	else
+		SAS_DPRINTK("no task to abort\n");
 	if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
 		return SUCCESS;