fs: dlm: cleanup lock order
authorAlexander Aring <aahringo@redhat.com>
Tue, 1 Aug 2023 18:09:44 +0000 (14:09 -0400)
committerDavid Teigland <teigland@redhat.com>
Thu, 10 Aug 2023 15:33:03 +0000 (10:33 -0500)
This patch cleanups the lock order to hold at first the close_lock and
then held the nodes_srcu read lock. Probably it will never be a problem
as nodes_srcu is only a read lock preventing the node pointer getting
freed.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/midcomms.c

index e1a0df67b566958acd8b2a9bc089a2991d42b0ba..8ebffbfdc00ae4486bb767cfbb479524d1888d48 100644 (file)
@@ -1489,12 +1489,12 @@ int dlm_midcomms_close(int nodeid)
 
        synchronize_srcu(&nodes_srcu);
 
-       idx = srcu_read_lock(&nodes_srcu);
        mutex_lock(&close_lock);
+       idx = srcu_read_lock(&nodes_srcu);
        node = nodeid2node(nodeid, 0);
        if (!node) {
-               mutex_unlock(&close_lock);
                srcu_read_unlock(&nodes_srcu, idx);
+               mutex_unlock(&close_lock);
                return dlm_lowcomms_close(nodeid);
        }