Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] fix EH thread teardown
@ 2005-09-07 13:51 Christoph Hellwig
  2005-09-07 14:01 ` Rolf Eike Beer
  2005-09-08 15:26 ` Rolf Eike Beer
  0 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2005-09-07 13:51 UTC (permalink / raw)
  To: jejb; +Cc: linux-scsi

As Rolf Eike Beer noted we might not actually get to the
kthread_should_stop() because we are waiting in the semaphore forever.
I didn't get a rmmod hang because of this, but my instrumentation showed
the thread defitiyly didn't exit.

So make sure to wake the EH thread before the kthread_stop, and to plug
the reaming race check kthead_should_stop() a second time just before
calling down_interruptible().


Index: scsi-misc-2.6/drivers/scsi/hosts.c
===================================================================
--- scsi-misc-2.6.orig/drivers/scsi/hosts.c	2005-09-07 14:21:44.000000000 +0200
+++ scsi-misc-2.6/drivers/scsi/hosts.c	2005-09-07 14:22:33.000000000 +0200
@@ -226,8 +226,10 @@
 	struct Scsi_Host *shost = dev_to_shost(dev);
 	struct device *parent = dev->parent;
 
-	if (shost->ehandler)
+	if (shost->ehandler) {
+		up(shost->eh_wait);
 		kthread_stop(shost->ehandler);
+	}
 	if (shost->work_q)
 		destroy_workqueue(shost->work_q);
 
Index: scsi-misc-2.6/drivers/scsi/scsi_error.c
===================================================================
--- scsi-misc-2.6.orig/drivers/scsi/scsi_error.c	2005-09-07 14:21:44.000000000 +0200
+++ scsi-misc-2.6/drivers/scsi/scsi_error.c	2005-09-07 14:22:58.000000000 +0200
@@ -1591,7 +1591,7 @@
 	SCSI_LOG_ERROR_RECOVERY(3, printk("Wake up parent of"
 					  " scsi_eh_%d\n",shost->host_no));
 
-	while (1) {
+	while (!kthread_should_stop()) {
 		/*
 		 * If we get a signal, it means we are supposed to go
 		 * away and die.  This typically happens if the user is

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] fix EH thread teardown
@ 2005-09-13 16:50 Alan Stern
  2005-09-13 17:01 ` Rolf Eike Beer
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Stern @ 2005-09-13 16:50 UTC (permalink / raw)
  To: Rolf Eike Beer; +Cc: Christoph Hellwig, SCSI development list

Rolf Eike Beer wrote:
> 
> Ok, we looked a bit closer on all this. http://lwn.net/Articles/65178/ tells 
> that ktread_stop() will not send a signal, so the down_interruptible() will 
> never return on kthread_stop(). But calling up() directly before 
> kthread_stop() adds a race condition: if reschedule happens right after the 
> up() we've won nothing and it will hang again.

This problem shows up in other ways as well.  With hot-unpluggable 
hosts, the call that does the last 'put' on the last device will hang 
waiting for the eh thread to terminate.  See

http://bugzilla.kernel.org/show_bug.cgi?id=5237

Alan Stern


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-09-14 16:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-07 13:51 [PATCH 1/2] fix EH thread teardown Christoph Hellwig
2005-09-07 14:01 ` Rolf Eike Beer
2005-09-08 15:26 ` Rolf Eike Beer
  -- strict thread matches above, loose matches on Subject: below --
2005-09-13 16:50 Alan Stern
2005-09-13 17:01 ` Rolf Eike Beer
2005-09-13 19:03   ` Alan Stern
2005-09-13 19:05     ` Christoph Hellwig
2005-09-13 20:57       ` Alan Stern
2005-09-14 16:24       ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox