Whamcloud - gitweb
LU-12780 lod: don't use ptlrpc_thread for recovery thread 61/36261/8
authorMr NeilBrown <neilb@suse.de>
Wed, 23 Oct 2019 00:30:49 +0000 (11:30 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 17 Mar 2020 03:40:30 +0000 (03:40 +0000)
commit3b0094779b58c162e5dc553f6d7cdff1910d0c3b
tree5b48e4dd76bfadf46bf4992b13d00f27cb2a0881
parent896e12c2e4fc98cbc15c675ec2894e9511aa92a7
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>
lustre/include/lu_object.h
lustre/lod/lod_dev.c
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c