[SCSI] libsas: delete device on sas address changed
authorDan Williams <dan.j.williams@intel.com>
Fri, 20 Jan 2012 02:43:08 +0000 (18:43 -0800)
committerJames Bottomley <JBottomley@Parallels.com>
Wed, 29 Feb 2012 21:33:39 +0000 (15:33 -0600)
If the phy is attached to a new sas address unregister the first address
before processing the new attachment.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/libsas/sas_expander.c

index 7e2d3c4c61713180cd7d4f3ba99b1edc92b1ba32..d63f0fbcd10383219cef6c61dec16d2d62d4a41a 100644 (file)
@@ -2005,6 +2005,15 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
                return res;
        }
 
+       /* delete the old link */
+       if (SAS_ADDR(phy->attached_sas_addr) &&
+           SAS_ADDR(sas_addr) != SAS_ADDR(phy->attached_sas_addr)) {
+               SAS_DPRINTK("ex %016llx phy 0x%x replace %016llx\n",
+                           SAS_ADDR(dev->sas_addr), phy_id,
+                           SAS_ADDR(phy->attached_sas_addr));
+               sas_unregister_devs_sas_addr(dev, phy_id, last);
+       }
+
        return sas_discover_new(dev, phy_id);
 }