Skip to contentSkip to conversation

scsi_scan.c : add missing interim SDEV_DEL state if slave_alloc fails

PATCH In review James Smart 2 participants 2 messages Jan 27, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi_scan.c : add missing interim SDEV_DEL state if slave_alloc fails

We were running i/o and performing a bunch of hba resets in a loop. This forces a lot of target removes and rescans. Since the resets are occuring during scan it's causing the scan i/o to timeout or fail, invoking error recovery, etc. We end up getting a nasty crash in scsi_scan.c due to references to old sdevs that had some lingering references that kept them around.

Fix by setting device state to SDEV_DEL if the LLD's slave_alloc fails. This will fail reference taking in subsequent teardown/scan paths.

-- james s

---

 scsi_scan.c |    1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_scan.c +1 -0
diff -upNr a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
@@ -310,6 +310,7 @@ static struct scsi_device *scsi_alloc_sd
 			 */
 			if (ret == -ENXIO)
 				display_failure_msg = 0;
+			scsi_device_set_state(sdev, SDEV_DEL);
 			goto out_device_destroy;
 		}
 	}
maintainer
#1 lore raw
Quoted 25 lines · James Smart

We were running i/o and performing a bunch of hba resets in a loop. This forces a lot of target removes and rescans. Since the resets are occuring during scan it's causing the scan i/o to timeout or fail, invoking error recovery, etc. We end up getting a nasty crash in scsi_scan.c due to references to old sdevs that had some lingering references that kept them around.

Fix by setting device state to SDEV_DEL if the LLD's slave_alloc fails. This will fail reference taking in subsequent teardown/scan paths.

-- james s

---

 scsi_scan.c |    1 +
 1 file changed, 1 insertion(+)

diff -upNr a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c

drivers/scsi/scsi_scan.c static struct scsi_device *scsi_alloc_sd · line 313

Quoted 4 lines
drivers/scsi/scsi_scan.c +1 -0
@@ -310,6 +310,7 @@ static struct scsi_device *scsi_alloc_sd
 			 */
 			if (ret == -ENXIO)
 				display_failure_msg = 0;
+			scsi_device_set_state(sdev, SDEV_DEL);

A minor nit (since we only have one user of out_device_destroy) is that the state setting should be done in the out_device_destroy: branch

James