Whamcloud - gitweb
LU-12780 osp: don't use ptlrpc_thread for lwp_notify_main()
Instead of ptlrpc_thread, use native kthread functionality.
- There is no need to synchronise on start-up. But we do
need to ensure class_export_get/put are balanced, and we
cannot be certain that the thread function will run.
So call class_export_get() before starting the thread,
and class_export_put() after it has finished.
- As the thread exits independantly, waiting for it to finish
is a little more complex than just using kthread_stop().
If the thread stops before lwp_device_fini() runs, it sets
->lpd_notify_task to NULL, and lwp_device_fini() doesn't wait.
If lwp_device_fini() runs first, it set ->lpd_notify_task to
NULL and calls kthread_stop(). The thread notices this, and
deliberately waits for kthread_should_stop() to avoid any
races in kthread code.
xchg() is used to ensure exactly one of the thread and
lwp_device_fini() sets lpd_notify_task to NULL.
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I45621f325d14194af5a44f86f7e605bdafbbb9be
Reviewed-on: https://review.whamcloud.com/36266
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>