Skip to contentSkip to conversation

GFS2: Allow glocks to be unlocked after withdraw

PATCH Superseded Bob Peterson 2 participants 2 messages May 5, 2017 1 message not in the archive GFS2 file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Allow glocks to be unlocked after withdraw

Hi,

Before this patch, glocks could not be unlocked after a withdraw, but that resulted in hangs during unmount. This patch allows GFS2 function do_xmote to demote locks to an unlocked state, but not promoting any upward.

---

fs/gfs2/glock.c +4 -2
index 9e81219..959a19c 100644
@@ -449,7 +449,8 @@ __acquires(&gl->gl_lockref.lock)
 	unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0);
 	int ret;
 
-	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) &&
+	    target != LM_ST_UNLOCKED)
 		return;
 	lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
 		      LM_FLAG_PRIORITY);
@@ -486,7 +487,8 @@ __acquires(&gl->gl_lockref.lock)
 		}
 		else if (ret) {
 			pr_err("lm_lock ret %d\n", ret);
-			GLOCK_BUG_ON(gl, 1);
+			GLOCK_BUG_ON(gl, !test_bit(SDF_SHUTDOWN,
+						   &sdp->sd_flags));
 		}
 	} else { /* lock_nolock */
 		finish_xmote(gl, target);
#2 lore raw

PATCH 1/1 GFS2: Allow glocks to be unlocked after withdraw

Bob,

Quoted 6 lines · Bob Peterson

Hi,

Before this patch, glocks could not be unlocked after a withdraw, but that resulted in hangs during unmount. This patch allows GFS2 function do_xmote to demote locks to an unlocked state, but not promoting any upward.

the commit message should point out that this relates to commit 0d1c7ae9d8 which currently is on for-next, so it fixes a regression and should probably end up in this cycle as well.

Quoted 17 lines

---

fs/gfs2/glock.c +2 -1
index 9e81219..959a19c 100644
@@ -449,7 +449,8 @@ __acquires(&gl->gl_lockref.lock)
        unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0);
        int ret;
 
-       if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+       if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) &&
+           target != LM_ST_UNLOCKED)
                return;
        lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
                      LM_FLAG_PRIORITY);

fs/gfs2/glock.c __acquires(&gl->gl_lockref.lock) · line 494

Quoted 9 lines
fs/gfs2/glock.c +2 -1
@@ -486,7 +487,8 @@ __acquires(&gl->gl_lockref.lock)
                }
                else if (ret) {
                        pr_err("lm_lock ret %d\n", ret);
-                       GLOCK_BUG_ON(gl, 1);
+                       GLOCK_BUG_ON(gl, !test_bit(SDF_SHUTDOWN,
+                                                  &sdp->sd_flags));
                }
        } else { /* lock_nolock */
                finish_xmote(gl, target);

Thanks,
Andreas