1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

merge from tridge

(This used to be ctdb commit 9e6bc12c9be2dabcfb9c6aeef257ef4737287fab)
This commit is contained in:
Ronnie Sahlberg 2007-10-16 11:26:22 +10:00
commit 7e2e1b14fb
7 changed files with 83 additions and 38 deletions

View File

@ -23,6 +23,8 @@ POPT_LIBS = @POPT_LIBS@
POPT_CFLAGS = @POPT_CFLAGS@
POPT_OBJ = @POPT_OBJ@
IPQ_LIBS = @IPQ_LIBS@
CFLAGS=-g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir) \
-I@tallocdir@ -I@tdbdir@/include -I@libreplacedir@ \
-DVARDIR=\"$(localstatedir)\" -DETCDIR=\"$(etcdir)\" \
@ -54,7 +56,7 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o server/ctdb_lockwait.o \
TEST_BINS=bin/ctdb_bench bin/ctdb_fetch bin/ctdb_store bin/ctdb_persistent bin/rb_test \
@INFINIBAND_BINS@
BINS = bin/ctdb @CTDB_SCSI_IO@ @CTDB_IPMUX@ bin/smnotify
BINS = bin/ctdb @CTDB_SCSI_IO@ bin/ctdb_ipmux bin/smnotify
SBINS = bin/ctdbd
DIRS = lib bin
@ -86,7 +88,7 @@ bin/scsi_io: $(CTDB_CLIENT_OBJ) utils/scsi_io/scsi_io.o
bin/ctdb_ipmux: $(CTDB_CLIENT_OBJ) utils/ipmux/ipmux.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ utils/ipmux/ipmux.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) -lipq
@$(CC) $(CFLAGS) -o $@ utils/ipmux/ipmux.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) $(IPQ_LIBS)
bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o
@echo Linking $@

View File

@ -18,13 +18,11 @@ case `uname` in
Linux*)
CTDB_SYSTEM_OBJ=common/system_linux.o
CTDB_SCSI_IO=bin/scsi_io
CTDB_IPMUX=bin/ctdb_ipmux
CTDB_PCAP_LDFLAGS=
;;
AIX*)
CTDB_SYSTEM_OBJ=common/system_aix.o
CTDB_SCSI_IO=
CTDB_IPMUX=
CTDB_PCAP_LDFLAGS=-lpcap
;;
*)
@ -49,6 +47,14 @@ m4_include(libtdb.m4)
m4_include(libevents.m4)
m4_include(ib/config.m4)
AC_CHECK_HEADERS(libipq.h linux/netfilter.h)
IPQ_LIBS=""
if test x"$ac_cv_header_libipq_h" = x"yes"; then
IPQ_LIBS="-lipq"
fi
AC_SUBST(IPQ_LIBS)
AC_CHECK_HEADERS(sched.h)
AC_CHECK_FUNCS(sched_setscheduler)
@ -65,7 +71,6 @@ fi
AC_SUBST(EXTRA_OBJ)
AC_SUBST(CTDB_SYSTEM_OBJ)
AC_SUBST(CTDB_SCSI_IO)
AC_SUBST(CTDB_IPMUX)
AC_SUBST(CTDB_PCAP_LDFLAGS)
AC_OUTPUT(Makefile)

View File

