propogate flag changes to all connected nodes
authorAndrew Tridgell <tridge@samba.org>
Sat, 9 Jun 2007 11:58:50 +0000 (21:58 +1000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 9 Jun 2007 11:58:50 +0000 (21:58 +1000)
include/ctdb.h
server/ctdb_control.c
server/ctdb_monitor.c
server/ctdb_recoverd.c
server/ctdb_server.c
server/ctdb_traverse.c

index 587a4015fc1bd98231fac8b3d0a5213101d093aa..72efc3affcb4dbe9bec2fb65530d87b3b8bae559 100644 (file)
@@ -93,6 +93,8 @@ struct ctdb_call_info {
 #define CTDB_BROADCAST_ALL    0xF0000002
 /* send a broadcast to all nodes in the current vnn map */
 #define CTDB_BROADCAST_VNNMAP 0xF0000003
+/* send a broadcast to all connected nodes */
+#define CTDB_BROADCAST_CONNECTED 0xF0000004
 
 
 struct event_context;
index 2a9182647b1a5bd0fdbcba19a9762f85a5e191d0..ede2c492e75f8a5a8dfd5565b6d9dd067741bb57 100644 (file)
@@ -433,12 +433,17 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
        struct ctdb_control_state *state;
        size_t len;
 
-       if (((destnode == CTDB_BROADCAST_VNNMAP) || (destnode == CTDB_BROADCAST_VNNMAP)) && !(flags & CTDB_CTRL_FLAG_NOREPLY)) {
+       if (((destnode == CTDB_BROADCAST_VNNMAP) || 
+            (destnode == CTDB_BROADCAST_ALL) ||
+            (destnode == CTDB_BROADCAST_CONNECTED)) && 
+           !(flags & CTDB_CTRL_FLAG_NOREPLY)) {
                DEBUG(0,("Attempt to broadcast control without NOREPLY\n"));
                return -1;
        }
 
-       if (destnode != CTDB_BROADCAST_VNNMAP && destnode != CTDB_BROADCAST_ALL && 
+       if (destnode != CTDB_BROADCAST_VNNMAP && 
+           destnode != CTDB_BROADCAST_ALL && 
+           destnode != CTDB_BROADCAST_CONNECTED && 
            (!ctdb_validate_vnn(ctdb, destnode) || 
             (ctdb->nodes[destnode]->flags & NODE_FLAGS_DISCONNECTED))) {
                if (!(flags & CTDB_CTRL_FLAG_NOREPLY)) {
index 940dd133bf52fc00b5d20d4b1cd1a813fe60ca28..73938a32b18ad99cd0e4dd1e3c80ae72553e1217 100644 (file)
@@ -122,7 +122,7 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
        data.dsize = sizeof(c);
 
        /* tell the other nodes that something has changed */
-       ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
+       ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_CONNECTED,
                                 CTDB_SRVID_NODE_FLAGS_CHANGED, data);
 
 }
@@ -213,7 +213,7 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
        data.dsize = sizeof(c);
 
        /* tell the other nodes that something has changed */
-       ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
+       ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_CONNECTED,
                                 CTDB_SRVID_NODE_FLAGS_CHANGED, data);
 
        if ((node->flags & NODE_FLAGS_BANNED) && !(old_flags & NODE_FLAGS_BANNED)) {
index 3d0811ea40e75bbffb1b4a132817c343efeb71fb..90b7997744596183865aec7aa3055ebaca71ddb0 100644 (file)
@@ -392,7 +392,7 @@ static int update_flags_on_all_nodes(struct ctdb_context *ctdb, struct ctdb_node
                data.dptr = (uint8_t *)&c;
                data.dsize = sizeof(c);
 
-               ctdb_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
+               ctdb_send_message(ctdb, CTDB_BROADCAST_CONNECTED,
                                  CTDB_SRVID_NODE_FLAGS_CHANGED, data);
 
        }
index 3a32326943f65bb620ad00dfd50a92e42796f0d3..ce051be5481b6059acd72354f9614e53be5b38ec 100644 (file)
@@ -390,7 +390,8 @@ static void ctdb_defer_packet(struct ctdb_context *ctdb, struct ctdb_req_header
 /*
   broadcast a packet to all nodes
 */
-static void ctdb_broadcast_packet_all(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
+static void ctdb_broadcast_packet_all(struct ctdb_context *ctdb, 
+                                     struct ctdb_req_header *hdr)
 {
        int i;
        for (i=0;i<ctdb->num_nodes;i++) {
@@ -402,7 +403,8 @@ static void ctdb_broadcast_packet_all(struct ctdb_context *ctdb, struct ctdb_req
 /*
   broadcast a packet to all nodes in the current vnnmap
 */
-static void ctdb_broadcast_packet_vnnmap(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
+static void ctdb_broadcast_packet_vnnmap(struct ctdb_context *ctdb, 
+                                        struct ctdb_req_header *hdr)
 {
        int i;
        for (i=0;i<ctdb->vnn_map->size;i++) {
@@ -411,6 +413,21 @@ static void ctdb_broadcast_packet_vnnmap(struct ctdb_context *ctdb, struct ctdb_
        }
 }
 
+/*
+  broadcast a packet to all connected nodes
+*/
+static void ctdb_broadcast_packet_connected(struct ctdb_context *ctdb, 
+                                           struct ctdb_req_header *hdr)
+{
+       int i;
+       for (i=0;i<ctdb->num_nodes;i++) {
+               if (!(ctdb->nodes[i]->flags & NODE_FLAGS_DISCONNECTED)) {
+                       hdr->destnode = ctdb->nodes[i]->vnn;
+                       ctdb_queue_packet(ctdb, hdr);
+               }
+       }
+}
+
 /*
   queue a packet or die
 */
@@ -425,6 +442,9 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        case CTDB_BROADCAST_VNNMAP:
                ctdb_broadcast_packet_vnnmap(ctdb, hdr);
                return;
+       case CTDB_BROADCAST_CONNECTED:
+               ctdb_broadcast_packet_connected(ctdb, hdr);
+               return;
        }
 
        ctdb->statistics.node_packets_sent++;
index caff809a677ba45c96d2acc6ba90a227c064113d..b8e82e34a3d50145d9f49ff1840d60a37a6b811e 100644 (file)
@@ -248,7 +248,8 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
        data.dsize = sizeof(r);
 
        /* tell all the nodes in the cluster to start sending records to this node */
-       ret = ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNNMAP, 0, CTDB_CONTROL_TRAVERSE_ALL,
+       ret = ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNNMAP, 0, 
+                                      CTDB_CONTROL_TRAVERSE_ALL,
                                       0, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL);
        if (ret != 0) {
                talloc_free(state);