Skip to content

Commit

Permalink
fs: dlm: add more midcomms hooks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Aring authored and teigland committed May 25, 2021
1 parent 6fb5cf9 commit a070a91
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 42 deletions.
3 changes: 2 additions & 1 deletion fs/dlm/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <net/sock.h>

#include "config.h"
#include "midcomms.h"
#include "lowcomms.h"

/*
Expand Down Expand Up @@ -532,7 +533,7 @@ static void drop_comm(struct config_group *g, struct config_item *i)
struct dlm_comm *cm = config_item_to_comm(i);
if (local_comm == cm)
local_comm = NULL;
dlm_lowcomms_close(cm->nodeid);
dlm_midcomms_close(cm->nodeid);
while (cm->addr_count--)
kfree(cm->addr[cm->addr_count]);
config_item_put(i);
Expand Down
8 changes: 4 additions & 4 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "dlm_internal.h"
#include <linux/dlm_device.h>
#include "memory.h"
#include "lowcomms.h"
#include "midcomms.h"
#include "requestqueue.h"
#include "util.h"
#include "dir.h"
Expand Down Expand Up @@ -3534,10 +3534,10 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
char *mb;

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

mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
mh = dlm_midcomms_get_mhandle(to_nodeid, mb_len, GFP_NOFS, &mb);
if (!mh)
return -ENOBUFS;

Expand Down Expand Up @@ -3589,7 +3589,7 @@ static int create_message(struct dlm_rsb *r, struct dlm_lkb *lkb,
static int send_message(struct dlm_mhandle *mh, struct dlm_message *ms)
{
dlm_message_out(ms);
dlm_lowcomms_commit_buffer(mh);
dlm_midcomms_commit_mhandle(mh);
return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions fs/dlm/lockspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "member.h"
#include "recoverd.h"
#include "dir.h"
#include "midcomms.h"
#include "lowcomms.h"
#include "config.h"
#include "memory.h"
Expand Down Expand Up @@ -390,7 +391,7 @@ static int threads_start(void)
}

/* Thread for sending/receiving messages for all lockspace's */
error = dlm_lowcomms_start();
error = dlm_midcomms_start();
if (error) {
log_print("cannot start dlm lowcomms %d", error);
goto scand_fail;
Expand Down Expand Up @@ -698,7 +699,7 @@ int dlm_new_lockspace(const char *name, const char *cluster,
error = 0;
if (!ls_count) {
dlm_scand_stop();
dlm_lowcomms_shutdown();
dlm_midcomms_shutdown();
dlm_lowcomms_stop();
}
out:
Expand Down Expand Up @@ -787,7 +788,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)

if (ls_count == 1) {
dlm_scand_stop();
dlm_lowcomms_shutdown();
dlm_midcomms_shutdown();
}

dlm_callback_stop(ls);
Expand Down
17 changes: 14 additions & 3 deletions fs/dlm/member.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "recover.h"
#include "rcom.h"
#include "config.h"
#include "midcomms.h"
#include "lowcomms.h"

int dlm_slots_version(struct dlm_header *h)
Expand Down Expand Up @@ -329,6 +330,7 @@ static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node)
memb->nodeid = node->nodeid;
memb->weight = node->weight;
memb->comm_seq = node->comm_seq;
dlm_midcomms_add_member(node->nodeid);
add_ordered_member(ls, memb);
ls->ls_num_nodes++;
return 0;
Expand Down Expand Up @@ -359,26 +361,34 @@ int dlm_is_removed(struct dlm_ls *ls, int nodeid)
return 0;
}

static void clear_memb_list(struct list_head *head)
static void clear_memb_list(struct list_head *head,
void (*after_del)(int nodeid))
{
struct dlm_member *memb;

while (!list_empty(head)) {
memb = list_entry(head->next, struct dlm_member, list);
list_del(&memb->list);
if (after_del)
after_del(memb->nodeid);
kfree(memb);
}
}

static void clear_members_cb(int nodeid)
{
dlm_midcomms_remove_member(nodeid);
}

void dlm_clear_members(struct dlm_ls *ls)
{
clear_memb_list(&ls->ls_nodes);
clear_memb_list(&ls->ls_nodes, clear_members_cb);
ls->ls_num_nodes = 0;
}

void dlm_clear_members_gone(struct dlm_ls *ls)
{
clear_memb_list(&ls->ls_nodes_gone);
clear_memb_list(&ls->ls_nodes_gone, NULL);
}

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

neg++;
list_move(&memb->list, &ls->ls_nodes_gone);
dlm_midcomms_remove_member(memb->nodeid);
ls->ls_num_nodes--;
dlm_lsop_recover_slot(ls, memb);
}
Expand Down
31 changes: 30 additions & 1 deletion fs/dlm/midcomms.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,36 @@
#include "lock.h"
#include "midcomms.h"

struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
gfp_t allocation, char **ppc)
{
return dlm_lowcomms_get_buffer(nodeid, len, allocation, ppc);
}

void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
{
dlm_lowcomms_commit_buffer(mh);
}

void dlm_midcomms_add_member(int nodeid) { }

void dlm_midcomms_remove_member(int nodeid) { }

int dlm_midcomms_start(void)
{
return dlm_lowcomms_start();
}

void dlm_midcomms_shutdown(void)
{
dlm_lowcomms_shutdown();
}

int dlm_midcomms_close(int nodeid)
{
return dlm_lowcomms_close(nodeid);
}

/*
* Called from the low-level comms layer to process a buffer of
* commands.
Expand Down Expand Up @@ -101,4 +131,3 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)

return ret;
}

8 changes: 8 additions & 0 deletions fs/dlm/midcomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#define __MIDCOMMS_DOT_H__

int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int buflen);
struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
gfp_t allocation, char **ppc);
void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh);
int dlm_midcomms_close(int nodeid);
int dlm_midcomms_start(void);
void dlm_midcomms_shutdown(void);
void dlm_midcomms_add_member(int nodeid);
void dlm_midcomms_remove_member(int nodeid);

#endif /* __MIDCOMMS_DOT_H__ */

Loading

0 comments on commit a070a91

Please sign in to comment.