Skip to contentSkip to conversation

gfs2: Fix regression in freeze_go_sync

PATCH Superseded Bob Peterson 1 participant 1 message Nov 17, 2020 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: Fix regression in freeze_go_sync

Hi,

Patch 541656d3a51 ("gfs2: freeze should work on read-only mounts") changed the check for glock state in function freeze_go_sync() from "gl->gl_state == LM_ST_SHARED" to "gl->gl_req == LM_ST_EXCLUSIVE". That's wrong and it regressed gfs2's freeze/thaw mechanism.

We need to check gl_state == LM_ST_SHARED and not gl_req == LM_ST_EXCLUSIVE because when any node does a freeze, all the nodes should have the freeze glock in SH mode and they all call do_xmote: One node for EX and the others for UN. They ALL must freeze locally, and they ALL must queue freeze work. The freeze_work calls freeze_func, which reacquires the freeze glock in SH, effectively waiting for the thaw on the node who holds the freeze glock in EX. Once thawed, the freeze_func acquires the freeze glock in SH and everybody goes back to thawed.

Fixes 541656d3a51 ("gfs2: freeze should work on read-only mounts")
---
 fs/gfs2/glops.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
fs/gfs2/glops.c +12 -1
index 6c1432d78dce..67f2921ae8d4 100644
@@ -571,7 +571,18 @@ static int freeze_go_sync(struct gfs2_glock *gl)
 	int error = 0;
 	struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
 
-	if (gl->gl_req == LM_ST_EXCLUSIVE && !gfs2_withdrawn(sdp)) {
+	/*
+	 * We need to check gl_state == LM_ST_SHARED here and not gl_req ==
+	 * LM_ST_EXCLUSIVE. That's because when any node does a freeze,
+	 * all the nodes should have the freeze glock in SH mode and they all
+	 * call do_xmote: One for EX and the others for UN. They ALL must
+	 * freeze locally, and they ALL must queue freeze work. The freeze_work
+	 * calls freeze_func, which tries to reacquire the freeze glock in SH,
+	 * effectively waiting for the thaw on the node who holds it in EX.
+	 * Once thawed, the work func acquires the freeze glock in
+	 * SH and everybody goes back to thawed.
+	 */
+	if (gl->gl_state == LM_ST_SHARED && !gfs2_withdrawn(sdp)) {
 		atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE);
 		error = freeze_super(sdp->sd_vfs);
 		if (error) {