Whamcloud - gitweb
LU-12780 lod: don't use ptlrpc_thread for recovery thread
rather than ptlrpc_thread, use native kthreads functionality.
- This saves a memory allocation - and associated error handling
and memory freeing - for a 'struct ptlrpc_thread'
- startup-up code is moved out of the thread to before the
thread is started. This make error handling clearer,
though it does require putting a 'struct lu_env' in
struct lod_recovery_data.
- As freeing lod_recovery_data and the env is most easily done
in the thread, add a completion to ensure the thread actually
starts. Without this it is possible for a kthread_stop() to
stop the thread before it calls the thread function at all.
- As the thread exits independently but is also waited for, we
need a handshake around kthread_stop(). Both thread_exit and
code that stops the thread use xchg() to store a NULL in the
task pointer ltd_recovery_task or lod_child_recovery_thread.
If the thread reads out a non-NULL pointer, it can exit because
nothing will wait for it.
If it gets NULL, it must wait for kthread_should_stop(). The waiter
will call kthread_shop() immediately after the xchg, so the wait
will be short.
We use wait_var_event() for this wait even though there is no
wake_up_var(). wait_var_event() is just a convenient macro that
handles thread state change for us - the wait queue is irrelevant.
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I95403fc38bac99f21a4353ec7814816b813184d0
Reviewed-on: https://review.whamcloud.com/36261
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>