All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH 4/4] ocfs2/dlm: return EINVAL when the lockres on migration target is in DROPPING_REF state
@ 2016-01-26  9:44 xuejiufei
  2016-01-27  1:39 ` Joseph Qi
  0 siblings, 1 reply; 2+ messages in thread
From: xuejiufei @ 2016-01-26  9:44 UTC (permalink / raw)
  To: ocfs2-devel

If master migrate this lock resource to node when it happened to purge
it, a new lock resource will be created and inserted into hash list. If
then master goes down, the lock resource being purged is recovered, so
there exist two lock resource with different owner. So return error to
master if the lock resource is in DROPPING state, master will retry to
migrate this lock resource.

Signed-off-by: xuejiufei <xuejiufei@huawei.com>
---
 fs/ocfs2/dlm/dlmrecovery.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index c19059a..4c7b548 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1403,12 +1403,24 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data,
 	 * and RECOVERY flag changed when it completes. */
 	hash = dlm_lockid_hash(mres->lockname, mres->lockname_len);
 	spin_lock(&dlm->spinlock);
-	res = __dlm_lookup_lockres(dlm, mres->lockname, mres->lockname_len,
+	res = __dlm_lookup_lockres_full(dlm, mres->lockname, mres->lockname_len,
 			hash);
 	if (res) {
 	 	/* this will get a ref on res */
 		/* mark it as recovering/migrating and hash it */
 		spin_lock(&res->spinlock);
+		if (res->state & DLM_LOCK_RES_DROPPING_REF) {
+			mlog(0, "%s: node is attempting to migrate "
+				"lockres %.*s, but marked as dropping "
+				" ref!\n", dlm->name,
+				mres->lockname_len, mres->lockname);
+			ret = -EINVAL;
+			spin_unlock(&res->spinlock);
+			spin_unlock(&dlm->spinlock);
+			dlm_lockres_put(res);
+			goto leave;
+		}
+
 		if (mres->flags & DLM_MRES_RECOVERY) {
 			res->state |= DLM_LOCK_RES_RECOVERING;
 		} else {
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Ocfs2-devel] [PATCH 4/4] ocfs2/dlm: return EINVAL when the lockres on migration target is in DROPPING_REF state
  2016-01-26  9:44 [Ocfs2-devel] [PATCH 4/4] ocfs2/dlm: return EINVAL when the lockres on migration target is in DROPPING_REF state xuejiufei
@ 2016-01-27  1:39 ` Joseph Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Qi @ 2016-01-27  1:39 UTC (permalink / raw)
  To: ocfs2-devel

On 2016/1/26 17:44, xuejiufei wrote:
> If master migrate this lock resource to node when it happened to purge
> it, a new lock resource will be created and inserted into hash list. If
> then master goes down, the lock resource being purged is recovered, so
> there exist two lock resource with different owner. So return error to
> master if the lock resource is in DROPPING state, master will retry to
> migrate this lock resource.
> 
> Signed-off-by: xuejiufei <xuejiufei@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>

> ---
>  fs/ocfs2/dlm/dlmrecovery.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
> index c19059a..4c7b548 100644
> --- a/fs/ocfs2/dlm/dlmrecovery.c
> +++ b/fs/ocfs2/dlm/dlmrecovery.c
> @@ -1403,12 +1403,24 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data,
>  	 * and RECOVERY flag changed when it completes. */
>  	hash = dlm_lockid_hash(mres->lockname, mres->lockname_len);
>  	spin_lock(&dlm->spinlock);
> -	res = __dlm_lookup_lockres(dlm, mres->lockname, mres->lockname_len,
> +	res = __dlm_lookup_lockres_full(dlm, mres->lockname, mres->lockname_len,
>  			hash);
>  	if (res) {
>  	 	/* this will get a ref on res */
>  		/* mark it as recovering/migrating and hash it */
>  		spin_lock(&res->spinlock);
> +		if (res->state & DLM_LOCK_RES_DROPPING_REF) {
> +			mlog(0, "%s: node is attempting to migrate "
> +				"lockres %.*s, but marked as dropping "
> +				" ref!\n", dlm->name,
> +				mres->lockname_len, mres->lockname);
> +			ret = -EINVAL;
> +			spin_unlock(&res->spinlock);
> +			spin_unlock(&dlm->spinlock);
> +			dlm_lockres_put(res);
> +			goto leave;
> +		}
> +
>  		if (mres->flags & DLM_MRES_RECOVERY) {
>  			res->state |= DLM_LOCK_RES_RECOVERING;
>  		} else {
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-27  1:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-26  9:44 [Ocfs2-devel] [PATCH 4/4] ocfs2/dlm: return EINVAL when the lockres on migration target is in DROPPING_REF state xuejiufei
2016-01-27  1:39 ` Joseph Qi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.