Commit 5760a97c authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds
Browse files

ocfs2/dlm: do not get resource spinlock if lockres is new

There is a deadlock case which reported by Guozhonghua:

This case is caused by &res->spinlock and &dlm->master_lock
misordering in different threads.

It was introduced by commit 8d400b81 ("ocfs2/dlm: Clean up refmap
helpers").  Since lockres is new, it doesn't not require the
&res->spinlock.  So remove it.

Fixes: 8d400b81

 ("ocfs2/dlm: Clean up refmap helpers")
Signed-off-by: default avatarJoseph Qi <>
Reviewed-by: default avatarjoyce.xue <>
Reported-by: default avatarGuozhonghua <>
Cc: Joel Becker <>
Cc: Mark Fasheh <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 56d7acc7
......@@ -655,12 +655,9 @@ void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm,
clear_bit(bit, res->refmap);
void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
static void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name,
......@@ -668,6 +665,13 @@ void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
__dlm_lockres_grab_inflight_ref(dlm, res);
void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
......@@ -894,10 +898,8 @@ lookup:
/* finally add the lockres to its hash bucket */
__dlm_insert_lockres(dlm, res);
/* Grab inflight ref to pin the resource */
dlm_lockres_grab_inflight_ref(dlm, res);
/* since this lockres is new it doesn't not require the spinlock */
__dlm_lockres_grab_inflight_ref(dlm, res);
/* get an extra ref on the mle in case this is a BLOCK
* if so, the creator of the BLOCK may try to put the last
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment