From 916643c4b8d136c9c96afa5cd21d1eb6030d148c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 19 Jul 2019 08:38:44 -0400 Subject: [PATCH] LU-9859 libcfs: initialize bit_wait_table With older platforms wait_event_var() is missing so we needed to provide are own version. This included creating a local bit_wait_table like the kernel has. That table was never properly initialized so it can cause failures under the right conditions. Test-Parameters: trivial Fixes: 372ef85512 ("LU-11089 obd: use wait_event_var() in lu_context_key_degister()") Signed-off-by: James Simmons Change-Id: I310d37da7c1b54166224b367446cc905c02ab8bc Reviewed-on: https://review.whamcloud.com/35567 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/linux/linux-wait.h | 1 + libcfs/libcfs/linux/linux-wait.c | 8 ++++++++ libcfs/libcfs/module.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/libcfs/include/libcfs/linux/linux-wait.h b/libcfs/include/libcfs/linux/linux-wait.h index b0142c7..a497dce 100644 --- a/libcfs/include/libcfs/linux/linux-wait.h +++ b/libcfs/include/libcfs/linux/linux-wait.h @@ -51,6 +51,7 @@ static inline void clear_and_wake_up_bit(int bit, void *word) #endif /* ! HAVE_CLEAR_AND_WAKE_UP_BIT */ #ifndef HAVE_WAIT_VAR_EVENT +extern void __init wait_bit_init(void); extern void init_wait_var_entry(struct wait_bit_queue_entry *wbq_entry, void *var, int flags); extern void wake_up_var(void *var); diff --git a/libcfs/libcfs/linux/linux-wait.c b/libcfs/libcfs/linux/linux-wait.c index dd08cac..5843d80 100644 --- a/libcfs/libcfs/linux/linux-wait.c +++ b/libcfs/libcfs/linux/linux-wait.c @@ -104,4 +104,12 @@ void wake_up_var(void *var) __wake_up_bit(__var_waitqueue(var), var, -1); } EXPORT_SYMBOL(wake_up_var); + +void __init wait_bit_init(void) +{ + int i; + + for (i = 0; i < WAIT_TABLE_SIZE; i++) + init_waitqueue_head(bit_wait_table + i); +} #endif /* ! HAVE_WAIT_VAR_EVENT */ diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index de792a9..7c0985e 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -592,6 +592,9 @@ static int __init libcfs_init(void) { int rc; +#ifndef HAVE_WAIT_VAR_EVENT + wait_bit_init(); +#endif rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc); -- 1.8.3.1