>From 9e96c5dd094d3822093656e87b71cd433e818cd2 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Sat, 8 Mar 2008 12:28:17 +0100 Subject: [PATCH] Remove reap_ref struct scsi_target contains a 'reap_ref' counter, which is basically a reference counter for the target. As we now have proper reference counting we can remove this and clear out the calling sequence for scsi_target_reap(). Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_scan.c | 22 ++++++++++++++-------- drivers/scsi/scsi_sysfs.c | 3 --- include/scsi/scsi_device.h | 1 - 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index d61a8e8..2feab2a 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -448,7 +448,6 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, return starget; found: - found_target->reap_ref++; spin_unlock_irqrestore(shost->host_lock, flags); if (found_target->state != STARGET_DEL) { put_device(parent); @@ -505,7 +504,7 @@ void scsi_target_reap(struct scsi_target *starget) spin_lock_irqsave(shost->host_lock, flags); - if (--starget->reap_ref == 0 && list_empty(&starget->devices)) { + if (list_empty(&starget->devices)) { if (starget->state == STARGET_CREATED) { spin_unlock_irqrestore(shost->host_lock, flags); starget->state = STARGET_DEL; @@ -1516,8 +1515,13 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, if (scsi_host_scan_allowed(shost)) scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); mutex_unlock(&shost->scan_mutex); - transport_configure_device(&starget->dev); - scsi_target_reap(starget); + /* + * scsi_target_reap is called from the release function + * of each sdev. + */ + if (starget->state != STARGET_DEL) + transport_configure_device(&starget->dev); + put_device(&starget->dev); return sdev; @@ -1595,10 +1599,12 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, } out_reap: - /* now determine if the target has any children at all - * and if not, nuke it */ - transport_configure_device(&starget->dev); - scsi_target_reap(starget); + /* + * scsi_target_reap is called from the release function + * of each sdev. + */ + if (starget->state != STARGET_DEL) + transport_configure_device(&starget->dev); put_device(&starget->dev); } diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index bd49d4e..4db0fed 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -297,7 +297,6 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) starget = to_scsi_target(parent); spin_lock_irqsave(sdev->host->host_lock, flags); - starget->reap_ref++; list_del(&sdev->siblings); list_del(&sdev->same_target_siblings); list_del(&sdev->starved_entry); @@ -937,7 +936,6 @@ static void __scsi_remove_target(struct scsi_target *starget) struct scsi_device *sdev; spin_lock_irqsave(shost->host_lock, flags); - starget->reap_ref++; restart: list_for_each_entry(sdev, &shost->__devices, siblings) { if (sdev->channel != starget->channel || @@ -950,7 +948,6 @@ static void __scsi_remove_target(struct scsi_target *starget) goto restart; } spin_unlock_irqrestore(shost->host_lock, flags); - scsi_target_reap(starget); } static int __remove_child (struct device * dev, void * data) diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index f6a9fe0..ccc437b 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -196,7 +196,6 @@ struct scsi_target { struct list_head siblings; struct list_head devices; struct device dev; - unsigned int reap_ref; /* protected by the host lock */ unsigned int channel; unsigned int id; /* target id ... replace * scsi_device.id eventually */ -- 1.5.3.2