Skip to content

Commit a070a91

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: add more midcomms hooks
This patch prepares hooks to redirect to the midcomms layer which will be used by the midcomms re-transmit handling. There exists the new concept of stateless buffers allocation and commits. This can be used to bypass the midcomms re-transmit handling. It is used by RCOM_STATUS and RCOM_NAMES messages, because they have their own ping-like re-transmit handling. As well these two messages will be used to determine the DLM version per node, because these two messages are per observation the first messages which are exchanged. Cluster manager events for node membership are added to add support for half-closed connections in cases that the peer connection get to an end of file but DLM still holds membership of the node. In this time DLM can still trigger new message which we should allow. After the cluster manager node removal event occurs it safe to close the connection. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 6fb5cf9 commit a070a91

7 files changed

Lines changed: 133 additions & 42 deletions

File tree

fs/dlm/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <net/sock.h>
2121

2222
#include "config.h"
23+
#include "midcomms.h"
2324
#include "lowcomms.h"
2425

2526
/*
@@ -532,7 +533,7 @@ static void drop_comm(struct config_group *g, struct config_item *i)
532533
struct dlm_comm *cm = config_item_to_comm(i);
533534
if (local_comm == cm)
534535
local_comm = NULL;
535-
dlm_lowcomms_close(cm->nodeid);
536+
dlm_midcomms_close(cm->nodeid);
536537
while (cm->addr_count--)
537538
kfree(cm->addr[cm->addr_count]);
538539
config_item_put(i);

fs/dlm/lock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "dlm_internal.h"
6060
#include <linux/dlm_device.h>
6161
#include "memory.h"
62-
#include "lowcomms.h"
62+
#include "midcomms.h"
6363
#include "requestqueue.h"
6464
#include "util.h"
6565
#include "dir.h"
@@ -3534,10 +3534,10 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
35343534
char *mb;
35353535

35363536
/* get_buffer gives us a message handle (mh) that we need to
3537-
pass into lowcomms_commit and a message buffer (mb) that we
3537+
pass into midcomms_commit and a message buffer (mb) that we
35383538
write our data into */
35393539

3540-
mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
3540+
mh = dlm_midcomms_get_mhandle(to_nodeid, mb_len, GFP_NOFS, &mb);
35413541
if (!mh)
35423542
return -ENOBUFS;
35433543

@@ -3589,7 +3589,7 @@ static int create_message(struct dlm_rsb *r, struct dlm_lkb *lkb,
35893589
static int send_message(struct dlm_mhandle *mh, struct dlm_message *ms)
35903590
{
35913591
dlm_message_out(ms);
3592-
dlm_lowcomms_commit_buffer(mh);
3592+
dlm_midcomms_commit_mhandle(mh);
35933593
return 0;
35943594
}
35953595

fs/dlm/lockspace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "member.h"
1717
#include "recoverd.h"
1818
#include "dir.h"
19+
#include "midcomms.h"
1920
#include "lowcomms.h"
2021
#include "config.h"
2122
#include "memory.h"
@@ -390,7 +391,7 @@ static int threads_start(void)
390391
}
391392

392393
/* Thread for sending/receiving messages for all lockspace's */
393-
error = dlm_lowcomms_start();
394+
error = dlm_midcomms_start();
394395
if (error) {
395396
log_print("cannot start dlm lowcomms %d", error);
396397
goto scand_fail;
@@ -698,7 +699,7 @@ int dlm_new_lockspace(const char *name, const char *cluster,
698699
error = 0;
699700
if (!ls_count) {
700701
dlm_scand_stop();
701-
dlm_lowcomms_shutdown();
702+
dlm_midcomms_shutdown();
702703
dlm_lowcomms_stop();
703704
}
704705
out:
@@ -787,7 +788,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
787788

788789
if (ls_count == 1) {
789790
dlm_scand_stop();
790-
dlm_lowcomms_shutdown();
791+
dlm_midcomms_shutdown();
791792
}
792793

793794
dlm_callback_stop(ls);

fs/dlm/member.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "recover.h"
1616
#include "rcom.h"
1717
#include "config.h"
18+
#include "midcomms.h"
1819
#include "lowcomms.h"
1920

2021
int dlm_slots_version(struct dlm_header *h)
@@ -329,6 +330,7 @@ static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node)
329330
memb->nodeid = node->nodeid;
330331
memb->weight = node->weight;
331332
memb->comm_seq = node->comm_seq;
333+
dlm_midcomms_add_member(node->nodeid);
332334
add_ordered_member(ls, memb);
333335
ls->ls_num_nodes++;
334336
return 0;
@@ -359,26 +361,34 @@ int dlm_is_removed(struct dlm_ls *ls, int nodeid)
359361
return 0;
360362
}
361363

