From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
SCSI development list <linux-scsi@vger.kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@suse.de>,
Kernel development list <linux-kernel@vger.kernel.org>,
Tejun Heo <tj@kernel.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
linux-fsdevel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@aristanetworks.com>
Subject: Re: [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories.
Date: Tue, 26 May 2009 23:49:32 +0000 [thread overview]
Message-ID: <1243381772.2815.96.camel@localhost.localdomain> (raw)
In-Reply-To: <ac3eb2510905261503k32db6197m84d1e78858e53da1@mail.gmail.com>
On Wed, 2009-05-27 at 00:03 +0200, Kay Sievers wrote:
> On Tue, May 26, 2009 at 23:56, Alan Stern <stern@rowland.harvard.edu> wrote:
> > On Tue, 26 May 2009, Kay Sievers wrote:
> >
> >> Ok, I copied my newly installed system to another disks, to have a
> >> root filesytem to trash again by this bug. :)
> >>
> >> Which of your patches should I try?
> >
> > James's patch, not mine.
>
> I tried both, both don't fix the issue. With Alan's patch it *seems*
> the target device never gets removed, at least I didn't see anything
> in the kobject debug logs.
OK ... perhaps we have to wait a little harder: try this; it waits until
all the targets have disappeared from visibility via an event.
James
---
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 89d41a4..b2946bf 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -173,6 +173,8 @@ void scsi_remove_host(struct Scsi_Host *shost)
BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY));
spin_unlock_irqrestore(shost->host_lock, flags);
+ scsi_wait_for_targets_gone(shost);
+
transport_unregister_device(&shost->shost_gendev);
device_unregister(&shost->shost_dev);
device_del(&shost->shost_gendev);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index c447838..367216c 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -32,6 +32,7 @@
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/spinlock.h>
+#include <linux/wait.h>
#include <linux/async.h>
#include <scsi/scsi.h>
@@ -324,6 +325,12 @@ out:
return NULL;
}
+static DECLARE_WAIT_QUEUE_HEAD(scsi_target_removed);
+void scsi_wait_for_targets_gone(struct Scsi_Host *shost)
+{
+ wait_event(scsi_target_removed, list_empty(&shost->__targets));
+}
+
static void scsi_target_destroy(struct scsi_target *starget)
{
struct device *dev = &starget->dev;
@@ -336,6 +343,7 @@ static void scsi_target_destroy(struct scsi_target *starget)
shost->hostt->target_destroy(starget);
list_del_init(&starget->siblings);
spin_unlock_irqrestore(shost->host_lock, flags);
+ wake_up(&scsi_target_removed);
put_device(dev);
}
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index b62a097..b63a901 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -747,6 +747,7 @@ static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)
extern void scsi_unblock_requests(struct Scsi_Host *);
extern void scsi_block_requests(struct Scsi_Host *);
+extern void scsi_wait_for_targets_gone(struct Scsi_Host *);
struct class_container;
next prev parent reply other threads:[~2009-05-26 23:49 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ac3eb2510905260927we3c748akbbcaf3f3ac1da096@mail.gmail.com>
2009-05-26 19:29 ` [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories Alan Stern
2009-05-26 21:09 ` James Bottomley
2009-05-26 21:13 ` Kay Sievers
2009-05-26 21:56 ` Alan Stern
2009-05-26 22:03 ` Kay Sievers
2009-05-26 23:49 ` James Bottomley [this message]
2009-05-27 0:02 ` Kay Sievers
2009-05-27 2:17 ` Alan Stern
2009-05-27 11:35 ` Hannes Reinecke
2009-05-27 16:01 ` James Bottomley
2009-05-27 16:16 ` Alan Stern
2009-05-27 16:24 ` James Bottomley
2009-05-27 17:01 ` Alan Stern
2009-05-27 17:08 ` James Bottomley
2009-05-27 18:07 ` Alan Stern
2009-05-27 19:44 ` James Bottomley
2009-05-27 20:40 ` Alan Stern
2009-05-27 20:49 ` James Bottomley
2009-05-27 21:31 ` Alan Stern
2009-05-27 21:42 ` James Bottomley
2009-05-27 22:15 ` Alan Stern
2009-05-27 22:22 ` James Bottomley
2009-05-28 15:24 ` Alan Stern
2009-05-28 15:45 ` Eric W. Biederman
2009-05-28 17:51 ` Alan Stern
2009-05-28 18:21 ` James Bottomley
2009-05-28 20:02 ` Alan Stern
2009-05-28 20:10 ` James Bottomley
2009-05-28 21:04 ` Alan Stern
2009-05-29 12:32 ` Hannes Reinecke
2009-05-29 20:08 ` Alan Stern
2009-05-27 18:00 ` Eric W. Biederman
2009-05-27 18:15 ` Alan Stern
2009-05-27 18:24 ` Eric W. Biederman
2009-05-27 21:38 ` Alan Stern
2009-05-27 22:06 ` Eric W. Biederman
2009-05-27 22:18 ` Alan Stern
2009-05-26 21:39 ` Alan Stern
[not found] <1243252896.4853.9.camel@poy>
2009-05-25 15:49 ` Alan Stern
2009-05-25 18:19 ` Kay Sievers
2009-05-25 20:14 ` 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=1243381772.2815.96.camel@localhost.localdomain \
--to=james.bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=cornelia.huck@de.ibm.com \
--cc=ebiederm@aristanetworks.com \
--cc=ebiederm@xmission.com \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tj@kernel.org \
/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