Whamcloud - gitweb
LU-12362 ptlrpc: use wait_woken() in ptlrpcd() 69/45069/4
authorMr NeilBrown <neilb@suse.de>
Tue, 28 Sep 2021 05:20:30 +0000 (15:20 +1000)
committerOleg Drokin <green@whamcloud.com>
Sun, 10 Oct 2021 03:30:44 +0000 (03:30 +0000)
commit885b494632ca16d95fd09685a571b76d80d09414
treeb205306613a50ef506e1aff6f49a8ee03f474c6c
parent9ec5e2329bf3d7e38fa899a259221aa58fb48cd4
LU-12362 ptlrpc: use wait_woken() in ptlrpcd()

Using wait_event() to wait for ptlrpcd_check() to succeed is
problematic.  ptlrpcd_check() is complex and can wait for other
events.  This nested waiting can behave differently to expectation and
generates a warning

   do not call blocking ops when !TASK_RUNNING

This happens because the task state is set to TASK_IDLE before
ptlrpcd_check() is calls.

A better approach (introduce for precisely this use-case) is to use
wait_woken() and woken_wake_function().

When a wake_up is requested on the waitq, woken_wake_function() sets a
flag to record the wakeup.  wait_woken() will wait until this flag is
set.  This way, the task state doesn't need to be set until after
ptlrpcd_check() has completed.

wait_woken() was introduced in Linux 3.19, so libcfs is enhance to
provide the functionality on older kernels.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Iaddf56e2e76c204435bbef3c857e54ce0a6772bc
Reviewed-on: https://review.whamcloud.com/45069
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: xinliang <xinliang.liu@linaro.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-wait.h
libcfs/libcfs/linux/linux-wait.c
lustre/ptlrpc/ptlrpcd.c