public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Patrick Mansfield <patmans@us.ibm.com>,
	Mike Anderson <andmike@us.ibm.com>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] fix sd open/remove race
Date: 09 Apr 2004 11:08:52 -0500	[thread overview]
Message-ID: <1081526932.2203.61.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0404091141180.1000-100000@ida.rowland.org>

On Fri, 2004-04-09 at 10:55, Alan Stern wrote:
> Hmm.  That wouldn't matter if you cleared the indicator in sd_remove.  
> Then the race would only be sd_remove against sd_open.  Also, you do have
> to admit, your way of doing it is more obscure.  You should at least add
> comments explaining this 3-way race and the fact that the semaphore is
> already acquired during scsi_disk_release.

But, as I pointed out before, you can't clear the indicator in sd_remove
because, fundamentally, that's not where the race is.  The fundamental
race is the get/put one making sure no-one can get a reference to a
freed object.

sd_remove is just the disconnection indication.  It triggers a put of
the object, causing garbage collection if it's the last put, but that's
all it does.  To mediate the race, the synchronisation has to be around
object acquisition/deallocation.

I can add comments, but the placement of the semaphores is natural to
mediate the object acquisition/deallocation race.  The three thread
illustration was just the first thing that came into my head for
explaining what problems could be caused by not doing natural semaphore
placement.

James



  reply	other threads:[~2004-04-09 16:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040408115148.A12041@beaverton.ibm.com>
2004-04-09 14:11 ` [PATCH] fix sd open/remove race Alan Stern
2004-04-09 14:28   ` James Bottomley
2004-04-09 15:24     ` Alan Stern
2004-04-09 15:35       ` James Bottomley
2004-04-09 15:55         ` Alan Stern
2004-04-09 16:08           ` James Bottomley [this message]
2004-04-09 18:29             ` Alan Stern
2004-04-09 18:45               ` James Bottomley
2004-04-09 19:58                 ` Alan Stern
2004-04-07  3:25 James Bottomley

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=1081526932.2203.61.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=andmike@us.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=patmans@us.ibm.com \
    --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