From: Alex Zhuravlev Date: Sat, 15 Feb 2020 06:16:15 +0000 (+0300) Subject: LU-13253 libcfs: protect libcfs_debug_dumplog() X-Git-Tag: 2.13.53~119 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=cfba9a1ecc6b20746c289afc8e3c81097e07d8a3 LU-13253 libcfs: protect libcfs_debug_dumplog() as it uses global state to wait for dumping thread completion and it doesn't make sense to dump concurrently. Signed-off-by: Alex Zhuravlev Change-Id: Ie6916a0bb53a0a3aa8992413811fe7a908f86276 Reviewed-on: https://review.whamcloud.com/37588 Tested-by: jenkins Reviewed-by: Neil Brown Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index f48d9e5..8669dad 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -400,11 +400,17 @@ static int libcfs_debug_dumplog_thread(void *arg) return 0; } +static DEFINE_MUTEX(libcfs_debug_dumplog_lock); + void libcfs_debug_dumplog(void) { struct task_struct *dumper; ENTRY; + + if (mutex_trylock(&libcfs_debug_dumplog_lock) == 0) + return; + /* If a previous call was interrupted, debug_complete->done * might be elevated, and so we won't actually wait here. * So we reinit the completion to ensure we wait for @@ -420,6 +426,8 @@ void libcfs_debug_dumplog(void) PTR_ERR(dumper)); else wait_for_completion_interruptible(&debug_complete); + + mutex_unlock(&libcfs_debug_dumplog_lock); } EXPORT_SYMBOL(libcfs_debug_dumplog);