From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
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 16:09:59 -0500 [thread overview]
Message-ID: <1243372199.2815.77.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0905261508210.9278-100000@iolanthe.rowland.org>
On Tue, 2009-05-26 at 15:29 -0400, Alan Stern wrote:
> On Tue, 26 May 2009, Kay Sievers wrote:
>
> > On Mon, May 25, 2009 at 13:45, Kay Sievers <kay.sievers@vrfy.org> wrote:
> > > On Mon, May 25, 2009 at 04:06, Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > >> by the way -- so it's a little difficult to trigger.
> > >
> > > I can trigger it pretty reliable now on plain -rc7 , but only with
> > > more hubs in-between the storage device. It usually take less than
> > > 10-15 connect/disconnect cycles.
> > >
> > > It looks like a serious bug though, after the bug triggered, random,
> > > likely unrelated, applications crash, and I can not cleanly shot down
> > > anymore.
> >
> > Just a heads up if anybody is trying to reproduce this, it trashed my
> > ext3 rootfs, which is not recoverable.
> >
> > Not sure what exactly caused this, but I didn't have anything like
> > this for a very long time.
> >
> > I tried to reproduce the issue a few times more, and it crashed random
> > processes after the bug triggered, like mentioned above, and the box
> > never shut down cleanly.
> >
> > It's entirely possible, that bug causes serious issues.
>
> If you don't mind trashing some more ext3 root filesystems :-) you can
> try this patch. It's almost certainly not quite the right thing to do
> and I have probably messed up the target's reference counting, but
> maybe it's a step in the right direction.
>
> This strange business of deferring unregistration into a workqueue
> means that the calls might not be executed in the same order that
> they're made.
>
> Alan Stern
>
>
> Index: usb-2.6/drivers/scsi/scsi_scan.c
> ===================================================================
> --- usb-2.6.orig/drivers/scsi/scsi_scan.c
> +++ usb-2.6/drivers/scsi/scsi_scan.c
> @@ -956,6 +956,7 @@ static inline void scsi_destroy_sdev(str
> if (sdev->host->hostt->slave_destroy)
> sdev->host->hostt->slave_destroy(sdev);
> transport_destroy_device(&sdev->sdev_gendev);
> + put_device(sdev->sdev_gendev.parent);
> put_device(&sdev->sdev_gendev);
> }
>
> Index: usb-2.6/drivers/scsi/scsi_sysfs.c
> ===================================================================
> --- usb-2.6.orig/drivers/scsi/scsi_sysfs.c
> +++ usb-2.6/drivers/scsi/scsi_sysfs.c
> @@ -327,8 +327,6 @@ static void scsi_device_dev_release_user
> sdev->request_queue = NULL;
> }
>
> - scsi_target_reap(scsi_target(sdev));
> -
> kfree(sdev->inquiry);
> kfree(sdev);
>
> @@ -954,6 +952,7 @@ void __scsi_remove_device(struct scsi_de
> if (sdev->host->hostt->slave_destroy)
> sdev->host->hostt->slave_destroy(sdev);
> transport_destroy_device(dev);
> + scsi_target_reap(scsi_target(sdev));
> put_device(dev);
> }
Um, well, you're right, it's wrong. The reap needs to be matched with
the reap_ref++
It's hard to follow the problem without full context, but if I
understand correctly the problem is you want all the target directories
removed before you call device_del() on the host and the thing that gets
in the way is the necessary user context removal of the host. So a
simple solution, rather than mucking with the way it works, is to wait
for the workqueues to complete. Does this fix it?
James
---
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index c447838..5846c26 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1877,6 +1877,12 @@ void scsi_forget_host(struct Scsi_Host *shost)
goto restart;
}
spin_unlock_irqrestore(shost->host_lock, flags);
+
+ /*
+ * the sdev removal goes through a workqueue for user context, so
+ * make sure it's all complete before we return
+ */
+ flush_scheduled_work();
}
/*
next prev parent reply other threads:[~2009-05-26 21:09 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 [this message]
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
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=1243372199.2815.77.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