Skip to content

Commit 007b350

Browse files
committed
Merge tag 'dlm-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
Pull dlm updates from David Teigland: "This is a major dlm networking enhancement that adds message retransmission so that the dlm can reliably continue operating when network connections fail and nodes reconnect. Previously, this would result in lost messages which could only be handled as a node failure" * tag 'dlm-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm: (26 commits) fs: dlm: invalid buffer access in lookup error fs: dlm: fix race in mhandle deletion fs: dlm: rename socket and app buffer defines fs: dlm: introduce proto values fs: dlm: move dlm allow conn fs: dlm: use alloc_ordered_workqueue fs: dlm: fix memory leak when fenced fs: dlm: fix lowcomms_start error case fs: dlm: Fix spelling mistake "stucked" -> "stuck" fs: dlm: Fix memory leak of object mh fs: dlm: don't allow half transmitted messages fs: dlm: add midcomms debugfs functionality fs: dlm: add reliable connection if reconnect fs: dlm: add union in dlm header for lockspace id fs: dlm: move out some hash functionality fs: dlm: add functionality to re-transmit a message fs: dlm: make buffer handling per msg fs: dlm: add more midcomms hooks fs: dlm: public header in out utility fs: dlm: fix connection tcp EOF handling ...
2 parents 8418dab + 957adb6 commit 007b350

File tree

14 files changed

+1924
-191
lines changed

14 files changed

+1924
-191
lines changed

fs/dlm/config.c

Lines changed: 14 additions & 4 deletions
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
/*
@@ -79,6 +80,9 @@ struct dlm_cluster {
7980
unsigned int cl_new_rsb_count;
8081
unsigned int cl_recover_callbacks;
8182
char cl_cluster_name[DLM_LOCKSPACE_LEN];
83+
84+
struct dlm_spaces *sps;
85+
struct dlm_comms *cms;
8286
};
8387

8488
static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
@@ -204,7 +208,7 @@ static int dlm_check_zero(unsigned int x)
204208

205209
static int dlm_check_buffer_size(unsigned int x)
206210
{
207-
if (x < DEFAULT_BUFFER_SIZE)
211+
if (x < DLM_MAX_SOCKET_BUFSIZE)
208212
return -EINVAL;
209213

210214
return 0;
@@ -409,6 +413,9 @@ static struct config_group *make_cluster(struct config_group *g,
409413
if (!cl || !sps || !cms)
410414
goto fail;
411415

416+
cl->sps = sps;
417+
cl->cms = cms;
418+
412419
config_group_init_type_name(&cl->group, name, &cluster_type);
413420
config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type);
414421
config_group_init_type_name(&cms->cs_group, "comms", &comms_type);
@@ -458,6 +465,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)
458465
static void release_cluster(struct config_item *i)
459466
{
460467
struct dlm_cluster *cl = config_item_to_cluster(i);
468+
469+
kfree(cl->sps);
470+
kfree(cl->cms);
461471
kfree(cl);
462472
}
463473

@@ -532,7 +542,7 @@ static void drop_comm(struct config_group *g, struct config_item *i)
532542
struct dlm_comm *cm = config_item_to_comm(i);
533543
if (local_comm == cm)
534544
local_comm = NULL;
535-
dlm_lowcomms_close(cm->nodeid);
545+
dlm_midcomms_close(cm->nodeid);
536546
while (cm->addr_count--)
537547
kfree(cm->addr[cm->addr_count]);
538548
config_item_put(i);
@@ -942,7 +952,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
942952
#define DEFAULT_SCAN_SECS 5
943953
#define DEFAULT_LOG_DEBUG 0
944954
#define DEFAULT_LOG_INFO 1
945-
#define DEFAULT_PROTOCOL 0
955+
#define DEFAULT_PROTOCOL DLM_PROTO_TCP
946956
#define DEFAULT_MARK 0
947957
#define DEFAULT_TIMEWARN_CS 500 /* 5 sec = 500 centiseconds */
948958
#define DEFAULT_WAITWARN_US 0
@@ -952,7 +962,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
952962

