mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
merge from tridge
(This used to be ctdb commit 5f1f889e0e124c5275463795c004ae971945e1ae)
This commit is contained in:
commit
317dec2f9e
@ -78,14 +78,6 @@ void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags)
|
||||
ctdb->flags |= flags;
|
||||
}
|
||||
|
||||
/*
|
||||
clear some ctdb flags
|
||||
*/
|
||||
void ctdb_clear_flags(struct ctdb_context *ctdb, unsigned flags)
|
||||
{
|
||||
ctdb->flags &= ~flags;
|
||||
}
|
||||
|
||||
/*
|
||||
set the directory for the local databases
|
||||
*/
|
||||
@ -222,14 +214,16 @@ uint32_t ctdb_get_vnn(struct ctdb_context *ctdb)
|
||||
}
|
||||
|
||||
/*
|
||||
return the number of connected nodes
|
||||
return the number of enabled nodes
|
||||
*/
|
||||
uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb)
|
||||
uint32_t ctdb_get_num_enabled_nodes(struct ctdb_context *ctdb)
|
||||
{
|
||||
int i;
|
||||
uint32_t count=0;
|
||||
for (i=0;i<ctdb->vnn_map->size;i++) {
|
||||
if (ctdb->nodes[ctdb->vnn_map->map[i]]->flags & NODE_FLAGS_CONNECTED) {
|
||||
struct ctdb_node *node = ctdb->nodes[ctdb->vnn_map->map[i]];
|
||||
if ((node->flags & NODE_FLAGS_CONNECTED) &&
|
||||
!(node->flags & NODE_FLAGS_DISABLED)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -487,7 +481,7 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
|
||||
node = ctdb->nodes[hdr->destnode];
|
||||
|
||||
if (hdr->destnode == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (hdr->destnode == ctdb->vnn) {
|
||||
ctdb_defer_packet(ctdb, hdr);
|
||||
} else {
|
||||
node->tx_cnt++;
|
||||
|
@ -47,7 +47,7 @@
|
||||
/*
|
||||
a varient of input packet that can be used in lock requeue
|
||||
*/
|
||||
void ctdb_call_input_pkt(void *p, struct ctdb_req_header *hdr)
|
||||
static void ctdb_call_input_pkt(void *p, struct ctdb_req_header *hdr)
|
||||
{
|
||||
struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
|
||||
ctdb_input_pkt(ctdb, hdr);
|
||||
|
@ -287,8 +287,7 @@ struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db,
|
||||
|
||||
ret = ctdb_ltdb_fetch(ctdb_db, call->key, &header, ctdb_db, &data);
|
||||
|
||||
if (ret == 0 &&
|
||||
header.dmaster == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (ret == 0 && header.dmaster == ctdb->vnn) {
|
||||
state = ctdb_client_call_local_send(ctdb_db, call, &header, &data);
|
||||
talloc_free(data.dptr);
|
||||
ctdb_ltdb_unlock(ctdb_db, call->key);
|
||||
@ -1109,31 +1108,6 @@ int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb, struct timeval timeout, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
delete all records from a tdb
|
||||
*/
|
||||
int ctdb_ctrl_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA indata;
|
||||
int32_t res;
|
||||
|
||||
indata.dsize = sizeof(uint32_t);
|
||||
indata.dptr = (unsigned char *)talloc_array(mem_ctx, uint32_t, 1);
|
||||
|
||||
((uint32_t *)(&indata.dptr[0]))[0] = dbid;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_CLEAR_DB, 0, indata,
|
||||
NULL, NULL, &res, NULL, NULL);
|
||||
if (ret != 0 || res != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for cleardb failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
ping a node, return number of clients connected
|
||||
*/
|
||||
@ -1364,7 +1338,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name)
|
||||
ctdb_db->db_id = *(uint32_t *)data.dptr;
|
||||
talloc_free(data.dptr);
|
||||
|
||||
ret = ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(1, 0), CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
|
||||
ret = ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(2, 0), CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
|
||||
if (ret != 0) {
|
||||
DEBUG(0,("Failed to get dbpath for database '%s'\n", name));
|
||||
talloc_free(ctdb_db);
|
||||
|
@ -112,10 +112,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_set_dmaster));
|
||||
return ctdb_control_set_dmaster(ctdb, indata);
|
||||
|
||||
case CTDB_CONTROL_CLEAR_DB:
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_control_clear_db(ctdb, indata);
|
||||
|
||||
case CTDB_CONTROL_PUSH_DB:
|
||||
return ctdb_control_push_db(ctdb, indata);
|
||||
|
||||
|
@ -359,7 +359,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
call->call_data.dsize = c->calldatalen;
|
||||
call->flags = c->flags;
|
||||
|
||||
if (header.dmaster == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (header.dmaster == ctdb->vnn) {
|
||||
state = ctdb_call_local_send(ctdb_db, call, &header, &data);
|
||||
} else {
|
||||
state = ctdb_daemon_call_send_remote(ctdb_db, call, &header);
|
||||
@ -511,26 +511,6 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
|
||||
|
||||
|
||||
|
||||
static void ctdb_read_from_parent(struct event_context *ev, struct fd_event *fde,
|
||||
uint16_t flags, void *private_data)
|
||||
{
|
||||
int *fd = private_data;
|
||||
int cnt;
|
||||
char buf;
|
||||
|
||||
/* XXX this is a good place to try doing some cleaning up before exiting */
|
||||
cnt = read(*fd, &buf, 1);
|
||||
if (cnt==0) {
|
||||
DEBUG(2,(__location__ " parent process exited. filedescriptor dissappeared\n"));
|
||||
exit(1);
|
||||
} else {
|
||||
DEBUG(0,(__location__ " ctdb: did not expect data from parent process\n"));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
create a unix domain socket and bind it
|
||||
return a file descriptor open on the socket
|
||||
@ -588,66 +568,6 @@ static int unlink_destructor(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
start the protocol going
|
||||
*/
|
||||
int ctdb_start(struct ctdb_context *ctdb)
|
||||
{
|
||||
pid_t pid;
|
||||
static int fd[2];
|
||||
int res;
|
||||
struct fd_event *fde;
|
||||
const char *domain_socket_name;
|
||||
|
||||
/* get rid of any old sockets */
|
||||
unlink(ctdb->daemon.name);
|
||||
|
||||
/* create a unix domain stream socket to listen to */
|
||||
res = ux_socket_bind(ctdb);
|
||||
if (res!=0) {
|
||||
DEBUG(0,(__location__ " Failed to open CTDB unix domain socket\n"));
|
||||
exit(10);
|
||||
}
|
||||
|
||||
res = pipe(&fd[0]);
|
||||
if (res) {
|
||||
DEBUG(0,(__location__ " Failed to open pipe for CTDB\n"));
|
||||
exit(1);
|
||||
}
|
||||
pid = fork();
|
||||
if (pid==-1) {
|
||||
DEBUG(0,(__location__ " Failed to fork CTDB daemon\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pid) {
|
||||
close(fd[0]);
|
||||
close(ctdb->daemon.sd);
|
||||
ctdb->daemon.sd = -1;
|
||||
ctdb->vnn = ctdb_ctrl_getvnn(ctdb, timeval_zero(), CTDB_CURRENT_NODE);
|
||||
if (ctdb->vnn == (uint32_t)-1) {
|
||||
DEBUG(0,(__location__ " Failed to get ctdb vnn\n"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
block_signal(SIGPIPE);
|
||||
|
||||
/* ensure the socket is deleted on exit of the daemon */
|
||||
domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name);
|
||||
talloc_set_destructor(domain_socket_name, unlink_destructor);
|
||||
|
||||
close(fd[1]);
|
||||
|
||||
ctdb->ev = event_context_init(NULL);
|
||||
fde = event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, ctdb_read_from_parent, &fd[0]);
|
||||
fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, ctdb_accept_client, ctdb);
|
||||
ctdb_main_loop(ctdb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
start the protocol going as a daemon
|
||||
|
@ -115,7 +115,7 @@ int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn,
|
||||
int len;
|
||||
|
||||
/* see if this is a message to ourselves */
|
||||
if (vnn == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (vnn == ctdb->vnn) {
|
||||
return ctdb_local_message(ctdb, srvid, data);
|
||||
}
|
||||
|
||||
|
@ -392,48 +392,6 @@ int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int traverse_cleardb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *p)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = tdb_delete(tdb, key);
|
||||
if (ret) {
|
||||
DEBUG(0,(__location__ " failed to delete tdb record\n"));
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctdb_control_clear_db(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||
{
|
||||
uint32_t dbid = *(uint32_t *)indata.dptr;
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
|
||||
if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
|
||||
DEBUG(0,("rejecting ctdb_control_clear_db when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctdb_db = find_ctdb_db(ctdb, dbid);
|
||||
if (!ctdb_db) {
|
||||
DEBUG(0,(__location__ " Unknown db 0x%08x\n",dbid));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb_lock_all_databases_mark(ctdb) != 0) {
|
||||
DEBUG(0,(__location__ " Failed to get lock on entired db - failing\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdb_traverse(ctdb_db->ltdb->tdb, traverse_cleardb, NULL);
|
||||
|
||||
ctdb_lock_all_databases_unmark(ctdb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ctdb_set_recmode_state {
|
||||
struct ctdb_req_control *c;
|
||||
uint32_t recmode;
|
||||
|
@ -662,7 +662,7 @@ static void force_election(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint3
|
||||
/*
|
||||
the main monitoring loop
|
||||
*/
|
||||
void monitor_cluster(struct ctdb_context *ctdb)
|
||||
static void monitor_cluster(struct ctdb_context *ctdb)
|
||||
{
|
||||
uint32_t vnn, num_active, recmode, recmaster;
|
||||
TALLOC_CTX *mem_ctx=NULL;
|
||||
@ -697,6 +697,8 @@ again:
|
||||
"MonitorFrequency", &ctdb->tunable.monitor_frequency);
|
||||
ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE,
|
||||
"ElectionTimeout", &ctdb->tunable.election_timeout);
|
||||
ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE,
|
||||
"TakeoverTimeout", &ctdb->tunable.takeover_timeout);
|
||||
|
||||
vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
|
||||
if (vnn == (uint32_t)-1) {
|
||||
|
@ -116,9 +116,9 @@ static int ctdb_traverse_local_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DAT
|
||||
|
||||
The traverse is finished when the callback is called with tdb_null for key and data
|
||||
*/
|
||||
struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
{
|
||||
struct ctdb_traverse_local_handle *h;
|
||||
int ret;
|
||||
@ -217,9 +217,9 @@ static void ctdb_traverse_all_timeout(struct event_context *ev, struct timed_eve
|
||||
The traverse is finished when the callback is called with tdb_null
|
||||
for key and data
|
||||
*/
|
||||
struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
{
|
||||
struct ctdb_traverse_all_handle *state;
|
||||
struct ctdb_context *ctdb = ctdb_db->ctdb;
|
||||
@ -372,7 +372,7 @@ int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB
|
||||
|
||||
if (key.dsize == 0 && data.dsize == 0) {
|
||||
state->null_count++;
|
||||
if (state->null_count != ctdb_get_num_connected_nodes(ctdb)) {
|
||||
if (state->null_count != ctdb_get_num_enabled_nodes(ctdb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ static const struct {
|
||||
{ "RecoverTimeout", 5, offsetof(struct ctdb_tunable, recover_timeout) },
|
||||
{ "MonitorFrequency", 1, offsetof(struct ctdb_tunable, monitor_frequency) },
|
||||
{ "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) },
|
||||
{ "TakeoverTimeout", 5, offsetof(struct ctdb_tunable, takeover_timeout) },
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -105,17 +105,6 @@ uint32_t ctdb_hash(const TDB_DATA *key)
|
||||
return (1103515243 * value + 12345);
|
||||
}
|
||||
|
||||
/*
|
||||
hash function for a string
|
||||
*/
|
||||
uint32_t ctdb_hash_string(const char *str)
|
||||
{
|
||||
TDB_DATA data;
|
||||
data.dptr = (uint8_t *)discard_const(str);
|
||||
data.dsize = strlen(str)+1;
|
||||
return ctdb_hash(&data);
|
||||
}
|
||||
|
||||
/*
|
||||
a type checking varient of idr_find
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ double timeval_elapsed(struct timeval *tv)
|
||||
/**
|
||||
return a timeval struct with the given elements
|
||||
*/
|
||||
struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = secs;
|
||||
@ -55,7 +55,7 @@ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
return tv;
|
||||
}
|
||||
|
||||
int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
{
|
||||
if (tv1->tv_sec > tv2->tv_sec) return 1;
|
||||
if (tv1->tv_sec < tv2->tv_sec) return -1;
|
||||
@ -64,8 +64,8 @@ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timeval timeval_until(const struct timeval *tv1,
|
||||
const struct timeval *tv2)
|
||||
_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1,
|
||||
const struct timeval *tv2)
|
||||
{
|
||||
struct timeval t;
|
||||
if (timeval_compare(tv1, tv2) >= 0) {
|
||||
@ -81,7 +81,7 @@ struct timeval timeval_until(const struct timeval *tv1,
|
||||
return t;
|
||||
}
|
||||
|
||||
_PUBLIC_ struct timeval timeval_add(const struct timeval *tv,
|
||||
static struct timeval timeval_add(const struct timeval *tv,
|
||||
uint32_t secs, uint32_t usecs)
|
||||
{
|
||||
struct timeval tv2 = *tv;
|
||||
@ -100,7 +100,7 @@ _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
|
||||
return timeval_add(&tv, secs, usecs);
|
||||
}
|
||||
|
||||
_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
static char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct stat sbuf;
|
||||
char *p;
|
||||
@ -122,7 +122,7 @@ _PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
}
|
||||
|
||||
|
||||
_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
static char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
int fd;
|
||||
char *p;
|
||||
|
@ -20,6 +20,11 @@
|
||||
# default is to not manage Samba
|
||||
# CTDB_MANAGES_SAMBA=yes
|
||||
|
||||
# you may wish to raise the file descriptor limit for ctdb
|
||||
# use a ulimit command here. ctdb needs one file descriptor per
|
||||
# connected client (ie. one per connected client in Samba)
|
||||
# ulimit -n 10000
|
||||
|
||||
# the NODES file must be specified or ctdb won't start
|
||||
# it should contain a list of IPs that ctdb will use
|
||||
# it must be exactly the same on all cluster nodes
|
||||
|
@ -5,7 +5,9 @@
|
||||
# This script is called with one of the following sets of arguments
|
||||
# startup : called when ctdb starts
|
||||
# shutdown : called when ctdb shuts down
|
||||
# takeip
|
||||
# takeip : called when an IP address is taken over
|
||||
# releaseip : called when an IP address is released
|
||||
# recovered : called when ctdb has finished a recovery event
|
||||
|
||||
. /etc/ctdb/functions
|
||||
loadconfig ctdb
|
||||
|
@ -17,8 +17,14 @@ case $cmd in
|
||||
smb_dirs=`testparm -st 2> /dev/null | egrep '^\s*path = ' | cut -d= -f2`
|
||||
ctdb_wait_directories "Samba" $smb_dirs
|
||||
|
||||
# start Samba service
|
||||
service smb start
|
||||
# make sure samba is not already started
|
||||
service smb stop > /dev/null 2>&1
|
||||
service winbind stop > /dev/null 2>&1
|
||||
|
||||
# start Samba service. Start it reniced, as under very heavy load
|
||||
# the number of smbd processes will mean that it leaves few cycles for
|
||||
# anything else
|
||||
nice service smb start
|
||||
service winbind start
|
||||
|
||||
# wait for the Samba tcp ports to become available
|
||||
|
@ -16,6 +16,8 @@ case $cmd in
|
||||
/bin/mkdir -p /etc/ctdb/state/statd/ip
|
||||
ctdb_wait_directories "nfslock" "$STATD_SHARED_DIRECTORY"
|
||||
|
||||
# make sure the service is stopped first
|
||||
service nfslock stop > /dev/null 2>&1
|
||||
service nfslock start
|
||||
;;
|
||||
|
||||
|
@ -14,9 +14,11 @@ case $cmd in
|
||||
mkdir -p /etc/ctdb/state/nfs
|
||||
|
||||
# wait for all nfs exported directories to become available
|
||||
nfs_dirs=`cut -d' ' -f1 /etc/exports`
|
||||
nfs_dirs=`grep -v '^#' < /etc/exports | cut -d' ' -f1`
|
||||
ctdb_wait_directories "NFS" $nfs_dirs
|
||||
|
||||
# make sure nfs is stopped before we start it, or it may get a bind error
|
||||
service nfs stop > /dev/null 2>&1
|
||||
service nfs start
|
||||
;;
|
||||
|
||||
|
@ -48,14 +48,12 @@ static struct {
|
||||
const char *logfile;
|
||||
const char *recovery_lock_file;
|
||||
const char *db_dir;
|
||||
int self_connect;
|
||||
} options = {
|
||||
.nlist = ETCDIR "/ctdb/nodes",
|
||||
.transport = "tcp",
|
||||
.event_script = ETCDIR "/ctdb/events",
|
||||
.logfile = VARDIR "/log/log.ctdb",
|
||||
.db_dir = VARDIR "/ctdb",
|
||||
.self_connect = 0,
|
||||
};
|
||||
|
||||
|
||||
@ -79,7 +77,6 @@ int main(int argc, const char *argv[])
|
||||
{ "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
|
||||
{ "listen", 0, POPT_ARG_STRING, &options.myaddress, 0, "address to listen on", "address" },
|
||||
{ "transport", 0, POPT_ARG_STRING, &options.transport, 0, "protocol transport", NULL },
|
||||
{ "self-connect", 0, POPT_ARG_NONE, &options.self_connect, 0, "enable self connect", "boolean" },
|
||||
{ "dbdir", 0, POPT_ARG_STRING, &options.db_dir, 0, "directory for the tdb files", NULL },
|
||||
{ "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
|
||||
POPT_TABLEEND
|
||||
@ -125,10 +122,6 @@ int main(int argc, const char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (options.self_connect) {
|
||||
ctdb_set_flags(ctdb, CTDB_FLAG_SELF_CONNECT);
|
||||
}
|
||||
|
||||
ret = ctdb_set_transport(ctdb, options.transport);
|
||||
if (ret == -1) {
|
||||
printf("ctdb_set_transport failed - %s\n", ctdb_errstr(ctdb));
|
||||
|
@ -106,10 +106,9 @@ static int ctdb_ibw_start(struct ctdb_context *ctdb)
|
||||
/* everything async here */
|
||||
for (i=0;i<ctdb->num_nodes;i++) {
|
||||
struct ctdb_node *node = ctdb->nodes[i];
|
||||
if (!(ctdb->flags & CTDB_FLAG_SELF_CONNECT) &&
|
||||
ctdb_same_address(&ctdb->address, &node->address))
|
||||
continue;
|
||||
ctdb_ibw_node_connect(node);
|
||||
if (!ctdb_same_address(&ctdb->address, &node->address)) {
|
||||
ctdb_ibw_node_connect(node);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -49,7 +49,6 @@ struct ctdb_call_info {
|
||||
/*
|
||||
ctdb flags
|
||||
*/
|
||||
#define CTDB_FLAG_SELF_CONNECT (1<<0)
|
||||
#define CTDB_FLAG_TORTURE (1<<1)
|
||||
|
||||
/*
|
||||
@ -102,11 +101,6 @@ int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
|
||||
*/
|
||||
void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
|
||||
|
||||
/*
|
||||
clear some flags
|
||||
*/
|
||||
void ctdb_clear_flags(struct ctdb_context *ctdb, unsigned flags);
|
||||
|
||||
/*
|
||||
set max acess count before a dmaster migration
|
||||
*/
|
||||
@ -277,11 +271,6 @@ int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
|
||||
|
||||
/*
|
||||
delete all records from a tdb
|
||||
*/
|
||||
int ctdb_ctrl_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid);
|
||||
|
||||
/*
|
||||
write a record on a specific db (this implicitely updates dmaster of the record to locally be the vnn of the node where the control is executed on)
|
||||
*/
|
||||
|
@ -50,6 +50,7 @@ struct ctdb_tunable {
|
||||
uint32_t recover_timeout;
|
||||
uint32_t monitor_frequency;
|
||||
uint32_t election_timeout;
|
||||
uint32_t takeover_timeout;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -109,6 +110,7 @@ struct ctdb_node {
|
||||
void *private_data; /* private to transport */
|
||||
uint32_t vnn;
|
||||
#define NODE_FLAGS_CONNECTED 0x00000001
|
||||
#define NODE_FLAGS_DISABLED 0x00000002
|
||||
uint32_t flags;
|
||||
|
||||
/* used by the dead node monitoring */
|
||||
@ -367,7 +369,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
|
||||
CTDB_CONTROL_GET_DBMAP = 9,
|
||||
CTDB_CONTROL_GET_NODEMAP = 10,
|
||||
CTDB_CONTROL_SET_DMASTER = 11,
|
||||
CTDB_CONTROL_CLEAR_DB = 12,
|
||||
/* #12 removed */
|
||||
CTDB_CONTROL_PULL_DB = 13,
|
||||
CTDB_CONTROL_PUSH_DB = 14,
|
||||
CTDB_CONTROL_GET_RECMODE = 15,
|
||||
@ -891,7 +893,6 @@ struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
|
||||
int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
int32_t ctdb_control_clear_db(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
|
||||
int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control *c,
|
||||
@ -905,7 +906,7 @@ int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
|
||||
|
||||
int ctdb_start_recoverd(struct ctdb_context *ctdb);
|
||||
|
||||
uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb);
|
||||
uint32_t ctdb_get_num_enabled_nodes(struct ctdb_context *ctdb);
|
||||
|
||||
int ctdb_start_monitoring(struct ctdb_context *ctdb);
|
||||
void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "../include/ctdb_private.h"
|
||||
|
||||
|
||||
#define TAKEOVER_TIMEOUT() timeval_current_ofs(5,0)
|
||||
#define TAKEOVER_TIMEOUT() timeval_current_ofs(ctdb->tunable.takeover_timeout,0)
|
||||
|
||||
#define CTDB_ARP_INTERVAL 1
|
||||
#define CTDB_ARP_REPEAT 3
|
||||
@ -180,7 +180,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
|
||||
state->c = talloc_steal(ctdb, c);
|
||||
state->sin = talloc(ctdb, struct sockaddr_in);
|
||||
CTDB_NO_MEMORY(ctdb, state->sin);
|
||||
*state->sin = *(struct sockaddr_in *)indata.dptr;
|
||||
*state->sin = pip->sin;
|
||||
|
||||
DEBUG(0,("Takover of IP %s/%u on interface %s\n",
|
||||
ip, ctdb->nodes[ctdb->vnn]->public_netmask_bits,
|
||||
@ -284,7 +284,7 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
|
||||
state->c = talloc_steal(state, c);
|
||||
state->sin = talloc(state, struct sockaddr_in);
|
||||
CTDB_NO_MEMORY(ctdb, state->sin);
|
||||
*state->sin = *(struct sockaddr_in *)indata.dptr;
|
||||
*state->sin = pip->sin;
|
||||
|
||||
ret = ctdb_event_script_callback(ctdb, state, release_ip_callback, state,
|
||||
"releaseip %s %s %u",
|
||||
@ -403,7 +403,8 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
|
||||
|
||||
/* work out which node will look after each public IP */
|
||||
for (i=0;i<nodemap->num;i++) {
|
||||
if (nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) {
|
||||
if ((nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) &&
|
||||
!(nodemap->nodes[i].flags & NODE_FLAGS_DISABLED)) {
|
||||
ctdb->nodes[i]->takeover_vnn = nodemap->nodes[i].vnn;
|
||||
} else {
|
||||
/* assign this dead nodes IP to the next higher node */
|
||||
@ -411,6 +412,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
|
||||
j != i;
|
||||
j=(j+1)%nodemap->num) {
|
||||
if ((nodemap->nodes[j].flags & NODE_FLAGS_CONNECTED) &&
|
||||
!(nodemap->nodes[j].flags & NODE_FLAGS_DISABLED) &&
|
||||
ctdb_same_subnet(ctdb->nodes[j]->public_address,
|
||||
ctdb->nodes[i]->public_address,
|
||||
ctdb->nodes[j]->public_netmask_bits)) {
|
||||
|
@ -48,7 +48,7 @@ int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface)
|
||||
|
||||
/* for now, we only handle AF_INET addresses */
|
||||
if (saddr->sin_family != AF_INET) {
|
||||
DEBUG(0,(__location__ " not an ipv4 address\n"));
|
||||
DEBUG(0,(__location__ " not an ipv4 address (family is %u)\n", saddr->sin_family));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -386,6 +386,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
|
||||
if (state->child == 0) {
|
||||
close(state->fd[0]);
|
||||
ctdb_set_realtime(false);
|
||||
set_close_on_exec(state->fd[1]);
|
||||
va_start(ap, fmt);
|
||||
ret = ctdb_event_script_v(ctdb, fmt, ap);
|
||||
va_end(ap);
|
||||
|
@ -80,10 +80,10 @@ static int ctdb_tcp_start(struct ctdb_context *ctdb)
|
||||
struct ctdb_node *node = *(ctdb->nodes + i);
|
||||
struct ctdb_tcp_node *tnode = talloc_get_type(
|
||||
node->private_data, struct ctdb_tcp_node);
|
||||
if (!(ctdb->flags & CTDB_FLAG_SELF_CONNECT) &&
|
||||
ctdb_same_address(&ctdb->address, &node->address)) continue;
|
||||
event_add_timed(ctdb->ev, tnode, timeval_zero(),
|
||||
ctdb_tcp_node_connect, node);
|
||||
if (!ctdb_same_address(&ctdb->address, &node->address)) {
|
||||
event_add_timed(ctdb->ev, tnode, timeval_zero(),
|
||||
ctdb_tcp_node_connect, node);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -383,7 +383,7 @@ static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **ar
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ctdb_ctrl_shutdown(ctdb, timeval_current_ofs(1, 0), options.vnn);
|
||||
ret = ctdb_ctrl_shutdown(ctdb, TIMELIMIT(), options.vnn);
|
||||
if (ret != 0) {
|
||||
printf("Unable to shutdown node %u\n", options.vnn);
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user