Skip to content

Commit

Permalink
Merge pull request ceph#1592 from ceph/wip-7965
Browse files Browse the repository at this point in the history
lockdep: fix when instantiated multiple times (bug 7965)

Reviewed-by: Josh Durgin <[email protected]>
  • Loading branch information
jdurgin committed Apr 3, 2014
2 parents eae5a37 + c43822c commit 89f38c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/common/lockdep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,30 @@ static BackTrace *follows[MAX_LOCKS][MAX_LOCKS]; // follows[a][b] means b
void lockdep_register_ceph_context(CephContext *cct)
{
pthread_mutex_lock(&lockdep_mutex);
g_lockdep_ceph_ctx = cct;
if (g_lockdep_ceph_ctx == NULL) {
g_lockdep_ceph_ctx = cct;
lockdep_dout(0) << "lockdep start" << dendl;
}
pthread_mutex_unlock(&lockdep_mutex);
}

void lockdep_unregister_ceph_context(CephContext *cct)
{
pthread_mutex_lock(&lockdep_mutex);
if (cct == g_lockdep_ceph_ctx) {
lockdep_dout(0) << "lockdep stop" << dendl;
// this cct is going away; shut it down!
g_lockdep = false;
g_lockdep_ceph_ctx = NULL;

// blow away all of our state, too, in case it starts up again.
held.clear();
for (unsigned i = 0; i < MAX_LOCKS; ++i)
for (unsigned j = 0; j < MAX_LOCKS; ++j)
follows[i][j] = NULL;
lock_names.clear();
lock_ids.clear();
last_id = 0;
}
pthread_mutex_unlock(&lockdep_mutex);
}
Expand Down Expand Up @@ -104,7 +117,6 @@ int lockdep_register(const char *name)
int id;

pthread_mutex_lock(&lockdep_mutex);

if (last_id == 0)
for (int i=0; i<MAX_LOCKS; i++)
for (int j=0; j<MAX_LOCKS; j++)
Expand Down
1 change: 0 additions & 1 deletion src/global/global_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ void global_init(std::vector < const char * > *alt_def_args,
}

if (g_lockdep) {
dout(1) << "lockdep is enabled" << dendl;
lockdep_register_ceph_context(g_ceph_context);
}
register_assert_context(g_ceph_context);
Expand Down

0 comments on commit 89f38c0

Please sign in to comment.