Skip to contentSkip to conversation

ocfs2: do not return DLM_MIGRATE_RESPONSE_MASTERY_REF to avoid endless, loop during umount

PATCH New akpm at linux-foundation.org 2 participants 2 messages Mar 19, 2014 – Mar 31, 2014 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 5/8 ocfs2: do not return DLM_MIGRATE_RESPONSE_MASTERY_REF to avoid endless, loop during umount

From: jiangyiwen <[email protected]>
Subject: ocfs2: do not return DLM_MIGRATE_RESPONSE_MASTERY_REF to avoid endless,loop during umount

The following case may lead to endless loop during umount.

node A node B node C node D
umount volume,
migrate lockres1
to B
want to lock lockres1, send MASTER_REQUEST_MSG to C
init block mle
send
MIGRATE_REQUEST_MSG
to C
find a block
mle, and then
return DLM_MIGRATE_RESPONSE_MASTERY_REF to B
set C in refmap
umount successfully
try to umount, endless
loop occurs when migrate
lockres1 since C is in
refmap

So we can fix this endless loop case by only returning DLM_MIGRATE_RESPONSE_MASTERY_REF if it has a mastery mle when receiving MIGRATE_REQUEST_MSG.

[akpm at linux-foundation.org: coding-style fixes]
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Xue jiufei <[email protected]>

---

 fs/ocfs2/dlm/dlmmaster.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/ocfs2/dlm/dlmmaster.c renamed from fs/ocfs2/dlm/dlmmaster.c~ocfs2-do-not-return-dlm_migrate_response_mastery_ref-to-avoid-endlessloop-during-umount +9 -5
diff -puN fs/ocfs2/dlm/dlmmaster.c~ocfs2-do-not-return-dlm_migrate_response_mastery_ref-to-avoid-endlessloop-during-umount fs/ocfs2/dlm/dlmmaster.c
@@ -3084,11 +3084,15 @@ static int dlm_add_migration_mle(struct
 			/* remove it so that only one mle will be found */
 			__dlm_unlink_mle(dlm, tmp);
 			__dlm_mle_detach_hb_events(dlm, tmp);
-			ret = DLM_MIGRATE_RESPONSE_MASTERY_REF;
-			mlog(0, "%s:%.*s: master=%u, newmaster=%u, "
-			    "telling master to get ref for cleared out mle "
-			    "during migration\n", dlm->name, namelen, name,
-			    master, new_master);
+			if (tmp->type == DLM_MLE_MASTER) {
+				ret = DLM_MIGRATE_RESPONSE_MASTERY_REF;
+				mlog(0, "%s:%.*s: master=%u, newmaster=%u, "
+						"telling master to get ref "
+						"for cleared out mle during "
+						"migration\n", dlm->name,
+						namelen, name, master,
+						new_master);
+			}
 		}
 		spin_unlock(&tmp->spinlock);
 	}

_

#1 lore raw

PATCH 5/8 ocfs2: do not return DLM_MIGRATE_RESPONSE_MASTERY_REF to avoid endless, loop during umount

Quoted 33 lines · Andrew Morton

From: jiangyiwen <[email protected]>
Subject: ocfs2: do not return DLM_MIGRATE_RESPONSE_MASTERY_REF to avoid endless,loop during umount

The following case may lead to endless loop during umount.

node A node B node C node D
umount volume,
migrate lockres1
to B
want to lock lockres1, send MASTER_REQUEST_MSG to C
init block mle
send
MIGRATE_REQUEST_MSG
to C
find a block
mle, and then
return DLM_MIGRATE_RESPONSE_MASTERY_REF to B
set C in refmap
umount successfully
try to umount, endless
loop occurs when migrate
lockres1 since C is in
refmap

So we can fix this endless loop case by only returning DLM_MIGRATE_RESPONSE_MASTERY_REF if it has a mastery mle when receiving MIGRATE_REQUEST_MSG.

Quoted 6 lines
[akpm at linux-foundation.org: coding-style fixes]
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Xue jiufei <[email protected]>

Ok, I _think_ I got this race condition, and the patch itself seems sane.

How was this bug hit, and how much testing did you do with this patch? I ask because dlm changes can sometimes have unintended effects and I really don't understand that particular code well enough right now to tell with 100% certainty we didn't mess something else up.

Actually, I'm going to CC Sunil in the hopes he can look at this.

	--Mark
Quoted 29 lines

---

 fs/ocfs2/dlm/dlmmaster.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff -puN fs/ocfs2/dlm/dlmmaster.c~ocfs2-do-not-return-dlm_migrate_response_mastery_ref-to-avoid-endlessloop-during-umount fs/ocfs2/dlm/dlmmaster.c

fs/ocfs2/dlm/dlmmaster.c renamed from fs/ocfs2/dlm/dlmmaster.c~ocfs2-do-not-return-dlm_migrate_response_mastery_ref-to-avoid-endlessloop-during-umount +9 -5
@@ -3084,11 +3084,15 @@ static int dlm_add_migration_mle(struct
 			/* remove it so that only one mle will be found */
 			__dlm_unlink_mle(dlm, tmp);
 			__dlm_mle_detach_hb_events(dlm, tmp);
-			ret = DLM_MIGRATE_RESPONSE_MASTERY_REF;
-			mlog(0, "%s:%.*s: master=%u, newmaster=%u, "
-			    "telling master to get ref for cleared out mle "
-			    "during migration\n", dlm->name, namelen, name,
-			    master, new_master);
+			if (tmp->type == DLM_MLE_MASTER) {
+				ret = DLM_MIGRATE_RESPONSE_MASTERY_REF;
+				mlog(0, "%s:%.*s: master=%u, newmaster=%u, "
+						"telling master to get ref "
+						"for cleared out mle during "
+						"migration\n", dlm->name,
+						namelen, name, master,
+						new_master);
+			}
 		}
 		spin_unlock(&tmp->spinlock);
 	}
Quoted 1 line

_

--
Mark Fasheh