953963
struct dlm_config_info dlm_config = {
954964
.ci_tcp_port = DEFAULT_TCP_PORT,
955-
.ci_buffer_size = DEFAULT_BUFFER_SIZE,
965+
.ci_buffer_size = DLM_MAX_SOCKET_BUFSIZE,
956966
.ci_rsbtbl_size = DEFAULT_RSBTBL_SIZE,
957967
.ci_recover_timer = DEFAULT_RECOVER_TIMER,
958968
.ci_toss_secs = DEFAULT_TOSS_SECS,

fs/dlm/config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef __CONFIG_DOT_H__
1313
#define __CONFIG_DOT_H__
1414

15-
#define DEFAULT_BUFFER_SIZE 4096
15+
#define DLM_MAX_SOCKET_BUFSIZE 4096
1616

1717
struct dlm_config_node {
1818
int nodeid;
@@ -23,6 +23,9 @@ struct dlm_config_node {
2323

2424
#define DLM_MAX_ADDR_COUNT 3
2525

26+
#define DLM_PROTO_TCP 0
27+
#define DLM_PROTO_SCTP 1
28+
2629
struct dlm_config_info {
2730
int ci_tcp_port;
2831
int ci_buffer_size;

fs/dlm/debug_fs.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
#include <linux/slab.h>
1717

1818
#include "dlm_internal.h"
19+
#include "midcomms.h"
1920
#include "lock.h"
2021

2122
#define DLM_DEBUG_BUF_LEN 4096
2223
static char debug_buf[DLM_DEBUG_BUF_LEN];
2324
static struct mutex debug_buf_lock;
2425

2526
static struct dentry *dlm_root;
27+
static struct dentry *dlm_comms;
2628

2729
static char *print_lockmode(int mode)
2830
{
@@ -738,6 +740,57 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
738740
debugfs_remove(ls->ls_debug_toss_dentry);
739741
}
740742

743+
static int dlm_state_show(struct seq_file *file, void *offset)
744+
{
745+
seq_printf(file, "%s\n", dlm_midcomms_state(file->private));
746+
return 0;
747+
}
748+
DEFINE_SHOW_ATTRIBUTE(dlm_state);
749+
750+
static int dlm_flags_show(struct seq_file *file, void *offset)
751+
{
752+
seq_printf(file, "%lu\n", dlm_midcomms_flags(file->private));
753+
return 0;
754+
}
755+
DEFINE_SHOW_ATTRIBUTE(dlm_flags);
756+
757+
static int dlm_send_queue_cnt_show(struct seq_file *file, void *offset)
758+
{
759+
seq_printf(file, "%d\n", dlm_midcomms_send_queue_cnt(file->private));
760+
return 0;
761+
}
762+
DEFINE_SHOW_ATTRIBUTE(dlm_send_queue_cnt);
763+
764+
static int dlm_version_show(struct seq_file *file, void *offset)
765+
{
766+
seq_printf(file, "0x%08x\n", dlm_midcomms_version(file->private));
767+
return 0;
768+
}
769+
DEFINE_SHOW_ATTRIBUTE(dlm_version);
770+
771+
void *dlm_create_debug_comms_file(int nodeid, void *data)
772+
{
773+
struct dentry *d_node;
774+
char name[256];
775+
776+
memset(name, 0, sizeof(name));
777+
snprintf(name, 256, "%d", nodeid);
778+
779+
d_node = debugfs_create_dir(name, dlm_comms);
780+
debugfs_create_file("state", 0444, d_node, data, &dlm_state_fops);
781+
debugfs_create_file("flags", 0444, d_node, data, &dlm_flags_fops);
782+
debugfs_create_file("send_queue_count", 0444, d_node, data,
783+
&dlm_send_queue_cnt_fops);
784+
debugfs_create_file("version", 0444, d_node, data, &dlm_version_fops);
785+
786+
return d_node;
787+
}
788+
789+
void dlm_delete_debug_comms_file(void *ctx)
790+
{
791+
debugfs_remove(ctx);
792+
}
793+
741794
void dlm_create_debug_file(struct dlm_ls *ls)
742795
{
743796
char name[DLM_LOCKSPACE_LEN + 8];
@@ -797,6 +850,7 @@ void __init dlm_register_debugfs(void)
797850
{
798851
mutex_init(&debug_buf_lock);
799852
dlm_root = debugfs_create_dir("dlm", NULL);
853+
dlm_comms = debugfs_create_dir("comms", dlm_root);
800854
}
801855

802856
void dlm_unregister_debugfs(void)

fs/dlm/dlm_internal.h

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ struct dlm_header;
5757
struct dlm_message;
5858
struct dlm_rcom;
5959
struct dlm_mhandle;
60+
struct dlm_msg;
6061

6162
#define log_print(fmt, args...) \
6263
printk(KERN_ERR "dlm: "fmt"\n" , ##args)
64+
#define log_print_ratelimited(fmt, args...) \
65+
printk_ratelimited(KERN_ERR "dlm: "fmt"\n", ##args)
6366
#define log_error(ls, fmt, args...) \
6467
printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args)
6568

@@ -368,23 +371,33 @@ static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
368371
/* dlm_header is first element of all structs sent between nodes */
369372

370373
#define DLM_HEADER_MAJOR 0x00030000
371-
#define DLM_HEADER_MINOR 0x00000001
374+
#define DLM_HEADER_MINOR 0x00000002
375+
376+
#define DLM_VERSION_3_1 0x00030001
377+
#define DLM_VERSION_3_2 0x00030002
372378

373379
#define DLM_HEADER_SLOTS 0x00000001
374380

375381
#define DLM_MSG 1
376382
#define DLM_RCOM 2
383+
#define DLM_OPTS 3
384+
#define DLM_ACK 4
385+
#define DLM_FIN 5
377386

378387
struct dlm_header {
379388
uint32_t h_version;
380-
uint32_t h_lockspace;
389+
union {
390+
/* for DLM_MSG and DLM_RCOM */
391+
uint32_t h_lockspace;
392+
/* for DLM_ACK and DLM_OPTS */
393+
uint32_t h_seq;
394+
} u;
381395
uint32_t h_nodeid; /* nodeid of sender */
382396
uint16_t h_length;
383397
uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */
384398
uint8_t h_pad;
385399
};
386400

387-
388401
#define DLM_MSG_REQUEST 1
389402
#define DLM_MSG_CONVERT 2
390403
#define DLM_MSG_UNLOCK 3
@@ -452,10 +465,29 @@ struct dlm_rcom {
452465
char rc_buf[];
453466
};
454467

468+
struct dlm_opt_header {
469+
uint16_t t_type;
470+
uint16_t t_length;
471+
uint32_t o_pad;
472+
/* need to be 8 byte aligned */
473+
char t_value[];
474+
};
475+
476+
/* encapsulation header */
477+
struct dlm_opts {
478+
struct dlm_header o_header;
479+
uint8_t o_nextcmd;
480+
uint8_t o_pad;
481+
uint16_t o_optlen;
482+
uint32_t o_pad2;
483+
char o_opts[];
484+
};
485+
455486
union dlm_packet {
456487
struct dlm_header header; /* common to other two */
457488
struct dlm_message message;
458489
struct dlm_rcom rcom;
490+
struct dlm_opts opts;
459491
};
460492

461493
#define DLM_RSF_NEED_SLOTS 0x00000001
@@ -722,11 +754,15 @@ void dlm_register_debugfs(void);
722754
void dlm_unregister_debugfs(void);
723755
void dlm_create_debug_file(struct dlm_ls *ls);
724756
void dlm_delete_debug_file(struct dlm_ls *ls);
757+
void *dlm_create_debug_comms_file(int nodeid, void *data);
758+
void dlm_delete_debug_comms_file(void *ctx);
725759
#else
726760
static inline void dlm_register_debugfs(void) { }
727761
static inline void dlm_unregister_debugfs(void) { }
728762
static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
729763
static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
764+
static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
765+
static inline void dlm_delete_debug_comms_file(void *ctx) { }
730766
#endif
731767

732768
#endif /* __DLM_INTERNAL_DOT_H__ */

fs/dlm/lock.c

Lines changed: 8 additions & 8 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,17 +3534,17 @@ 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

35443544
ms = (struct dlm_message *) mb;
35453545

35463546
ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
3547-
ms->m_header.h_lockspace = ls->ls_global_id;
3547+
ms->m_header.u.h_lockspace = ls->ls_global_id;
35483548
ms->m_header.h_nodeid = dlm_our_nodeid();
35493549
ms->m_header.h_length = mb_len;
35503550
ms->m_header.h_cmd = DLM_MSG;
@@ -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

@@ -5038,16 +5038,16 @@ void dlm_receive_buffer(union dlm_packet *p, int nodeid)
50385038

50395039
if (hd->h_nodeid != nodeid) {
50405040
log_print("invalid h_nodeid %d from %d lockspace %x",
5041-
hd->h_nodeid, nodeid, hd->h_lockspace);
5041+
hd->h_nodeid, nodeid, hd->u.h_lockspace);
50425042
return;
50435043
}
50445044

5045-
ls = dlm_find_lockspace_global(hd->h_lockspace);
5045+
ls = dlm_find_lockspace_global(hd->u.h_lockspace);
50465046
if (!ls) {
50475047
if (dlm_config.ci_log_debug) {
50485048
printk_ratelimited(KERN_DEBUG "dlm: invalid lockspace "
50495049
"%u from %d cmd %d type %d\n",
5050-
hd->h_lockspace, nodeid, hd->h_cmd, type);
5050+
hd->u.h_lockspace, nodeid, hd->h_cmd, type);
50515051
}
50525052

50535053
if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)

fs/dlm/lockspace.c

Lines changed: 10 additions & 4 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;
@@ -566,7 +567,12 @@ static int new_lockspace(const char *name, const char *cluster,
566567
mutex_init(&ls->ls_requestqueue_mutex);
567568
mutex_init(&ls->ls_clear_proc_locks);
568569

569-
ls->ls_recover_buf = kmalloc(LOWCOMMS_MAX_TX_BUFFER_LEN, GFP_NOFS);
570+
/* Due backwards compatibility with 3.1 we need to use maximum
571+
* possible dlm message size to be sure the message will fit and
572+
* not having out of bounds issues. However on sending side 3.2
573+
* might send less.
574+
*/
575+
ls->ls_recover_buf = kmalloc(DLM_MAX_SOCKET_BUFSIZE, GFP_NOFS);
570576
if (!ls->ls_recover_buf)
571577
goto out_lkbidr;
572578

@@ -698,7 +704,7 @@ int dlm_new_lockspace(const char *name, const char *cluster,
698704
error = 0;
699705
if (!ls_count) {
700706
dlm_scand_stop();
701-
dlm_lowcomms_shutdown();
707+
dlm_midcomms_shutdown();
702708
dlm_lowcomms_stop();
703709
}
704710
out:
@@ -787,7 +793,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
787793

788794
if (ls_count == 1) {
789795
dlm_scand_stop();
790-
dlm_lowcomms_shutdown();
796+
dlm_midcomms_shutdown();
791797
}
792798

793799
dlm_callback_stop(ls);

0 commit comments

Comments
 (0)