]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
lockdep: stop lockdep when its cct goes away
authorSage Weil <sage@inktank.com>
Wed, 11 Jul 2012 15:58:22 +0000 (08:58 -0700)
committerSage Weil <sage@inktank.com>
Wed, 11 Jul 2012 15:58:22 +0000 (08:58 -0700)
When a cct is destroyed, tell lockdep so that it can shut down if it needed
it.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/ceph_context.cc
src/common/lockdep.cc
src/common/lockdep.h

index 84a0953cbd96ff07d74867409a74efdaca41c951..4134dd785ee82f4a275bf8d127fcc32ecf496c83 100644 (file)
@@ -22,6 +22,7 @@
 #include "common/debug.h"
 #include "common/HeartbeatMap.h"
 #include "common/errno.h"
+#include "common/lockdep.h"
 #include "log/Log.h"
 
 #include <iostream>
@@ -250,6 +251,10 @@ CephContext::CephContext(uint32_t module_type_)
 
 CephContext::~CephContext()
 {
+  if (_conf->lockdep) {
+    lockdep_unregister_ceph_context(this);
+  }
+
   join_service_thread();
 
   _admin_socket->unregister_command("perfcounters_dump");
index 1e0c45fa41ffcecd8b01c0b65eab94ca931e3402..9dbe5f08bf47719cfd2a3fc52c6111dae178c855 100644 (file)
@@ -64,6 +64,17 @@ void lockdep_register_ceph_context(CephContext *cct)
   pthread_mutex_unlock(&lockdep_mutex);
 }
 
+void lockdep_unregister_ceph_context(CephContext *cct)
+{
+  pthread_mutex_lock(&lockdep_mutex);
+  if (cct == g_lockdep_ceph_ctx) {
+    // this cct is going away; shut it down!
+    g_lockdep = false;
+    g_lockdep_ceph_ctx = NULL;
+  }
+  pthread_mutex_unlock(&lockdep_mutex);
+}
+
 int lockdep_dump_locks()
 {
   pthread_mutex_lock(&lockdep_mutex);
index 9debdb667710374690129810e75546cf83758e1d..1dcf05378ee9ee5bf71ac9ac65125b6ecfa9316d 100644 (file)
@@ -20,6 +20,7 @@ class CephContext;
 extern int g_lockdep;
 
 extern void lockdep_register_ceph_context(CephContext *cct);
+extern void lockdep_unregister_ceph_context(CephContext *cct);
 extern int lockdep_register(const char *n);
 extern int lockdep_will_lock(const char *n, int id);
 extern int lockdep_locked(const char *n, int id, bool force_backtrace=false);