Whamcloud - gitweb
LU-12780 osp: don't use ptlrpc_thread for osp_sync_thread()
Instead of ptlrpc_thread, just use native kthread functionality.
- Move allocations to before the thread is created, so error
reporting is easier.
- add a completion so that we can be sure that the thread is stared,
and hence know that cleanup will eventually happen.
- use kthread_stop() to tell the thread to stop, and
kthread_should_stop() to see if it has bene told.
- clear ->opd_sync_task before calling kthread_stop(), and
use a test for NULL to see if the thread is stopping
- As some error conditions can cause the thread to exit before being
asked, and as kthread_stop() doesn't handle this possibility, add
an extra handshake.
Both thread-exit and osp_sync_fini() atomically exchange NULL for
the thread pointer.
If thread-exit is first, the exit proceeds and osp_sync_fini() never
waits. For osp_sync_fini() is first, it calls kthread_exit() to
wait, and thread-exit doesn't happen until it is sure that
kthread_stop() is waiting.
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I952cbdae90252476853854d89b8f1a78d95ddbde
Reviewed-on: https://review.whamcloud.com/36265
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>