Commit b1432a2a authored by Junxiao Bi's avatar Junxiao Bi Committed by Linus Torvalds

ocfs2: dlm: fix race between purge and get lock resource

There is a race window in dlm_get_lock_resource(), which may return a
lock resource which has been purged.  This will cause the process to
hang forever in dlmlock() as the ast msg can't be handled due to its
lock resource not existing.

    dlm_get_lock_resource {
        tmpres = __dlm_lookup_lockres_full(dlm, lockid, namelen, hash);
        if (tmpres) {
             >>>>>>>> race window, dlm_run_purge_list() may run and purge
                              the lock resource
Signed-off-by: default avatarJunxiao Bi <>
Cc: Joseph Qi <>
Cc: Mark Fasheh <>
Cc: Joel Becker <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent d8fd150f
......@@ -757,6 +757,19 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
if (tmpres) {
* Right after dlm spinlock was released, dlm_thread could have
* purged the lockres. Check if lockres got unhashed. If so
* start over.
if (hlist_unhashed(&tmpres->hash_node)) {
tmpres = NULL;
goto lookup;
/* Wait on the thread that is mastering the resource */
if (tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
Markdown is supported
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