Whamcloud - gitweb
LU-12780 osd: use native kthreads for scrub. 24/38824/13
authorMr NeilBrown <neilb@suse.de>
Mon, 18 May 2020 22:48:58 +0000 (08:48 +1000)
committerOleg Drokin <green@whamcloud.com>
Tue, 1 Sep 2020 03:44:04 +0000 (03:44 +0000)
commitb76df292c241a6db8dfad76d0f5f4cb8babe22bf
treeceea0febced8bbcf78ef669c2950ce79c77d692f
parent689714eb511d39e225da64d8bfae42a4b2554626
LU-12780 osd: use native kthreads for scrub.

The 'scrub' thread has nothing to do with ptlrpc, so
using ptlrpc_thread is strange - and not necessary.  This patch
switches to native kthread interfaces.

A particular advantage of the switch is seen in the convertion of
thread_is_running().
This is uses in two completely different ways.
1/ The thread itself needs to know if it has been asked to stop.
  It currently uss thread_is_running().  After the patch it
  uses kthread_should_stop().

2/ Other code needs to know if the thread is still active or not.  It
  previously used thread_is_running(), so it looked just like the
  first case.  Now it checks a new flag ->os_running, which is
  set precisely when SVC_RUNNING was set, and cleared when any other
  status was set.

As the thread can stop itself (e.g if osd_scrub_prep fails) or can be
asked to stop (scrub_stop()), we need to avoid confusion between the
two.  This is achieved by calling 'xchg(&scrub->os_task,NULL)'.
If the thread finds that to be non-NULL, it has stopped itself
and can just exit.  If scrub_stop() finds it to be non-NULL,
it calls kthread_should_stop() to stop the thread.

Instead of using the waitqueue in the 'struct ptlrpc_thread', we use
wake_up_var() and wait_var_event() on the 'scrub' pointer.  This is
used both to tell the thread there is work to do, and for callers to
wait for the task to make progress, or to exit.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ib2f1845151734687e89a1b0d6a5135a5a4ba6e5c
Reviewed-on: https://review.whamcloud.com/38824
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>
libcfs/include/libcfs/linux/linux-wait.h
lustre/include/lustre_scrub.h
lustre/obdclass/scrub.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_scrub.c
lustre/osd-zfs/osd_index.c
lustre/osd-zfs/osd_object.c
lustre/osd-zfs/osd_scrub.c