Commit a6fa3640 authored by Kurt Hackel's avatar Kurt Hackel Committed by Mark Fasheh

ocfs2_dlm: wake up sleepers on the lockres waitqueue

The dlm was not waking up threads waiting on the lockres wait queue,
waiting for the lockres to be no longer be in the DLM_LOCK_RES_IN_PROGRESS
and the DLM_LOCK_RES_MIGRATING states.
Signed-off-by: default avatarKurt Hackel <kurt.hackel@oracle.com>
Signed-off-by: default avatarSunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 28b72d9c
...@@ -428,7 +428,7 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -428,7 +428,7 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data)
struct dlm_lockstatus *lksb; struct dlm_lockstatus *lksb;
enum dlm_status status = DLM_NORMAL; enum dlm_status status = DLM_NORMAL;
u32 flags; u32 flags;
int call_ast = 0, kick_thread = 0, ast_reserved = 0; int call_ast = 0, kick_thread = 0, ast_reserved = 0, wake = 0;
if (!dlm_grab(dlm)) { if (!dlm_grab(dlm)) {
dlm_error(DLM_REJECTED); dlm_error(DLM_REJECTED);
...@@ -524,8 +524,11 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -524,8 +524,11 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data)
cnv->requested_type, cnv->requested_type,
&call_ast, &kick_thread); &call_ast, &kick_thread);
res->state &= ~DLM_LOCK_RES_IN_PROGRESS; res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
wake = 1;
} }
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
if (wake)
wake_up(&res->wq);
if (status != DLM_NORMAL) { if (status != DLM_NORMAL) {
if (status != DLM_NOTQUEUED) if (status != DLM_NOTQUEUED)
......
...@@ -1967,6 +1967,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -1967,6 +1967,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data)
spin_unlock(&mle->spinlock); spin_unlock(&mle->spinlock);
if (res) { if (res) {
int wake = 0;
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
if (mle->type == DLM_MLE_MIGRATION) { if (mle->type == DLM_MLE_MIGRATION) {
mlog(0, "finishing off migration of lockres %.*s, " mlog(0, "finishing off migration of lockres %.*s, "
...@@ -1974,6 +1975,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -1974,6 +1975,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data)
res->lockname.len, res->lockname.name, res->lockname.len, res->lockname.name,
dlm->node_num, mle->new_master); dlm->node_num, mle->new_master);
res->state &= ~DLM_LOCK_RES_MIGRATING; res->state &= ~DLM_LOCK_RES_MIGRATING;
wake = 1;
dlm_change_lockres_owner(dlm, res, mle->new_master); dlm_change_lockres_owner(dlm, res, mle->new_master);
BUG_ON(res->state & DLM_LOCK_RES_DIRTY); BUG_ON(res->state & DLM_LOCK_RES_DIRTY);
} else { } else {
...@@ -1981,6 +1983,8 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -1981,6 +1983,8 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data)
} }
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
have_lockres_ref = 1; have_lockres_ref = 1;
if (wake)
wake_up(&res->wq);
} }
/* master is known, detach if not already detached. /* master is known, detach if not already detached.
...@@ -2342,7 +2346,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, ...@@ -2342,7 +2346,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
struct list_head *queue, *iter; struct list_head *queue, *iter;
int i; int i;
struct dlm_lock *lock; struct dlm_lock *lock;
int empty = 1; int empty = 1, wake = 0;
if (!dlm_grab(dlm)) if (!dlm_grab(dlm))
return -EINVAL; return -EINVAL;
...@@ -2467,6 +2471,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, ...@@ -2467,6 +2471,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
res->lockname.name, target); res->lockname.name, target);
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
res->state &= ~DLM_LOCK_RES_MIGRATING; res->state &= ~DLM_LOCK_RES_MIGRATING;
wake = 1;
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -2525,6 +2530,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, ...@@ -2525,6 +2530,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
dlm_put_mle_inuse(mle); dlm_put_mle_inuse(mle);
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
res->state &= ~DLM_LOCK_RES_MIGRATING; res->state &= ~DLM_LOCK_RES_MIGRATING;
wake = 1;
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
goto leave; goto leave;
} }
...@@ -2567,6 +2573,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, ...@@ -2567,6 +2573,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
dlm_put_mle_inuse(mle); dlm_put_mle_inuse(mle);
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
res->state &= ~DLM_LOCK_RES_MIGRATING; res->state &= ~DLM_LOCK_RES_MIGRATING;
wake = 1;
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
goto leave; goto leave;
} }
...@@ -2595,6 +2602,11 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, ...@@ -2595,6 +2602,11 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
if (ret < 0) if (ret < 0)
dlm_kick_thread(dlm, res); dlm_kick_thread(dlm, res);
/* wake up waiters if the MIGRATING flag got set
* but migration failed */
if (wake)
wake_up(&res->wq);
/* TODO: cleanup */ /* TODO: cleanup */
if (mres) if (mres)
free_page((unsigned long)mres); free_page((unsigned long)mres);
......
...@@ -1420,6 +1420,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data) ...@@ -1420,6 +1420,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data)
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
res->state &= ~DLM_LOCK_RES_IN_PROGRESS; res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
wake_up(&res->wq);
/* add an extra ref for just-allocated lockres /* add an extra ref for just-allocated lockres
* otherwise the lockres will be purged immediately */ * otherwise the lockres will be purged immediately */
......
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