File rely-on-sb-handlers.patch of Package drbd.16013

diff -Naur drbd-9.0.11+git.1e2bccdc.orig/drbd/drbd_state.c drbd-9.0.11+git.1e2bccdc/drbd/drbd_state.c
--- drbd-9.0.11+git.1e2bccdc.orig/drbd/drbd_state.c	2019-08-27 13:34:08.462567903 +0800
+++ drbd-9.0.11+git.1e2bccdc/drbd/drbd_state.c	2019-08-30 12:56:37.664186710 +0800
@@ -1398,8 +1398,13 @@
 		nc = rcu_dereference(connection->transport.net_conf);
 		two_primaries = nc ? nc->two_primaries : false;
 		if (peer_role[NEW] == R_PRIMARY && peer_role[OLD] != R_PRIMARY && !two_primaries) {
-			if (role[NOW] == R_PRIMARY)
-				return SS_TWO_PRIMARIES;
+			if (role[NOW] == R_PRIMARY) {
+				if (role[OLD] == R_PRIMARY && connection->cstate[OLD] < C_CONNECTED) {
+					drbd_info(connection, "Two primaries but not allowed. Rely on split brain handler or to disconnect.\n");
+				} else {
+					return SS_TWO_PRIMARIES;
+				}
+			}
 			idr_for_each_entry(&resource->devices, device, vnr) {
 				if (device->open_ro_cnt)
 					return SS_PRIMARY_READER;
@@ -3665,7 +3670,11 @@
 		mask = NODE_MASK(connection->peer_node_id);
 		if ((resource->twopc_reply.primary_nodes & mask) &&
 		    !(connection->transport.net_conf->two_primaries)) {
-			rv = SS_TWO_PRIMARIES;
+			if (connection->cstate[OLD] < C_CONNECTED && connection->cstate[NEW] == C_CONNECTED) {
+				drbd_info(connection, "Two primaries but not allowed after reconnected. Rely on split brain handler or to disconnect.\n");
+			} else {
+				rv = SS_TWO_PRIMARIES;
+			}
 			break;
 		}
 	}
@@ -3739,7 +3748,11 @@
 		nc = rcu_dereference(connection->transport.net_conf);
 		if (!nc->two_primaries &&
 		    NODE_MASK(connection->peer_node_id) & reply->primary_nodes) {
-			rv = SS_PRIMARY_READER;
+			if (connection->cstate[OLD] < C_CONNECTED && connection->cstate[NEW] == C_CONNECTED) {
+				drbd_info(connection, "Two primaries and device is opened as read only. Rely on split brain handler or to disconnect.\n");
+			} else {
+				rv = SS_PRIMARY_READER;
+			}
 			break;
 		}
 	}
openSUSE Build Service is sponsored by