[sheepdog] [PATCH v3 10/11] cluster driver: don't use SD_MAX_NODES for local and corosync

Liu Yuan namei.unix at gmail.com
Sat Sep 21 18:12:27 CEST 2013


They can't scale to SD_MAX_NODES, just order them to use private marco of max
nodes to support. (both as 1024)

This is a preparation patch.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/cluster/corosync.c |   13 +++++++------
 sheep/cluster/local.c    |    9 +++++----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 954add9..45756e8 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -20,6 +20,7 @@
 #include "work.h"
 
 #define CPG_INIT_RETRY_CNT 10
+#define COROSYNC_MAX_NODES 1024
 
 struct cpg_node {
 	uint32_t nodeid;
@@ -36,7 +37,7 @@ static struct cpg_node this_node;
 static LIST_HEAD(corosync_block_event_list);
 static LIST_HEAD(corosync_nonblock_event_list);
 
-static struct cpg_node cpg_nodes[SD_MAX_NODES];
+static struct cpg_node cpg_nodes[COROSYNC_MAX_NODES];
 static size_t nr_cpg_nodes;
 static bool self_elect;
 static bool join_finished;
@@ -72,7 +73,7 @@ struct corosync_event {
 	size_t msg_len;
 
 	uint32_t nr_nodes;
-	struct cpg_node nodes[SD_MAX_NODES];
+	struct cpg_node nodes[COROSYNC_MAX_NODES];
 
 	bool callbacked;
 
@@ -84,7 +85,7 @@ struct corosync_message {
 	enum corosync_message_type type:16;
 	uint16_t nr_nodes;
 	uint32_t msg_len;
-	struct cpg_node nodes[SD_MAX_NODES];
+	struct cpg_node nodes[COROSYNC_MAX_NODES];
 	uint8_t msg[0];
 };
 
@@ -543,9 +544,9 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 {
 	struct corosync_event *cevent;
 	int i;
-	struct cpg_node member_sheep[SD_MAX_NODES];
-	struct cpg_node joined_sheep[SD_MAX_NODES];
-	struct cpg_node left_sheep[SD_MAX_NODES];
+	struct cpg_node member_sheep[COROSYNC_MAX_NODES];
+	struct cpg_node joined_sheep[COROSYNC_MAX_NODES];
+	struct cpg_node left_sheep[COROSYNC_MAX_NODES];
 	bool promote = true;
 
 	sd_debug("mem:%zu, joined:%zu, left:%zu", member_list_entries,
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index b0e7fc2..824279c 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -24,6 +24,7 @@
 
 #define MAX_EVENTS 500
 #define PROCESS_CHECK_INTERVAL 50 /* ms */
+#define LOCAL_MAX_NODES 1024
 
 static const char *shmfile = "/tmp/sheepdog_shm";
 static int shmfd;
@@ -80,7 +81,7 @@ struct local_event {
 	uint8_t buf[SD_MAX_EVENT_BUF_SIZE];
 
 	size_t nr_lnodes; /* the number of sheep processes */
-	struct local_node lnodes[SD_MAX_NODES];
+	struct local_node lnodes[LOCAL_MAX_NODES];
 };
 
 /* shared memory queue */
@@ -182,7 +183,7 @@ static void shm_queue_notify(void)
 {
 	int i;
 	size_t nr;
-	struct local_node lnodes[SD_MAX_NODES];
+	struct local_node lnodes[LOCAL_MAX_NODES];
 
 	nr = get_nodes(lnodes);
 
@@ -196,7 +197,7 @@ static bool is_shm_queue_valid(void)
 {
 	int i;
 	size_t nr;
-	struct local_node lnodes[SD_MAX_NODES];
+	struct local_node lnodes[LOCAL_MAX_NODES];
 
 	nr = get_nodes(lnodes);
 
@@ -311,7 +312,7 @@ static void check_pids(void *arg)
 {
 	int i;
 	size_t nr;
-	struct local_node lnodes[SD_MAX_NODES];
+	struct local_node lnodes[LOCAL_MAX_NODES];
 	struct local_event *ev;
 
 	shm_queue_lock();
-- 
1.7.9.5




More information about the sheepdog mailing list