Whamcloud - gitweb
LU-12780 osp: don't use ptlrpc_thread for lwp_notify_main() 66/36266/7
authorMr NeilBrown <neilb@suse.de>
Wed, 23 Oct 2019 00:30:50 +0000 (11:30 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 24 Mar 2020 05:16:44 +0000 (05:16 +0000)
commit051f0adeb0615da83c819ff74da467bb4117ae63
treef7120195df3295935e15a925401bd31cf47c25d1
parent862e9bf632dc44f1102bfc2aef10504e506f1225
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>
lustre/osp/lwp_dev.c