@ -87,6 +87,7 @@ struct ctdb_tunable {
uint32_t recovery_ban_period;
uint32_t database_hash_size;
uint32_t rerecovery_timeout;
uint32_t enable_bans;
};
/*

View File

@ -39,7 +39,7 @@ CC="gcc"
## always run autogen.sh
./autogen.sh
CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
CFLAGS="$RPM_OPT_FLAGS $EXTRA -O0 -D_GNU_SOURCE" ./configure \
--prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \
--mandir=%{_mandir} \

View File

@ -59,7 +59,7 @@ static void ctdb_unban_node(struct ctdb_recoverd *rec, uint32_t pnn)
struct ctdb_context *ctdb = rec->ctdb;
if (!ctdb_validate_pnn(ctdb, pnn)) {
DEBUG(0,("Bad pnn %u in ctdb_ban_node\n", pnn));
DEBUG(0,("Bad pnn %u in ctdb_unban_node\n", pnn));
return;
}
@ -99,6 +99,11 @@ static void ctdb_ban_node(struct ctdb_recoverd *rec, uint32_t pnn, uint32_t ban_
return;
}
if (0 == ctdb->tunable.enable_bans) {
DEBUG(0,("Bans are disabled - ignoring ban of node %u\n", pnn));
return;
}
if (pnn == ctdb->pnn) {
DEBUG(0,("self ban - lowering our election priority\n"));
/* banning ourselves - lower our election priority */
@ -708,6 +713,50 @@ static void ctdb_wait_timeout(struct ctdb_context *ctdb, uint32_t secs)
}
}
/*
update our local flags from all remote connected nodes.
*/
static int update_local_flags(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
{
int j;
TALLOC_CTX *mem_ctx = talloc_new(ctdb);
/* get the nodemap for all active remote nodes and verify
they are the same as for this node
*/
for (j=0; j<nodemap->num; j++) {
struct ctdb_node_map *remote_nodemap=NULL;
int ret;
if (nodemap->nodes[j].flags & NODE_FLAGS_DISCONNECTED) {
continue;
}
if (nodemap->nodes[j].pnn == ctdb->pnn) {
continue;
}
ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
mem_ctx, &remote_nodemap);
if (ret != 0) {
DEBUG(0, (__location__ " Unable to get nodemap from remote node %u\n",
nodemap->nodes[j].pnn));
talloc_free(mem_ctx);
return -1;
}
if (nodemap->nodes[j].flags != remote_nodemap->nodes[j].flags) {
DEBUG(0,("Remote node %u had flags 0x%x, local had 0x%x - updating local\n",
nodemap->nodes[j].pnn, nodemap->nodes[j].flags,
remote_nodemap->nodes[j].flags));
nodemap->nodes[j].flags = remote_nodemap->nodes[j].flags;
}
talloc_free(remote_nodemap);
}
talloc_free(mem_ctx);
return 0;
}
/* Create a new random generation ip.
The generation id can not be the INVALID_GENERATION id
*/
@ -1019,12 +1068,12 @@ static bool ctdb_election_win(struct ctdb_recoverd *rec, struct election_message
/* we cant win if we are banned */
if (rec->node_flags & NODE_FLAGS_BANNED) {
return 0;
return false;
}
/* we will automatically win if the other node is banned */
if (em->node_flags & NODE_FLAGS_BANNED) {
return 1;
return true;
}
/* try to use the most connected node */
@ -1575,7 +1624,7 @@ again:
goto again;
}
/* grap the nodemap from the recovery master to check if it is banned*/
/* grap the nodemap from the recovery master to check if it is banned */
ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
mem_ctx, &remote_nodemap);
if (ret != 0) {
@ -1645,34 +1694,11 @@ again:
}
/* we are recovery master, go through the list of all connected nodes
and get the nodeflags from them and update our copy of nodeflags
*/
for (j=0; j<nodemap->num; j++) {
if (nodemap->nodes[j].flags & NODE_FLAGS_DISCONNECTED) {
continue;
}
if (nodemap->nodes[j].pnn == pnn) {
continue;
}
ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
mem_ctx, &remote_nodemap);
if (ret != 0) {
DEBUG(0, (__location__ " Unable to get nodemap from remote node %u\n",
nodemap->nodes[j].pnn));
goto again;
}
/* update our nodemap flags according to the other
server - this gets the NODE_FLAGS_DISABLED
flag. Note that the remote node is authoritative
for its flags (except CONNECTED, which we know
matches in this code) */
if (nodemap->nodes[j].flags != remote_nodemap->nodes[j].flags) {
nodemap->nodes[j].flags = remote_nodemap->nodes[j].flags;
rec->need_takeover_run = true;
}
/* ensure our local copies of flags are right */
ret = update_local_flags(ctdb, nodemap);
if (ret != 0) {
DEBUG(0,("Unable to update local flags\n"));
goto again;
}
/* update the list of public ips that a node can handle for

View File

@ -43,6 +43,7 @@ static const struct {
{ "RecoveryBanPeriod", 300, offsetof(struct ctdb_tunable, recovery_ban_period) },
{ "DatabaseHashSize", 10000, offsetof(struct ctdb_tunable, database_hash_size) },
{ "RerecoveryTimeout", 10, offsetof(struct ctdb_tunable, rerecovery_timeout) },
{ "EnableBans", 1, offsetof(struct ctdb_tunable, enable_bans) },
};
/*

View File

@ -25,6 +25,8 @@
#include "cmdline.h"
#include "ctdb.h"
#include "ctdb_private.h"
#if defined(HAVE_LINUX_NETFILTER_H) && defined(HAVE_LIBIPQ_H)
#include <linux/netfilter.h>
#include <libipq.h>
@ -227,3 +229,11 @@ int main(int argc, const char *argv[])
return 0;
}
#else
int main(void)
{
printf("ipmux tool disabled - lacking netfilter and libipq development libs\n");
return 1;
}
#endif