Jiri Slaby ef7db2
From: Alexander Aring <aahringo@redhat.com>
Jiri Slaby ef7db2
Date: Thu, 12 Jan 2023 17:10:34 -0500
Jiri Slaby ef7db2
Subject: [PATCH] fs: dlm: fix race setting stop tx flag
Jiri Slaby ef7db2
References: bsc#1012628
Jiri Slaby ef7db2
Patch-mainline: 6.2.3
Jiri Slaby ef7db2
Git-commit: 164272113b685927126c938b4a9cbd2075eb15ee
Jiri Slaby ef7db2
Jiri Slaby ef7db2
commit 164272113b685927126c938b4a9cbd2075eb15ee upstream.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
This patch sets the stop tx flag before we commit the dlm message.
Jiri Slaby ef7db2
This flag will report about unexpected transmissions after we
Jiri Slaby ef7db2
send the DLM_FIN message out, which should be the last message sent.
Jiri Slaby ef7db2
When we commit the dlm fin message, it could be that we already
Jiri Slaby ef7db2
got an ack back and the CLOSED state change already happened.
Jiri Slaby ef7db2
We should not set this flag when we are in CLOSED state. To avoid this
Jiri Slaby ef7db2
race we simply set the tx flag before the state change can be in
Jiri Slaby ef7db2
progress by moving it before dlm_midcomms_commit_mhandle().
Jiri Slaby ef7db2
Jiri Slaby ef7db2
Cc: stable@vger.kernel.org
Jiri Slaby ef7db2
Fixes: 489d8e559c65 ("fs: dlm: add reliable connection if reconnect")
Jiri Slaby ef7db2
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Jiri Slaby ef7db2
Signed-off-by: David Teigland <teigland@redhat.com>
Jiri Slaby ef7db2
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jiri Slaby ef7db2
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Jiri Slaby ef7db2
---
Jiri Slaby ef7db2
 fs/dlm/midcomms.c | 2 +-
Jiri Slaby ef7db2
 1 file changed, 1 insertion(+), 1 deletion(-)
Jiri Slaby ef7db2
Jiri Slaby ef7db2
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
Jiri Slaby ef7db2
index a3eb19c8..9d459d5b 100644
Jiri Slaby ef7db2
--- a/fs/dlm/midcomms.c
Jiri Slaby ef7db2
+++ b/fs/dlm/midcomms.c
Jiri Slaby ef7db2
@@ -406,6 +406,7 @@ static int dlm_send_fin(struct midcomms_node *node,
Jiri Slaby ef7db2
 	if (!mh)
Jiri Slaby ef7db2
 		return -ENOMEM;
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
+	set_bit(DLM_NODE_FLAG_STOP_TX, &node->flags);
Jiri Slaby ef7db2
 	mh->ack_rcv = ack_rcv;
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
 	m_header = (struct dlm_header *)ppc;
Jiri Slaby ef7db2
@@ -417,7 +418,6 @@ static int dlm_send_fin(struct midcomms_node *node,
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
 	pr_debug("sending fin msg to node %d\n", node->nodeid);
Jiri Slaby ef7db2
 	dlm_midcomms_commit_mhandle(mh, NULL, 0);
Jiri Slaby ef7db2
-	set_bit(DLM_NODE_FLAG_STOP_TX, &node->flags);
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
 	return 0;
Jiri Slaby ef7db2
 }
Jiri Slaby ef7db2
-- 
Jiri Slaby ef7db2
2.35.3
Jiri Slaby ef7db2