Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [PATCH] drbd: drop a postponed resync start that outlived its resync
@ 2026-11-30  7:02 Kitae Yoo
  0 siblings, 0 replies; only message in thread
From: Kitae Yoo @ 2026-11-30  7:02 UTC (permalink / raw)
  To: drbd-dev

do_start_resync() postpones itself while a previous resync is still
active and retries every HZ/10. When the start for a Behind->SyncTarget
transition is posted a second time while the resync it asked for is
already running, the second instance finds that very resync active and
keeps postponing until it ends. It then fires from Established and calls
drbd_start_resync() for a transition that has already happened.

On a 3-node setup (protocol A, on-congestion pull-ahead, one slow
link) this showed up as about 2,000 "postponing start_resync ..." lines
per run on the slow target, followed by a start from Established once
the real resync had finished.

The callers that post RS_START (resync-after-behind in receive_state(),
the Ahead->SyncSource timer in drbd_req.c, and the postpone timer
itself) all do so while the peer device is Behind or Ahead, and retries
from drbd_start_resync() set B_RS_H_DONE first. So a start that finds
the peer device in any other state, without B_RS_H_DONE, is stale: log
it and drop it.

Tested on DRBD 9.3.4 (same hunk applies to master and compiles), kernel
7.0.0-43, 3 diskful nodes, LINSTOR, 2 cycles of the workload above on
each module:

  unpatched: about 2,000 "postponing" lines per run, stale starts
             fired from Established
  patched:   0 "postponing" lines, 0 starts from Established,
             "dropping stale start_resync" 3-4 times while the real
             resync was running, every resync completed, no
             out-of-sync bits left on any Established pair

Signed-off-by: Kitae Yoo <ryugitae777@gmail.com>
---
 drbd/drbd_sender.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drbd/drbd_sender.c b/drbd/drbd_sender.c
--- a/drbd/drbd_sender.c
+++ b/drbd/drbd_sender.c
@@ -3223,6 +3223,21 @@
 
 static void do_start_resync(struct drbd_peer_device *peer_device)
 {
+	enum drbd_repl_state repl_state = peer_device->repl_state[NOW];
+
+	/* A Behind->SyncTarget or Ahead->SyncSource start can outlive the resync
+	 * it asked for: the postpone condition below is then satisfied by that
+	 * very resync until it ends, and the start fires from Established.
+	 * Retries from drbd_start_resync() (B_RS_H_DONE) may start from other
+	 * states. */
+	if (!test_bit(B_RS_H_DONE, peer_device->flags) &&
+	    repl_state != L_BEHIND && repl_state != L_AHEAD) {
+		drbd_info(peer_device, "dropping stale start_resync (%s, %lu bits)\n",
+			  drbd_repl_str(repl_state), drbd_bm_total_weight(peer_device));
+		clear_bit(AHEAD_TO_SYNC_SOURCE, peer_device->flags);
+		return;
+	}
+
 	/*
 	 * Postpone resync in any of these situations:
 	 * - There is still activity from a previous resync according to rs_pending_cnt.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30  7:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  7:02 [PATCH] drbd: drop a postponed resync start that outlived its resync Kitae Yoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox