Fix stale receiver thread state when drbd_connect() returns zero
PATCH 1/1 Fix stale receiver thread state when drbd_connect() returns zero
Hello.
Although I know that drbd 0.7 is old and not supported anymore, I still feel that this information may be usable for people.
I have spent a while trying to find out why sometimes failover on drbd 0.7.24 fails on out customer's system.
At last, I was able to track what was hapenning.
I did not check, but the same issue may be present in later versions of drbd as well.
The patch below is against drbd 0.7.24 release.
From cf7541852c39bb507b4a3ccc42a9d8fa365cbbd3 Mon Sep 17 00:00:00 2001
From: Nikita V. Youshchenko <[email protected]>
Date: Thu, 6 Nov 2008 00:42:47 +0300
Subject: [PATCH] Fix stale receiver thread state when drbd_connect() returns zero.
The following call stack may happen:
drbd_init() ->
drbd_connect() ->
drbd_do_handshake() ->
drbd_recv_header() ->
drbd_recv()At this level socket receive is called, that may return 0 (in case of peer connection reset). Then drbd_thread_restart_nowait(&mdev->receiver) will be called, and receiver state will be set to Restarting.
Later control returns to drbd_init(), goes to error path, and then to a new iteration of connection loop, leaving receiver state set to Restarting.
Much later, this causes breakages. For example, drbd device does not handle failover correctly.
This patch fixes stale receiver state on the described error path.
--- drbd/drbd_receiver.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drbd/drbd_receiver.c +4 -0
@@ -2105,6 +2105,10 @@ int drbdd_init(struct Drbd_thread *thi)drbd_disconnect (mdev);if (h ==0 ) {schedule_timeout (HZ ); +spin_lock (&thi->t_lock); +if (thi->t_state == Restarting) + thi->t_state = Running; +spin_unlock (&thi->t_lock);continue ; }
Signature · 1 line
1.5.6.5