Skip to content

Commit

Permalink
ocfs2: Fix a race in o2dlm lockres mastery
Browse files Browse the repository at this point in the history
In o2dlm, the master of a lock resource keeps a map of all interested
nodes.  This prevents the master from purging the resource before an
interested node can create a lock.

A race between the mastery thread and the mastery handler allowed an
interested node to discover who the master is without informing the
master directly.  This is easily fixed by holding the dlm spinlock a
little longer in the mastery handler.

Signed-off-by: Srinivas Eeda <srinivas.eeda@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
  • Loading branch information
Srinivas Eeda authored and Joel Becker committed Mar 24, 2010
1 parent b54c2ca commit 1474147
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/ocfs2/dlm/dlmmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,6 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
ok:
spin_unlock(&res->spinlock);
}
spin_unlock(&dlm->spinlock);

// mlog(0, "woo! got an assert_master from node %u!\n",
// assert->node_idx);
Expand Down Expand Up @@ -1926,7 +1925,6 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
/* master is known, detach if not already detached.
* ensures that only one assert_master call will happen
* on this mle. */
spin_lock(&dlm->spinlock);
spin_lock(&dlm->master_lock);

rr = atomic_read(&mle->mle_refs.refcount);
Expand Down Expand Up @@ -1959,14 +1957,14 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
__dlm_put_mle(mle);
}
spin_unlock(&dlm->master_lock);
spin_unlock(&dlm->spinlock);
} else if (res) {
if (res->owner != assert->node_idx) {
mlog(0, "assert_master from %u, but current "
"owner is %u (%.*s), no mle\n", assert->node_idx,
res->owner, namelen, name);
}
}
spin_unlock(&dlm->spinlock);

done:
ret = 0;
Expand Down

0 comments on commit 1474147

Please sign in to comment.