[PATCH] aic94xx: Hotplug ex_change_count race fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In some cases while hotplugging disks on a system with an expander the
broadcast primitive will be posted and begin processing before the
expander change count is updated.  This causes the device that triggered
the broadcast to not be found.

--Alexis   



Signed-off-by: Alexis Bruemmer <alexisb@xxxxxxxxxx>

-------

diff -pNura linux-2.6.18-git4-orig/drivers/scsi/libsas/sas_expander.c linux-2.6.18-git4/drivers/scsi/libsas/sas_expander.c
--- linux-2.6.18-git4-orig/drivers/scsi/libsas/sas_expander.c	2006-09-26 07:42:43.000000000 -0700
+++ linux-2.6.18-git4/drivers/scsi/libsas/sas_expander.c	2006-09-26 08:28:50.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/scatterlist.h>
+#include <linux/delay.h>
 
 #include "sas_internal.h"
 
@@ -1760,23 +1761,34 @@ out:
 int sas_ex_revalidate_domain(struct domain_device *port_dev)
 {
 	int res;
+	int i;
 	struct domain_device *dev = NULL;
 
-	res = sas_find_bcast_dev(port_dev, &dev);
-	if (res)
-		goto out;
-	if (dev) {
-		struct expander_device *ex = &dev->ex_dev;
-		int i = 0, phy_id;
-
-		do {
-			phy_id = -1;
-			res = sas_find_bcast_phy(dev, &phy_id, i);
-			if (phy_id == -1)
-				break;
-			res = sas_rediscover(dev, phy_id);
-			i = phy_id + 1;
-		} while (i < ex->num_phys);
+	
+	/* Some expanders seem to generate a BROADCAST primitive before
+	 * they actually update their own "expander change count" field!
+	 * If we didn't find a device that caused the BROADCAST
+	 * primitive, let us wait and retry.
+	 */
+	for (i = 0; i < 2; i++) {
+		res = sas_find_bcast_dev(port_dev, &dev);
+		if (res)
+			goto out;
+		if (dev) {
+			struct expander_device *ex = &dev->ex_dev;
+			int i = 0, phy_id;
+
+			do {
+				phy_id = -1;
+				res = sas_find_bcast_phy(dev, &phy_id, i);
+				if (phy_id == -1)
+					break;
+				res = sas_rediscover(dev, phy_id);
+				i = phy_id + 1;
+			} while (i < ex->num_phys);
+			break;
+		}
+		ssleep(1);
 	}
 out:
 	return res;


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux