Whamcloud - gitweb
LU-11089 obd: use wait_event_var() in lu_context_key_degister() 67/33667/13
authorNeilBrown <neilb@suse.com>
Tue, 21 May 2019 14:22:39 +0000 (10:22 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 1 Jun 2019 03:55:48 +0000 (03:55 +0000)
commit372ef85512dd2a722415fba9a3df66f81029508b
tree9651b3ef2495ae209c1d4b52472eadb6ad02ad1e
parent4ac0324fb9d824915b3dd11b75e81e609d9e8e84
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

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/33667
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Oleg Drokin <green@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