362-
static void clear_memb_list(struct list_head *head)
364+
static void clear_memb_list(struct list_head *head,
365+
void (*after_del)(int nodeid))
363366
{
364367
struct dlm_member *memb;
365368

366369
while (!list_empty(head)) {
367370
memb = list_entry(head->next, struct dlm_member, list);
368371
list_del(&memb->list);
372+
if (after_del)
373+
after_del(memb->nodeid);
369374
kfree(memb);
370375
}
371376
}
372377

378+
static void clear_members_cb(int nodeid)
379+
{
380+
dlm_midcomms_remove_member(nodeid);
381+
}
382+
373383
void dlm_clear_members(struct dlm_ls *ls)
374384
{
375-
clear_memb_list(&ls->ls_nodes);
385+
clear_memb_list(&ls->ls_nodes, clear_members_cb);
376386
ls->ls_num_nodes = 0;
377387
}
378388

379389
void dlm_clear_members_gone(struct dlm_ls *ls)
380390
{
381-
clear_memb_list(&ls->ls_nodes_gone);
391+
clear_memb_list(&ls->ls_nodes_gone, NULL);
382392
}
383393

384394
static void make_member_array(struct dlm_ls *ls)
@@ -552,6 +562,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
552562

553563
neg++;
554564
list_move(&memb->list, &ls->ls_nodes_gone);
565+
dlm_midcomms_remove_member(memb->nodeid);
555566
ls->ls_num_nodes--;
556567
dlm_lsop_recover_slot(ls, memb);
557568
}

fs/dlm/midcomms.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@
2828
#include "lock.h"
2929
#include "midcomms.h"
3030

31+
struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
32+
gfp_t allocation, char **ppc)
33+
{
34+
return dlm_lowcomms_get_buffer(nodeid, len, allocation, ppc);
35+
}
36+
37+
void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
38+
{
39+
dlm_lowcomms_commit_buffer(mh);
40+
}
41+
42+
void dlm_midcomms_add_member(int nodeid) { }
43+
44+
void dlm_midcomms_remove_member(int nodeid) { }
45+
46+
int dlm_midcomms_start(void)
47+
{
48+
return dlm_lowcomms_start();
49+
}
50+
51+
void dlm_midcomms_shutdown(void)
52+
{
53+
dlm_lowcomms_shutdown();
54+
}
55+
56+
int dlm_midcomms_close(int nodeid)
57+
{
58+
return dlm_lowcomms_close(nodeid);
59+
}
60+
3161
/*
3262
* Called from the low-level comms layer to process a buffer of
3363
* commands.
@@ -101,4 +131,3 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
101131

102132
return ret;
103133
}
104-

fs/dlm/midcomms.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
#define __MIDCOMMS_DOT_H__
1414

1515
int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int buflen);
16+
struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
17+
gfp_t allocation, char **ppc);
18+
void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh);
19+
int dlm_midcomms_close(int nodeid);
20+
int dlm_midcomms_start(void);
21+
void dlm_midcomms_shutdown(void);
22+
void dlm_midcomms_add_member(int nodeid);
23+
void dlm_midcomms_remove_member(int nodeid);
1624

1725
#endif /* __MIDCOMMS_DOT_H__ */
1826

0 commit comments

Comments
 (0)