Skip to contentSkip to conversation

gfs2: fix scheduling while atomic bug in glocks

PATCH New Bob Peterson 1 participant 1 message May 18, 2021 1 message not in the archive GFS2 file system

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 scheduling while atomic bug in glocks

Before this patch, in the unlikely event that gfs2_glock_dq encountered a withdraw, it would do a wait_on_bit to wait for its journal to be recovered, but it never released the glock's spin_lock, which caused a scheduling-while-atomic error.

This patch unlocks the lockref spin_lock before waiting for recovery.

Fixes 601ef0d52e961 ("gfs2: Force withdraw to replay journals and wait

for it to finish"

---
 fs/gfs2/glock.c | 2 ++
 1 file changed, 2 insertions(+)
fs/gfs2/glock.c +2 -0
index 79f47f227e81..d7bee2ab5d2b 100644
@@ -1471,9 +1471,11 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
 	    glock_blocked_by_withdraw(gl) &&
 	    gh->gh_gl != sdp->sd_jinode_gl) {
 		sdp->sd_glock_dqs_held++;
+		spin_unlock(&gl->gl_lockref.lock);
 		might_sleep();
 		wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_RECOVERY,
 			    TASK_UNINTERRUPTIBLE);
+		spin_lock(&gl->gl_lockref.lock);
 	}
 	if (gh->gh_flags & GL_NOCACHE)
 		handle_callback(gl, LM_ST_UNLOCKED, 0, false);