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>