public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* RHEL5 - groupd: send and check version messages
@ 2008-08-26 16:49 David Teigland
0 siblings, 0 replies; only message in thread
From: David Teigland @ 2008-08-26 16:49 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=37d49522dbede24ff06a912ebc577b17da907912
Commit: 37d49522dbede24ff06a912ebc577b17da907912
Parent: acf1eaef5132ef56bb29e333bc9ee35117b7da1c
Author: David Teigland <teigland@redhat.com>
AuthorDate: Thu Aug 21 13:55:52 2008 -0500
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Tue Aug 26 11:32:24 2008 -0500
groupd: send and check version messages
for better compatibility with and upgrades to cluster3 eventually.
bz 457104
- cluster3 nodes that are trying to detect old cluster2 nodes will be
helped by the cluster2 groupd sending its version.
- if someone adds a cluster2 node to a cluster3 cluster (which is not
supposed to be done), detect the newer version and exit
Signed-off-by: David Teigland <teigland@redhat.com>
---
group/daemon/cpg.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
group/daemon/gd_internal.h | 3 +-
group/daemon/main.c | 2 +-
3 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/group/daemon/cpg.c b/group/daemon/cpg.c
index d5cfb8d..2cac91f 100644
--- a/group/daemon/cpg.c
+++ b/group/daemon/cpg.c
@@ -33,6 +33,20 @@ static cpg_handle_t saved_handle;
static struct cpg_name saved_name;
static int message_flow_control_on;
+#define GROUP_LIBGROUP 2
+#define GROUP_LIBCPG 3
+
+#define CLUSTER2 2
+#define CLUSTER3 3
+
+struct group_version {
+ uint32_t nodeid;
+ uint16_t cluster;
+ uint16_t group_mode;
+ uint16_t groupd_compat;
+ uint16_t groupd_count;
+ uint32_t unused;
+};
static node_t *find_group_node(group_t *g, int nodeid)
{
@@ -194,6 +208,52 @@ static int send_gid(uint32_t gid)
return send_message_groupd(&g, &msg, sizeof(msg), MSG_GLOBAL_ID);
}
+static void _send_version(int nodeid, int cluster, int mode, int compat)
+{
+ group_t g, *gp;
+ char *buf;
+ msg_t *msg;
+ int len;
+ int count = 0;
+ struct group_version *ver;
+
+ list_for_each_entry(gp, &gd_groups, list)
+ count++;
+
+ /* just so log_group will work */
+ memset(&g, 0, sizeof(group_t));
+ strcpy(g.name, "groupd");
+
+ len = sizeof(msg_t) + sizeof(struct group_version);
+
+ buf = malloc(len);
+ if (!buf)
+ return;
+ memset(buf, 0, len);
+
+ msg = (msg_t *)buf;
+ ver = (struct group_version *)(buf + sizeof(msg_t));
+
+ msg->ms_type = MSG_GROUP_VERSION;
+ msg_bswap_out(msg);
+
+ log_debug("send_version nodeid %d cluster %d mode %d compat %d",
+ nodeid, cluster, mode, compat);
+
+ ver->nodeid = cpu_to_le32(nodeid);
+ ver->cluster = cpu_to_le16(cluster);
+ ver->group_mode = cpu_to_le16(mode);
+ ver->groupd_compat = cpu_to_le16(compat);
+ ver->groupd_count = cpu_to_le16(count);
+
+ send_message_groupd(&g, buf, len, MSG_GROUP_VERSION);
+}
+
+static void send_version(void)
+{
+ _send_version(our_nodeid, CLUSTER2, GROUP_LIBGROUP, 1);
+}
+
void process_groupd_confchg(void)
{
group_t *g;
@@ -204,6 +264,9 @@ void process_groupd_confchg(void)
log_debug("groupd confchg total %d left %d joined %d",
saved_member_count, saved_left_count, saved_joined_count);
+ if (saved_joined_count)
+ send_version();
+
memcpy(&groupd_cpg_member, &saved_member, sizeof(saved_member));
groupd_cpg_member_count = saved_member_count;
@@ -303,6 +366,29 @@ group_t *find_group_by_handle(cpg_handle_t h)
return NULL;
}
+static void version_copy_in(struct group_version *ver)
+{
+ ver->nodeid = le32_to_cpu(ver->nodeid);
+ ver->cluster = le16_to_cpu(ver->cluster);
+ ver->group_mode = le16_to_cpu(ver->group_mode);
+ ver->groupd_compat = le16_to_cpu(ver->groupd_compat);
+ ver->groupd_count = le16_to_cpu(ver->groupd_count);
+}
+
+static void receive_version(int from, msg_t *msg, int len)
+{
+ struct group_version *ver;
+
+ ver = (struct group_version *)((char *)msg + sizeof(msg_t));
+
+ version_copy_in(ver);
+
+ if (ver->group_mode == GROUP_LIBCPG) {
+ log_print("incompatible group mode from %d", from);
+ exit(1);
+ }
+}
+
void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
uint32_t nodeid, uint32_t pid, void *data, int data_len)
{
@@ -318,6 +404,11 @@ void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
msg_bswap_in(msg);
+ if (msg->ms_type == MSG_GROUP_VERSION) {
+ receive_version(nodeid, msg, data_len);
+ return;
+ }
+
if (msg->ms_type == MSG_GLOBAL_ID) {
to_nodeid = msg->ms_global_id & 0x0000FFFF;
counter = (msg->ms_global_id >> 16) & 0x0000FFFF;
diff --git a/group/daemon/gd_internal.h b/group/daemon/gd_internal.h
index 691d187..f1269cc 100644
--- a/group/daemon/gd_internal.h
+++ b/group/daemon/gd_internal.h
@@ -191,9 +191,10 @@ struct app {
#define MSG_APP_RECOVER 3
#define MSG_APP_INTERNAL 4
#define MSG_GLOBAL_ID 5
+#define MSG_GROUP_VERSION 6
#define MSG_VER_MAJOR 1
-#define MSG_VER_MINOR 0
+#define MSG_VER_MINOR 1
#define MSG_VER_PATCH 0
struct msg {
diff --git a/group/daemon/main.c b/group/daemon/main.c
index 90a9b48..a31937f 100644
--- a/group/daemon/main.c
+++ b/group/daemon/main.c
@@ -109,7 +109,7 @@ static int do_read(int fd, void *buf, size_t count)
static int ignore_gfs_nolock(char *sysfs_dir, char *table)
{
char path[PATH_MAX];
- int rv, fd;
+ int fd;
if (!strstr(sysfs_dir, "gfs"))
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-26 16:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-26 16:49 RHEL5 - groupd: send and check version messages David Teigland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).