Add release function to sd for scsi_disk structure
PATCH 1/1 Add release function to sd for scsi_disk structure
This patch is against 2.6.0-test8.
This patch removes the delay in calling device_del on the sdev struct device during a surprise removal event. Reference counting functions for sd's scsi_disk structure where also added to fix issues of unregistering when a sd is open.
I have tested this patch using scsi_debug with differnt combinations of adds / removes. I mounted both partitioned and un-partitioned sd disks, remove the host, and then did a umount. The ref count debug output shows the objects staying in place prior to the umount and cleaning up once the umount is called.
-andmike
--
Michael Anderson
[email protected]
DESC
This patch fixes an issue with a delayed call of device_del on the sdev_gendev struct device.
- Remove the delayed call to device_del.
- Add kobject to sd scsi_disk structure.
- Add release function for scsi_disk kobject.
- Add get / put functions for scsi_disk and calls to these functions.
EDESC
drivers/scsi/scsi.c | 4 -- drivers/scsi/scsi_sysfs.c | 3 -- drivers/scsi/sd.c | 63 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 13 deletions(-)
drivers/scsi/scsi_sysfs.c renamed from drivers/scsi/scsi_sysfs.c~blkdev_release +1 -2
@@ -412,8 +412,7 @@ void scsi_remove_device(struct scsi_deviset_bit (SDEV_DEL , &sdev->sdev_state);if (sdev->host->hostt->slave_destroy) sdev->host->hostt->slave_destroy (sdev); -if (!atomic_read (&sdev->access_count)) -device_del (&sdev->sdev_gendev); +device_del (&sdev->sdev_gendev);up_write (&class->subsys.rwsem); }
drivers/scsi/scsi.c renamed from drivers/scsi/scsi.c~blkdev_release +1 -3
@@ -914,9 +914,7 @@ void scsi_device_put(struct scsi_devicereturn ;module_put (sdev->host->hostt->module); -if (atomic_dec_and_test (&sdev->access_count)) -if (test_bit (SDEV_DEL , &sdev->sdev_state)) -device_del (&sdev->sdev_gendev); +atomic_dec (&sdev->access_count);put_device (&sdev->sdev_gendev);class_put (&sdev_class); }
drivers/scsi/sd.c renamed from drivers/scsi/sd.c~blkdev_release +55 -8
132 lines not on this page · raw message
_
Quoted 7 lines · Mike Anderson
This patch is against 2.6.0-test8.
This patch removes the delay in calling
device_delon the sdev struct device during a surprise removal event. Reference counting functions for sd'sscsi_diskstructure where also added to fix issues of unregistering when a sd is open.
Quoted 5 lines
I have tested this patch using
scsi_debugwith differnt combinations of adds / removes. I mounted both partitioned and un-partitioned sd disks, remove the host, and then did a umount. The ref count debug output shows the objects staying in place prior to the umount and cleaning up once the umount is called.
This looks like a reasonable bandaid until the block layer is fixed.
Quoted 3 lines · Christoph Hellwig [[email protected]] wrote:
This looks like a reasonable bandaid until the block layer is fixed.
Since I do not know the extent of the block layer changes maybe my assumption is incorrect, but wouldn't will still need a release of some kind to know when it is safe to do a free?
-andmike
--
Michael Anderson
[email protected]
Quoted 8 lines · Mike Anderson
Quoted 3 lines · Christoph Hellwig [[email protected]] wrote:
This looks like a reasonable bandaid until the block layer is fixed.
Since I do not know the extent of the block layer changes maybe my assumption is incorrect, but wouldn't will still need a release of some kind to know when it is safe to do a free?
We'll have to see. My assumption would be that freeing any private data should be fine after ->remove. If that's not going to be guaranteed we should try to make your patch a bit more generic (e.g. no sd-specific ktype)