Skip to contentSkip to conversation

ocfs2: skip uninitialized lockres in ocfs2_mark_lockres_freeing()

PATCH Applied Joseph Qi 1 participant 1 message Sep 3 OCFS2

lore
Share & tools
lore

Joseph Qi

author maintainer
#0 lore raw

PATCH 1/1 ocfs2: skip uninitialized lockres in ocfs2_mark_lockres_freeing()

A hard readonly mount skips ocfs2_dlm_init(), so the per-osb lock resources are never initialized and osb->cconn stays NULL. Before commit 550842cc60987 ("ocfs2: fix freeing uninitialized resource on ocfs2_dlm_shutdown") ocfs2_dismount_volume() only called ocfs2_dlm_shutdown() when osb->cconn was set. It now calls it unconditionally, so unmounting a hard readonly mount drops the osb locks and takes the never initialized l_lock in ocfs2_mark_lockres_freeing(). With lockdep enabled this triggers:

INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator.

ocfs2_drop_lock() and ocfs2_lock_res_free() already skip lock resources without OCFS2_LOCK_INITIALIZED. Add the same check to ocfs2_mark_lockres_freeing(), which is reachable before them through ocfs2_simple_drop_lockres(), so an uninitialized lockres is never touched.

Fixes 550842cc60987 ("ocfs2: fix freeing uninitialized resource on ocfs2_dlm_shutdown")
---
 fs/ocfs2/dlmglue.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ocfs2/dlmglue.c +4 -0
index a23dd8f86c89..cf3318b0d3a8 100644
@@ -3525,6 +3525,10 @@ void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
 	struct ocfs2_mask_waiter mw;
 	unsigned long flags, flags2;
 
+	/* We didn't get anywhere near actually using this lockres. */
+	if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED))
+		return;
+
 	ocfs2_init_mask_waiter(&mw);
 
 	spin_lock_irqsave(&lockres->l_lock, flags);
Signature · 1 line
2.39.3