Commit c53567ad authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm:
  dlm: use more NOFS allocation
  dlm: connect to nodes earlier
  dlm: fix use count with multiple joins
  dlm: Make name input parameter of {,dlm_}new_lockspace() const
parents 4ddbac98 748285cc
...@@ -49,7 +49,8 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len) ...@@ -49,7 +49,8 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
spin_unlock(&ls->ls_recover_list_lock); spin_unlock(&ls->ls_recover_list_lock);
if (!found) if (!found)
de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_KERNEL); de = kzalloc(sizeof(struct dlm_direntry) + len,
ls->ls_allocation);
return de; return de;
} }
...@@ -211,7 +212,7 @@ int dlm_recover_directory(struct dlm_ls *ls) ...@@ -211,7 +212,7 @@ int dlm_recover_directory(struct dlm_ls *ls)
dlm_dir_clear(ls); dlm_dir_clear(ls);
last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_KERNEL); last_name = kmalloc(DLM_RESNAME_MAXLEN, ls->ls_allocation);
if (!last_name) if (!last_name)
goto out; goto out;
...@@ -322,7 +323,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, ...@@ -322,7 +323,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
if (namelen > DLM_RESNAME_MAXLEN) if (namelen > DLM_RESNAME_MAXLEN)
return -EINVAL; return -EINVAL;
de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL); de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation);
if (!de) if (!de)
return -ENOMEM; return -ENOMEM;
......
...@@ -384,7 +384,7 @@ static void threads_stop(void) ...@@ -384,7 +384,7 @@ static void threads_stop(void)
dlm_astd_stop(); dlm_astd_stop();
} }
static int new_lockspace(char *name, int namelen, void **lockspace, static int new_lockspace(const char *name, int namelen, void **lockspace,
uint32_t flags, int lvblen) uint32_t flags, int lvblen)
{ {
struct dlm_ls *ls; struct dlm_ls *ls;
...@@ -419,16 +419,14 @@ static int new_lockspace(char *name, int namelen, void **lockspace, ...@@ -419,16 +419,14 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
break; break;
} }
ls->ls_create_count++; ls->ls_create_count++;
module_put(THIS_MODULE); *lockspace = ls;
error = 1; /* not an error, return 0 */ error = 1;
break; break;
} }
spin_unlock(&lslist_lock); spin_unlock(&lslist_lock);
if (error < 0)
goto out;
if (error) if (error)
goto ret_zero; goto out;
error = -ENOMEM; error = -ENOMEM;
...@@ -583,7 +581,6 @@ static int new_lockspace(char *name, int namelen, void **lockspace, ...@@ -583,7 +581,6 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
dlm_create_debug_file(ls); dlm_create_debug_file(ls);
log_debug(ls, "join complete"); log_debug(ls, "join complete");
ret_zero:
*lockspace = ls; *lockspace = ls;
return 0; return 0;
...@@ -614,7 +611,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace, ...@@ -614,7 +611,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
return error; return error;
} }
int dlm_new_lockspace(char *name, int namelen, void **lockspace, int dlm_new_lockspace(const char *name, int namelen, void **lockspace,
uint32_t flags, int lvblen) uint32_t flags, int lvblen)
{ {
int error = 0; int error = 0;
...@@ -628,7 +625,9 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace, ...@@ -628,7 +625,9 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace,
error = new_lockspace(name, namelen, lockspace, flags, lvblen); error = new_lockspace(name, namelen, lockspace, flags, lvblen);
if (!error) if (!error)
ls_count++; ls_count++;
else if (!ls_count) if (error > 0)
error = 0;
if (!ls_count)
threads_stop(); threads_stop();
out: out:
mutex_unlock(&ls_lock); mutex_unlock(&ls_lock);
......
...@@ -309,6 +309,20 @@ static void lowcomms_state_change(struct sock *sk) ...@@ -309,6 +309,20 @@ static void lowcomms_state_change(struct sock *sk)
lowcomms_write_space(sk); lowcomms_write_space(sk);
} }
int dlm_lowcomms_connect_node(int nodeid)
{
struct connection *con;
if (nodeid == dlm_our_nodeid())
return 0;
con = nodeid2con(nodeid, GFP_NOFS);
if (!con)
return -ENOMEM;
lowcomms_connect_sock(con);
return 0;
}
/* Make a socket active */ /* Make a socket active */
static int add_sock(struct socket *sock, struct connection *con) static int add_sock(struct socket *sock, struct connection *con)
{ {
...@@ -486,7 +500,7 @@ static void process_sctp_notification(struct connection *con, ...@@ -486,7 +500,7 @@ static void process_sctp_notification(struct connection *con,
return; return;
} }
new_con = nodeid2con(nodeid, GFP_KERNEL); new_con = nodeid2con(nodeid, GFP_NOFS);
if (!new_con) if (!new_con)
return; return;
...@@ -722,7 +736,7 @@ static int tcp_accept_from_sock(struct connection *con) ...@@ -722,7 +736,7 @@ static int tcp_accept_from_sock(struct connection *con)
* the same time and the connections cross on the wire. * the same time and the connections cross on the wire.
* In this case we store the incoming one in "othercon" * In this case we store the incoming one in "othercon"
*/ */
newcon = nodeid2con(nodeid, GFP_KERNEL); newcon = nodeid2con(nodeid, GFP_NOFS);
if (!newcon) { if (!newcon) {
result = -ENOMEM; result = -ENOMEM;
goto accept_err; goto accept_err;
...@@ -732,7 +746,7 @@ static int tcp_accept_from_sock(struct connection *con) ...@@ -732,7 +746,7 @@ static int tcp_accept_from_sock(struct connection *con)
struct connection *othercon = newcon->othercon; struct connection *othercon = newcon->othercon;
if (!othercon) { if (!othercon) {
othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL); othercon = kmem_cache_zalloc(con_cache, GFP_NOFS);
if (!othercon) { if (!othercon) {
log_print("failed to allocate incoming socket"); log_print("failed to allocate incoming socket");
mutex_unlock(&newcon->sock_mutex); mutex_unlock(&newcon->sock_mutex);
...@@ -1421,7 +1435,7 @@ static int work_start(void) ...@@ -1421,7 +1435,7 @@ static int work_start(void)
static void stop_conn(struct connection *con) static void stop_conn(struct connection *con)
{ {
con->flags |= 0x0F; con->flags |= 0x0F;
if (con->sock) if (con->sock && con->sock->sk)
con->sock->sk->sk_user_data = NULL; con->sock->sk->sk_user_data = NULL;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
******************************************************************************* *******************************************************************************
** **
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -19,6 +19,7 @@ void dlm_lowcomms_stop(void); ...@@ -19,6 +19,7 @@ void dlm_lowcomms_stop(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);
#endif /* __LOWCOMMS_DOT_H__ */ #endif /* __LOWCOMMS_DOT_H__ */
/****************************************************************************** /******************************************************************************
******************************************************************************* *******************************************************************************
** **
** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. ** Copyright (C) 2005-2009 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "recover.h" #include "recover.h"
#include "rcom.h" #include "rcom.h"
#include "config.h" #include "config.h"
#include "lowcomms.h"
static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new) static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
{ {
...@@ -45,9 +46,9 @@ static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new) ...@@ -45,9 +46,9 @@ static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
static int dlm_add_member(struct dlm_ls *ls, int nodeid) static int dlm_add_member(struct dlm_ls *ls, int nodeid)
{ {
struct dlm_member *memb; struct dlm_member *memb;
int w; int w, error;
memb = kzalloc(sizeof(struct dlm_member), GFP_KERNEL); memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation);
if (!memb) if (!memb)
return -ENOMEM; return -ENOMEM;
...@@ -57,6 +58,12 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid) ...@@ -57,6 +58,12 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid)
return w; return w;
} }
error = dlm_lowcomms_connect_node(nodeid);
if (error < 0) {
kfree(memb);
return error;
}
memb->nodeid = nodeid; memb->nodeid = nodeid;
memb->weight = w; memb->weight = w;
add_ordered_member(ls, memb); add_ordered_member(ls, memb);
...@@ -136,7 +143,7 @@ static void make_member_array(struct dlm_ls *ls) ...@@ -136,7 +143,7 @@ static void make_member_array(struct dlm_ls *ls)
ls->ls_total_weight = total; ls->ls_total_weight = total;
array = kmalloc(sizeof(int) * total, GFP_KERNEL); array = kmalloc(sizeof(int) * total, ls->ls_allocation);
if (!array) if (!array)
return; return;
...@@ -219,7 +226,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) ...@@ -219,7 +226,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
continue; continue;
log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]); log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]);
memb = kzalloc(sizeof(struct dlm_member), GFP_KERNEL); memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation);
if (!memb) if (!memb)
return -ENOMEM; return -ENOMEM;
memb->nodeid = rv->new[i]; memb->nodeid = rv->new[i];
...@@ -334,7 +341,7 @@ int dlm_ls_start(struct dlm_ls *ls) ...@@ -334,7 +341,7 @@ int dlm_ls_start(struct dlm_ls *ls)
int *ids = NULL, *new = NULL; int *ids = NULL, *new = NULL;
int error, ids_count = 0, new_count = 0; int error, ids_count = 0, new_count = 0;
rv = kzalloc(sizeof(struct dlm_recover), GFP_KERNEL); rv = kzalloc(sizeof(struct dlm_recover), ls->ls_allocation);
if (!rv) if (!rv)
return -ENOMEM; return -ENOMEM;
......
...@@ -35,7 +35,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms) ...@@ -35,7 +35,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
struct rq_entry *e; struct rq_entry *e;
int length = ms->m_header.h_length - sizeof(struct dlm_message); int length = ms->m_header.h_length - sizeof(struct dlm_message);
e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); e = kmalloc(sizeof(struct rq_entry) + length, ls->ls_allocation);
if (!e) { if (!e) {
log_print("dlm_add_requestqueue: out of memory len %d", length); log_print("dlm_add_requestqueue: out of memory len %d", length);
return; return;
......
...@@ -81,8 +81,8 @@ struct dlm_lksb { ...@@ -81,8 +81,8 @@ struct dlm_lksb {
* the cluster, the calling node joins it. * the cluster, the calling node joins it.
*/ */
int dlm_new_lockspace(char *name, int namelen, dlm_lockspace_t **lockspace, int dlm_new_lockspace(const char *name, int namelen,
uint32_t flags, int lvblen); dlm_lockspace_t **lockspace, uint32_t flags, int lvblen);
/* /*
* dlm_release_lockspace * dlm_release_lockspace
......
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