public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 4/7] Fix various bugs in the target code
Date: Mon, 10 Aug 2009 10:53:20 -0500	[thread overview]
Message-ID: <1249919600.4089.111.camel@mulgrave.site> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0908101104080.3208-100000@iolanthe.rowland.org>

On Mon, 2009-08-10 at 11:08 -0400, Alan Stern wrote:
> This patch (as1276) fixes some bugs in the SCSI target code:
> 
> 	In scsi_alloc_target(), a newly-created target was added to
> 	the host's list of targets before the host's target_alloc()
> 	method was called.

So this one is the design way the target code works:  allocate and add
first so the transport and target code have a fully usable device.

> 	In the same routine, if a match was found with an old target
> 	in the DEL state then that target's reap_ref was mistakenly
> 	incremented.  This is harmless, but it shouldn't happen.

It's required for the state != DEL case ... the reap_ref loses
significance after the state moves to DEL, so it's by design.

> 	If we have to wait for an old target to disappear, instead of
> 	calling flush_scheduled_work() the patch calls
> 	schedule_timeout_uninterruptible(1).  After all, whatever is
> 	pinning the old target might not have anything to do with a
> 	workqueue.  Besides, flush_scheduled_work() is prone to
> 	deadlocks and should never be used by drivers.

I don't really buy this; it's not (yet) a documented restriction of
flush_scheduled_work() and we have a few drivers using it.  It only
deadlocks if you call it from a running workqueue.

> 	scsi_target_reap() changed starget->state outside the
> 	protection of the host lock.

So does everything else that manipulates the target state.

> 	__scsi_add_device() called scsi_alloc_target() outside the
> 	protection of the host's scan_mutex, meaning that it might
> 	find an incompletely-initialized target or it might create
> 	a duplicate target.

scan mutex isn't used as a determinant for this.  There can be a slight
race in initialisation, but really, it isn't important.

> 	scsi_sysfs_add_sdev() would call transport_configure_device()
> 	for a target each time a new device was added under that
> 	target.  The call has been moved to scsi_target_add(), where
> 	it will be made only once.

That, unfortunately is an SPI required feature ... we can't actually
configure the target until we have a device because of the way SPI
parameters work.

James



  reply	other threads:[~2009-08-10 15:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10 15:08 [PATCH 4/7] Fix various bugs in the target code Alan Stern
2009-08-10 15:53 ` James Bottomley [this message]
2009-08-10 19:05   ` Alan Stern
2009-08-11 15:12   ` Alan Stern
2009-08-11 15:15     ` James Bottomley
2009-08-12 18:31   ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2009-08-13 14:25 Alan Stern

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=1249919600.4089.111.camel@mulgrave.site \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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