From 2a1299a1086681d143bcd55144fe633e3a142827 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 3 Nov 2008 15:55:14 -0800 Subject: [PATCH] lockdep: error out on recursive locks 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 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc index b6a45b089180c..dd60d07defd41 100644 --- a/src/common/Mutex.cc +++ b/src/common/Mutex.cc @@ -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::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? -- 2.39.5