[PATCH] ocfs2: shut down idle timer during socket teardown

Runyu Xiao posted 1 patch 3 weeks ago
fs/ocfs2/cluster/tcp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] ocfs2: shut down idle timer during socket teardown
Posted by Runyu Xiao 3 weeks ago
o2net_idle_timer() rearms sc_idle_timeout from its callback. The socket
shutdown path uses timer_delete_sync(), which waits for a running callback
but does not prevent the callback from rearming the timer after deletion.

The socket container is released after this path, and sc_kref_release()
expects the timer to be inactive. Use timer_shutdown_sync() so the timer
cannot be queued again during teardown.

Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
 fs/ocfs2/cluster/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 474fe1414..cef8cfa2a 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -733,7 +733,7 @@ static void o2net_shutdown_sc(struct work_struct *work)
 	if (o2net_unregister_callbacks(sc->sc_sock->sk, sc)) {
 		/* we shouldn't flush as we're in the thread, the
 		 * races with pending sc work structs are harmless */
-		timer_delete_sync(&sc->sc_idle_timeout);
+		timer_shutdown_sync(&sc->sc_idle_timeout);
 		o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work);
 		sc_put(sc);
 		kernel_sock_shutdown(sc->sc_sock, SHUT_RDWR);
@@ -1513,7 +1513,7 @@ static void o2net_sc_send_keep_req(struct work_struct *work)
 	sc_put(sc);
 }
 
-/* socket shutdown does a timer_delete_sync against this as it tears down.
+/* socket shutdown shuts down this timer as it tears down.
  * we can't start this timer until we've got to the point in sc buildup
  * where shutdown is going to be involved */
 static void o2net_idle_timer(struct timer_list *t)
-- 
2.34.1