linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luo Jiaxing <luojiaxing@huawei.com>
To: <martin.petersen@oracle.com>, <jejb@linux.ibm.com>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<john.garry@huawei.com>, <yanaijie@huawei.com>,
	<chenxiang66@hisilicon.com>, <luojiaxing@huawei.com>,
	<linuxarm@huawei.com>
Subject: [PATCH v1 2/2] {topost} scsi: libsas: check link status at ATA prereset() ops
Date: Wed, 22 Jul 2020 17:04:03 +0800	[thread overview]
Message-ID: <1595408643-63011-3-git-send-email-luojiaxing@huawei.com> (raw)
In-Reply-To: <1595408643-63011-1-git-send-email-luojiaxing@huawei.com>

We found out that libata will retry reset even if SATA disk is unpluged. We
should report offline to libata to avoid meaningless reset on the disk.
Libata provide an ops of prereset() for this purpose, it was called by
ata_eh_reset() only and used to decide whether to skip reset base on the
return value of it.

We check status of phy and disk at prereset(). If disk is already offline
or phy is disabled, we return -ENOENT to libata to skip disk reset.

As prereset() should be best-effort, we should continue to try disk reset
beyond the situation we mentioned before.

Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/libsas/sas_ata.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index a7d16d2..1b93332 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -507,8 +507,22 @@ void sas_ata_end_eh(struct ata_port *ap)
 	spin_unlock_irqrestore(&ha->lock, flags);
 }
 
+static int sas_ata_prereset(struct ata_link *link, unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	struct domain_device *dev = ap->private_data;
+	struct sas_phy *local_phy = sas_get_local_phy(dev);
+	int res = 0;
+
+	if (!local_phy->enabled || test_bit(SAS_DEV_GONE, &dev->state))
+		res = -ENOENT;
+	sas_put_local_phy(local_phy);
+
+	return res;
+}
+
 static struct ata_port_operations sas_sata_ops = {
-	.prereset		= ata_std_prereset,
+	.prereset		= sas_ata_prereset,
 	.hardreset		= sas_ata_hard_reset,
 	.error_handler		= ata_std_error_handler,
 	.post_internal_cmd	= sas_ata_post_internal,
-- 
2.7.4


  parent reply	other threads:[~2020-07-22  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22  9:04 [PATCH v1 0/2] scsi: libsas: An improvement on error handle and tidy-up Luo Jiaxing
2020-07-22  9:04 ` [PATCH v1 1/2] {topost} scsi: libsas: delete postreset at sas_sata_ops Luo Jiaxing
2020-07-22 10:27   ` Jason Yan
2020-07-22  9:04 ` Luo Jiaxing [this message]
2020-07-22 10:31   ` [PATCH v1 2/2] {topost} scsi: libsas: check link status at ATA prereset() ops Jason Yan
2020-07-25  2:50 ` [PATCH v1 0/2] scsi: libsas: An improvement on error handle and tidy-up Martin K. Petersen

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=1595408643-63011-3-git-send-email-luojiaxing@huawei.com \
    --to=luojiaxing@huawei.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=yanaijie@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).