[CIFS] don't allow demultiplex thread to exit until kthread_stop is called
commite691b9d1a096fbaaff9d6d6aef1adc593b786e62
authorSteve French <sfrench@us.ibm.com>
Sun, 11 May 2008 15:53:33 +0000 (11 15:53 +0000)
committerSteve French <sfrench@us.ibm.com>
Sun, 11 May 2008 17:45:44 +0000 (11 17:45 +0000)
treea329a4d115315d4dd459d171c3c98b2bc8c4728b
parent67750fb9e07940c078d1edb16fd736ccc92a4a4e
[CIFS] don't allow demultiplex thread to exit until kthread_stop is called

cifs_demultiplex_thread can exit under several conditions:

1) if it's signaled
2) if there's a problem with session setup
3) if kthread_stop is called on it

The first two are problems. If kthread_stop is called on the thread,
there is no guarantee that it will still be up. We need to have the
thread stay up until kthread_stop is called on it.

One option would be to not even try to tear things down until after
kthread_stop is called. However, in the case where there is a problem
setting up the session, there's no real reason to try continuing the
loop.

This patch allows the thread to clean up and prepare for exit under all
three conditions, but it has the thread go to sleep until kthread_stop
is called. This allows us to simplify the shutdown code somewhat since
we can be reasonably sure that the thread won't exit after being
signaled but before kthread_stop is called.

It also removes the places where the thread itself set the tsk variable
since it appeared that it could have a potential race where the thread
might never be shut down.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/connect.c