[DLM] fix reference counting
[pandora-kernel.git] / fs / dlm / config.c
index 8665c88..5069b2c 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-2007 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
@@ -89,6 +89,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,6 +103,8 @@ enum {
        CLUSTER_ATTR_TOSS_SECS,
        CLUSTER_ATTR_SCAN_SECS,
        CLUSTER_ATTR_LOG_DEBUG,
+       CLUSTER_ATTR_PROTOCOL,
+       CLUSTER_ATTR_TIMEWARN_CS,
 };
 
 struct cluster_attribute {
@@ -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,
 };
 
@@ -425,6 +433,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;
@@ -744,9 +754,16 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)
 
 static struct space *get_space(char *name)
 {
+       struct config_item *i;
+
        if (!space_list)
                return NULL;
-       return to_space(config_group_find_obj(space_list, name));
+
+       down(&space_list->cg_subsys->su_sem);
+       i = config_group_find_obj(space_list, name);
+       up(&space_list->cg_subsys->su_sem);
+
+       return to_space(i);
 }
 
 static void put_space(struct space *sp)
@@ -772,20 +789,20 @@ static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr)
                        if (cm->nodeid != nodeid)
                                continue;
                        found = 1;
+                       config_item_get(i);
                        break;
                } else {
                        if (!cm->addr_count ||
                            memcmp(cm->addr[0], addr, sizeof(*addr)))
                                continue;
                        found = 1;
+                       config_item_get(i);
                        break;
                }
        }
        up(&clusters_root.subsys.su_sem);
 
-       if (found)
-               config_item_get(i);
-       else
+       if (!found)
                cm = NULL;
        return cm;
 }
@@ -904,6 +921,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 +933,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
 };