From: Christoph Hellwig <hch@infradead.org>
To: James.Smart@Emulex.Com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [Patch] Correct issue with midlayer scsi target allocation and transports that create the targets
Date: Fri, 10 Jun 2005 21:25:43 +0100 [thread overview]
Message-ID: <20050610202543.GA13494@infradead.org> (raw)
In-Reply-To: <9BB4DECD4CFE6D43AA8EA8D768ED51C201AC6F@xbl3.ad.emulex.com>
> Here's a proposed patch. The real problem in all of this was that
> we had 2 places allocating a scsi target (or should I say, that
> invoked the scan function that makes the target, but the parents
> are different). This patch adds a transport alloc_target function,
> which allows the transport to adjusts the parent, and then calls
> back into the midlayer to complete the allocation (small recursive
> call). It has one additional optimization in that, if the transport
> is doling out targets, it fails target allocations on things that
> don't exist. This will make scanning slightly faster. I also like
> this patch as it leaves all "scan" logic in the midlayer.
I don't like the recursion part of this at all. I'd suggest to make
scsi_alloc_target a tiny wrapper around the transport ->alloc_target +
a default action, the shared body that's in scsi_alloc_target will
become __scsi_alloc_target.
> + spin_lock_irqsave(shost->host_lock, flags);
> + list_for_each_entry_safe(rport, next_rport,
> + &fc_host_rports(shost), peers) {
you don't actually need list_for_each_entry_safe here as you're dropping
out of the loop once the right rport has been found.
> + if ((rport->channel == channel) &&
> + (rport->scsi_target_id == id)) {
> + spin_unlock_irqrestore(shost->host_lock, flags);
> + starget = scsi_alloc_target(&rport->dev, channel, id);
> + if (starget)
> + return 0;
> + return 1;
this is always under the scan_mutex, right? else we'd get a race after
the sin_unlock but before registering the new target.
next prev parent reply other threads:[~2005-06-10 20:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-10 19:03 [Patch] Correct issue with midlayer scsi target allocation and transports that create the targets James.Smart
2005-06-10 20:25 ` Christoph Hellwig [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-06-11 2:24 James.Smart
2005-06-11 15:37 ` Christoph Hellwig
2005-06-11 18:15 ` Patrick Mansfield
2005-06-11 18:18 ` Christoph Hellwig
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=20050610202543.GA13494@infradead.org \
--to=hch@infradead.org \
--cc=James.Smart@Emulex.Com \
--cc=linux-scsi@vger.kernel.org \
/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