failed after done REVALIDATING DOMAIN. Then after its port is added to
the
sas_port_del_list, the port will not be deleted until the end of the next
REVALIDATING DOMAIN and sas_destruct_ports() is called. A warning about
creating a duplicate port will occur in the new REVALIDATING DOMAIN when
the end device reconnects. Therefore, the previous destroy_list and
sas_port_del_list should be handled before REVALIDATING DOMAIN.
Signed-off-by: Xingui Yang <yangxingui@xxxxxxxxxx>
---
Changes since v1:
- Simplify the process of getting ex_phy id based on Jason's suggestion.
- Update commit information.
---
drivers/scsi/libsas/sas_discover.c | 2 ++
drivers/scsi/libsas/sas_expander.c | 8 ++++++++
drivers/scsi/libsas/sas_internal.h | 6 +++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/libsas/sas_discover.c
b/drivers/scsi/libsas/sas_discover.c
index 8fb7c41c0962..aae90153f4c6 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -517,6 +517,8 @@ static void sas_revalidate_domain(struct
work_struct *work)
struct sas_ha_struct *ha = port->ha;
struct domain_device *ddev = port->port_dev;
+ sas_destruct_devices(port);
+ sas_destruct_ports(port);
/* prevent revalidation from finding sata links in recovery */
mutex_lock(&ha->disco_mutex);
if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) {
diff --git a/drivers/scsi/libsas/sas_expander.c
b/drivers/scsi/libsas/sas_expander.c
index f6e6db8b8aba..45793c10009b 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1856,6 +1856,14 @@ static void sas_unregister_devs_sas_addr(struct
domain_device *parent,
}
}
+void sas_ex_unregister_end_dev(struct domain_device *dev)
+{
+ struct domain_device *parent = dev->parent;
+ struct sas_phy *phy = dev->phy;
+
+ sas_unregister_devs_sas_addr(parent, phy->number, true);
+}
+
static int sas_discover_bfs_by_root_level(struct domain_device *root,
const int level)
{
diff --git a/drivers/scsi/libsas/sas_internal.h
b/drivers/scsi/libsas/sas_internal.h
index 3804aef165ad..434f928c2ed8 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -50,6 +50,7 @@ void sas_discover_event(struct asd_sas_port *port,
enum discover_event ev);
void sas_init_dev(struct domain_device *dev);
void sas_unregister_dev(struct asd_sas_port *port, struct
domain_device *dev);
+void sas_ex_unregister_end_dev(struct domain_device *dev);
void sas_scsi_recover_host(struct Scsi_Host *shost);
@@ -145,7 +146,10 @@ static inline void sas_fail_probe(struct
domain_device *dev, const char *func, i
func, dev->parent ? "exp-attached" :
"direct-attached",
SAS_ADDR(dev->sas_addr), err);
- sas_unregister_dev(dev->port, dev);
+ if (dev->parent && !dev_is_expander(dev->dev_type))
+ sas_ex_unregister_end_dev(dev);
+ else
+ sas_unregister_dev(dev->port, dev);
}
static inline void sas_fill_in_rphy(struct domain_device *dev,