Commit 6bab076a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'dlm-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm

Pull dlm updates from David Teigland:
 "This includes more dlm networking cleanups and improvements for making
  dlm shutdowns more robust"

* tag 'dlm-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm:
  fs: dlm: fix missing unlock on error in accept_from_sock()
  fs: dlm: add shutdown hook
  fs: dlm: flush swork on shutdown
  fs: dlm: remove unaligned memory access handling
  fs: dlm: check on minimum msglen size
  fs: dlm: simplify writequeue handling
  fs: dlm: use GFP_ZERO for page buffer
  fs: dlm: change allocation limits
  fs: dlm: add check if dlm is currently running
  fs: dlm: add errno handling to check callback
  fs: dlm: set subclass for othercon sock_mutex
  fs: dlm: set connected bit after accept
  fs: dlm: fix mark setting deadlock
  fs: dlm: fix debugfs dump
parents 9ec1efbf 2fd8db2d
...@@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item, ...@@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item,
CONFIGFS_ATTR(cluster_, cluster_name); CONFIGFS_ATTR(cluster_, cluster_name);
static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
int *info_field, bool (*check_cb)(unsigned int x), int *info_field, int (*check_cb)(unsigned int x),
const char *buf, size_t len) const char *buf, size_t len)
{ {
unsigned int x; unsigned int x;
...@@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, ...@@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
if (rc) if (rc)
return rc; return rc;
if (check_cb && check_cb(x)) if (check_cb) {
return -EINVAL; rc = check_cb(x);
if (rc)
return rc;
}
*cl_field = x; *cl_field = x;
*info_field = x; *info_field = x;
...@@ -161,17 +164,53 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \ ...@@ -161,17 +164,53 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
} \ } \
CONFIGFS_ATTR(cluster_, name); CONFIGFS_ATTR(cluster_, name);
static bool dlm_check_zero(unsigned int x) static int dlm_check_protocol_and_dlm_running(unsigned int x)
{
switch (x) {
case 0:
/* TCP */
break;
case 1:
/* SCTP */
break;
default:
return -EINVAL;
}
if (dlm_allow_conn)
return -EBUSY;
return 0;
}
static int dlm_check_zero_and_dlm_running(unsigned int x)
{
if (!x)
return -EINVAL;
if (dlm_allow_conn)
return -EBUSY;
return 0;
}
static int dlm_check_zero(unsigned int x)
{ {
return !x; if (!x)
return -EINVAL;
return 0;
} }
static bool dlm_check_buffer_size(unsigned int x) static int dlm_check_buffer_size(unsigned int x)
{ {
return (x < DEFAULT_BUFFER_SIZE); if (x < DEFAULT_BUFFER_SIZE)
return -EINVAL;
return 0;
} }
CLUSTER_ATTR(tcp_port, dlm_check_zero); CLUSTER_ATTR(tcp_port, dlm_check_zero_and_dlm_running);
CLUSTER_ATTR(buffer_size, dlm_check_buffer_size); CLUSTER_ATTR(buffer_size, dlm_check_buffer_size);
CLUSTER_ATTR(rsbtbl_size, dlm_check_zero); CLUSTER_ATTR(rsbtbl_size, dlm_check_zero);
CLUSTER_ATTR(recover_timer, dlm_check_zero); CLUSTER_ATTR(recover_timer, dlm_check_zero);
...@@ -179,7 +218,7 @@ CLUSTER_ATTR(toss_secs, dlm_check_zero); ...@@ -179,7 +218,7 @@ CLUSTER_ATTR(toss_secs, dlm_check_zero);
CLUSTER_ATTR(scan_secs, dlm_check_zero); CLUSTER_ATTR(scan_secs, dlm_check_zero);
CLUSTER_ATTR(log_debug, NULL); CLUSTER_ATTR(log_debug, NULL);
CLUSTER_ATTR(log_info, NULL); CLUSTER_ATTR(log_info, NULL);
CLUSTER_ATTR(protocol, NULL); CLUSTER_ATTR(protocol, dlm_check_protocol_and_dlm_running);
CLUSTER_ATTR(mark, NULL); CLUSTER_ATTR(mark, NULL);
CLUSTER_ATTR(timewarn_cs, dlm_check_zero); CLUSTER_ATTR(timewarn_cs, dlm_check_zero);
CLUSTER_ATTR(waitwarn_us, NULL); CLUSTER_ATTR(waitwarn_us, NULL);
...@@ -688,6 +727,7 @@ static ssize_t comm_mark_show(struct config_item *item, char *buf) ...@@ -688,6 +727,7 @@ static ssize_t comm_mark_show(struct config_item *item, char *buf)
static ssize_t comm_mark_store(struct config_item *item, const char *buf, static ssize_t comm_mark_store(struct config_item *item, const char *buf,
size_t len) size_t len)
{ {
struct dlm_comm *comm;
unsigned int mark; unsigned int mark;
int rc; int rc;
...@@ -695,7 +735,15 @@ static ssize_t comm_mark_store(struct config_item *item, const char *buf, ...@@ -695,7 +735,15 @@ static ssize_t comm_mark_store(struct config_item *item, const char *buf,
if (rc) if (rc)
return rc; return rc;
config_item_to_comm(item)->mark = mark; if (mark == 0)
mark = dlm_config.ci_mark;
comm = config_item_to_comm(item);
rc = dlm_lowcomms_nodes_set_mark(comm->nodeid, mark);
if (rc)
return rc;
comm->mark = mark;
return len; return len;
} }
...@@ -870,24 +918,6 @@ int dlm_comm_seq(int nodeid, uint32_t *seq) ...@@ -870,24 +918,6 @@ int dlm_comm_seq(int nodeid, uint32_t *seq)
return 0; return 0;
} }
void dlm_comm_mark(int nodeid, unsigned int *mark)
{
struct dlm_comm *cm;
cm = get_comm(nodeid);
if (!cm) {
*mark = dlm_config.ci_mark;
return;
}
if (cm->mark)
*mark = cm->mark;
else
*mark = dlm_config.ci_mark;
put_comm(cm);
}
int dlm_our_nodeid(void) int dlm_our_nodeid(void)
{ {
return local_comm ? local_comm->nodeid : 0; return local_comm ? local_comm->nodeid : 0;
......
...@@ -48,7 +48,6 @@ void dlm_config_exit(void); ...@@ -48,7 +48,6 @@ void dlm_config_exit(void);
int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out, int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out,
int *count_out); int *count_out);
int dlm_comm_seq(int nodeid, uint32_t *seq); int dlm_comm_seq(int nodeid, uint32_t *seq);
void dlm_comm_mark(int nodeid, unsigned int *mark);
int dlm_our_nodeid(void); int dlm_our_nodeid(void);
int dlm_our_addr(struct sockaddr_storage *addr, int num); int dlm_our_addr(struct sockaddr_storage *addr, int num);
......
...@@ -542,6 +542,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos) ...@@ -542,6 +542,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
if (bucket >= ls->ls_rsbtbl_size) { if (bucket >= ls->ls_rsbtbl_size) {
kfree(ri); kfree(ri);
++*pos;
return NULL; return NULL;
} }
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep; tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
......
...@@ -3541,8 +3541,6 @@ static int _create_message(struct dlm_ls *ls, int mb_len, ...@@ -3541,8 +3541,6 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
if (!mh) if (!mh)
return -ENOBUFS; return -ENOBUFS;
memset(mb, 0, mb_len);
ms = (struct dlm_message *) mb; ms = (struct dlm_message *) mb;
ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
......
...@@ -404,12 +404,6 @@ static int threads_start(void) ...@@ -404,12 +404,6 @@ static int threads_start(void)
return error; return error;
} }
static void threads_stop(void)
{
dlm_scand_stop();
dlm_lowcomms_stop();
}
static int new_lockspace(const char *name, const char *cluster, static int new_lockspace(const char *name, const char *cluster,
uint32_t flags, int lvblen, uint32_t flags, int lvblen,
const struct dlm_lockspace_ops *ops, void *ops_arg, const struct dlm_lockspace_ops *ops, void *ops_arg,
...@@ -702,8 +696,11 @@ int dlm_new_lockspace(const char *name, const char *cluster, ...@@ -702,8 +696,11 @@ int dlm_new_lockspace(const char *name, const char *cluster,
ls_count++; ls_count++;
if (error > 0) if (error > 0)
error = 0; error = 0;
if (!ls_count) if (!ls_count) {
threads_stop(); dlm_scand_stop();
dlm_lowcomms_shutdown();
dlm_lowcomms_stop();
}
out: out:
mutex_unlock(&ls_lock); mutex_unlock(&ls_lock);
return error; return error;
...@@ -788,6 +785,11 @@ static int release_lockspace(struct dlm_ls *ls, int force) ...@@ -788,6 +785,11 @@ static int release_lockspace(struct dlm_ls *ls, int force)
dlm_recoverd_stop(ls); dlm_recoverd_stop(ls);
if (ls_count == 1) {
dlm_scand_stop();
dlm_lowcomms_shutdown();
}
dlm_callback_stop(ls); dlm_callback_stop(ls);
remove_lockspace(ls); remove_lockspace(ls);
...@@ -880,7 +882,7 @@ int dlm_release_lockspace(void *lockspace, int force) ...@@ -880,7 +882,7 @@ int dlm_release_lockspace(void *lockspace, int force)
if (!error) if (!error)
ls_count--; ls_count--;
if (!ls_count) if (!ls_count)
threads_stop(); dlm_lowcomms_stop();
mutex_unlock(&ls_lock); mutex_unlock(&ls_lock);
return error; return error;
......
This diff is collapsed.
...@@ -14,13 +14,18 @@ ...@@ -14,13 +14,18 @@
#define LOWCOMMS_MAX_TX_BUFFER_LEN 4096 #define LOWCOMMS_MAX_TX_BUFFER_LEN 4096
/* switch to check if dlm is running */
extern int dlm_allow_conn;
int dlm_lowcomms_start(void); int dlm_lowcomms_start(void);
void dlm_lowcomms_shutdown(void);
void dlm_lowcomms_stop(void); void dlm_lowcomms_stop(void);
void dlm_lowcomms_exit(void); void dlm_lowcomms_exit(void);
int dlm_lowcomms_close(int nodeid); int dlm_lowcomms_close(int nodeid);
void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc); void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc);
void dlm_lowcomms_commit_buffer(void *mh); void dlm_lowcomms_commit_buffer(void *mh);
int dlm_lowcomms_connect_node(int nodeid); int dlm_lowcomms_connect_node(int nodeid);
int dlm_lowcomms_nodes_set_mark(int nodeid, unsigned int mark);
int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len); int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len);
#endif /* __LOWCOMMS_DOT_H__ */ #endif /* __LOWCOMMS_DOT_H__ */
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
* into packets and sends them to the comms layer. * into packets and sends them to the comms layer.
*/ */
#include <asm/unaligned.h>
#include "dlm_internal.h" #include "dlm_internal.h"
#include "lowcomms.h" #include "lowcomms.h"
#include "config.h" #include "config.h"
...@@ -45,13 +43,22 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len) ...@@ -45,13 +43,22 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
while (len >= sizeof(struct dlm_header)) { while (len >= sizeof(struct dlm_header)) {
hd = (struct dlm_header *)ptr; hd = (struct dlm_header *)ptr;
/* no message should be more than this otherwise we /* no message should be more than DEFAULT_BUFFER_SIZE or
* cannot deliver this message to upper layers * less than dlm_header size.
*
* Some messages does not have a 8 byte length boundary yet
* which can occur in a unaligned memory access of some dlm
* messages. However this problem need to be fixed at the
* sending side, for now it seems nobody run into architecture
* related issues yet but it slows down some processing.
* Fixing this issue should be scheduled in future by doing
* the next major version bump.
*/ */
msglen = get_unaligned_le16(&hd->h_length); msglen = le16_to_cpu(hd->h_length);
if (msglen > DEFAULT_BUFFER_SIZE) { if (msglen > DEFAULT_BUFFER_SIZE ||
log_print("received invalid length header: %u, will abort message parsing", msglen < sizeof(struct dlm_header)) {
msglen); log_print("received invalid length header: %u from node %d, will abort message parsing",
msglen, nodeid);
return -EBADMSG; return -EBADMSG;
} }
...@@ -84,15 +91,7 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len) ...@@ -84,15 +91,7 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
goto skip; goto skip;
} }
/* for aligned memory access, we just copy current message dlm_receive_buffer((union dlm_packet *)ptr, nodeid);
* to begin of the buffer which contains already parsed buffer
* data and should provide align access for upper layers
* because the start address of the buffer has a aligned
* address. This memmove can be removed when the upperlayer
* is capable of unaligned memory access.
*/
memmove(buf, ptr, msglen);
dlm_receive_buffer((union dlm_packet *)buf, nodeid);
skip: skip:
ret += msglen; ret += msglen;
......
...@@ -41,7 +41,6 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len, ...@@ -41,7 +41,6 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
to_nodeid, type, len); to_nodeid, type, len);
return -ENOBUFS; return -ENOBUFS;
} }
memset(mb, 0, mb_len);
rc = (struct dlm_rcom *) mb; rc = (struct dlm_rcom *) mb;
...@@ -462,7 +461,6 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) ...@@ -462,7 +461,6 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_NOFS, &mb); mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_NOFS, &mb);
if (!mh) if (!mh)
return -ENOBUFS; return -ENOBUFS;
memset(mb, 0, mb_len);
rc = (struct dlm_rcom *) mb; rc = (struct dlm_rcom *) mb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment