From: James Bottomley <James.Bottomley@SteelEye.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Mike Anderson <andmike@us.ibm.com>, Greg KH <greg@kroah.com>,
linux-usb-devel@lists.sourceforge.net,
SCSI Mailing List <linux-scsi@vger.kernel.org>,
mdharm-usb@one-eyed-alien.net
Subject: Re: oops on usb storage device disconnect with 2.6.14-rc1
Date: Sat, 17 Sep 2005 19:36:41 -0500 [thread overview]
Message-ID: <1127003801.4794.13.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0509152133170.9589-100000@netrider.rowland.org>
On Thu, 2005-09-15 at 21:52 -0400, Alan Stern wrote:
> In short, those iterations must be carried out as in my patch.
OK, I looked at making this work while reaping the target correctly, but
I couldn't (basic problem is that the target list keeps the target until
it has no more devices, a condition that could be made untrue by
something as simple as an open of the sysfs file).
So, rather than try that, I thought a better approach might be to make
the host state model work for us. i.e. if we know the host is being
removed, there's no point allowing target or device removal because at
some point the host removal will do it for us. This enforcement would
ensure we're the only legitimate removers of the target and device.
The alternative is to migrate to klists, I think ...
James
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -7,6 +7,7 @@
struct request_queue;
struct scsi_cmnd;
struct scsi_device;
+struct scsi_target;
struct scsi_host_template;
struct scsi_request;
struct Scsi_Host;
@@ -125,6 +126,7 @@ extern void scsi_sysfs_device_initialize
extern int scsi_sysfs_target_initialize(struct scsi_device *);
extern struct scsi_transport_template blank_transport_template;
extern void __scsi_remove_device(struct scsi_device *);
+extern void __scsi_remove_target(struct scsi_target *);
extern struct bus_type scsi_bus_type;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1481,7 +1481,7 @@ void scsi_forget_host(struct Scsi_Host *
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry_safe(starget, tmp, &shost->__targets, siblings) {
spin_unlock_irqrestore(shost->host_lock, flags);
- scsi_remove_target(&starget->dev);
+ __scsi_remove_target(starget);
spin_lock_irqsave(shost->host_lock, flags);
}
spin_unlock_irqrestore(shost->host_lock, flags);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -710,7 +710,8 @@ void scsi_remove_device(struct scsi_devi
struct Scsi_Host *shost = sdev->host;
down(&shost->scan_mutex);
- __scsi_remove_device(sdev);
+ if (scsi_host_scan_allowed(shost))
+ __scsi_remove_device(sdev);
up(&shost->scan_mutex);
}
EXPORT_SYMBOL(scsi_remove_device);
@@ -728,7 +729,7 @@ void __scsi_remove_target(struct scsi_ta
sdev->id != starget->id)
continue;
spin_unlock_irqrestore(shost->host_lock, flags);
- scsi_remove_device(sdev);
+ __scsi_remove_device(sdev);
spin_lock_irqsave(shost->host_lock, flags);
}
spin_unlock_irqrestore(shost->host_lock, flags);
@@ -755,7 +756,16 @@ void scsi_remove_target(struct device *d
struct device *rdev;
if (scsi_is_target_device(dev)) {
+ struct Scsi_Host *shost = dev_to_shost(dev);
+
+ down(&shost->scan_mutex);
+ /* We deny target removal here if the host is being
+ * deleted, since it will remove the target itself */
+ if (!scsi_host_scan_allowed(shost))
+ goto out;
__scsi_remove_target(to_scsi_target(dev));
+ out:
+ up(&shost->scan_mutex);
return;
}
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -654,7 +654,8 @@ static inline struct device *scsi_get_de
**/
static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)
{
- return shost->shost_state == SHOST_RUNNING;
+ return shost->shost_state == SHOST_RUNNING ||
+ shost->shost_state == SHOST_RECOVERY;
}
extern void scsi_unblock_requests(struct Scsi_Host *);
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
next prev parent reply other threads:[~2005-09-18 0:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-15 19:03 oops on usb storage device disconnect with 2.6.14-rc1 Greg KH
2005-09-15 19:23 ` [linux-usb-devel] " Alan Stern
2005-09-15 19:29 ` Greg KH
2005-09-15 19:57 ` James Bottomley
2005-09-15 21:08 ` [linux-usb-devel] " James Bottomley
2005-09-15 22:19 ` Mike Anderson
2005-09-15 22:38 ` [linux-usb-devel] " James Bottomley
2005-09-15 23:55 ` Mike Anderson
2005-09-16 1:46 ` James Bottomley
2005-09-16 1:52 ` [linux-usb-devel] " Alan Stern
2005-09-16 2:27 ` James Bottomley
2005-09-18 0:36 ` James Bottomley [this message]
2005-09-18 2:33 ` [linux-usb-devel] " Alan Stern
2005-09-18 20:00 ` James Bottomley
2005-09-18 0:35 ` James Bottomley
2005-09-18 20:05 ` James Bottomley
2005-09-18 20:37 ` Alan Stern
2005-09-18 22:01 ` [linux-usb-devel] " Greg KH
2005-09-18 22:34 ` Greg KH
2005-09-19 15:19 ` [linux-usb-devel] " James Bottomley
2005-09-20 14:48 ` Greg KH
2005-09-15 23:46 ` [linux-usb-devel] " Greg KH
2005-09-16 1:57 ` 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=1127003801.4794.13.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=andmike@us.ibm.com \
--cc=greg@kroah.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=mdharm-usb@one-eyed-alien.net \
--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