• NeilBrown's avatar
    sunrpc: allow svc threads to fail initialisation cleanly · 3391fc92
    NeilBrown authored
    If an svc thread needs to perform some initialisation that might fail,
    it has no good way to handle the failure.
    
    Before the thread can exit it must call svc_exit_thread(), but that
    requires the service mutex to be held.  The thread cannot simply take
    the mutex as that could deadlock if there is a concurrent attempt to
    shut down all threads (which is unlikely, but not impossible).
    
    nfsd currently call svc_exit_thread() unprotected in the unlikely event
    that unshare_fs_struct() fails.
    
    We can clean this up by introducing svc_thread_init_status() by which an
    svc thread can report whether initialisation has succeeded.  If it has,
    it continues normally into the action loop.  If it has not,
    svc_thread_init_status() immediately aborts the thread.
    svc_start_kthread() waits for either of these to happen, and calls
    svc_exit_thread() (under the mutex) if the thread aborted.
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    3391fc92
callback.c 8.9 KB