Skip to contentSkip to conversation

gfs2: check context on gfs2_glock_put

PATCH New Alexander Aring 2 participants 2 messages Oct 13, 2021 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: check context on gfs2_glock_put

This patch adds a might_sleep() call into gfs2_glock_put() which could sleep if last reference is released. A comment leaves a note for the programmer that the only reason why it might can sleep is that the DLM api is called which is currently sleepable context. Checking on sleepable context in gfs2_glock_put() will show us problems earlier instead of seeing issues only if the last put occurred.

---
 fs/gfs2/glock.c | 3 +++
 1 file changed, 3 insertions(+)
fs/gfs2/glock.c +3 -0
index ccbfbc93e954..689dbe37fd91 100644
@@ -294,6 +294,9 @@ void gfs2_glock_queue_put(struct gfs2_glock *gl)
 
 void gfs2_glock_put(struct gfs2_glock *gl)
 {
+	/* last put could call sleepable dlm api */
+	might_sleep();
+
 	if (lockref_put_or_lock(&gl->gl_lockref))
 		return;
 
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 gfs2: check context on gfs2_glock_put

Quoted 6 lines · Alexander Aring

This patch adds a might_sleep() call into gfs2_glock_put() which could sleep if last reference is released. A comment leaves a note for the programmer that the only reason why it might can sleep is that the DLM api is called which is currently sleepable context. Checking on sleepable context in gfs2_glock_put() will show us problems earlier instead of seeing issues only if the last put occurred.

Thanks, I've pushed this to for-next.

Andreas