[SCM] CTDB repository - branch master updated - ctdb-1.0.114-248-gacded03
Ronnie Sahlberg
sahlberg at samba.org
Tue Aug 17 20:39:51 MDT 2010
The branch, master has been updated
via acded034e2f0dcae4c2c9e54e16a001caf23caec (commit)
from 7ef2cddad5326fdcc26138906948342039829495 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit acded034e2f0dcae4c2c9e54e16a001caf23caec
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed Aug 18 12:36:03 2010 +1000
Remove the structure ctdb_control_tcp_vnn since this is identical to the structure ctdb_tcp_connection.
Add a new "ctdb deltickle" command to delete tickles from the database.
This can ONLY be used for tickles created by "ctdb addtickle".
Push any "addtickle/deltickle" updates to other nodes every TickleUpdateInterval seconds'
-----------------------------------------------------------------------
Summary of changes:
include/ctdb_private.h | 11 +--------
include/ctdb_protocol.h | 1 +
server/ctdb_control.c | 12 +++++++++-
server/ctdb_takeover.c | 50 ++++++++++++++++++++++++++++++++++------------
tools/ctdb.c | 49 +++++++++++++++++++++++++++++++++++++++++----
5 files changed, 94 insertions(+), 29 deletions(-)
Changeset truncated at 500 lines:
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index af271f4..8166e15 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -46,6 +46,7 @@ extern pid_t ctdbd_pid;
/*
a tcp connection description
+ also used by tcp_add and tcp_remove controls
*/
struct ctdb_tcp_connection {
ctdb_sock_addr src_addr;
@@ -542,14 +543,6 @@ struct ctdb_control_gratious_arp {
};
/*
- struct for tcp_add and tcp_remove controls
- */
-struct ctdb_control_tcp_vnn {
- ctdb_sock_addr src;
- ctdb_sock_addr dest;
-};
-
-/*
persistent store control - update this record on all other nodes
*/
struct ctdb_control_persistent_store {
@@ -1120,7 +1113,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
TDB_DATA indata);
-int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tcp_update_needed);
int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index 7a5d32d..99765d4 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -329,6 +329,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_GET_PUBLIC_IP_INFO = 123,
CTDB_CONTROL_GET_IFACES = 124,
CTDB_CONTROL_SET_IFACE_LINK_STATE = 125,
+ CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE = 126,
};
/*
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index cbacd17..bfb7bd1 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -334,8 +334,16 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return ctdb_control_startup(ctdb, srcnode);
case CTDB_CONTROL_TCP_ADD:
- CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_tcp_vnn));
- return ctdb_control_tcp_add(ctdb, indata);
+ CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_tcp_connection));
+ return ctdb_control_tcp_add(ctdb, indata, false);
+
+ case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE:
+ CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_tcp_connection));
+ return ctdb_control_tcp_add(ctdb, indata, true);
+
+ case CTDB_CONTROL_TCP_REMOVE:
+ CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_tcp_connection));
+ return ctdb_control_tcp_remove(ctdb, indata);
case CTDB_CONTROL_SET_TUNABLE:
return ctdb_control_set_tunable(ctdb, indata);
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 89e9cef..cc801b1 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -1562,7 +1562,7 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
struct ctdb_control_tcp_addr new_addr;
struct ctdb_control_tcp_addr *tcp_sock = NULL;
struct ctdb_tcp_list *tcp;
- struct ctdb_control_tcp_vnn t;
+ struct ctdb_tcp_connection t;
int ret;
TDB_DATA data;
struct ctdb_client_ip *ip;
@@ -1642,8 +1642,8 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
DLIST_ADD(client->tcp_list, tcp);
- t.src = tcp_sock->src;
- t.dest = tcp_sock->dest;
+ t.src_addr = tcp_sock->src;
+ t.dst_addr = tcp_sock->dest;
data.dptr = (uint8_t *)&t;
data.dsize = sizeof(t);
@@ -1699,22 +1699,24 @@ static struct ctdb_tcp_connection *ctdb_tcp_find(struct ctdb_tcp_array *array,
return NULL;
}
+
+
/*
called by a daemon to inform us of a TCP connection that one of its
clients managing that should tickled with an ACK when IP takeover is
done
*/
-int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata)
+int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tcp_update_needed)
{
- struct ctdb_control_tcp_vnn *p = (struct ctdb_control_tcp_vnn *)indata.dptr;
+ struct ctdb_tcp_connection *p = (struct ctdb_tcp_connection *)indata.dptr;
struct ctdb_tcp_array *tcparray;
struct ctdb_tcp_connection tcp;
struct ctdb_vnn *vnn;
- vnn = find_public_ip_vnn(ctdb, &p->dest);
+ vnn = find_public_ip_vnn(ctdb, &p->dst_addr);
if (vnn == NULL) {
DEBUG(DEBUG_INFO,(__location__ " got TCP_ADD control for an address which is not a public address '%s'\n",
- ctdb_addr_to_str(&p->dest)));
+ ctdb_addr_to_str(&p->dst_addr)));
return -1;
}
@@ -1734,16 +1736,20 @@ int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata)
tcparray->connections = talloc_size(tcparray, sizeof(struct ctdb_tcp_connection));
CTDB_NO_MEMORY(ctdb, tcparray->connections);
- tcparray->connections[tcparray->num].src_addr = p->src;
- tcparray->connections[tcparray->num].dst_addr = p->dest;
+ tcparray->connections[tcparray->num].src_addr = p->src_addr;
+ tcparray->connections[tcparray->num].dst_addr = p->dst_addr;
tcparray->num++;
+
+ if (tcp_update_needed) {
+ vnn->tcp_update_needed = true;
+ }
return 0;
}
/* Do we already have this tickle ?*/
- tcp.src_addr = p->src;
- tcp.dst_addr = p->dest;
+ tcp.src_addr = p->src_addr;
+ tcp.dst_addr = p->dst_addr;
if (ctdb_tcp_find(vnn->tcp_array, &tcp) != NULL) {
DEBUG(DEBUG_DEBUG,("Already had tickle info for %s:%u for vnn:%u\n",
ctdb_addr_to_str(&tcp.dst_addr),
@@ -1759,8 +1765,8 @@ int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata)
CTDB_NO_MEMORY(ctdb, tcparray->connections);
vnn->tcp_array = tcparray;
- tcparray->connections[tcparray->num].src_addr = p->src;
- tcparray->connections[tcparray->num].dst_addr = p->dest;
+ tcparray->connections[tcparray->num].src_addr = p->src_addr;
+ tcparray->connections[tcparray->num].dst_addr = p->dst_addr;
tcparray->num++;
DEBUG(DEBUG_INFO,("Added tickle info for %s:%u from vnn %u\n",
@@ -1768,6 +1774,10 @@ int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata)
ntohs(tcp.dst_addr.ip.sin_port),
vnn->pnn));
+ if (tcp_update_needed) {
+ vnn->tcp_update_needed = true;
+ }
+
return 0;
}
@@ -1836,6 +1846,20 @@ static void ctdb_remove_tcp_connection(struct ctdb_context *ctdb, struct ctdb_tc
/*
+ called by a daemon to inform us of a TCP connection that one of its
+ clients used are no longer needed in the tickle database
+ */
+int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata)
+{
+ struct ctdb_tcp_connection *conn = (struct ctdb_tcp_connection *)indata.dptr;
+
+ ctdb_remove_tcp_connection(ctdb, conn);
+
+ return 0;
+}
+
+
+/*
called when a daemon restarts - send all tickes for all public addresses
we are serving immediately to the new node.
*/
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 4285ef5..d509f17 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -981,11 +981,11 @@ static int control_recmaster(struct ctdb_context *ctdb, int argc, const char **a
}
/*
- add a list of all tickle to a public address
+ add a tickle to a public address
*/
static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_control_tcp_vnn t;
+ struct ctdb_tcp_connection t;
TDB_DATA data;
int ret;
@@ -993,11 +993,11 @@ static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **
usage();
}
- if (parse_ip_port(argv[0], &t.src) == 0) {
+ if (parse_ip_port(argv[0], &t.src_addr) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
- if (parse_ip_port(argv[1], &t.dest) == 0) {
+ if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
return -1;
}
@@ -1006,7 +1006,7 @@ static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **
data.dsize = sizeof(t);
/* tell all nodes about this tcp connection */
- ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_TCP_ADD,
+ ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE,
0, data, ctdb, NULL, NULL, NULL, NULL);
if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to add tickle\n"));
@@ -1018,6 +1018,43 @@ static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **
/*
+ delete a tickle from a node
+ */
+static int control_del_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ struct ctdb_tcp_connection t;
+ TDB_DATA data;
+ int ret;
+
+ if (argc < 2) {
+ usage();
+ }
+
+ if (parse_ip_port(argv[0], &t.src_addr) == 0) {
+ DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
+ return -1;
+ }
+ if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
+ DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
+ return -1;
+ }
+
+ data.dptr = (uint8_t *)&t;
+ data.dsize = sizeof(t);
+
+ /* tell all nodes about this tcp connection */
+ ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_TCP_REMOVE,
+ 0, data, ctdb, NULL, NULL, NULL, NULL);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Failed to remove tickle\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/*
get a list of all tickles for this pnn
*/
static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char **argv)
@@ -4425,6 +4462,8 @@ static const struct {
{ "gettickles", control_get_tickles, false, false, "get the list of tickles registered for this ip", "<ip>" },
{ "addtickle", control_add_tickle, false, false, "add a tickle for this ip", "<ip>:<port> <ip>:<port>" },
+ { "deltickle", control_del_tickle, false, false, "delete a tickle from this ip", "<ip>:<port> <ip>:<port>" },
+
{ "regsrvid", regsrvid, false, false, "register a server id", "<pnn> <type> <id>" },
{ "unregsrvid", unregsrvid, false, false, "unregister a server id", "<pnn> <type> <id>" },
{ "chksrvid", chksrvid, false, false, "check if a server id exists", "<pnn> <type> <id>" },
--
CTDB repository
More information about the samba-cvs
mailing list