ocfs2: set gap to seperate entry and value when xattr in bucket
[safe/jmp/linux-2.6] / fs / dlm / config.c
index 8665c88..fd9859f 100644 (file)
@@ -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-2008 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
@@ -14,6 +14,9 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/configfs.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <net/ipv6.h>
 #include <net/sock.h>
 
 #include "config.h"
 
 static struct config_group *space_list;
 static struct config_group *comm_list;
-static struct comm *local_comm;
+static struct dlm_comm *local_comm;
 
-struct clusters;
-struct cluster;
-struct spaces;
-struct space;
-struct comms;
-struct comm;
-struct nodes;
-struct node;
+struct dlm_clusters;
+struct dlm_cluster;
+struct dlm_spaces;
+struct dlm_space;
+struct dlm_comms;
+struct dlm_comm;
+struct dlm_nodes;
+struct dlm_node;
 
 static struct config_group *make_cluster(struct config_group *, const char *);
 static void drop_cluster(struct config_group *, struct config_item *);
@@ -68,17 +71,22 @@ static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
 static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
                          const char *buf, size_t len);
 
-static ssize_t comm_nodeid_read(struct comm *cm, char *buf);
-static ssize_t comm_nodeid_write(struct comm *cm, const char *buf, size_t len);
-static ssize_t comm_local_read(struct comm *cm, char *buf);
-static ssize_t comm_local_write(struct comm *cm, const char *buf, size_t len);
-static ssize_t comm_addr_write(struct comm *cm, const char *buf, size_t len);
-static ssize_t node_nodeid_read(struct node *nd, char *buf);
-static ssize_t node_nodeid_write(struct node *nd, const char *buf, size_t len);
-static ssize_t node_weight_read(struct node *nd, char *buf);
-static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len);
-
-struct cluster {
+static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf);
+static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf,
+                               size_t len);
+static ssize_t comm_local_read(struct dlm_comm *cm, char *buf);
+static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
+                               size_t len);
+static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf,
+                               size_t len);
+static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf);
+static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
+                               size_t len);
+static ssize_t node_weight_read(struct dlm_node *nd, char *buf);
+static ssize_t node_weight_write(struct dlm_node *nd, const char *buf,
+                               size_t len);
+
+struct dlm_cluster {
        struct config_group group;
        unsigned int cl_tcp_port;
        unsigned int cl_buffer_size;
@@ -89,6 +97,8 @@ struct cluster {
        unsigned int cl_toss_secs;
        unsigned int cl_scan_secs;
        unsigned int cl_log_debug;
+       unsigned int cl_protocol;
+       unsigned int cl_timewarn_cs;
 };
 
 enum {
@@ -101,16 +111,18 @@ enum {
        CLUSTER_ATTR_TOSS_SECS,
        CLUSTER_ATTR_SCAN_SECS,
        CLUSTER_ATTR_LOG_DEBUG,
+       CLUSTER_ATTR_PROTOCOL,
+       CLUSTER_ATTR_TIMEWARN_CS,
 };
 
 struct cluster_attribute {
        struct configfs_attribute attr;
-       ssize_t (*show)(struct cluster *, char *);
-       ssize_t (*store)(struct cluster *, const char *, size_t);
+       ssize_t (*show)(struct dlm_cluster *, char *);
+       ssize_t (*store)(struct dlm_cluster *, const char *, size_t);
 };
 
-static ssize_t cluster_set(struct cluster *cl, unsigned int *cl_field,
-                          unsigned int *info_field, int check_zero,
+static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
+                          int *info_field, int check_zero,
                           const char *buf, size_t len)
 {
        unsigned int x;
@@ -129,21 +141,13 @@ static ssize_t cluster_set(struct cluster *cl, unsigned int *cl_field,
        return len;
 }
 
-#define __CONFIGFS_ATTR(_name,_mode,_read,_write) {                           \
-       .attr   = { .ca_name = __stringify(_name),                            \
-                   .ca_mode = _mode,                                         \
-                   .ca_owner = THIS_MODULE },                                \
-       .show   = _read,                                                      \
-       .store  = _write,                                                     \
-}
-
 #define CLUSTER_ATTR(name, check_zero)                                        \
-static ssize_t name##_write(struct cluster *cl, const char *buf, size_t len)  \
+static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t len) \
 {                                                                             \
        return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name,         \
                           check_zero, buf, len);                             \
 }                                                                             \
