Whamcloud - gitweb
LU-11089 obd: use wait_event_var() in lu_context_key_degister() 73/38573/4
authorNeilBrown <neilb@suse.com>
Tue, 21 May 2019 14:22:39 +0000 (10:22 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 21 May 2020 06:07:58 +0000 (06:07 +0000)
commitceb45b5fbe35a65539b76678d8187a902504b138
tree4706858436945e87d95b8fd8e0d827e9f48d5191
parent6b0011b8b9cd1a0fc5752512067ae2e384bf8adb
LU-11089 obd: use wait_event_var() in lu_context_key_degister()

lu_context_key_degister() has an open coded loop which calls
schedule() without setting a new task state.  This is generally
a bad idea - it could easily just spin.

Instead, use wait_event_var() to wait for ->lct_used to be zero,
and arrange to get a wakeup when that happens.
Previously ->lct_used would only fall down to 1.  Now we decrement
it an extra time so that wake_up, which only happens when the
count reaches zero, will only happen when lu_context_key_degister()
is actually waiting for it.

Note that this patch removes key_fini() from protection by
lu_keys_guard.  key_fini() calls are not always protected
by a lock, and there seems to be no need here.  Nothing else
can be acting on the given key in that context at this point,
so no race is possible.

Linux-commit: ef84c07364211bb4e398a9de45d1c13a32059cee
Lustre-commit: 372ef85512dd2a722415fba9a3df66f81029508b
Lustre-change: https://review.whamcloud.com/33667

Change-Id: I9514bd21916f75fce00e393612967fb197e3a1c4
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/38573
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/linux/Makefile.am
libcfs/include/libcfs/linux/linux-misc.h
libcfs/include/libcfs/linux/linux-wait.h [new file with mode: 0644]
libcfs/libcfs/Makefile.in
libcfs/libcfs/linux/Makefile.am
libcfs/libcfs/linux/linux-wait.c [new file with mode: 0644]
lustre/obdclass/lu_object.c