File fix-hang-demote-after-ioerror.patch of Package drbd.openSUSE_Leap_42.3_Update

commit b5f48453e1b95d7a53bee1820f2ff1d5b23cb6f1
Author: Philipp Reisner <philipp.reisner@linbit.com>
Date:   Wed Jul 11 11:51:03 2018 +0200

    drbd: fix hanging demote after IO error
    
    Pavel Klevtsov reported:
      This call hungs in the next case:
      1. Start writing to Primary node (A)
      2. Get IOError & Disconnect on Secondary node (B)
      3. Continue writing to A
      4. Stop writing to A
      5. Connect & Resync B -> UpToDate
      6. Try to change role A (from primary to secondary)
      7. Hanging till Disconnect B
    
    The patch is sufficient. The possible race that finish_state_change() clears
    the bit after a drbdsetup demote tested the bit is no problem, since then
    the disk state will change to D_UNKNOWN and the sleeping drbdsetup will
    waiter will be woken.

diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index ca5df671..6d33cb9e 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -2397,6 +2397,9 @@ static void finish_state_change(struct drbd_resource *resource, struct completio
 				    disk_state[NEW] == D_UP_TO_DATE)
 					create_new_uuid = true;
 			}
+
+			if (peer_disk_state[NEW] < D_UP_TO_DATE && test_bit(GOT_NEG_ACK, &peer_device->flags))
+				clear_bit(GOT_NEG_ACK, &peer_device->flags);
 		}
 
 		if (disk_state[OLD] >= D_INCONSISTENT && disk_state[NEW] < D_INCONSISTENT &&
openSUSE Build Service is sponsored by