Skip to contentSkip to conversation

drbd: fix a bug of do_change_disk_state when attach

PATCH In review Rui Xu 2 participants 3 messages Feb 23, 2022 – Apr 7, 2022 DRBD driver

lore
Share & tools
lore

Rui Xu

author
#0 lore raw

PATCH 1/1 drbd: fix a bug of do_change_disk_state when attach

There is a bug in do_change_disk_state when attach disk to drbd. Consider this scenario:

Primary: node-1, Secondary: node-2, node-3

(1) Network failure occurs on node-1 so that node-2 and node-3 will lose connection to node-1

(2) Detach the disk of drbd on node-2 use 'drbdadm detach'

(3) Attach the disk of drbd on node-2 use 'drbdadm attach'

we can see that disk state of node-2 will stay in the negotiating and miss a handshake with node-3, what causes this is when we attach, disk state will going to negotiating from attaching, we will determine whether a two-pc is required in do_change_disk_state, since we lose the connection with node-1 and node-1 was first connection, connection->agreeed _pro_version will less than 110, at last, we will not do a two-pc, which leads a problem that node-3 will not send p_state to node-2, then node-2 miss a handshake with node-3 and the disk state of node-2 will not change.

Fix it by using supports_two_phase_commit to determine whether a two-pc is really required.

---
 drbd/drbd_state.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drbd/drbd_state.c +1 -4
index aeaf36a..2cb501d 100644
@@ -5173,10 +5173,7 @@ static bool do_change_disk_state(struct change_context *context, enum change_pha
 	if (device->disk_state[NOW] == D_ATTACHING &&
 	    context->val.disk == D_NEGOTIATING) {
 		if (device_has_peer_devices_with_disk(device)) {
-			struct drbd_connection *connection =
-				first_connection(device->resource);
-			cluster_wide_state_change =
-				connection && connection->agreed_pro_version >= 110;
+			cluster_wide_state_change = supports_two_phase_commit(device->resource);
 		} else {
 			/* very last part of attach */
 			context->val.disk = disk_state_from_md(device);
Signature · 1 line
1.8.3.1
author
#1 lore raw

PING
From: Rui Xu <[email protected]>
Date: 2022-02-23 16:44:42
To: [email protected],[email protected]
Cc: [email protected],Rui Xu <[email protected]>
Subject: [PATCH] drbd: fix a bug of do_change_disk_state when attach>There is a bug in do_change_disk_state when attach disk to

Quoted 47 lines

drbd. Consider this scenario:

Primary: node-1, Secondary: node-2, node-3

(1) Network failure occurs on node-1 so that node-2 and node-3 will lose connection to node-1

(2) Detach the disk of drbd on node-2 use 'drbdadm detach'

(3) Attach the disk of drbd on node-2 use 'drbdadm attach'

we can see that disk state of node-2 will stay in the negotiating and miss a handshake with node-3, what causes this is when we attach, disk state will going to negotiating from attaching, we will determine whether a two-pc is required in do_change_disk_state, since we lose the connection with node-1 and node-1 was first connection, connection->agreeed _pro_version will less than 110, at last, we will not do a two-pc, which leads a problem that node-3 will not send p_state to node-2, then node-2 miss a handshake with node-3 and the disk state of node-2 will not change.

Fix it by using supports_two_phase_commit to determine whether a two-pc is really required.

---
drbd/drbd_state.c | 5 +----

1 file changed, 1 insertion(+), 4 deletions(-)
drbd/drbd_state.c +1 -4
index aeaf36a..2cb501d 100644
@@ -5173,10 +5173,7 @@ static bool do_change_disk_state(struct change_context *context, enum change_pha
 	if (device->disk_state[NOW] == D_ATTACHING &&
 	    context->val.disk == D_NEGOTIATING) {
 		if (device_has_peer_devices_with_disk(device)) {
-			struct drbd_connection *connection =
-				first_connection(device->resource);
-			cluster_wide_state_change =
-				connection && connection->agreed_pro_version >= 110;
+			cluster_wide_state_change = supports_two_phase_commit(device->resource);
 		} else {
 			/* very last part of attach */
 			context->val.disk = disk_state_from_md(device);
Signature · 1 line
1.8.3.1
#2 lore raw

Hi,

The patch looks plausible but the commit message is hard to understand. Please split the 8 line sentence into multiple sentences. Also explain at the start which versions need to be mixed to trigger this bug.

Regarding versions - it looks like you have a 3 node cluster where one node is running DRBD 8. This is not recommended. What is your use-case?

Best regards,
Joel