On Mon, 8 Jun 2009, Hannes Reinecke wrote: > Hi Alan, > > Alan Stern wrote: > > This patch (as1249) adds an extra state, STARGET_NEW, to the SCSI > > target state model. A target is in this state initially and changes > > over to STARGET_CREATED when the hostt->target_alloc() call has been > > made. > > > > This simplifies target destruction. There's no need for a separate > > scsi_target_destroy() function; everything can be handled within > > scsi_target_reap(). The error paths are more robust because now it's > > easy to verify that all the destructors are called along every > > pathway. > > > Hmm. Is there a specific reason why we have to keep the ->reap_ref > counter around and cannot use the 'normal' driver core reference > counting for this? Yes, there's a very good reason. > Duplicating refcounting doesn't seem logical to me, given that > we already have a 'struct device' hanging about ... We are talking about two different refcounts serving two different purposes. The refcount that is embedded inside struct device controls the structure's overall lifetime; when that count goes to 0 the release method is called and the structure is deallocated. By contrast, starget->reap_ref is (or rather, becomes later on in the patch series) a count of the number of visible LUNs below the target. When this number drops to 0 the target is removed from visibility, i.e., we call device_del() for it. But it remains allocated until the other refcount also becomes 0. Alan Stern -- 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