Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Linus Torvalds committed Jun 12, 2009
2 parents 4ddbac9 + 748285c commit c53567a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
7 changes: 4 additions & 3 deletions fs/dlm/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
spin_unlock(&ls->ls_recover_list_lock);

if (!found)
de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_KERNEL);
de = kzalloc(sizeof(struct dlm_direntry) + len,
ls->ls_allocation);
return de;
}

Expand Down Expand Up @@ -211,7 +212,7 @@ int dlm_recover_directory(struct dlm_ls *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)
goto out;

Expand Down Expand Up @@ -322,7 +323,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
if (namelen > DLM_RESNAME_MAXLEN)
return -EINVAL;

de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL);
de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation);
if (!de)
return -ENOMEM;

Expand Down
17 changes: 8 additions & 9 deletions fs/dlm/lockspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static void threads_stop(void)
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)
{
struct dlm_ls *ls;
Expand Down Expand Up @@ -419,16 +419,14 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
break;
}
ls->ls_create_count++;
module_put(THIS_MODULE);
error = 1; /* not an error, return 0 */
*lockspace = ls;
error = 1;
break;
}
spin_unlock(&lslist_lock);

if (error < 0)
goto out;
if (error)
goto ret_zero;
goto out;

error = -ENOMEM;

Expand Down Expand Up @@ -583,7 +581,6 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
dlm_create_debug_file(ls);

log_debug(ls, "join complete");
ret_zero:
*lockspace = ls;
return 0;

Expand Down Expand Up @@ -614,7 +611,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
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)
{
int error = 0;
Expand All @@ -628,7 +625,9 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace,
error = new_lockspace(name, namelen, lockspace, flags, lvblen);
if (!error)
ls_count++;
else if (!ls_count)
if (error > 0)
error = 0;
if (!ls_count)
threads_stop();
out:
mutex_unlock(&ls_lock);
Expand Down
22 changes: 18 additions & 4 deletions fs/dlm/lowcomms.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,20 @@ static void lowcomms_state_change(struct sock *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 */
static int add_sock(struct socket *sock, struct connection *con)
{
Expand Down Expand Up @@ -486,7 +500,7 @@ static void process_sctp_notification(struct connection *con,
return;
}

new_con = nodeid2con(nodeid, GFP_KERNEL);
new_con = nodeid2con(nodeid, GFP_NOFS);
if (!new_con)
return;

Expand Down Expand Up @@ -722,7 +736,7 @@ static int tcp_accept_from_sock(struct connection *con)
* the same time and the connections cross on the wire.
* In this case we store the incoming one in "othercon"
*/
newcon = nodeid2con(nodeid, GFP_KERNEL);
newcon = nodeid2con(nodeid, GFP_NOFS);
if (!newcon) {
result = -ENOMEM;
goto accept_err;
Expand All @@ -732,7 +746,7 @@ static int tcp_accept_from_sock(struct connection *con)
struct connection *othercon = newcon->othercon;

if (!othercon) {
othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL);
othercon = kmem_cache_zalloc(con_cache, GFP_NOFS);
if (!othercon) {
log_print("failed to allocate incoming socket");
mutex_unlock(&newcon->sock_mutex);
Expand Down Expand Up @@ -1421,7 +1435,7 @@ static int work_start(void)
static void stop_conn(struct connection *con)
{
con->flags |= 0x0F;
if (con->sock)
if (con->sock && con->sock->sk)
con->sock->sk->sk_user_data = NULL;
}

Expand Down
3 changes: 2 additions & 1 deletion fs/dlm/lowcomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*******************************************************************************
**
** 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,
** modify, copy, or redistribute it subject to the terms and conditions
Expand All @@ -19,6 +19,7 @@ void dlm_lowcomms_stop(void);
int dlm_lowcomms_close(int nodeid);
void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc);
void dlm_lowcomms_commit_buffer(void *mh);
int dlm_lowcomms_connect_node(int nodeid);

#endif /* __LOWCOMMS_DOT_H__ */

19 changes: 13 additions & 6 deletions fs/dlm/member.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
*******************************************************************************
**
** 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,
** modify, copy, or redistribute it subject to the terms and conditions
Expand All @@ -17,6 +17,7 @@
#include "recover.h"
#include "rcom.h"
#include "config.h"
#include "lowcomms.h"

static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
{
Expand Down Expand Up @@ -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)
{
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)
return -ENOMEM;

Expand All @@ -57,6 +58,12 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid)
return w;
}

error = dlm_lowcomms_connect_node(nodeid);
if (error < 0) {
kfree(memb);
return error;
}

memb->nodeid = nodeid;
memb->weight = w;
add_ordered_member(ls, memb);
Expand Down Expand Up @@ -136,7 +143,7 @@ static void make_member_array(struct dlm_ls *ls)

ls->ls_total_weight = total;

array = kmalloc(sizeof(int) * total, GFP_KERNEL);
array = kmalloc(sizeof(int) * total, ls->ls_allocation);
if (!array)
return;

Expand Down Expand Up @@ -219,7 +226,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
continue;
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)
return -ENOMEM;
memb->nodeid = rv->new[i];
Expand Down Expand Up @@ -334,7 +341,7 @@ int dlm_ls_start(struct dlm_ls *ls)
int *ids = NULL, *new = NULL;
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)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion fs/dlm/requestqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
struct rq_entry *e;
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) {
log_print("dlm_add_requestqueue: out of memory len %d", length);
return;
Expand Down
4 changes: 2 additions & 2 deletions include/linux/dlm.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ struct dlm_lksb {
* the cluster, the calling node joins it.
*/

int dlm_new_lockspace(char *name, int namelen, dlm_lockspace_t **lockspace,
uint32_t flags, int lvblen);
int dlm_new_lockspace(const char *name, int namelen,
dlm_lockspace_t **lockspace, uint32_t flags, int lvblen);

/*
* dlm_release_lockspace
Expand Down

0 comments on commit c53567a

Please sign in to comment.