split the vnn broadcast address into two
authorRonnie Sahlberg <sahlberg@ronnie>
Sat, 5 May 2007 03:17:26 +0000 (13:17 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sat, 5 May 2007 03:17:26 +0000 (13:17 +1000)
one broadcast address for all nodes
and one broadcast address for all nodes in the current vnnmap

update all useage of the old flag to now only broadcast to the vnnmap
except for tools/ctdb_control where it makes more sense to broadcast to
all nodes

common/ctdb.c
common/ctdb_control.c
common/ctdb_ltdb.c
common/ctdb_traverse.c
include/ctdb_private.h
tools/ctdb_control.c

index 7894fcc32069d22cabed29ae8677bac90a3fbdd8..4699e8f2d70e380fd0421bc1620d3fc80bed6e06 100644 (file)
@@ -469,7 +469,7 @@ static void ctdb_defer_packet(struct ctdb_context *ctdb, struct ctdb_req_header
 /*
   broadcast a packet to all nodes
 */
-static void ctdb_broadcast_packet(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_get_num_nodes(ctdb);i++) {
@@ -478,6 +478,18 @@ static void ctdb_broadcast_packet(struct ctdb_context *ctdb, struct ctdb_req_hea
        }
 }
 
+/*
+  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)
+{
+       int i;
+       for (i=0;i<ctdb->vnn_map->size;i++) {
+               hdr->destnode = ctdb->vnn_map->map[i];
+               ctdb_queue_packet(ctdb, hdr);
+       }
+}
+
 /*
   queue a packet or die
 */
@@ -485,8 +497,12 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 {
        struct ctdb_node *node;
 
-       if (hdr->destnode == CTDB_BROADCAST_VNN) {
-               ctdb_broadcast_packet(ctdb, hdr);
+       switch (hdr->destnode) {
+       case CTDB_BROADCAST_ALL:
+               ctdb_broadcast_packet_all(ctdb, hdr);
+               return;
+       case CTDB_BROADCAST_VNNMAP:
+               ctdb_broadcast_packet_vnnmap(ctdb, hdr);
                return;
        }
 
index 2422ff945f6e758da7cb89b01bdf434434ffb1f6..51f1ca2c07bcae3aae924cce3e397e3a8a4375ed 100644 (file)
@@ -533,7 +533,7 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
        struct ctdb_control_state *state;
        size_t len;
 
-       if (destnode == CTDB_BROADCAST_VNN && !(flags & CTDB_CTRL_FLAG_NOREPLY)) {
+       if (((destnode == CTDB_BROADCAST_VNNMAP) || (destnode == CTDB_BROADCAST_VNNMAP)) && !(flags & CTDB_CTRL_FLAG_NOREPLY)) {
                DEBUG(0,("Attempt to broadcast control without NOREPLY\n"));
                return -1;
        }
index 312d1b98c3982ffa25fe3046e222b7e21d896083..1dd3433cf721f0db2023f1f566025c1777dc7de6 100644 (file)
@@ -388,7 +388,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        }
        
        /* tell all the other nodes about this database */
-       ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNN, 0,
+       ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNNMAP, 0,
                                 CTDB_CONTROL_DB_ATTACH, 0, CTDB_CTRL_FLAG_NOREPLY,
                                 indata, NULL, NULL);
 
@@ -434,7 +434,7 @@ static void ctdb_ltdb_seqnum_check(struct event_context *ev, struct timed_event
                TDB_DATA data;
                data.dptr = (uint8_t *)&ctdb_db->db_id;
                data.dsize = sizeof(uint32_t);
-               ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNN, 0,
+               ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNNMAP, 0,
                                         CTDB_CONTROL_UPDATE_SEQNUM, 0, CTDB_CTRL_FLAG_NOREPLY,
                                         data, NULL, NULL);             
        }
index c71457d717ed1c188e8688bd0f81506e44fc5a67..a1d5e6b1d80e918577954dfc0d0e9d2be5c512ce 100644 (file)
@@ -263,7 +263,7 @@ struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context
        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_VNN, 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);
index 81cf60f1cfc83c66fb4094f3a8f983477099d7c4..6eb915e57ff2367a5c46bf9991af9c135421914d 100644 (file)
 #define CTDB_NULL_FUNC      0xFF000001
 #define CTDB_FETCH_FUNC     0xFF000002
 
-#define CTDB_CURRENT_NODE  0xF0000001
-#define CTDB_BROADCAST_VNN 0xF0000002
+/* used on the domain socket, send a pdu to the local daemon */
+#define CTDB_CURRENT_NODE     0xF0000001
+/* send a broadcast to all nodes in the cluster, active or not */
+#define CTDB_BROADCAST_ALL    0xF0000002
+/* send a broadcast to all nodes in the current vnn map */
+#define CTDB_BROADCAST_VNNMAP 0xF0000003
 
 #define CTDB_MAX_REDIRECT_COUNT 3
 #define CTDB_DEFAULT_SEQNUM_FREQUENCY 1
index 3f5d369b6858f52911c70b8ed8ff9bd1c14f6719..813e920b9b239ea8be43b359dd51eb2a7ff9286f 100644 (file)
@@ -945,7 +945,7 @@ static int control_dumpmemory(struct ctdb_context *ctdb, int argc, const char **
                usage();
        }
        if (strcmp(argv[0], "all") == 0) {
-               vnn = CTDB_BROADCAST_VNN;
+               vnn = CTDB_BROADCAST_ALL;
        } else {
                vnn = strtoul(argv[0], NULL, 0);
        }