This patch (as1248) changes the meaning of starget->reap_ref. Now it serves to count the number of underlying devices beneath the target, plus one when we want to prevent an empty target from being reaped. Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> --- Index: usb-2.6/drivers/scsi/scsi_scan.c =================================================================== --- usb-2.6.orig/drivers/scsi/scsi_scan.c +++ usb-2.6/drivers/scsi/scsi_scan.c @@ -483,14 +483,13 @@ void scsi_target_reap(struct scsi_target spin_lock_irqsave(shost->host_lock, flags); state = starget->state; - empty = --starget->reap_ref == 0 && - list_empty(&starget->devices) ? 1 : 0; + empty = --starget->reap_ref == 0; spin_unlock_irqrestore(shost->host_lock, flags); if (!empty) return; - BUG_ON(state == STARGET_DEL); + BUG_ON(state == STARGET_DEL || !list_empty(&starget->devices)); starget->state = STARGET_DEL; if (state == STARGET_RUNNING) { transport_remove_device(&starget->dev); Index: usb-2.6/drivers/scsi/scsi_sysfs.c =================================================================== --- usb-2.6.orig/drivers/scsi/scsi_sysfs.c +++ usb-2.6/drivers/scsi/scsi_sysfs.c @@ -302,7 +302,6 @@ static void scsi_device_dev_release_user 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); @@ -1089,6 +1088,7 @@ void scsi_sysfs_device_initialize(struct sdev->scsi_level = starget->scsi_level; transport_setup_device(&sdev->sdev_gendev); spin_lock_irqsave(shost->host_lock, flags); + starget->reap_ref++; list_add_tail(&sdev->same_target_siblings, &starget->devices); list_add_tail(&sdev->siblings, &shost->__devices); spin_unlock_irqrestore(shost->host_lock, flags); -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html