]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
lockdep: error out on recursive locks
authorSage Weil <sage@newdream.net>
Mon, 3 Nov 2008 23:55:14 +0000 (15:55 -0800)
committerSage Weil <sage@newdream.net>
Tue, 4 Nov 2008 00:54:29 +0000 (16:54 -0800)
There is no checking between instances, here.. this currently just
assumes that if you take two locks of the same type that that is bad.
(In practice, the caller could do this safely with some care.)

src/common/Mutex.cc

index b6a45b089180c686f3f955b15a8daf1104c8f54c..dd60d07defd41039434b62df0507d02de3509d04 100644 (file)
@@ -52,8 +52,8 @@ void Mutex::_register()
     lock_names[id] = name;
     dout(10) << "registered '" << name << "' as " << id << std::endl;
   } else {
-    dout(20) << "had '" << name << "' as " << id << std::endl;
     id = p->second;
+    dout(20) << "had '" << name << "' as " << id << std::endl;
   }
 
   pthread_mutex_unlock(&lockdep_mutex);
@@ -98,7 +98,20 @@ void Mutex::_will_lock()
   for (map<int, BackTrace *>::iterator p = m.begin();
        p != m.end();
        p++) {
-    if (!follows[p->first][id]) {
+    if (p->first == id) {
+      *_dout << std::endl;
+      dout(0) << "recursive lock of " << name << " (" << id << ")" << std::endl;
+      BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+      bt->print(*_dout);
+      if (g_lockdep >= 2) {
+       *_dout << std::endl;
+       dout(0) << "previously locked at" << std::endl;
+       p->second->print(*_dout);
+      }
+      *_dout << std::endl;
+      assert(0);
+    }
+    else if (!follows[p->first][id]) {
       // new dependency 
       
       // did we just create a cycle?