[Drbd-dev] [PATCH] drbd: fix a bug of do_change_disk_state when attach

Rui Xu rui.xu at easystack.cn
Wed Feb 23 09:44:42 CET 2022


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.

Signed-off-by: Rui Xu <rui.xu at easystack.cn>
---
 drbd/drbd_state.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index aeaf36a..2cb501d 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -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);
-- 
1.8.3.1



More information about the drbd-dev mailing list