From: "zhengbing.huang" <zhengbing.huang@easystack.cn>
To: drbd-dev@lists.linux.dev
Cc: "zhengbing . huang" <zhengbing.huang@easystack.cn>
Subject: [PATCH 2/2] drbd: send state before bitmap to avoid receive_bitmap race
Date: Wed, 23 Sep 2026 14:01:09 +0800 [thread overview]
Message-ID: <20260923060109.3208507-1-zhengbing.huang@easystack.cn> (raw)
When a node becomes SyncSource (L_WF_BITMAP_S), after_state_chg() on the
worker thread queues the bitmap send while receive_state() on the receiver
thread sends the P_STATE that lets the peer reach L_WF_BITMAP_T. These race,
so the bitmap can arrive while the peer is still L_ESTABLISHED and get
dropped in receive_bitmap(), logging "unexpected repl_state (Established) in
receive_bitmap".
Send the current state synchronously before queueing the bitmap so the peer
transitions to L_WF_BITMAP_T first.
Signed-off-by: zhengbing.huang <zhengbing.huang@easystack.cn>
---
drbd/drbd_state.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index 4ddb31cb8..65414a774 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -4884,6 +4884,12 @@ static int w_after_state_change(struct drbd_work *w, int unused)
* it does no harm to resync a small amount of
* additional data. */
drbd_set_pending_out_of_sync(peer_device);
+ /* Tell the peer about our new state before sending the
+ * bitmap, so it can reach L_WF_BITMAP_T first. Otherwise
+ * the bitmap may arrive while the peer is still
+ * L_ESTABLISHED and get dropped in receive_bitmap().
+ */
+ drbd_send_state(peer_device, new_state);
/* ldev_safe: ref from extra_ldev_ref_for_after_state_chg() */
drbd_queue_bitmap_io(device, &drbd_send_bitmap, NULL,
"send_bitmap (WFBitMapS)",
--
2.43.0
next reply other threads:[~2026-09-23 8:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 6:01 zhengbing.huang [this message]
2026-09-25 10:16 ` [PATCH 2/2] drbd: send state before bitmap to avoid receive_bitmap race Philipp Reisner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923060109.3208507-1-zhengbing.huang@easystack.cn \
--to=zhengbing.huang@easystack.cn \
--cc=drbd-dev@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).