Skip to contentSkip to conversation

Implement scsi_resurrect_device()

PATCH In review Hannes Reinecke 1 participant 1 message May 23, 2007 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 8/9 Implement scsi_resurrect_device()

This is the main part. This patch implements a function scsi_resurrect_device() which puts a sdev in state SDEV_CANCEL back into SDEV_RUNNING.
So during scan any device in state SDEV_DEL (ie waiting to be deleted) will be put back into SDEV_RUNNING and normal scanning can continue on these devices. Of course there is a high likelyhood that the device will drop back into SDEV_DEL afterwards, but it is perfectly useable during the scan operation.
For this to work I actually had to modify the allowed state transitions, as it's now perfectly possible to move back from SDEV_DEL into SDEV_CANCEL.

---
 drivers/scsi/scsi.c      |    3 ++
 drivers/scsi/scsi_lib.c  |    2 +
 drivers/scsi/scsi_scan.c |   52 +++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 56 insertions(+), 1 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 1f5a07b..4288572 100644
@@ -1945,6 +1945,7 @@ scsi_device_set_state(struct scsi_device
 		case SDEV_OFFLINE:
 		case SDEV_QUIESCE:
 		case SDEV_BLOCK:
+		case SDEV_CANCEL:
 			break;
 		default:
 			goto illegal;
@@ -1990,6 +1991,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 +51 -1

76 lines not on this page · raw message

Signature · 1 line
1.4.3.4