Whamcloud - gitweb
LU-12780 osp: don't use ptlrpc_thread for osp_sync_thread() 65/36265/8
authorMr NeilBrown <neilb@suse.de>
Wed, 23 Oct 2019 00:30:50 +0000 (11:30 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Apr 2020 08:09:56 +0000 (08:09 +0000)
commit8afc9590a78f6b20c338c027e17043bb22012817
tree85314bd83720969b7df381f0ad4ad44ee26615a0
parent95211684d4bde4c4009ec9184956aff61658b735
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>
lustre/osp/osp_internal.h
lustre/osp/osp_sync.c