Skip to contentSkip to conversation

Resurrect sdev

RFC PATCH New Hannes Reinecke 1 participant 1 message Feb 13, 2007

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Resurrect sdev

Hi all,

as discussed in San Jose here is a patch to resurrect sdevs which are in state SDEV_CANCEL / SDEV_DEL.

I've updated sdev handling functions to be better aligned with the state machine; we now have:

scsi_remove_device(): Same as before; transitioning into SDEV_CANCEL.
Initiate the device removal.
scsi_destroy_device(): Transition into SDEV_DEL; just initiate
the final device_put(). Device will be deleted properly once the refcount drops to zero.
scsi_configure_device(): Transistion into SDEV_RUNNING.
If scsi_configure_device() succeeds it has to be added to sysfs with scsi_sysfs_add_sdev(). If it fails the sdev should be deleted with scsi_destroy_device().
scsi_resurrect_device(): Wrapper around scsi_configure_device.
Transition a deleted device into SDEV_RUNNING.
If it fails the device is in SDEV_DEL.

I've gone through the scanning mechanism and hopefully got it done properly. I tried to ensure that after the scanning the sdevs are either in SDEV_RUNNING or SDEV_DEL.

Patch apprears to work properly, but I haven't been running any stress tests on it. Ie those cases which the patch is trying to solve :-)

Comments etc. welcome.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke			[email protected]
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstra�e 5				+49 911 74053 688
90409 N�rnberg				http://www.suse.de
block/elevator.c +0 -0
block/ll_rw_blk.c +0 -0
drivers/block/DAC960.c +0 -0
drivers/block/cciss.c +0 -0
drivers/block/cpqarray.c +0 -0
drivers/block/floppy.c +0 -0
drivers/block/nbd.c +0 -0
drivers/block/sx8.c +0 -0
drivers/block/ub.c +0 -0
drivers/block/viodasd.c +0 -0
drivers/ide/ide-cd.c +0 -0
drivers/ide/ide-io.c +0 -0
drivers/message/i2o/i2o_block.c +0 -0
drivers/mmc/mmc_block.c +0 -0
drivers/s390/block/dasd.c +0 -0
drivers/s390/char/tape_block.c +0 -0
drivers/scsi/ide-scsi.c +0 -0
drivers/scsi/scsi_lib.c +0 -0
drivers/scsi/scsi_scan.c +31 -34

142 lines not on this page · raw message

drivers/scsi/scsi_sysfs.c +70 -16

139 lines not on this page · raw message

drivers/scsi/scsi_transport_fc.c +0 -0
include/linux/blkdev.h +0 -0
include/scsi/scsi_device.h +8 -0
index ebf31b1..af127aa 100644
@@ -202,6 +202,8 @@ extern struct scsi_device *__scsi_add_de
 		uint, uint, uint, void *hostdata);
 extern int scsi_add_device(struct Scsi_Host *host, uint channel,
 			   uint target, uint lun);
+extern int scsi_configure_device(struct scsi_device *);
+extern int scsi_resurrect_device(struct scsi_device *);
 extern void scsi_remove_device(struct scsi_device *);
 extern int scsi_device_cancel(struct scsi_device *, int);
 
@@ -316,6 +318,12 @@ static inline unsigned int sdev_id(struc
 #define scmd_id(scmd) sdev_id((scmd)->device)
 #define scmd_channel(scmd) sdev_channel((scmd)->device)
 
+static inline void scsi_destroy_device(struct scsi_device *sdev)
+{
+	scsi_device_set_state(sdev, SDEV_DEL);
+	put_device(&sdev->sdev_gendev);
+}
+
 static inline int scsi_device_online(struct scsi_device *sdev)
 {
 	return sdev->sdev_state != SDEV_OFFLINE;