Skip to content

Commit

Permalink
drbd: do not attempt to start resync if we receive bitmap twice
Browse files Browse the repository at this point in the history
We expect to only receive the bitmap once in a bitmap exchange. In the
situation described in the recent commit "drbd: use mod_timer() instead
of add_timer() for starting resync", the peer breaks this assumption.
This change protects us against this unexpected behavior of our peer.
  • Loading branch information
JoelColledge committed Mar 24, 2023
1 parent 8644c72 commit f560511
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -7858,7 +7858,10 @@ static int receive_bitmap(struct drbd_connection *connection, struct packet_info

drbd_bm_slot_unlock(peer_device);

if (repl_state == L_WF_BITMAP_S) {
if (test_bit(B_RS_H_DONE, &peer_device->flags)) {
/* We have entered drbd_start_resync() since starting the bitmap exchange. */
drbd_warn(peer_device, "Received bitmap more than once; ignoring\n");
} else if (repl_state == L_WF_BITMAP_S) {
drbd_start_resync(peer_device, L_SYNC_SOURCE);
} else if (repl_state == L_WF_BITMAP_T) {
if (connection->agreed_pro_version < 110) {
Expand Down
8 changes: 8 additions & 0 deletions drbd/drbd_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,14 @@ static void finish_state_change(struct drbd_resource *resource)
if (did != should)
start_new_epoch = true;

if (peer_device->repl_state[OLD] != L_WF_BITMAP_S &&
peer_device->repl_state[NEW] == L_WF_BITMAP_S)
clear_bit(B_RS_H_DONE, &peer_device->flags);

if (peer_device->repl_state[OLD] != L_WF_BITMAP_T &&
peer_device->repl_state[NEW] == L_WF_BITMAP_T)
clear_bit(B_RS_H_DONE, &peer_device->flags);

if (!is_sync_state(peer_device, NOW) &&
is_sync_state(peer_device, NEW)) {
clear_bit(RS_DONE, &peer_device->flags);
Expand Down

0 comments on commit f560511

Please sign in to comment.