-static ssize_t name##_read(struct cluster *cl, char *buf)                     \
+static ssize_t name##_read(struct dlm_cluster *cl, char *buf)                 \
 {                                                                             \
        return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name);               \
 }                                                                             \
@@ -159,6 +163,8 @@ CLUSTER_ATTR(recover_timer, 1);
 CLUSTER_ATTR(toss_secs, 1);
 CLUSTER_ATTR(scan_secs, 1);
 CLUSTER_ATTR(log_debug, 0);
+CLUSTER_ATTR(protocol, 0);
+CLUSTER_ATTR(timewarn_cs, 1);
 
 static struct configfs_attribute *cluster_attrs[] = {
        [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr,
@@ -170,6 +176,8 @@ static struct configfs_attribute *cluster_attrs[] = {
        [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr,
        [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr,
        [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr,
+       [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol.attr,
+       [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr,
        NULL,
 };
 
@@ -181,8 +189,8 @@ enum {
 
 struct comm_attribute {
        struct configfs_attribute attr;
-       ssize_t (*show)(struct comm *, char *);
-       ssize_t (*store)(struct comm *, const char *, size_t);
+       ssize_t (*show)(struct dlm_comm *, char *);
+       ssize_t (*store)(struct dlm_comm *, const char *, size_t);
 };
 
 static struct comm_attribute comm_attr_nodeid = {
@@ -222,8 +230,8 @@ enum {
 
 struct node_attribute {
        struct configfs_attribute attr;
-       ssize_t (*show)(struct node *, char *);
-       ssize_t (*store)(struct node *, const char *, size_t);
+       ssize_t (*show)(struct dlm_node *, char *);
+       ssize_t (*store)(struct dlm_node *, const char *, size_t);
 };
 
 static struct node_attribute node_attr_nodeid = {
@@ -248,26 +256,26 @@ static struct configfs_attribute *node_attrs[] = {
        NULL,
 };
 
-struct clusters {
+struct dlm_clusters {
        struct configfs_subsystem subsys;
 };
 
-struct spaces {
+struct dlm_spaces {
        struct config_group ss_group;
 };
 
-struct space {
+struct dlm_space {
        struct config_group group;
        struct list_head members;
        struct mutex members_lock;
        int members_count;
 };
 
-struct comms {
+struct dlm_comms {
        struct config_group cs_group;
 };
 
-struct comm {
+struct dlm_comm {
        struct config_item item;
        int nodeid;
        int local;
@@ -275,15 +283,16 @@ struct comm {
        struct sockaddr_storage *addr[DLM_MAX_ADDR_COUNT];
 };
 
-struct nodes {
+struct dlm_nodes {
        struct config_group ns_group;
 };
 
-struct node {
+struct dlm_node {
        struct config_item item;
        struct list_head list; /* space->members */
        int nodeid;
        int weight;
+       int new;
 };
 
 static struct configfs_group_operations clusters_ops = {
@@ -371,38 +380,40 @@ static struct config_item_type node_type = {
        .ct_owner = THIS_MODULE,
 };
 
-static struct cluster *to_cluster(struct config_item *i)
+static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
 {
-       return i ? container_of(to_config_group(i), struct cluster, group):NULL;
+       return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
+                  NULL;
 }
 
-static struct space *to_space(struct config_item *i)
+static struct dlm_space *config_item_to_space(struct config_item *i)
 {
-       return i ? container_of(to_config_group(i), struct space, group) : NULL;
+       return i ? container_of(to_config_group(i), struct dlm_space, group) :
+                  NULL;
 }
 
-static struct comm *to_comm(struct config_item *i)
+static struct dlm_comm *config_item_to_comm(struct config_item *i)
 {
-       return i ? container_of(i, struct comm, item) : NULL;
+       return i ? container_of(i, struct dlm_comm, item) : NULL;
 }
 
-static struct node *to_node(struct config_item *i)
+static struct dlm_node *config_item_to_node(struct config_item *i)
 {
-       return i ? container_of(i, struct node, item) : NULL;
+       return i ? container_of(i, struct dlm_node, item) : NULL;
 }
 
 static struct config_group *make_cluster(struct config_group *g,
                                         const char *name)
 {
-       struct cluster *cl = NULL;
-       struct spaces *sps = NULL;
-       struct comms *cms = NULL;
+       struct dlm_cluster *cl = NULL;
+       struct dlm_spaces *sps = NULL;
+       struct dlm_comms *cms = NULL;
        void *gps = NULL;
 
-       cl = kzalloc(sizeof(struct cluster), GFP_KERNEL);
+       cl = kzalloc(sizeof(struct dlm_cluster), GFP_KERNEL);
        gps = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL);
-       sps = kzalloc(sizeof(struct spaces), GFP_KERNEL);
-       cms = kzalloc(sizeof(struct comms), GFP_KERNEL);
+       sps = kzalloc(sizeof(struct dlm_spaces), GFP_KERNEL);
+       cms = kzalloc(sizeof(struct dlm_comms), GFP_KERNEL);
 
        if (!cl || !gps || !sps || !cms)
                goto fail;
@@ -425,6 +436,8 @@ static struct config_group *make_cluster(struct config_group *g,
        cl->cl_toss_secs = dlm_config.ci_toss_secs;
        cl->cl_scan_secs = dlm_config.ci_scan_secs;
        cl->cl_log_debug = dlm_config.ci_log_debug;
+       cl->cl_protocol = dlm_config.ci_protocol;
+       cl->cl_timewarn_cs = dlm_config.ci_timewarn_cs;
 
        space_list = &sps->ss_group;
        comm_list = &cms->cs_group;
@@ -435,12 +448,12 @@ static struct config_group *make_cluster(struct config_group *g,
        kfree(gps);
        kfree(sps);
        kfree(cms);
-       return NULL;
+       return ERR_PTR(-ENOMEM);
 }
 
 static void drop_cluster(struct config_group *g, struct config_item *i)
 {
-       struct cluster *cl = to_cluster(i);
+       struct dlm_cluster *cl = config_item_to_cluster(i);
        struct config_item *tmp;
        int j;
 
@@ -458,20 +471,20 @@ static void drop_cluster(struct config_group *g, struct config_item *i)
 
 static void release_cluster(struct config_item *i)
 {
-       struct cluster *cl = to_cluster(i);
+       struct dlm_cluster *cl = config_item_to_cluster(i);
        kfree(cl->group.default_groups);
        kfree(cl);
 }
 
 static struct config_group *make_space(struct config_group *g, const char *name)
 {
-       struct space *sp = NULL;
-       struct nodes *nds = NULL;
+       struct dlm_space *sp = NULL;
+       struct dlm_nodes *nds = NULL;
        void *gps = NULL;
 
-       sp = kzalloc(sizeof(struct space), GFP_KERNEL);
+       sp = kzalloc(sizeof(struct dlm_space), GFP_KERNEL);
        gps = kcalloc(2, sizeof(struct config_group *), GFP_KERNEL);
-       nds = kzalloc(sizeof(struct nodes), GFP_KERNEL);
+       nds = kzalloc(sizeof(struct dlm_nodes), GFP_KERNEL);
 
        if (!sp || !gps || !nds)
                goto fail;
@@ -492,12 +505,12 @@ static struct config_group *make_space(struct config_group *g, const char *name)
        kfree(sp);
        kfree(gps);
        kfree(nds);
-       return NULL;
+       return ERR_PTR(-ENOMEM);
 }
 
 static void drop_space(struct config_group *g, struct config_item *i)
 {
-       struct space *sp = to_space(i);
+       struct dlm_space *sp = config_item_to_space(i);
        struct config_item *tmp;
        int j;
 
@@ -514,18 +527,18 @@ static void drop_space(struct config_group *g, struct config_item *i)
 
 static void release_space(struct config_item *i)
 {
-       struct space *sp = to_space(i);
+       struct dlm_space *sp = config_item_to_space(i);
        kfree(sp->group.default_groups);
        kfree(sp);
 }
 
 static struct config_item *make_comm(struct config_group *g, const char *name)
 {
-       struct comm *cm;
+       struct dlm_comm *cm;
 
-       cm = kzalloc(sizeof(struct comm), GFP_KERNEL);
+       cm = kzalloc(sizeof(struct dlm_comm), GFP_KERNEL);
        if (!cm)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        config_item_init_type_name(&cm->item, name, &comm_type);
        cm->nodeid = -1;
@@ -536,7 +549,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
 
 static void drop_comm(struct config_group *g, struct config_item *i)
 {
-       struct comm *cm = to_comm(i);
+       struct dlm_comm *cm = config_item_to_comm(i);
        if (local_comm == cm)
                local_comm = NULL;
        dlm_lowcomms_close(cm->nodeid);
@@ -547,22 +560,23 @@ static void drop_comm(struct config_group *g, struct config_item *i)
 
 static void release_comm(struct config_item *i)
 {
-       struct comm *cm = to_comm(i);
+       struct dlm_comm *cm = config_item_to_comm(i);
        kfree(cm);
 }
 
 static struct config_item *make_node(struct config_group *g, const char *name)
 {
-       struct space *sp = to_space(g->cg_item.ci_parent);
-       struct node *nd;
+       struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
+       struct dlm_node *nd;
 
-       nd = kzalloc(sizeof(struct node), GFP_KERNEL);
+       nd = kzalloc(sizeof(struct dlm_node), GFP_KERNEL);
        if (!nd)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        config_item_init_type_name(&nd->item, name, &node_type);
        nd->nodeid = -1;
        nd->weight = 1;  /* default weight of 1 if none is set */
+       nd->new = 1;     /* set to 0 once it's been read by dlm_nodeid_list() */
 
        mutex_lock(&sp->members_lock);
        list_add(&nd->list, &sp->members);
@@ -574,8 +588,8 @@ static struct config_item *make_node(struct config_group *g, const char *name)
 
 static void drop_node(struct config_group *g, struct config_item *i)
 {
-       struct space *sp = to_space(g->cg_item.ci_parent);
-       struct node *nd = to_node(i);
+       struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
+       struct dlm_node *nd = config_item_to_node(i);
 
        mutex_lock(&sp->members_lock);
        list_del(&nd->list);
@@ -587,11 +601,11 @@ static void drop_node(struct config_group *g, struct config_item *i)
 
 static void release_node(struct config_item *i)
 {
-       struct node *nd = to_node(i);
+       struct dlm_node *nd = config_item_to_node(i);
        kfree(nd);
 }
 
-static struct clusters clusters_root = {
+static struct dlm_clusters clusters_root = {
        .subsys = {
                .su_group = {
                        .cg_item = {
@@ -602,10 +616,10 @@ static struct clusters clusters_root = {
        },
 };
 
-int dlm_config_init(void)
+int __init dlm_config_init(void)
 {
        config_group_init(&clusters_root.subsys.su_group);
-       init_MUTEX(&clusters_root.subsys.su_sem);
+       mutex_init(&clusters_root.subsys.su_mutex);
        return configfs_register_subsystem(&clusters_root.subsys);
 }
 
@@ -621,7 +635,7 @@ void dlm_config_exit(void)
 static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a,
                            char *buf)
 {
-       struct cluster *cl = to_cluster(i);
+       struct dlm_cluster *cl = config_item_to_cluster(i);
        struct cluster_attribute *cla =
                        container_of(a, struct cluster_attribute, attr);
        return cla->show ? cla->show(cl, buf) : 0;
@@ -631,7 +645,7 @@ static ssize_t store_cluster(struct config_item *i,
                             struct configfs_attribute *a,
                             const char *buf, size_t len)
 {
-       struct cluster *cl = to_cluster(i);
+       struct dlm_cluster *cl = config_item_to_cluster(i);
        struct cluster_attribute *cla =
                container_of(a, struct cluster_attribute, attr);
        return cla->store ? cla->store(cl, buf, len) : -EINVAL;
@@ -640,7 +654,7 @@ static ssize_t store_cluster(struct config_item *i,
 static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
                         char *buf)
 {
-       struct comm *cm = to_comm(i);
+       struct dlm_comm *cm = config_item_to_comm(i);
        struct comm_attribute *cma =
                        container_of(a, struct comm_attribute, attr);
        return cma->show ? cma->show(cm, buf) : 0;
@@ -649,29 +663,31 @@ static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
 static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a,
                          const char *buf, size_t len)
 {
-       struct comm *cm = to_comm(i);
+       struct dlm_comm *cm = config_item_to_comm(i);
        struct comm_attribute *cma =
                container_of(a, struct comm_attribute, attr);
        return cma->store ? cma->store(cm, buf, len) : -EINVAL;
 }
 
-static ssize_t comm_nodeid_read(struct comm *cm, char *buf)
+static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf)
 {
        return sprintf(buf, "%d\n", cm->nodeid);
 }
 
-static ssize_t comm_nodeid_write(struct comm *cm, const char *buf, size_t len)
+static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf,
+                                size_t len)
 {
        cm->nodeid = simple_strtol(buf, NULL, 0);
        return len;
 }
 
-static ssize_t comm_local_read(struct comm *cm, char *buf)
+static ssize_t comm_local_read(struct dlm_comm *cm, char *buf)
 {
        return sprintf(buf, "%d\n", cm->local);
 }
 
-static ssize_t comm_local_write(struct comm *cm, const char *buf, size_t len)
+static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
+                               size_t len)
 {
        cm->local= simple_strtol(buf, NULL, 0);
        if (cm->local && !local_comm)
@@ -679,7 +695,7 @@ static ssize_t comm_local_write(struct comm *cm, const char *buf, size_t len)
        return len;
 }
 
-static ssize_t comm_addr_write(struct comm *cm, const char *buf, size_t len)
+static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
 {
        struct sockaddr_storage *addr;
 
@@ -701,7 +717,7 @@ static ssize_t comm_addr_write(struct comm *cm, const char *buf, size_t len)
 static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
                         char *buf)
 {
-       struct node *nd = to_node(i);
+       struct dlm_node *nd = config_item_to_node(i);
        struct node_attribute *nda =
                        container_of(a, struct node_attribute, attr);
        return nda->show ? nda->show(nd, buf) : 0;
@@ -710,29 +726,31 @@ static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
 static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
                          const char *buf, size_t len)
 {
-       struct node *nd = to_node(i);
+       struct dlm_node *nd = config_item_to_node(i);
        struct node_attribute *nda =
                container_of(a, struct node_attribute, attr);
        return nda->store ? nda->store(nd, buf, len) : -EINVAL;
 }
 
-static ssize_t node_nodeid_read(struct node *nd, char *buf)
+static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf)
 {
        return sprintf(buf, "%d\n", nd->nodeid);
 }
 
-static ssize_t node_nodeid_write(struct node *nd, const char *buf, size_t len)
+static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
+                                size_t len)
 {
        nd->nodeid = simple_strtol(buf, NULL, 0);
        return len;
 }
 
-static ssize_t node_weight_read(struct node *nd, char *buf)
+static ssize_t node_weight_read(struct dlm_node *nd, char *buf)
 {
        return sprintf(buf, "%d\n", nd->weight);
 }
 
-static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)
+static ssize_t node_weight_write(struct dlm_node *nd, const char *buf,
+                                size_t len)
 {
        nd->weight = simple_strtol(buf, NULL, 0);
        return len;
@@ -742,66 +760,100 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)
  * Functions for the dlm to get the info that's been configured
  */
 
-static struct space *get_space(char *name)
+static struct dlm_space *get_space(char *name)
 {
+       struct config_item *i;
+
        if (!space_list)
                return NULL;
-       return to_space(config_group_find_obj(space_list, name));
+
+       mutex_lock(&space_list->cg_subsys->su_mutex);
+       i = config_group_find_item(space_list, name);
+       mutex_unlock(&space_list->cg_subsys->su_mutex);
+
+       return config_item_to_space(i);
 }
 
-static void put_space(struct space *sp)
+static void put_space(struct dlm_space *sp)
 {
        config_item_put(&sp->group.cg_item);
 }
 
-static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr)
+static int addr_compare(struct sockaddr_storage *x, struct sockaddr_storage *y)
+{
+       switch (x->ss_family) {
+       case AF_INET: {
+               struct sockaddr_in *sinx = (struct sockaddr_in *)x;
+               struct sockaddr_in *siny = (struct sockaddr_in *)y;
+               if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr)
+                       return 0;
+               if (sinx->sin_port != siny->sin_port)
+                       return 0;
+               break;
+       }
+       case AF_INET6: {
+               struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x;
+               struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y;
+               if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr))
+                       return 0;
+               if (sinx->sin6_port != siny->sin6_port)
+                       return 0;
+               break;
+       }
+       default:
+               return 0;
+       }
+       return 1;
+}
+
+static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr)
 {
        struct config_item *i;
-       struct comm *cm = NULL;
+       struct dlm_comm *cm = NULL;
        int found = 0;
 
        if (!comm_list)
                return NULL;
 
-       down(&clusters_root.subsys.su_sem);
+       mutex_lock(&clusters_root.subsys.su_mutex);
 
        list_for_each_entry(i, &comm_list->cg_children, ci_entry) {
-               cm = to_comm(i);
+               cm = config_item_to_comm(i);
 
                if (nodeid) {
                        if (cm->nodeid != nodeid)
                                continue;
                        found = 1;
+                       config_item_get(i);
                        break;
                } else {
-                       if (!cm->addr_count ||
-                           memcmp(cm->addr[0], addr, sizeof(*addr)))
+                       if (!cm->addr_count || !addr_compare(cm->addr[0], addr))
                                continue;
                        found = 1;
+                       config_item_get(i);
                        break;
                }
        }
-       up(&clusters_root.subsys.su_sem);
+       mutex_unlock(&clusters_root.subsys.su_mutex);
 
-       if (found)
-               config_item_get(i);
-       else
+       if (!found)
                cm = NULL;
        return cm;
 }
 
-static void put_comm(struct comm *cm)
+static void put_comm(struct dlm_comm *cm)
 {
        config_item_put(&cm->item);
 }
 
 /* caller must free mem */
-int dlm_nodeid_list(char *lsname, int **ids_out)
+int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out,
+                   int **new_out, int *new_count_out)
 {
-       struct space *sp;
-       struct node *nd;
-       int i = 0, rv = 0;
-       int *ids;
+       struct dlm_space *sp;
+       struct dlm_node *nd;
+       int i = 0, rv = 0, ids_count = 0, new_count = 0;
+       int *ids, *new;
 
        sp = get_space(lsname);
        if (!sp)
@@ -809,23 +861,50 @@ int dlm_nodeid_list(char *lsname, int **ids_out)
 
        mutex_lock(&sp->members_lock);
        if (!sp->members_count) {
-               rv = 0;
+               rv = -EINVAL;
+               printk(KERN_ERR "dlm: zero members_count\n");
                goto out;
        }
 
-       ids = kcalloc(sp->members_count, sizeof(int), GFP_KERNEL);
+       ids_count = sp->members_count;
+
+       ids = kcalloc(ids_count, sizeof(int), GFP_KERNEL);
        if (!ids) {
                rv = -ENOMEM;
                goto out;
        }
 
-       rv = sp->members_count;
-       list_for_each_entry(nd, &sp->members, list)
+       list_for_each_entry(nd, &sp->members, list) {
                ids[i++] = nd->nodeid;
+               if (nd->new)
+                       new_count++;
+       }
+
+       if (ids_count != i)
+               printk(KERN_ERR "dlm: bad nodeid count %d %d\n", ids_count, i);
+
+       if (!new_count)
+               goto out_ids;
 
-       if (rv != i)
-               printk("bad nodeid count %d %d\n", rv, i);
+       new = kcalloc(new_count, sizeof(int), GFP_KERNEL);
+       if (!new) {
+               kfree(ids);
+               rv = -ENOMEM;
+               goto out;
+       }
+
+       i = 0;
+       list_for_each_entry(nd, &sp->members, list) {
+               if (nd->new) {
+                       new[i++] = nd->nodeid;
+                       nd->new = 0;
+               }
+       }
+       *new_count_out = new_count;
+       *new_out = new;
 
+ out_ids:
+       *ids_count_out = ids_count;
        *ids_out = ids;
  out:
        mutex_unlock(&sp->members_lock);
@@ -835,8 +914,8 @@ int dlm_nodeid_list(char *lsname, int **ids_out)
 
 int dlm_node_weight(char *lsname, int nodeid)
 {
-       struct space *sp;
-       struct node *nd;
+       struct dlm_space *sp;
+       struct dlm_node *nd;
        int w = -EEXIST;
 
        sp = get_space(lsname);
@@ -858,7 +937,7 @@ int dlm_node_weight(char *lsname, int nodeid)
 
 int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr)
 {
-       struct comm *cm = get_comm(nodeid, NULL);
+       struct dlm_comm *cm = get_comm(nodeid, NULL);
        if (!cm)
                return -EEXIST;
        if (!cm->addr_count)
@@ -870,7 +949,7 @@ int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr)
 
 int dlm_addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid)
 {
-       struct comm *cm = get_comm(0, addr);
+       struct dlm_comm *cm = get_comm(0, addr);
        if (!cm)
                return -EEXIST;
        *nodeid = cm->nodeid;
@@ -904,6 +983,8 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
 #define DEFAULT_TOSS_SECS         10
 #define DEFAULT_SCAN_SECS          5
 #define DEFAULT_LOG_DEBUG          0
+#define DEFAULT_PROTOCOL           0
+#define DEFAULT_TIMEWARN_CS      500 /* 5 sec = 500 centiseconds */
 
 struct dlm_config_info dlm_config = {
        .ci_tcp_port = DEFAULT_TCP_PORT,
@@ -914,6 +995,8 @@ struct dlm_config_info dlm_config = {
        .ci_recover_timer = DEFAULT_RECOVER_TIMER,
        .ci_toss_secs = DEFAULT_TOSS_SECS,
        .ci_scan_secs = DEFAULT_SCAN_SECS,
-       .ci_log_debug = DEFAULT_LOG_DEBUG
+       .ci_log_debug = DEFAULT_LOG_DEBUG,
+       .ci_protocol = DEFAULT_PROTOCOL,
+       .ci_timewarn_cs = DEFAULT_TIMEWARN_CS
 };