[PATCH 5/5] scsi host / scsi target state model update

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

 



Use new SCSI target state model in scsi_forget_host to help with list
traversal and deletion of devices.

Signed-off-by: Mike Anderson <andmike@xxxxxxxxxx>
---

 linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c  |   32 +++++++++--------
 linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_sysfs.c |    1 
 2 files changed, 18 insertions(+), 15 deletions(-)

diff -puN drivers/scsi/scsi_scan.c~tgt_remove drivers/scsi/scsi_scan.c
--- linux-2.6.12-rc6-mm1/drivers/scsi/scsi_scan.c~tgt_remove	2005-06-16 10:48:38.000000000 -0700
+++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c	2005-06-16 10:48:38.000000000 -0700
@@ -1414,25 +1414,27 @@ EXPORT_SYMBOL(scsi_scan_single_target);
 
 void scsi_forget_host(struct Scsi_Host *shost)
 {
-	struct scsi_target *starget, *tmp;
+	struct scsi_target *starget;
 	unsigned long flags;
 
-	/*
-	 * Ok, this look a bit strange.  We always look for the first device
-	 * on the list as scsi_remove_device removes them from it - thus we
-	 * also have to release the lock.
-	 * We don't need to get another reference to the device before
-	 * releasing the lock as we already own the reference from
-	 * scsi_register_device that's release in scsi_remove_device.  And
-	 * after that we don't look at sdev anymore.
-	 */
-	spin_lock_irqsave(shost->host_lock, flags);
-	list_for_each_entry_safe(starget, tmp, &shost->__targets, siblings) {
-		spin_unlock_irqrestore(shost->host_lock, flags);
-		scsi_remove_target(&starget->dev);
+	while (1) {
+		starget = NULL;
 		spin_lock_irqsave(shost->host_lock, flags);
+		list_for_each_entry(starget, &shost->__targets, siblings) {
+			if (starget->stgt_state == STGT_DEL)
+				continue;
+			if (starget->stgt_state != STGT_CANCEL) {
+				scsi_target_set_state(starget, STGT_CANCEL);
+				break;
+			}
+		}
+		spin_unlock_irqrestore(shost->host_lock, flags);
+
+		if (starget && starget->stgt_state != STGT_DEL)
+			scsi_remove_target(&starget->dev);
+		else
+			return;
 	}
-	spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
 /*
diff -puN drivers/scsi/scsi_sysfs.c~tgt_remove drivers/scsi/scsi_sysfs.c
--- linux-2.6.12-rc6-mm1/drivers/scsi/scsi_sysfs.c~tgt_remove	2005-06-16 10:48:38.000000000 -0700
+++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_sysfs.c	2005-06-16 10:48:38.000000000 -0700
@@ -750,6 +750,7 @@ void __scsi_remove_target(struct scsi_ta
 		scsi_remove_device(sdev);
 		spin_lock_irqsave(shost->host_lock, flags);
 	}
+	scsi_target_set_state(starget, STGT_DEL);
 	spin_unlock_irqrestore(shost->host_lock, flags);
 	scsi_target_reap(starget);
 }
_
-
: 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