Skip to contentSkip to conversation

ocfs2: be within spinlock when checking the owner of a lockres

PATCH New Wengang Wang 3 participants 3 messages Mar 24, 2010 – Apr 1, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: be within spinlock when checking the owner of a lockres

The checking of lockres owner in dlm_update_lvb() is not with spinlock protection. I don't see problem in current call path of dlm_update_lvb(). But just for code robustness.

---
 fs/ocfs2/dlm/dlmast.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
fs/ocfs2/dlm/dlmast.c +2 -3
index dccc439..b7a25ef 100644
@@ -185,9 +185,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
 	BUG_ON(!lksb);
 
 	/* only updates if this node masters the lockres */
+	spin_lock(&res->spinlock);
 	if (res->owner == dlm->node_num) {
-
-		spin_lock(&res->spinlock);
 		/* check the lksb flags for the direction */
 		if (lksb->flags & DLM_LKSB_GET_LVB) {
 			mlog(0, "getting lvb from lockres for %s node\n",
@@ -202,8 +201,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
  		 * here. In the future we might want to clear it at the time
  		 * the put is actually done.
 		 */
-		spin_unlock(&res->spinlock);
 	}
+	spin_unlock(&res->spinlock);
 
 	/* reset any lvb flags on the lksb */
 	lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
Signature · 1 line
1.6.6.1
#1 lore raw

PATCH 1/1 ocfs2: be within spinlock when checking the owner of a lockres

Quoted 35 lines · Wengang Wang

The checking of lockres owner in dlm_update_lvb() is not with spinlock protection. I don't see problem in current call path of dlm_update_lvb(). But just for code robustness.

---
 fs/ocfs2/dlm/dlmast.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
fs/ocfs2/dlm/dlmast.c +2 -3
index dccc439..b7a25ef 100644
@@ -185,9 +185,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
 	BUG_ON(!lksb);
 
 	/* only updates if this node masters the lockres */
+	spin_lock(&res->spinlock);
 	if (res->owner == dlm->node_num) {
-
-		spin_lock(&res->spinlock);
 		/* check the lksb flags for the direction */
 		if (lksb->flags & DLM_LKSB_GET_LVB) {
 			mlog(0, "getting lvb from lockres for %s node\n",
@@ -202,8 +201,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
  		 * here. In the future we might want to clear it at the time
  		 * the put is actually done.
 		 */
-		spin_unlock(&res->spinlock);
 	}
+	spin_unlock(&res->spinlock);
 
 	/* reset any lvb flags on the lksb */
 	lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
#2 lore raw

PATCH 1/1 ocfs2: be within spinlock when checking the owner of a lockres

In reply to Wengang Wang
Quoted 5 lines · Wengang Wang

The checking of lockres owner in dlm_update_lvb() is not with spinlock protection. I don't see problem in current call path of dlm_update_lvb(). But just for code robustness.

This patch is now in the fixes branch of ocfs2.git.

Joel

Signature · 11 lines
"You must remember this:
 A kiss is just a kiss,
 A sigh is just a sigh.
 The fundamental rules apply
 As time goes by."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127