Skip to content

Commit fe9b619

Browse files
Alexander Aringteigland
authored andcommitted
dlm: fix creating multiple node structures
This patch will lookup existing nodes instead of always creating them when dlm_midcomms_addr() is called. The idea is here to create midcomms nodes when user space getting informed that nodes joins the cluster. This is the case when dlm_midcomms_addr() is called, however it can be called multiple times by user space to add several address configurations to one node e.g. when using SCTP. Those multiple times need to be filtered out and we doing that by looking up if the node exists before. Due configfs entry it is safe that this function gets only called once at a time. Fixes: 63e711b ("fs: dlm: create midcomms nodes when configure") Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent bc15bec commit fe9b619

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/dlm/midcomms.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,21 @@ static struct midcomms_node *nodeid2node(int nodeid)
337337

338338
int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
339339
{
340-
int ret, r = nodeid_hash(nodeid);
340+
int ret, idx, r = nodeid_hash(nodeid);
341341
struct midcomms_node *node;
342342

343343
ret = dlm_lowcomms_addr(nodeid, addr, len);
344344
if (ret)
345345
return ret;
346346

347+
idx = srcu_read_lock(&nodes_srcu);
348+
node = __find_node(nodeid, r);
349+
if (node) {
350+
srcu_read_unlock(&nodes_srcu, idx);
351+
return 0;
352+
}
353+
srcu_read_unlock(&nodes_srcu, idx);
354+
347355
node = kmalloc(sizeof(*node), GFP_NOFS);
348356
if (!node)
349357
return -ENOMEM;

0 commit comments

Comments
 (0)