Whamcloud - gitweb
LU-13253 libcfs: protect libcfs_debug_dumplog()
[fs/lustre-release.git] / libcfs / libcfs / debug.c
index f48d9e5..8669dad 100644 (file)
@@ -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);