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 09:28:11 -0500 [thread overview]
Message-ID: <1081520891.2202.44.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0404091005520.1000-100000@ida.rowland.org>
On Fri, 2004-04-09 at 09:11, Alan Stern wrote:
> The patch is almost but not quite correct. It acquires the new semaphore
> unnecessarily during scsi_disk_put, it fails to acquire it when erasing
> the gendisk private_data, and it needs to erase the private_data during
> sd_remove (not scsi_disk_release). It also contains a syntax error.
Heh, the additional semicolon I'll remove.
However, the rest of your patch is wrong.
The reason is that what you're trying to synchronise is the naming
lookup (the gendisk open). You have to allow currently open devices to
continue to operate. NULL'ing out the disk->private_data before
del_gendisk would mean it was null for sd_release, so every attempt to
close the device after removal would oops. That's why the NULL must be
done in the reference release routine, not in the disconnection
indication routine. The race you're trying to prevent is the 0->1
reference after disconnection.
The original patch, By the way, did hold the sd_ref_sem around the NULL
of disk->private_data because the scsi_disk_release is triggered from
kobject_put on last put (and thus is under the semaphore).
James
next prev parent reply other threads:[~2004-04-09 14:29 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 [this message]
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
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=1081520891.2202.44.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