Skip to contentSkip to conversation

Implement scsi_resurrect_device()

PATCH New Hannes Reinecke 1 participant 1 message Jun 18, 2007 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 9/11 Implement scsi_resurrect_device()

This patch implements a function scsi_resurrect_device() which elevates a sdev from state SDEV_CANCEL back into SDEV_RUNNING.
So during a scan any sdev in SDEV_DEL is put into SDEV_CANCEL and then scsi_resurrect_device() is called. This will put the device into SDEV_RUNNING and the scan can proceed.
To allow this the state machine has to be expanded, as no transistion out of SDEV_CANCEL into SDEV_RUNNING and from SDEV_DEL into SDEV_CANCEL are now perfectly possible.

---
 drivers/scsi/scsi.c      |    3 ++
 drivers/scsi/scsi_lib.c  |    2 +
 drivers/scsi/scsi_scan.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 0 deletions(-)
drivers/scsi/scsi.c +3 -0
index 4c1e313..11f0f0d 100644
@@ -950,6 +950,9 @@ struct scsi_device *scsi_device_lookup_b
 
 	spin_lock_irqsave(shost->host_lock, flags);
 	sdev = __scsi_device_lookup_by_target(starget, lun);
+	/* This triggers a resurrection of the sdev */
+	if (sdev && sdev->sdev_state == SDEV_DEL)
+		scsi_device_set_state(sdev, SDEV_CANCEL);
 	if (sdev && scsi_device_get(sdev))
 		sdev = NULL;
 	spin_unlock_irqrestore(shost->host_lock, flags);
drivers/scsi/scsi_lib.c +2 -0
index bb32747..d1dc7ce 100644
@@ -1954,6 +1954,7 @@ scsi_device_set_state(struct scsi_device
 		case SDEV_OFFLINE:
 		case SDEV_QUIESCE:
 		case SDEV_BLOCK:
+		case SDEV_CANCEL:
 			break;
 		default:
 			goto illegal;
@@ -1999,6 +2000,7 @@ scsi_device_set_state(struct scsi_device
 		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 		case SDEV_BLOCK:
+		case SDEV_DEL:
 			break;
 		default:
 			goto illegal;
drivers/scsi/scsi_scan.c +53 -0

71 lines not on this page · raw message

Signature · 1 line
1.4.3.4