summaryrefslogtreecommitdiff
path: root/source4/cluster
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-08-08 03:18:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:01:33 -0500
commitb7b3e3e0d40f257942ec528cf069b3451caa699f (patch)
tree45938f6134a503ffb6990f72daf29464ac015371 /source4/cluster
parentedca65915afbfde51ab75a27d5ebcb5ab0c85f20 (diff)
downloadsamba-b7b3e3e0d40f257942ec528cf069b3451caa699f.tar.gz
samba-b7b3e3e0d40f257942ec528cf069b3451caa699f.tar.bz2
samba-b7b3e3e0d40f257942ec528cf069b3451caa699f.zip
r24274: - merge from ctdb bzr tree
- use ctdb_attach() instead of ctdb_db_handle() - make ctdb_attach() return an existing db handle if it exists (This used to be commit be85c48f8d4a22fd4ed922be6f7f1979f349d291)
Diffstat (limited to 'source4/cluster')
-rw-r--r--source4/cluster/ctdb/client/ctdb_client.c60
-rw-r--r--source4/cluster/ctdb/common/cmdline.c6
-rw-r--r--source4/cluster/ctdb/common/ctdb_util.c44
-rw-r--r--source4/cluster/ctdb/configure.ac20
-rw-r--r--source4/cluster/ctdb/include/ctdb.h2
-rw-r--r--source4/cluster/ctdb/include/ctdb_private.h86
-rw-r--r--source4/cluster/ctdb/opendb_ctdb.c2
-rw-r--r--source4/cluster/ctdb/packaging/RPM/ctdb.spec3
8 files changed, 200 insertions, 23 deletions
diff --git a/source4/cluster/ctdb/client/ctdb_client.c b/source4/cluster/ctdb/client/ctdb_client.c
index b72faa83d7..d85f883b22 100644
--- a/source4/cluster/ctdb/client/ctdb_client.c
+++ b/source4/cluster/ctdb/client/ctdb_client.c
@@ -1432,6 +1432,11 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name)
int ret;
int32_t res;
+ ctdb_db = ctdb_db_handle(ctdb, name);
+ if (ctdb_db) {
+ return ctdb_db;
+ }
+
ctdb_db = talloc_zero(ctdb, struct ctdb_db_context);
CTDB_NO_MEMORY_NULL(ctdb, ctdb_db);
@@ -2095,6 +2100,59 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
/*
+ kill a tcp connection
+ */
+int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
+ struct timeval timeout,
+ uint32_t destnode,
+ struct ctdb_control_killtcp *killtcp)
+{
+ TDB_DATA data;
+ int32_t res;
+ int ret;
+
+ data.dsize = sizeof(struct ctdb_control_killtcp);
+ data.dptr = (unsigned char *)killtcp;
+
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_KILL_TCP, 0, data, NULL,
+ NULL, &res, &timeout, NULL);
+ if (ret != 0 || res != 0) {
+ DEBUG(0,(__location__ " ctdb_control for killtcp failed\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ get a list of all tcp tickles that a node knows about for a particular vnn
+ */
+int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx, uint32_t vnn,
+ struct ctdb_control_tcp_tickle_list **list)
+{
+ int ret;
+ TDB_DATA data, outdata;
+ int32_t status;
+
+ data.dptr = (uint8_t*)&vnn;
+ data.dsize = sizeof(vnn);
+
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_GET_TCP_TICKLE_LIST, 0, data,
+ mem_ctx, &outdata, &status, NULL, NULL);
+ if (ret != 0) {
+ DEBUG(0,(__location__ " ctdb_control for get tcp tickles failed\n"));
+ return -1;
+ }
+
+ *list = (struct ctdb_control_tcp_tickle_list *)outdata.dptr;
+
+ return status;
+}
+
+/*
initialise the ctdb daemon for client applications
NOTE: In current code the daemon does not fork. This is for testing purposes only
@@ -2109,6 +2167,8 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
ctdb->idr = idr_init(ctdb);
CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr);
+ ctdb_set_socketname(ctdb, CTDB_PATH);
+
return ctdb;
}
diff --git a/source4/cluster/ctdb/common/cmdline.c b/source4/cluster/ctdb/common/cmdline.c
index f8fca5e4a0..df01110e8a 100644
--- a/source4/cluster/ctdb/common/cmdline.c
+++ b/source4/cluster/ctdb/common/cmdline.c
@@ -102,20 +102,20 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev)
/* initialise ctdb */
ctdb = ctdb_init(ev);
if (ctdb == NULL) {
- printf("Failed to init ctdb\n");
+ fprintf(stderr, "Failed to init ctdb\n");
exit(1);
}
/* tell ctdb the socket address */
ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname);
if (ret == -1) {
- printf("ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb));
+ fprintf(stderr, "ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb));
exit(1);
}
ret = ctdb_socket_connect(ctdb);
if (ret != 0) {
- DEBUG(0,(__location__ " Failed to connect to daemon\n"));
+ fprintf(stderr, __location__ " Failed to connect to daemon\n");
talloc_free(ctdb);
return NULL;
}
diff --git a/source4/cluster/ctdb/common/ctdb_util.c b/source4/cluster/ctdb/common/ctdb_util.c
index f8f7cb5150..54b1e4e7ff 100644
--- a/source4/cluster/ctdb/common/ctdb_util.c
+++ b/source4/cluster/ctdb/common/ctdb_util.c
@@ -192,20 +192,42 @@ struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
/*
if possible, make this task real time
*/
-void ctdb_set_realtime(bool enable)
+void ctdb_set_scheduler(struct ctdb_context *ctdb)
{
-#if HAVE_SCHED_SETSCHEDULER
+#if HAVE_SCHED_SETSCHEDULER
struct sched_param p;
- p.__sched_priority = 1;
-
- if (enable) {
- if (sched_setscheduler(getpid(), SCHED_FIFO, &p) == -1) {
- DEBUG(0,("Unable to set scheduler to SCHED_FIFO (%s)\n", strerror(errno)));
- } else {
- DEBUG(0,("Set scheduler to SCHED_FIFO\n"));
- }
+ if (ctdb->saved_scheduler_param == NULL) {
+ ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(p));
+ }
+
+ if (sched_getparam(0, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
+ DEBUG(0,("Unable to get old scheduler params\n"));
+ return;
+ }
+
+ p = *(struct sched_param *)ctdb->saved_scheduler_param;
+ p.sched_priority = 1;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) {
+ DEBUG(0,("Unable to set scheduler to SCHED_FIFO (%s)\n",
+ strerror(errno)));
} else {
- sched_setscheduler(getpid(), SCHED_OTHER, &p);
+ DEBUG(0,("Set scheduler to SCHED_FIFO\n"));
+ }
+#endif
+}
+
+/*
+ restore previous scheduler parameters
+ */
+void ctdb_restore_scheduler(struct ctdb_context *ctdb)
+{
+#if HAVE_SCHED_SETSCHEDULER
+ if (ctdb->saved_scheduler_param == NULL) {
+ ctdb_fatal(ctdb, "No saved scheduler parameters\n");
+ }
+ if (sched_setscheduler(0, SCHED_OTHER, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
+ ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n");
}
#endif
}
diff --git a/source4/cluster/ctdb/configure.ac b/source4/cluster/ctdb/configure.ac
index 86a70d157d..63ebc28c91 100644
--- a/source4/cluster/ctdb/configure.ac
+++ b/source4/cluster/ctdb/configure.ac
@@ -14,6 +14,23 @@ AC_DEFUN([SMB_ENABLE], [echo -n ""])
AC_INIT(ctdb.h)
AC_CONFIG_SRCDIR([server/ctdbd.c])
+case `uname` in
+ Linux*)
+ CTDB_SYSTEM_OBJ=common/system_linux.o
+ CTDB_SCSI_IO=bin/scsi_io
+ CTDB_PCAP_LDFLAGS=
+ ;;
+ AIX*)
+ CTDB_SYSTEM_OBJ=common/system_aix.o
+ CTDB_SCSI_IO=
+ CTDB_PCAP_LDFLAGS=-lpcap
+ ;;
+ *)
+ echo unknown system cant configure
+ exit
+ ;;
+esac
+
AC_LIBREPLACE_ALL_CHECKS
if test "$ac_cv_prog_gcc" = yes; then
@@ -44,5 +61,8 @@ if test x"$ctdb_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
fi
AC_SUBST(EXTRA_OBJ)
+AC_SUBST(CTDB_SYSTEM_OBJ)
+AC_SUBST(CTDB_SCSI_IO)
+AC_SUBST(CTDB_PCAP_LDFLAGS)
AC_OUTPUT(Makefile)
diff --git a/source4/cluster/ctdb/include/ctdb.h b/source4/cluster/ctdb/include/ctdb.h
index 6c25b7fa9d..a2b87401ca 100644
--- a/source4/cluster/ctdb/include/ctdb.h
+++ b/source4/cluster/ctdb/include/ctdb.h
@@ -367,4 +367,6 @@ int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
uint32_t destnode,
uint32_t set, uint32_t clear);
+int ctdb_socket_connect(struct ctdb_context *ctdb);
+
#endif
diff --git a/source4/cluster/ctdb/include/ctdb_private.h b/source4/cluster/ctdb/include/ctdb_private.h
index bd64f978eb..7542b3100f 100644
--- a/source4/cluster/ctdb/include/ctdb_private.h
+++ b/source4/cluster/ctdb/include/ctdb_private.h
@@ -37,6 +37,35 @@
#define CTDB_NULL_FUNC 0xFF000001
#define CTDB_FETCH_FUNC 0xFF000002
+/*
+ a tcp connection description
+ */
+struct ctdb_tcp_connection {
+ struct sockaddr_in saddr;
+ struct sockaddr_in daddr;
+};
+
+/* the wire representation for a tcp tickle array */
+struct ctdb_tcp_wire_array {
+ uint32_t num;
+ struct ctdb_tcp_connection connections[1];
+};
+
+/* the list of tcp tickles used by get/set tcp tickle list */
+struct ctdb_control_tcp_tickle_list {
+ uint32_t vnn;
+ struct ctdb_tcp_wire_array tickles;
+};
+
+/*
+ array of tcp connections
+ */
+struct ctdb_tcp_array {
+ uint32_t num;
+ struct ctdb_tcp_connection *connections;
+};
+
+
/* all tunable variables go in here */
struct ctdb_tunable {
uint32_t max_redirect_count;
@@ -51,6 +80,7 @@ struct ctdb_tunable {
uint32_t election_timeout;
uint32_t takeover_timeout;
uint32_t monitor_interval;
+ uint32_t tickle_update_interval;
uint32_t script_timeout;
uint32_t recovery_grace_period;
uint32_t recovery_ban_period;
@@ -139,6 +169,13 @@ struct ctdb_node {
/* the node number that has taken over this nodes public address, if any.
If not taken over, then set to -1 */
int32_t takeover_vnn;
+
+ /* List of clients to tickle for this public address */
+ struct ctdb_tcp_array *tcp_array;
+
+ /* whether we need to update the other nodes with changes to our list
+ of connected clients */
+ bool tcp_update_needed;
};
/*
@@ -274,6 +311,7 @@ struct ctdb_context {
uint32_t recovery_mode;
uint32_t monitoring_mode;
TALLOC_CTX *monitor_context;
+ TALLOC_CTX *tickle_update_context;
struct ctdb_tunable tunable;
enum ctdb_freeze_mode freeze_mode;
struct ctdb_freeze_handle *freeze_handle;
@@ -305,8 +343,10 @@ struct ctdb_context {
uint32_t recovery_master;
struct ctdb_call_state *pending_calls;
struct ctdb_takeover takeover;
- struct ctdb_tcp_list *tcp_list;
struct ctdb_client_ip *client_ip_list;
+ bool do_setsched;
+ void *saved_scheduler_param;
+ struct ctdb_kill_tcp *killtcp;
};
struct ctdb_db_context {
@@ -406,6 +446,9 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_GET_PUBLIC_IPS = 51,
CTDB_CONTROL_MODIFY_FLAGS = 52,
CTDB_CONTROL_GET_ALL_TUNABLES = 53,
+ CTDB_CONTROL_KILL_TCP = 54,
+ CTDB_CONTROL_GET_TCP_TICKLE_LIST = 55,
+ CTDB_CONTROL_SET_TCP_TICKLE_LIST = 56,
};
/*
@@ -442,6 +485,14 @@ struct ctdb_control_tcp {
};
/*
+ struct for kill_tcp control
+ */
+struct ctdb_control_killtcp {
+ struct sockaddr_in src;
+ struct sockaddr_in dst;
+};
+
+/*
struct for tcp_add and tcp_remove controls
*/
struct ctdb_control_tcp_vnn {
@@ -931,6 +982,7 @@ uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
void ctdb_stop_monitoring(struct ctdb_context *ctdb);
void ctdb_start_monitoring(struct ctdb_context *ctdb);
+void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
@@ -947,7 +999,8 @@ int ctdb_ctrl_set_rsn_nonempty(struct ctdb_context *ctdb, struct timeval timeout
uint32_t destnode, uint32_t db_id, uint64_t rsn);
int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, uint32_t db_id, uint64_t rsn);
-void ctdb_set_realtime(bool enable);
+void ctdb_set_scheduler(struct ctdb_context *ctdb);
+void ctdb_restore_scheduler(struct ctdb_context *ctdb);
int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
TDB_DATA indata,
@@ -980,22 +1033,23 @@ int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
/* from takeover/system.c */
int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface);
bool ctdb_sys_have_ip(const char *ip);
-int ctdb_sys_send_tcp(const struct sockaddr_in *dest,
+int ctdb_sys_send_tcp(int fd,
+ const struct sockaddr_in *dest,
const struct sockaddr_in *src,
uint32_t seq, uint32_t ack, int rst);
-int ctdb_sys_kill_tcp(struct event_context *ev,
- const struct sockaddr_in *dest,
- const struct sockaddr_in *src);
int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
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,
- uint32_t srcnode, TDB_DATA indata);
+ TDB_DATA indata);
int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
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);
+int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
+int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata);
void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
@@ -1032,4 +1086,22 @@ void ctdb_start_freeze(struct ctdb_context *ctdb);
bool parse_ip_port(const char *s, struct sockaddr_in *ip);
+int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
+int ctdb_sys_close_capture_socket(void *private_data);
+int ctdb_sys_open_sending_socket(void);
+int ctdb_sys_read_tcp_packet(int s, void *private_data, struct sockaddr_in *src, struct sockaddr_in *dst,
+ uint32_t *ack_seq, uint32_t *seq);
+
+int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
+ struct timeval timeout,
+ uint32_t destnode,
+ struct ctdb_control_killtcp *killtcp);
+
+int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
+ struct timeval timeout,
+ uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ uint32_t vnn,
+ struct ctdb_control_tcp_tickle_list **list);
+
#endif
diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c
index ed047b76ba..f894af839e 100644
--- a/source4/cluster/ctdb/opendb_ctdb.c
+++ b/source4/cluster/ctdb/opendb_ctdb.c
@@ -86,7 +86,7 @@ static struct odb_context *odb_ctdb_init(TALLOC_CTX *mem_ctx,
}
odb->ctdb = ctdb;
- odb->ctdb_db = ctdb_db_handle(ctdb, "opendb");
+ odb->ctdb_db = ctdb_attach(ctdb, "opendb");
if (!odb->ctdb_db) {
DEBUG(0,("Failed to get attached ctdb db handle for opendb\n"));
talloc_free(odb);
diff --git a/source4/cluster/ctdb/packaging/RPM/ctdb.spec b/source4/cluster/ctdb/packaging/RPM/ctdb.spec
index 6920e643ae..68cad76da1 100644
--- a/source4/cluster/ctdb/packaging/RPM/ctdb.spec
+++ b/source4/cluster/ctdb/packaging/RPM/ctdb.spec
@@ -5,7 +5,7 @@ Vendor: Samba Team
Packager: Samba Team <samba@samba.org>
Name: ctdb
Version: 1.0
-Release: 7
+Release: 8
Epoch: 0
License: GNU GPL version 3
Group: System Environment/Daemons
@@ -102,6 +102,7 @@ fi
%{_sysconfdir}/ctdb/statd-callout
%{_sbindir}/ctdbd
%{_bindir}/ctdb
+%{_bindir}/smnotify
%{_bindir}/onnode.ssh
%{_bindir}/onnode.rsh
%{_bindir}/onnode