Re: [Patch] take 4: Correct issue with midlayer scsi target allocation and transports that create the targets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 14, 2005 at 03:17:00PM -0700, Patrick Mansfield wrote:
> Hi ... yet another patch to fix user space scanning.
> 
> Based on code in James Smart patch, but moves the ->target_parent call
> outside of scsi_alloc_target.
> 
> Adding a transport->scan does not play well with __scsi_add_device and
> scsi_get_host_dev.
> 
> There appears to be a ref-counting issue with rport->dev, both in this
> patch, and in current code calling scsi_scan_target(&rport->dev ...), or I
> am misunderstanding the code (rport->dev ref count is not incremented)
> hence the FIXME.

> @@ -1190,10 +1199,15 @@ struct scsi_device *__scsi_add_device(st
>  				      uint id, uint lun, void *hostdata)
>  {
>  	struct scsi_device *sdev;
> -	struct device *parent = &shost->shost_gendev;
> +	struct device *parent;
>  	int res;
> -	struct scsi_target *starget = scsi_alloc_target(parent, channel, id);
> +	struct scsi_target *starget;
>  
> +	parent = scsi_target_parent(shost, channel, id);
> +	if (!parent)
> +		return ERR_PTR(-ENODEV);
> +

scsi_add_device is a library function for LLDDs, thus it does not need
this fix.  If we want LLDDs with objects below the target to use them
in the future we should probably change the prototype so it takes a parent
object.

>  int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
> @@ -1432,8 +1453,12 @@ struct scsi_device *scsi_get_host_dev(st
>  {
>  	struct scsi_device *sdev;
>  	struct scsi_target *starget;
> +	struct device *parent;
>  
> -	starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id);
> +	parent = scsi_target_parent(shost, 0, shost->this_id);
> +	if (!parent)
> +		return NULL;
> +	starget = scsi_alloc_target(parent, 0, shost->this_id);

scsi_get_host_dev is a library function for LLDDs and does not need to
care about this.

> +	list_for_each_entry(rport, &fc_host_rports(shost), peers)
> +		if ((rport->channel == channel) &&
> +		    (rport->scsi_target_id == id)) {

lots of superflous braces ;-)

-
: 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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux