int lockdep_dump_locks()
{
pthread_mutex_lock(&lockdep_mutex);
+ if (!g_lockdep)
+ goto out;
for (ceph::unordered_map<pthread_t, map<int,BackTrace*> >::iterator p = held.begin();
p != held.end();
*_dout << dendl;
}
}
-
+out:
pthread_mutex_unlock(&lockdep_mutex);
return 0;
}
static int _lockdep_register(const char *name)
{
- int id;
+ int id = -1;
+ if (!g_lockdep)
+ return id;
ceph::unordered_map<std::string, int>::iterator p = lock_ids.find(name);
if (p == lock_ids.end()) {
id = lockdep_get_free_id();
}
pthread_mutex_lock(&lockdep_mutex);
+ if (!g_lockdep) {
+ pthread_mutex_unlock(&lockdep_mutex);
+ return;
+ }
map<int, std::string>::iterator p = lock_names.find(id);
- assert(p != lock_names.end());
+ if (p == lock_names.end()) {
+ pthread_mutex_unlock(&lockdep_mutex);
+ return;
+ }
int &refs = lock_refs[id];
if (--refs == 0) {
pthread_t p = pthread_self();
pthread_mutex_lock(&lockdep_mutex);
+ if (!g_lockdep) {
+ pthread_mutex_unlock(&lockdep_mutex);
+ return id;
+ }
+
if (id < 0)
id = _lockdep_register(name);
+
lockdep_dout(20) << "_will_lock " << name << " (" << id << ")" << dendl;
// check dependency graph
}
}
}
-
pthread_mutex_unlock(&lockdep_mutex);
return id;
}
pthread_t p = pthread_self();
pthread_mutex_lock(&lockdep_mutex);
+ if (!g_lockdep)
+ goto out;
if (id < 0)
id = _lockdep_register(name);
held[p][id] = new BackTrace(BACKTRACE_SKIP);
else
held[p][id] = 0;
+out:
pthread_mutex_unlock(&lockdep_mutex);
return id;
}
}
pthread_mutex_lock(&lockdep_mutex);
+ if (!g_lockdep)
+ goto out;
lockdep_dout(20) << "_will_unlock " << name << dendl;
// don't assert.. lockdep may be enabled at any point in time
delete held[p][id];
held[p].erase(id);
+out:
pthread_mutex_unlock(&lockdep_mutex);
return id;
}