Skip to contentSkip to conversation

ocfs2/dlm: do not insert a new mle when another process is already migrating

PATCH New xuejiufei 2 participants 2 messages Dec 25, 2015 – Dec 30, 2015 OCFS2

lore
Share & tools
lore

xuejiufei

author
#0 lore raw

PATCH 1/1 ocfs2/dlm: do not insert a new mle when another process is already migrating

When two processes are migrating the same lockres, dlm_add_migration_mle() return -EEXIST, but insert a new mle in hash list. Function dlm_migrate_lockres will detach the ole mle and free the new one which is already in hash list, that will destroy the list.

---
 fs/ocfs2/dlm/dlmmaster.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +3 -2
index 936e11b..753dd9c 100644
@@ -2544,7 +2544,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
 	}
 
 fail:
-	if (oldmle) {
+	if (ret != -EEXIST && oldmle) {
 		/* master is known, detach if not already detached */
 		dlm_mle_detach_hb_events(dlm, oldmle);
 		dlm_put_mle(oldmle);
@@ -3141,7 +3141,8 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm,
 				mlog(0, "tried to migrate %.*s, but some "
 				     "process beat me to it\n",
 				     namelen, name);
-				ret = -EEXIST;
+				spin_unlock(&tmp->spinlock);
+				return -EEXIST;
 			} else {
 				/* bad.  2 NODES are trying to migrate! */
 				mlog(ML_ERROR, "migration error  mle: "
Signature · 1 line
1.8.4.3
#1 lore raw

PATCH 1/1 ocfs2/dlm: do not insert a new mle when another process is already migrating

Quoted 8 lines · xuejiufei

When two processes are migrating the same lockres, dlm_add_migration_mle() return -EEXIST, but insert a new mle in hash list. Function dlm_migrate_lockres will detach the ole mle and free the new one which is already in hash list, that will destroy the list.

Looks good.

Quoted 28 lines
---
 fs/ocfs2/dlm/dlmmaster.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +3 -2
index 936e11b..753dd9c 100644
@@ -2544,7 +2544,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
 	}
 
 fail:
-	if (oldmle) {
+	if (ret != -EEXIST && oldmle) {
 		/* master is known, detach if not already detached */
 		dlm_mle_detach_hb_events(dlm, oldmle);
 		dlm_put_mle(oldmle);
@@ -3141,7 +3141,8 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm,
 				mlog(0, "tried to migrate %.*s, but some "
 				     "process beat me to it\n",
 				     namelen, name);
-				ret = -EEXIST;
+				spin_unlock(&tmp->spinlock);
+				return -EEXIST;
 			} else {
 				/* bad.  2 NODES are trying to migrate! */
 				mlog(ML_ERROR, "migration error  mle: "