diff options
author | Luo Jiaxing <luojiaxing@huawei.com> | 2020-07-22 17:04:03 +0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-07-24 22:09:55 -0400 |
commit | 386533796574bcdfe25ef3b8c520bc5f3a9d7c89 (patch) | |
tree | a2d8d5ec4cf0329c98da7416da2b23a99f935523 | |
parent | 3a243c2c35002f51ff1e62a4337cffe39b17f3d6 (diff) | |
download | linux-386533796574bcdfe25ef3b8c520bc5f3a9d7c89.tar.gz linux-386533796574bcdfe25ef3b8c520bc5f3a9d7c89.tar.bz2 linux-386533796574bcdfe25ef3b8c520bc5f3a9d7c89.zip |
scsi: libsas: Check link status in ATA prereset()
libata currently attempts to reset even if the SATA disk is unplugged. To
avoid the meaningless reset of a missing disk, libsas should report offline
status to libata. libata already provides a .prereset callback for this
purpose. This is called by ata_eh_reset() and can be used to influence
whether a reset attempt should be made.
Add sas_ata_preset callback to check status of phy and disk. If the disk is
already offline or phy is disabled, we return -ENOENT to libata to avoid
the reset.
Link: https://lore.kernel.org/r/1595408643-63011-3-git-send-email-luojiaxing@huawei.com
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/libsas/sas_ata.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index a7d16d285b86..1b93332daa6b 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, |