Skip to contentSkip to conversation

ocfs2: add spinlock protection when dealing with lockres->purge.

PATCH New Wengang Wang 2 participants 2 messages Sep 3, 2009 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: add spinlock protection when dealing with lockres->purge.

when we check/modify lockres->purge, we should with the protection of lockres->spinlock. in dlm_purge_lockres(), the checking/modifying is not with the protectin. this patch fixes it.

---
 fs/ocfs2/dlm/dlmthread.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
fs/ocfs2/dlm/dlmthread.c +5 -1
index d490b66..98569e8 100644
@@ -212,14 +212,18 @@ static int dlm_purge_lockres(struct dlm_ctxt *dlm,
 		spin_lock(&dlm->spinlock);
 	}
 
+	spin_lock(&res->spinlock);
 	if (!list_empty(&res->purge)) {
 		mlog(0, "removing lockres %.*s:%p from purgelist, "
 		     "master = %d\n", res->lockname.len, res->lockname.name,
 		     res, master);
 		list_del_init(&res->purge);
+		spin_unlock(&res->spinlock);
 		dlm_lockres_put(res);
 		dlm->purge_count--;
-	}
+	} else
+		spin_unlock(&res->spinlock);
+
 	__dlm_unhash_lockres(res);
 
 	/* lockres is not in the hash now.  drop the flag and wake up
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH 1/1 ocfs2: add spinlock protection when dealing with lockres->purge.

Quoted 34 lines · Wengang Wang

when we check/modify lockres->purge, we should with the protection of lockres->spinlock. in dlm_purge_lockres(), the checking/modifying is not with the protectin. this patch fixes it.

---
 fs/ocfs2/dlm/dlmthread.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
fs/ocfs2/dlm/dlmthread.c +5 -1
index d490b66..98569e8 100644
@@ -212,14 +212,18 @@ static int dlm_purge_lockres(struct dlm_ctxt *dlm,
 		spin_lock(&dlm->spinlock);
 	}
 
+	spin_lock(&res->spinlock);
 	if (!list_empty(&res->purge)) {
 		mlog(0, "removing lockres %.*s:%p from purgelist, "
 		     "master = %d\n", res->lockname.len, res->lockname.name,
 		     res, master);
 		list_del_init(&res->purge);
+		spin_unlock(&res->spinlock);
 		dlm_lockres_put(res);
 		dlm->purge_count--;
-	}
+	} else
+		spin_unlock(&res->spinlock);
+
 	__dlm_unhash_lockres(res);
 
 	/* lockres is not in the hash now.  drop the flag and wake up