public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Patrick Mansfield <patmans@us.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	James.Smart@Emulex.Com, linux-scsi@vger.kernel.org
Subject: Re: [Patch] take 4: Correct issue with midlayer scsi target allocation and transports that create the targets
Date: Tue, 14 Jun 2005 23:35:35 +0100	[thread overview]
Message-ID: <20050614223535.GA6834@infradead.org> (raw)
In-Reply-To: <20050614221700.GA15695@us.ibm.com>

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 ;-)


  reply	other threads:[~2005-06-14 22:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-11  2:24 [Patch] Correct issue with midlayer scsi target allocation and transports that create the targets James.Smart
2005-06-11 15:37 ` Christoph Hellwig
2005-06-11 18:15   ` Patrick Mansfield
2005-06-11 18:18     ` Christoph Hellwig
2005-06-14 22:17   ` [Patch] take 4: " Patrick Mansfield
2005-06-14 22:35     ` Christoph Hellwig [this message]
2005-06-14 22:54       ` Patrick Mansfield
2005-06-17 11:11         ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2005-06-17 13:08 James.Smart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050614223535.GA6834@infradead.org \
    --to=hch@infradead.org \
    --cc=James.Smart@Emulex.Com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=patmans@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox