ctdbd: New control CTDB_CONTROL_IPREALLOCATED
[metze/samba/wip.git] / ctdb / include / ctdb_protocol.h
index a9f6249d617788c73d1530556ac679fbdb49a3f5..728edc08b915a1c8f9f9dd2edaf32e7f161fba40 100644 (file)
 #ifndef _CTDB_PROTOCOL_H
 #define _CTDB_PROTOCOL_H
 
-/* location of daemon socket */
-#define CTDB_PATH      "/tmp/ctdb.socket"
+/* location of daemon socket, set at configure time */
+#ifdef SOCKPATH
+#define CTDB_PATH      SOCKPATH
+#else
+#define CTDB_PATH      "/tmp/ctdb.socket"
+#endif
 
 /* default ctdb port number */
 #define CTDB_PORT 4379
 #define CTDB_DS_ALIGNMENT 8
 
 
-#define CTDB_NULL_FUNC      0xFF000001
-#define CTDB_FETCH_FUNC     0xFF000002
+#define CTDB_NULL_FUNC                  0xFF000001
+#define CTDB_FETCH_FUNC                 0xFF000002
+#define CTDB_FETCH_WITH_HEADER_FUNC     0xFF000003
 
 
-#define CTDB_IMMEDIATE_MIGRATION       0x00000001
 struct ctdb_call {
        int call_id;
        TDB_DATA key;
        TDB_DATA call_data;
        TDB_DATA reply_data;
        uint32_t status;
+#define CTDB_IMMEDIATE_MIGRATION               0x00000001
+#define CTDB_CALL_FLAG_VACUUM_MIGRATION                0x00000002
+#define CTDB_WANT_READONLY                     0x00000004
        uint32_t flags;
 };
 
@@ -49,6 +56,7 @@ struct ctdb_call {
 */
 struct ctdb_call_info {
        TDB_DATA key;          /* record key */
+       struct ctdb_ltdb_header *header;
        TDB_DATA record_data;  /* current data in the record */
        TDB_DATA *new_data;    /* optionally updated record data */
        TDB_DATA *call_data;   /* optionally passed from caller */
@@ -111,6 +119,14 @@ struct ctdb_call_info {
  */
 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
 
+/* A message id used to ask the recover daemon to send logs
+*/
+#define CTDB_SRVID_GETLOG  0xF801000000000000LL
+
+/* A message id used to ask the recover daemon to send logs
+*/
+#define CTDB_SRVID_CLEARLOG  0xF802000000000000LL
+
 /*
    a message ID to get the recovery daemon to push the node flags out
  */
@@ -126,6 +142,16 @@ struct ctdb_call_info {
  */
 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
 
+/* request recovery daemon to rebalance ips for a node.
+   input is uint32_t for the node id.
+*/
+#define CTDB_SRVID_REBALANCE_NODE 0xFB01000000000000LL
+
+/*
+   a message handler ID meaning to ask recovery master to reload all ips
+ */
+#define CTDB_SRVID_RELOAD_ALL_IPS 0xFB02000000000000LL
+
 /* A message id to ask the recovery daemon to temporarily disable the
    public ip checks
 */
@@ -136,24 +162,39 @@ struct ctdb_call_info {
 */
 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
 
-/* A range of ports reserved for samba (top 32 bits)
- * All ports matching the 32 top bits are reserved for exclusive use by
+/* A range of ports reserved for registering a PID (top 8 bits)
+ * All ports matching the 8 top bits are reserved for exclusive use by
+ * registering a SRVID that matches the process-id of the requesting process
+ */
+#define CTDB_SRVID_PID_RANGE   0x0000000000000000LL
+
+/* A range of ports reserved for samba (top 8 bits)
+ * All ports matching the 8 top bits are reserved for exclusive use by
  * CIFS server
  */
 #define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
 #define CTDB_SRVID_SAMBA_RANGE   0xFE00000000000000LL
 
-/* A range of ports reserved for a CTDB NFS server (top 32 bits)
- * All ports matching the 32 top bits are reserved for exclusive use by
+/* A range of ports reserved for a CTDB NFS server (top 8 bits)
+ * All ports matching the 8 top bits are reserved for exclusive use by
  * NFS server
  */
-#define CTDB_SRVID_NFSD_RANGE  0xFE01000000000000LL
+#define CTDB_SRVID_NFSD_RANGE  0xEE00000000000000LL
 
-/* A range of ports reserved for a CTDB ISCSI server (top 32 bits)
- * All ports matching the 32 top bits are reserved for exclusive use by
+/* A range of ports reserved for a CTDB ISCSI server (top 8 bits)
+ * All ports matching the 8 top bits are reserved for exclusive use by
  * ISCSI server
  */
-#define CTDB_SRVID_ISCSID_RANGE  0xFE02000000000000LL
+#define CTDB_SRVID_ISCSID_RANGE  0xDE00000000000000LL
+
+/* A range of ports reserved for testing (top 8 bits)
+ * All ports matching the 8 top bits are reserved for exclusive use by
+ * test applications
+ */
+#define CTDB_SRVID_TEST_RANGE  0xCE00000000000000LL
+
+/* Range of ports reserved for traversals */
+#define CTDB_SRVID_TRAVERSE_RANGE  0xBE00000000000000LL
 
 /* used on the domain socket, send a pdu to the local daemon */
 #define CTDB_CURRENT_NODE     0xF0000001
@@ -163,6 +204,8 @@ struct ctdb_call_info {
 #define CTDB_BROADCAST_VNNMAP 0xF0000003
 /* send a broadcast to all connected nodes */
 #define CTDB_BROADCAST_CONNECTED 0xF0000004
+/* send a broadcast to selected connected nodes */
+#define CTDB_MULTICAST 0xF0000005
 
 /* the key used for transaction locking on persistent databases */
 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
@@ -240,7 +283,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_SET_DEBUG               = 8,
                    CTDB_CONTROL_GET_DBMAP               = 9,
                    CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
-                   CTDB_CONTROL_SET_DMASTER             = 11,
+                   CTDB_CONTROL_SET_DMASTER             = 11, /* obsolete */
                    /* #12 removed */
                    CTDB_CONTROL_PULL_DB                 = 13,
                    CTDB_CONTROL_PUSH_DB                 = 14,
@@ -351,6 +394,17 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_GET_IFACES              = 124,
                    CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
                    CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE  = 126,
+                   CTDB_CONTROL_GET_STAT_HISTORY        = 127,
+                   CTDB_CONTROL_SCHEDULE_FOR_DELETION   = 128,
+                   CTDB_CONTROL_SET_DB_READONLY         = 129,
+                   CTDB_CONTROL_CHECK_SRVIDS            = 130,
+                   CTDB_CONTROL_TRAVERSE_START_EXT      = 131,
+                   CTDB_CONTROL_GET_DB_STATISTICS       = 132,
+                   CTDB_CONTROL_SET_DB_STICKY           = 133,
+                   CTDB_CONTROL_RELOAD_PUBLIC_IPS       = 134,
+                   CTDB_CONTROL_TRAVERSE_ALL_EXT        = 135,
+                   CTDB_CONTROL_RECEIVE_RECORDS         = 136,
+                   CTDB_CONTROL_IPREALLOCATED           = 137,
 };
 
 /*
@@ -469,8 +523,21 @@ enum ctdb_trans2_commit_error {
 struct ctdb_ltdb_header {
        uint64_t rsn;
        uint32_t dmaster;
-       uint32_t laccessor;
-       uint32_t lacount;
+       uint16_t laccessor;
+       uint16_t lacount;
+#define CTDB_REC_FLAG_DEFAULT                  0x00000000
+#define CTDB_REC_FLAG_MIGRATED_WITH_DATA       0x00010000
+#define CTDB_REC_FLAG_VACUUM_MIGRATED          0x00020000
+#define CTDB_REC_FLAG_AUTOMATIC                        0x00040000
+#define CTDB_REC_RO_HAVE_DELEGATIONS           0x01000000
+#define CTDB_REC_RO_HAVE_READONLY              0x02000000
+#define CTDB_REC_RO_REVOKING_READONLY          0x04000000
+#define CTDB_REC_RO_REVOKE_COMPLETE            0x08000000
+#define CTDB_REC_RO_FLAGS                      (CTDB_REC_RO_HAVE_DELEGATIONS|\
+                                                CTDB_REC_RO_HAVE_READONLY|\
+                                                CTDB_REC_RO_REVOKING_READONLY|\
+                                                CTDB_REC_RO_REVOKE_COMPLETE)
+       uint32_t flags;
 };
 
 
@@ -517,5 +584,201 @@ struct ctdb_node_map {
 #define NODE_FLAGS_DISABLED            (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
 #define NODE_FLAGS_INACTIVE            (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
 
+#define NODE_FLAGS_NOIPTAKEOVER                0x01000000 /* this node can takeover any new ip addresses, this flag is ONLY valid within the recovery daemon */
+
+
+/*
+ * Node capabilities
+ */
+#define CTDB_CAP_RECMASTER             0x00000001
+#define CTDB_CAP_LMASTER               0x00000002
+/* This capability is set if CTDB_LVS_PUBLIC_IP is set */
+#define CTDB_CAP_LVS                   0x00000004
+/* This capability is set if NATGW is enabled */
+#define CTDB_CAP_NATGW                 0x00000008
+
+
+struct ctdb_public_ip {
+       uint32_t pnn;
+       ctdb_sock_addr addr;
+};
+
+struct ctdb_all_public_ips {
+       uint32_t num;
+       struct ctdb_public_ip ips[1];
+};
+
+
+struct latency_counter {
+       int num;
+       double min;
+       double max;
+       double total;
+};
+
+/*
+  structure used to pass record data between the child and parent
+ */
+struct ctdb_rec_data {
+       uint32_t length;
+       uint32_t reqid;
+       uint32_t keylen;
+       uint32_t datalen;
+       uint8_t  data[1];
+};
+
+struct ctdb_traverse_start {
+       uint32_t db_id;
+       uint32_t reqid;
+       uint64_t srvid;
+};
+
+struct ctdb_traverse_start_ext {
+       uint32_t db_id;
+       uint32_t reqid;
+       uint64_t srvid;
+       bool withemptyrecords;
+};
+
+/*
+  ctdb statistics information
+ */
+#define MAX_COUNT_BUCKETS 16
+#define MAX_HOT_KEYS      10
+
+struct ctdb_statistics {
+       uint32_t num_clients;
+       uint32_t frozen;
+       uint32_t recovering;
+       uint32_t client_packets_sent;
+       uint32_t client_packets_recv;
+       uint32_t node_packets_sent;
+       uint32_t node_packets_recv;
+       uint32_t keepalive_packets_sent;
+       uint32_t keepalive_packets_recv;
+       struct {
+               uint32_t req_call;
+               uint32_t reply_call;
+               uint32_t req_dmaster;
+               uint32_t reply_dmaster;
+               uint32_t reply_error;
+               uint32_t req_message;
+               uint32_t req_control;
+               uint32_t reply_control;
+       } node;
+       struct {
+               uint32_t req_call;
+               uint32_t req_message;
+               uint32_t req_control;
+       } client;
+       struct {
+               uint32_t call;
+               uint32_t control;
+               uint32_t traverse;
+       } timeouts;
+       struct {
+               struct latency_counter ctdbd;
+               struct latency_counter recd;
+       } reclock;
+       struct {
+               uint32_t num_calls;
+               uint32_t num_current;
+               uint32_t num_pending;
+               uint32_t num_failed;
+               struct latency_counter latency;
+               uint32_t buckets[MAX_COUNT_BUCKETS];
+       } locks;
+       uint32_t total_calls;
+       uint32_t pending_calls;
+       uint32_t childwrite_calls;
+       uint32_t pending_childwrite_calls;
+       uint32_t memory_used;
+       uint32_t __last_counter; /* hack for control_statistics_all */
+       uint32_t max_hop_count;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
+       struct latency_counter call_latency;
+       struct latency_counter childwrite_latency;
+       uint32_t num_recoveries;
+       struct timeval statistics_start_time;
+       struct timeval statistics_current_time;
+       uint32_t total_ro_delegations;
+       uint32_t total_ro_revokes;
+};
+
+/*
+ * wire format for statistics history
+ */
+struct ctdb_statistics_wire {
+       uint32_t num;
+       struct ctdb_statistics stats[1];
+};
+
+/*
+ * db statistics
+ */
+struct ctdb_db_hot_key {
+       uint32_t count;
+       TDB_DATA key;
+};
+struct ctdb_db_statistics {
+       struct {
+               uint32_t num_calls;
+               uint32_t num_current;
+               uint32_t num_pending;
+               uint32_t num_failed;
+               struct latency_counter latency;
+               uint32_t buckets[MAX_COUNT_BUCKETS];
+       } locks;
+       uint32_t db_ro_delegations;
+       uint32_t db_ro_revokes;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
+       uint32_t num_hot_keys;
+       struct ctdb_db_hot_key hot_keys[MAX_HOT_KEYS];
+};
+struct ctdb_db_statistics_wire {
+       uint32_t db_ro_delegations;
+       uint32_t db_ro_revokes;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
+       uint32_t num_hot_keys;
+       char hot_keys[1];
+};
+
+/*
+ * wire format for interface list
+ */
+#ifdef IFNAMSIZ
+#define CTDB_IFACE_SIZE IFNAMSIZ
+#else
+#define CTDB_IFACE_SIZE 16
+#endif
+
+struct ctdb_iface_info {
+       char name[CTDB_IFACE_SIZE+2];
+       uint16_t link_state;
+       uint32_t references;
+};
+
+struct ctdb_ifaces_list {
+       uint32_t num;
+       struct ctdb_iface_info ifaces[1];
+};
+
+#define INVALID_GENERATION 1
+/* table that contains the mapping between a hash value and lmaster
+ */
+struct ctdb_vnn_map {
+       uint32_t generation;
+       uint32_t size;
+       uint32_t *map;
+};
+
+/* 
+   a wire representation of the vnn map
+ */
+struct ctdb_vnn_map_wire {
+       uint32_t generation;
+       uint32_t size;
+       uint32_t map[1];
+};
 
 #endif