All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] cciss: use timeout to ensure scan thread exits
@ 2009-06-16 20:43 Mike Miller (OS Dev)
  2009-06-16 21:10 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Miller (OS Dev) @ 2009-06-16 20:43 UTC (permalink / raw)
  To: Andrew Morton, Jens Axboe; +Cc: James Bottomley, LKML, LKML-SCSI

Patch 1 of 1

This patch implements wait_for_completion_interruptible_timeout in the
scan_thread function to ensure it will exit cleanly during rmmod. Calling
complete in cciss_remove_one caused a race condition. Using the wait with a
timeout seems to work around that but it does fire the thread. The overhead
should be minimal.

Changelog:
Replace wait_for_completion_interruptible with
wait_for_completion_interruptible_timeout in scan_thread().
Use 5 second timeout value to avoid race.

Signed-off-by: Mike Miller

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 4d4d5e0..76e7c10 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3043,7 +3043,7 @@ static int scan_thread(void *data)
 	h->rescan_wait = &wait;
 
 	for (;;) {
-		rc = wait_for_completion_interruptible(&wait);
+		rc = wait_for_completion_interruptible_timeout(&wait, 5);
 		if (kthread_should_stop())
 			break;
 		if (!rc)

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

* Re: [PATCH 1/1] cciss: use timeout to ensure scan thread exits
  2009-06-16 20:43 [PATCH 1/1] cciss: use timeout to ensure scan thread exits Mike Miller (OS Dev)
@ 2009-06-16 21:10 ` Andrew Morton
  2009-06-16 21:56   ` Mike Miller (OS Dev)
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-06-16 21:10 UTC (permalink / raw)
  To: Mike Miller (OS Dev)
  Cc: jens.axboe, james.bottomley, linux-kernel, linux-scsi

On Tue, 16 Jun 2009 15:43:25 -0500
"Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net> wrote:

> Patch 1 of 1
> 
> This patch implements wait_for_completion_interruptible_timeout in the
> scan_thread function to ensure it will exit cleanly during rmmod. Calling
> complete in cciss_remove_one caused a race condition. Using the wait with a
> timeout seems to work around that but it does fire the thread. The overhead
> should be minimal.
> 
> Changelog:
> Replace wait_for_completion_interruptible with
> wait_for_completion_interruptible_timeout in scan_thread().
> Use 5 second timeout value to avoid race.
> 
> Signed-off-by: Mike Miller
> 
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 4d4d5e0..76e7c10 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -3043,7 +3043,7 @@ static int scan_thread(void *data)
>  	h->rescan_wait = &wait;
>  
>  	for (;;) {
> -		rc = wait_for_completion_interruptible(&wait);
> +		rc = wait_for_completion_interruptible_timeout(&wait, 5);
>  		if (kthread_should_stop())
>  			break;
>  		if (!rc)

c'mon Mike, that's a hack.

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

* Re: [PATCH 1/1] cciss: use timeout to ensure scan thread exits
  2009-06-16 21:10 ` Andrew Morton
@ 2009-06-16 21:56   ` Mike Miller (OS Dev)
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Miller (OS Dev) @ 2009-06-16 21:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: jens.axboe, james.bottomley, linux-kernel, linux-scsi

On Tue, Jun 16, 2009 at 02:10:07PM -0700, Andrew Morton wrote:
> On Tue, 16 Jun 2009 15:43:25 -0500
> "Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net> wrote:
> 
> > Patch 1 of 1
> > 
> > This patch implements wait_for_completion_interruptible_timeout in the
> > scan_thread function to ensure it will exit cleanly during rmmod. Calling
> > complete in cciss_remove_one caused a race condition. Using the wait with a
> > timeout seems to work around that but it does fire the thread. The overhead
> > should be minimal.
> > 
> > Changelog:
> > Replace wait_for_completion_interruptible with
> > wait_for_completion_interruptible_timeout in scan_thread().
> > Use 5 second timeout value to avoid race.
> > 
> > Signed-off-by: Mike Miller
> > 
> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> > index 4d4d5e0..76e7c10 100644
> > --- a/drivers/block/cciss.c
> > +++ b/drivers/block/cciss.c
> > @@ -3043,7 +3043,7 @@ static int scan_thread(void *data)
> >  	h->rescan_wait = &wait;
> >  
> >  	for (;;) {
> > -		rc = wait_for_completion_interruptible(&wait);
> > +		rc = wait_for_completion_interruptible_timeout(&wait, 5);
> >  		if (kthread_should_stop())
> >  			break;
> >  		if (!rc)
> 
> c'mon Mike, that's a hack.

I'm open to suggestions. Calling complete in cciss_remove_one does not
resolve the issue. Other things I've tried may work once or twice but always
results in the hang.
Something I noticed in the trace was 2 calls to rebuild_lun_table when
trying to rmmod. Then it would get into the scheduler and just hang. During
rmmod I don't want to call rebuild_lun_table, just kill the thread and exit.

Ideas, suggestions, flames? Anyone???? 

-- mikem

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

end of thread, other threads:[~2009-06-16 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-16 20:43 [PATCH 1/1] cciss: use timeout to ensure scan thread exits Mike Miller (OS Dev)
2009-06-16 21:10 ` Andrew Morton
2009-06-16 21:56   ` Mike Miller (OS Dev)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.