From: Mike Anderson <andmike@us.ibm.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Christoph Hellwig <hch@infradead.org>,
SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: scsi_forget_host() and scsi_remove_device()
Date: Thu, 3 Jul 2003 15:19:40 -0700 [thread overview]
Message-ID: <20030703221940.GA5983@beaverton.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0307031650370.779-100000@ida.rowland.org>
Alan Stern [stern@rowland.harvard.edu] wrote:
> There's a real problem about the way scsi_forget_host() calls
> scsi_remove_device() for each device on the host's bus. The problem is
> that scsi_remove_device() unregisters the device in sysfs, which unbinds
> the device's driver. This happens immediately, without waiting for the
> reference count to be 0. So if the device is open (mounted, for example)
> when the host is unplugged, the filesystem will have a dangling reference
> to the unbound driver. Of course this will most likely cause a segfault
> when the user attempts to unmount the device.
>
> I don't know what the right way is to attack this problem, or what you're
> planning to do about it. One approach would be somehow to prevent any new
> references to the device from being created while waiting for all the
> existing references to go away. But that doesn't seem feasible.
>
> How are you going to address this problem?
>
> Alan Stern
>
Yes, this is an issue. I became more of issue one we started using the
LDM driver probe / remove functions.
I am still cleaning up a patch set for hosts and devices so it is not
quite ready for review yet (I got pulled off on to some other issues for
a few days).
For scsi devices here is a quick snap shot of what I trying to test.
scsi_device_register:
calls device_initialize on sdev_driverfs_dev
calls class_device_initialize on sdev_classdev
calls device_add on sdev_driverfs_dev
calls class_device_add on sdev_classdev
calls get_device on sdev_driverfs_dev
scsi_device_unregister:
sets a state the scsi_device indicating "delete"
calls class_device_unregister on sdev_classdev
scsi_device_cls_release:
calls put_device on sdev_driverfs_dev
scsi_device_dev_release:
calls device_del sdev_driverfs_dev (I have a hack in here to ensure
device_add was previously called).
calls scsi_free_sdev
scsi_device_get:
if device state says get ok
calls get_device on sdev_driverfs_dev
(I still have access_count on try_module_get in the function).
scsi_device_put:
calls put_device on sdev_driverfs_dev
(I still have access_count on try_module_put in the function).
The gets are only stopped for callers of scsi_device_get. If a
get_device is called from outside the subsystem I cannot stop this
though it would not cause bad things to happen just a longer time to
cleanup. A core flag would most likely be needed to stop this from
happening.
-andmike
--
Michael Anderson
andmike@us.ibm.com
next prev parent reply other threads:[~2003-07-03 22:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20030619213109.GB5644@kroah.com>
2003-06-20 20:05 ` Host drivers and conversion of SCSI to the driver model Alan Stern
2003-06-20 21:07 ` Mike Anderson
2003-06-23 14:57 ` Alan Stern
2003-06-27 10:03 ` Christoph Hellwig
2003-06-27 17:56 ` Alan Stern
2003-06-27 18:04 ` Christoph Hellwig
2003-06-27 19:23 ` Mike Anderson
2003-06-28 8:34 ` Christoph Hellwig
2003-06-28 15:08 ` Jeff Garzik
2003-06-28 15:12 ` Christoph Hellwig
2003-07-03 15:15 ` Alan Stern
2003-07-06 16:04 ` Christoph Hellwig
2003-07-03 21:02 ` scsi_forget_host() and scsi_remove_device() Alan Stern
2003-07-03 22:19 ` Mike Anderson [this message]
2003-07-04 14:16 ` Alan Stern
2003-07-04 19:36 ` Alan Stern
2003-07-04 19:54 ` Matthew Dharm
2003-07-05 14:11 ` Alan Stern
2003-07-05 16:25 ` Matthew Dharm
2003-07-06 16:13 ` Christoph Hellwig
2003-07-07 15:19 ` PATCH: (as54) Fix hot-unplugging for sr.c Alan Stern
2003-07-08 22:29 ` Mike Anderson
2003-07-09 14:04 ` Alan Stern
2003-07-09 14:44 ` Mike Anderson
2003-07-09 16:02 ` Alan Stern
2003-07-31 19:38 ` PATCH: (as33e) Fix removal of /proc/scsi/hostdir on hot-unplug Alan Stern
2003-08-01 20:03 ` Mike Anderson
2003-08-15 20:05 ` PATCH: (as84) Fix my earlier scsi procdir patch Alan Stern
2003-09-16 14:50 ` PATCH: (as84) Small fixup for SCSI proc code Alan Stern
2003-10-16 21:09 ` Race in removal of host class device attribute file Alan Stern
2003-10-16 22:47 ` Mike Anderson
2003-10-17 12:18 ` Alan Stern
2003-10-17 12:30 ` Christoph Hellwig
2003-12-10 15:02 ` Suggestion for aiding debugging of host removal Alan Stern
2003-12-10 15:14 ` Christoph Hellwig
2003-12-11 4:16 ` DMA Timeout with Promise S150TX4 and 2.6.0-test11-bk8 Paul
2003-12-11 7:48 ` Suggestion for aiding debugging of host removal Mike Anderson
2003-12-11 11:39 ` Christoph Hellwig
2003-12-11 15:14 ` Alan Stern
2003-07-06 16:11 ` scsi_forget_host() and scsi_remove_device() Christoph Hellwig
2003-07-07 16:06 ` Alan Stern
2003-07-03 20:20 ` SCSI documentation in scsi_mid_low_api.txt Alan Stern
2003-07-03 20:42 ` aic7xxx driver schedules() while holding spinlock Tony Battersby
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=20030703221940.GA5983@beaverton.ibm.com \
--to=andmike@us.ibm.com \
--cc=hch@infradead.org \
--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