[SCM] CTDB repository - branch master updated - ctdb-1.0.114-103-g93f1622
Ronnie Sahlberg
sahlberg at samba.org
Tue May 25 17:03:21 MDT 2010
The branch, master has been updated
via 93f1622cd4106fb1a2acbe643cbb2b3dc9fd0103 (commit)
via 76acb97ebcfc378e98767113a81e413969917bb1 (commit)
via d41b802250ddc0a89581eb6285edfd66bdc7a78a (commit)
via e553da6a060c9cd2514bdb888cf0e50d35572b88 (commit)
via d58b575e15015c5ef9493ab3ad3e8657c5787e2c (commit)
via dce2244e8ac6617c335cfcd721c3795071b9f2b2 (commit)
via 7411b2b577a16f85ad6913e1bfccce7ea260a613 (commit)
via 3727165f0d206999d2cfc2800ff8868640868c7c (commit)
via ebe4dd724338c156423cfdcc10a75b68c2084cde (commit)
via 1c2f08f104cf6b5f97998a3b9a426a4c5dfd4752 (commit)
via f36e891c00c63d5b9dfbaddacff86d9da72d3bb7 (commit)
via f02526486680db1473bdf10328e8f62a2590c745 (commit)
via 732cf6ead4aa2fbefc2b81328171f52c8d935341 (commit)
via 86e1f93df856f9627182ed0e18bfcff6866c0954 (commit)
via 09f05cbfc883e5aac33d3781b163cde178ece4cf (commit)
via 4bba6b8cd47b352f98d41f9f06258d5ac3c9adef (commit)
from 8e9fd36e4619b7cc7bb6f7f7416d13e4c00a296a (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 93f1622cd4106fb1a2acbe643cbb2b3dc9fd0103
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed May 26 09:01:26 2010 +1000
make install to install libctdb.a
commit 76acb97ebcfc378e98767113a81e413969917bb1
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed May 26 08:56:46 2010 +1000
make sure we build libctdb for "make all"
commit d41b802250ddc0a89581eb6285edfd66bdc7a78a
Merge: e553da6a060c9cd2514bdb888cf0e50d35572b88 3727165f0d206999d2cfc2800ff8868640868c7c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue May 25 12:48:49 2010 +1000
Merge commit 'rusty/libctdb2'
commit e553da6a060c9cd2514bdb888cf0e50d35572b88
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue May 25 12:47:15 2010 +1000
new version 1.9
commit d58b575e15015c5ef9493ab3ad3e8657c5787e2c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon May 24 12:33:47 2010 +1000
Add monitoring of quorum and make the node UNHEALTHY when quarum is lost
commit dce2244e8ac6617c335cfcd721c3795071b9f2b2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon May 24 09:51:52 2010 +1000
in 62.cnfs, lines in /etc/exports can have hte exports quoted,
so strip off any initial " on the exports line
commit 7411b2b577a16f85ad6913e1bfccce7ea260a613
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Fri May 21 14:25:47 2010 +1000
It was possible for ->recovery_mode to get out of sync with the new three db priorities in such a way that
->recovery_mode was set to normal but database priorities leven2 or 3 was still set to frozen.
causing the recovery daemon to fail to detect that a recovery was needed to recover access to the database.
BZ63951
commit 3727165f0d206999d2cfc2800ff8868640868c7c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Mon May 24 13:52:17 2010 +0930
libctdb: tweak interface for readrecordlock
Previously we could hang in poll with the callback pending (since we
fake it): explicitly call it immediately.
Note: I experienced corruption using DLIST_ADD_END (ctdb->pnn was blatted
when adding to the message_handler list). I switched them all to DLIST_ADD,
but maybe I'm using it wrong?
commit ebe4dd724338c156423cfdcc10a75b68c2084cde
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Mon May 24 13:17:36 2010 +0930
libctdb: uniform callbacks, _recv functions to pull out data.
This is a bit tricky for those cases where we need to do multiple or
zero I/Os (eg. attachdb and readrecordlock), but works well for the
simple cases.
commit 1c2f08f104cf6b5f97998a3b9a426a4c5dfd4752
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Fri May 21 12:13:10 2010 +0930
patch libctdb-single-callback.patch
commit f36e891c00c63d5b9dfbaddacff86d9da72d3bb7
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Thu May 20 16:16:04 2010 +0930
tst.c: update to Ronnie's latest
This provides a slightly more comprehensive test of the library.
commit f02526486680db1473bdf10328e8f62a2590c745
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Thu May 20 15:57:40 2010 +0930
libctdb: Ronnie's build changes, so we actually build libctdb with make.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 732cf6ead4aa2fbefc2b81328171f52c8d935341
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Fri May 21 12:07:41 2010 +0930
libctdb: first cut, supports getrecmaster only
This is a completely standalone library using only ctdb_protocol.h.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
Header from folded patch 'libctdb-message-handling.patch':
libctdb: add message handling to libctdb.
Now clients can send and receive ctdb messages.
commit 86e1f93df856f9627182ed0e18bfcff6866c0954
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Thu May 20 16:07:30 2010 +0930
libctdb: API changes from Ronnie's version
These simplifications mostly came up due to the implementation.
o Rename ctdb_context to ctdb_connection.
We already have a ctdb_context internally in ctdbd; don't confuse them!
o Rename ctdb_handle to struct ctdb_request.
From the user POV it's a request, and it's also useful internally to
avoid implicit cast to/from void *.
o Rename ctdb_db_context to ctdb_db.
o Introduce ctdb_lock.
This provides an explicit "lock object" you get from readrecordlock
and have to hand to those functions which need you to hold a lock.
o status args are "int" not int32_t.
Should this be a bool?
o Remove last traces on generic callback.
Without semi-sync API, this doesn't help anything and loses type safety.
o Remove the semi-async API.
We can add this later, but I think a sync and async API is enough for
our poor users for the moment :)
o Registering a message handler also takes a callback.
This way you can tell if it failed. Not sure if this is overkill, but it's
consistent.
o ctdb_service() takes an revents arg
Strictly not necessary for a nonblocking fd, but nice to know if a
read or write is possible.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 09f05cbfc883e5aac33d3781b163cde178ece4cf
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Thu May 20 16:01:28 2010 +0930
libctdb: ctdb.h and tst.c from Ronnie
This imports ctdb.h and tst.c from Ronnie's work: it's a separate commit
for now to make the changes obvious.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 4bba6b8cd47b352f98d41f9f06258d5ac3c9adef
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Thu May 20 15:18:30 2010 +0930
libctdb: reorganize headers: remove ctdb.h, add ctdb_client.h and ctdb_protocol.h
ctdb_client.h is the existing internal client interface (which was mainly
in ctdb.h), and ctdb_protocol.h is the information needed for the wire
protocol only.
ctdb.h will be the new, shiny, libctdb API.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
-----------------------------------------------------------------------
Summary of changes:
Makefile.in | 21 +-
common/cmdline.c | 2 +-
common/ctdb_io.c | 2 +-
common/ctdb_logging.c | 2 +-
config/events.d/62.cnfs | 29 ++-
include/ccan/typesafe_cb.h | 177 +++++++++
include/ctdb.h | 792 +++++++------------------------------
include/{ctdb.h => ctdb_client.h} | 276 +++----------
include/ctdb_private.h | 277 +-------------
include/ctdb_protocol.h | 452 +++++++++++++++++++++
include/includes.h | 2 +-
libctdb/control.c | 66 +++
libctdb/ctdb.c | 677 +++++++++++++++++++++++++++++++
libctdb/io_elem.c | 137 +++++++
libctdb/io_elem.h | 35 ++
libctdb/libctdb_private.h | 70 ++++
libctdb/local_tdb.c | 94 +++++
libctdb/local_tdb.h | 10 +
libctdb/messages.c | 117 ++++++
libctdb/messages.h | 8 +
libctdb/sync.c | 94 +++++
libctdb/tst.c | 188 +++++++++
packaging/RPM/ctdb.spec.in | 6 +-
server/ctdb_banning.c | 2 +-
server/ctdb_control.c | 11 +-
server/ctdb_daemon.c | 2 +-
server/ctdb_logging.c | 2 +-
server/ctdb_recoverd.c | 2 +-
tests/src/ctdb_bench.c | 2 +-
tools/ctdb.c | 2 +-
tools/ctdb_vacuum.c | 2 +-
31 files changed, 2402 insertions(+), 1157 deletions(-)
create mode 100644 include/ccan/typesafe_cb.h
copy include/{ctdb.h => ctdb_client.h} (72%)
create mode 100644 include/ctdb_protocol.h
create mode 100644 libctdb/control.c
create mode 100644 libctdb/ctdb.c
create mode 100644 libctdb/io_elem.c
create mode 100644 libctdb/io_elem.h
create mode 100644 libctdb/libctdb_private.h
create mode 100644 libctdb/local_tdb.c
create mode 100644 libctdb/local_tdb.h
create mode 100644 libctdb/messages.c
create mode 100644 libctdb/messages.h
create mode 100644 libctdb/sync.c
create mode 100644 libctdb/tst.c
Changeset truncated at 500 lines:
diff --git a/Makefile.in b/Makefile.in
index 4e70ce8..7b3c621 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,6 +2,9 @@
CC = @CC@
+AR = ar
+ARFLAGS = cru
+RANLIB = ranlib
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
@@ -41,7 +44,10 @@ UTIL_OBJ = lib/util/idtree.o lib/util/db_wrap.o lib/util/strlist.o lib/util/util
CTDB_COMMON_OBJ = common/ctdb_io.o common/ctdb_util.o \
common/ctdb_ltdb.o common/ctdb_message.o common/cmdline.o \
lib/util/debug.o common/rb_tree.o @CTDB_SYSTEM_OBJ@ common/system_common.o \
- common/ctdb_logging.c
+ common/ctdb_logging.c libctdb/libctdb.a
+
+CTDB_LIB_OBJ = libctdb/ctdb.o libctdb/io_elem.o libctdb/local_tdb.o \
+ libctdb/messages.o libctdb/sync.o libctdb/control.o
CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
@@ -72,7 +78,7 @@ DIRS = lib bin tests/bin
.SUFFIXES: .c .o .h .1 .1.xml .1.html
-all: showflags dirs doc $(CTDB_SERVER_OBJ) $(CTDB_CLIENT_OBJ) $(BINS) $(SBINS) $(TEST_BINS)
+all: showflags dirs doc $(CTDB_SERVER_OBJ) $(CTDB_CLIENT_OBJ) $(CTDB_LIB_OBJ) $(BINS) $(SBINS) $(TEST_BINS)
showflags:
@echo 'ctdb will be compiled with flags:'
@@ -102,6 +108,12 @@ bin/ctdbd: $(CTDB_SERVER_OBJ)
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ $(CTDB_SERVER_OBJ) $(LIB_FLAGS)
+libctdb/libctdb.a: $(CTDB_LIB_OBJ)
+ @echo Linking $@
+ -rm -f libctdb.a
+ @$(AR) $(ARFLAGS) libctdb/libctdb.a $(CTDB_LIB_OBJ)
+ @$(RANLIB) libctdb/libctdb.a
+
bin/scsi_io: $(CTDB_CLIENT_OBJ) utils/scsi_io/scsi_io.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ utils/scsi_io/scsi_io.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
@@ -184,7 +196,7 @@ doc: doc/ctdb.1 doc/ctdb.1.html \
doc/onnode.1 doc/onnode.1.html
clean:
- rm -f *.o */*.o */*/*.o */*~
+ rm -f *.o */*.o */*.a */*/*.o */*~
rm -f utils/smnotify/gen_xdr.c
rm -f $(BINS) $(SBINS) $(TEST_BINS)
@@ -207,7 +219,10 @@ install: all
${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir)
${INSTALLCMD} -m 755 bin/smnotify $(DESTDIR)$(bindir)
$(INSTALLCMD) -m 755 bin/ping_pong $(DESTDIR)$(bindir)
+ $(INSTALLCMD) -m 755 libctdb/libctdb.a $(DESTDIR)$(libdir)
${INSTALLCMD} -m 644 include/ctdb.h $(DESTDIR)$(includedir)
+ ${INSTALLCMD} -m 644 include/ctdb_client.h $(DESTDIR)$(includedir)
+ ${INSTALLCMD} -m 644 include/ctdb_protocol.h $(DESTDIR)$(includedir)
${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
diff --git a/common/cmdline.c b/common/cmdline.c
index 332a448..38af6eb 100644
--- a/common/cmdline.c
+++ b/common/cmdline.c
@@ -21,7 +21,7 @@
#include "lib/events/events.h"
#include "system/filesys.h"
#include "popt.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
#include "../include/ctdb_private.h"
#include "../common/rb_tree.h"
#include <ctype.h>
diff --git a/common/ctdb_io.c b/common/ctdb_io.c
index b7feed9..c9ac989 100644
--- a/common/ctdb_io.c
+++ b/common/ctdb_io.c
@@ -27,7 +27,7 @@
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
/* structures for packet queueing - see common/ctdb_io.c */
struct ctdb_partial {
diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index ea4d271..6acc060 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -22,7 +22,7 @@
#include "lib/tdb/include/tdb.h"
#include "system/time.h"
#include "../include/ctdb_private.h"
-#include "../include/ctdb.h"
+#include "../include/ctdb_client.h"
int log_ringbuf_size;
diff --git a/config/events.d/62.cnfs b/config/events.d/62.cnfs
index 2e01d8a..2577675 100755
--- a/config/events.d/62.cnfs
+++ b/config/events.d/62.cnfs
@@ -7,8 +7,9 @@ loadconfig
STATEDIR=$CTDB_BASE/state/gpfs
+
# filesystems needed by nfs
-NFS_FSS=`cat /etc/exports | egrep -v "^#" | sed -e "s/[ \t]*[^ \t]*$//"`
+NFS_FSS=`cat /etc/exports | egrep -v "^#" | sed -e "s/[ \t]*[^ \t]*$//" -e "s/\"//g"`
@@ -22,6 +23,12 @@ check_if_healthy() {
exit 0
}
+ [ -f "$STATEDIR/gpfsnoquorum" ] && {
+ logger No GPFS quorum. Node is UNHEALTHY
+ $CTDB_BASE/events.d/62.cnfs unhealthy "No GPFS quorum. Nodfe is UNHEALTHY."
+ exit 0
+ }
+
logger All required GPFS resources are available. CNFS part is healthy.
$CTDB_BASE/events.d/62.cnfs healthy
}
@@ -81,11 +88,31 @@ case "$1" in
# It checks that all required NFS filesystems are mounted
# and flags the node healthy if so.
gpfsstartup)
+ # assume we always have quorum when starting
+ # we are only interested in the case when we explicitely
+ # lost quorum in an otherwise happy cluster
+ mkdir -p $STATEDIR
+ rm -f "$STATEDIR/gpfsnoquorum"
logger "GPFS is is started."
check_if_healthy
;;
+ gpfsquorumreached)
+ mkdir -p $STATEDIR
+ rm -f "$STATEDIR/gpfsnoquorum"
+ logger "GPFS quorum has been reached."
+ check_if_healthy
+ ;;
+
+ gpfsquorumloss)
+ mkdir -p $STATEDIR
+ touch "$STATEDIR/gpfsnoquorum"
+ logger "GPFS quorum has been lost."
+ $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS quorum was lost! Marking node as UNHEALTHY."
+ ;;
+
+
diff --git a/include/ccan/typesafe_cb.h b/include/ccan/typesafe_cb.h
new file mode 100644
index 0000000..b1f2c5f
--- /dev/null
+++ b/include/ccan/typesafe_cb.h
@@ -0,0 +1,177 @@
+#ifndef CCAN_CAST_IF_TYPE_H
+#define CCAN_CAST_IF_TYPE_H
+
+#if (__GNUC__ >= 3)
+#define HAVE_TYPEOF 1
+#define HAVE_BUILTIN_CHOOSE_EXPR 1
+#define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1
+#endif
+
+#if HAVE_TYPEOF && HAVE_BUILTIN_CHOOSE_EXPR && HAVE_BUILTIN_TYPES_COMPATIBLE_P
+/**
+ * cast_if_type - only cast an expression if test matches a given type
+ * @desttype: the type to cast to
+ * @expr: the expression to cast
+ * @test: the expression to test
+ * @oktype: the type we allow
+ *
+ * This macro is used to create functions which allow multiple types.
+ * The result of this macro is used somewhere that a @desttype type is
+ * expected: if @expr was of type @oktype, it will be cast to
+ * @desttype type. As a result, if @expr is any type other than
+ * @oktype or @desttype, a compiler warning will be issued.
+ *
+ * This macro can be used in static initializers.
+ *
+ * This is merely useful for warnings: if the compiler does not
+ * support the primitives required for cast_if_type(), it becomes an
+ * unconditional cast, and the @test and @oktype argument is not used. In
+ * particular, this means that @oktype can be a type which uses
+ * the "typeof": it will not be evaluated if typeof is not supported.
+ *
+ * Example:
+ * // We can take either an unsigned long or a void *.
+ * void _set_some_value(void *val);
+ * #define set_some_value(e) \
+ * _set_some_value(cast_if_type(void *, (e), (e), unsigned long))
+ */
+#define cast_if_type(desttype, expr, test, oktype) \
+__builtin_choose_expr(__builtin_types_compatible_p(typeof(1?(test):0), oktype), \
+ (desttype)(expr), (expr))
+#else
+#define cast_if_type(desttype, expr, test, oktype) ((desttype)(expr))
+#endif
+
+/**
+ * cast_if_any - only cast an expression if it is one of the three given types
+ * @desttype: the type to cast to
+ * @expr: the expression to cast
+ * @test: the expression to test
+ * @ok1: the first type we allow
+ * @ok2: the second type we allow
+ * @ok3: the third type we allow
+ *
+ * This is a convenient wrapper for multiple cast_if_type() calls. You can
+ * chain them inside each other (ie. use cast_if_any() for expr) if you need
+ * more than 3 arguments.
+ *
+ * Example:
+ * // We can take either a long, unsigned long, void * or a const void *.
+ * void _set_some_value(void *val);
+ * #define set_some_value(expr) \
+ * _set_some_value(cast_if_any(void *, (expr), (expr), \
+ * long, unsigned long, const void *))
+ */
+#define cast_if_any(desttype, expr, test, ok1, ok2, ok3) \
+ cast_if_type(desttype, \
+ cast_if_type(desttype, \
+ cast_if_type(desttype, (expr), (test), ok1), \
+ ok2), \
+ ok3)
+
+/**
+ * typesafe_cb - cast a callback function if it matches the arg
+ * @rtype: the return type of the callback function
+ * @fn: the callback function to cast
+ * @arg: the (pointer) argument to hand to the callback function.
+ *
+ * If a callback function takes a single argument, this macro does
+ * appropriate casts to a function which takes a single void * argument if the
+ * callback provided matches the @arg (or a const or volatile version).
+ *
+ * It is assumed that @arg is of pointer type: usually @arg is passed
+ * or assigned to a void * elsewhere anyway.
+ *
+ * Example:
+ * void _register_callback(void (*fn)(void *arg), void *arg);
+ * #define register_callback(fn, arg) \
+ * _register_callback(typesafe_cb(void, (fn), (arg)), (arg))
+ */
+#define typesafe_cb(rtype, fn, arg) \
+ cast_if_type(rtype (*)(void *), (fn), (fn)(arg), rtype)
+
+/**
+ * typesafe_cb_const - cast a const callback function if it matches the arg
+ * @rtype: the return type of the callback function
+ * @fn: the callback function to cast
+ * @arg: the (pointer) argument to hand to the callback function.
+ *
+ * If a callback function takes a single argument, this macro does appropriate
+ * casts to a function which takes a single const void * argument if the
+ * callback provided matches the @arg.
+ *
+ * It is assumed that @arg is of pointer type: usually @arg is passed
+ * or assigned to a void * elsewhere anyway.
+ *
+ * Example:
+ * void _register_callback(void (*fn)(const void *arg), const void *arg);
+ * #define register_callback(fn, arg) \
+ * _register_callback(typesafe_cb_const(void, (fn), (arg)), (arg))
+ */
+#define typesafe_cb_const(rtype, fn, arg) \
+ sizeof((fn)((const void *)0)), \
+ cast_if_type(rtype (*)(const void *), \
+ (fn), (fn)(arg), rtype (*)(typeof(arg)))
+
+/**
+ * typesafe_cb_preargs - cast a callback function if it matches the arg
+ * @rtype: the return type of the callback function
+ * @fn: the callback function to cast
+ * @arg: the (pointer) argument to hand to the callback function.
+ *
+ * This is a version of typesafe_cb() for callbacks that take other arguments
+ * before the @arg.
+ *
+ * Example:
+ * void _register_callback(void (*fn)(int, void *arg), void *arg);
+ * #define register_callback(fn, arg) \
+ * _register_callback(typesafe_cb_preargs(void, (fn), (arg), int),\
+ * (arg))
+ */
+#define typesafe_cb_preargs(rtype, fn, arg, ...) \
+ cast_if_type(rtype (*)(__VA_ARGS__, void *), (fn), (fn), \
+ rtype (*)(__VA_ARGS__, typeof(arg)))
+/**
+ * typesafe_cb_postargs - cast a callback function if it matches the arg
+ * @rtype: the return type of the callback function
+ * @fn: the callback function to cast
+ * @arg: the (pointer) argument to hand to the callback function.
+ *
+ * This is a version of typesafe_cb() for callbacks that take other arguments
+ * after the @arg.
+ *
+ * Example:
+ * void _register_callback(void (*fn)(void *arg, int), void *arg);
+ * #define register_callback(fn, arg) \
+ * _register_callback(typesafe_cb_postargs(void, (fn), (arg), int),\
+ * (arg))
+ */
+#define typesafe_cb_postargs(rtype, fn, arg, ...) \
+ cast_if_type(rtype (*)(void *, __VA_ARGS__), (fn), (fn), \
+ rtype (*)(typeof(arg), __VA_ARGS__))
+/**
+ * typesafe_cb_cmp - cast a compare function if it matches the arg
+ * @rtype: the return type of the callback function
+ * @fn: the callback function to cast
+ * @arg: the (pointer) argument(s) to hand to the compare function.
+ *
+ * If a callback function takes two matching-type arguments, this macro does
+ * appropriate casts to a function which takes two const void * arguments if
+ * the callback provided takes two a const pointers to @arg.
+ *
+ * It is assumed that @arg is of pointer type: usually @arg is passed
+ * or assigned to a void * elsewhere anyway. Note also that the type
+ * arg points to must be defined.
+ *
+ * Example:
+ * void _my_qsort(void *base, size_t nmemb, size_t size,
+ * int (*cmp)(const void *, const void *));
+ * #define my_qsort(base, nmemb, cmpfn) \
+ * _my_qsort((base), (nmemb), sizeof(*(base)), \
+ * typesafe_cb_cmp(int, (cmpfn), (base)), (arg))
+ */
+#define typesafe_cb_cmp(rtype, cmpfn, arg) \
+ cast_if_type(rtype (*)(const void *, const void *), (cmpfn), \
+ rtype (*)(const typeof(*arg)*, const typeof(*arg)*))
+
+#endif /* CCAN_CAST_IF_TYPE_H */
diff --git a/include/ctdb.h b/include/ctdb.h
index 540ca98..bd4fdc1 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -1,126 +1,64 @@
-/*
+/*
ctdb database library
- Copyright (C) Andrew Tridgell 2006
+ Copyright (C) Ronnie sahlberg 2010
+ Copyright (C) Rusty Russell 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CTDB_H
#define _CTDB_H
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <tdb.h>
-#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;
- uint32_t flags;
-};
+/* All *_send() functions are guaranteed to be non-blocking and fully
+ * asynchronous. The non-_send variants are synchronous. */
/*
- structure passed to a ctdb call backend function
-*/
-struct ctdb_call_info {
- TDB_DATA key; /* record key */
- 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 */
- TDB_DATA *reply_data; /* optionally returned by function */
- uint32_t status; /* optional reply status - defaults to zero */
-};
-
-#define CTDB_ERR_INVALID 1
-#define CTDB_ERR_NOMEM 2
-
-/*
- ctdb flags
-*/
-#define CTDB_FLAG_TORTURE (1<<1)
-
-/*
- a message handler ID meaning "give me all messages"
+ * Connect to ctdb using the specified domain socket.
+ * Returns a ctdb context if successful or NULL.
+ *
+ * Use ctdb_free() to release the returned ctdb_connection when finished.
*/
-#define CTDB_SRVID_ALL (~(uint64_t)0)
+struct ctdb_connection *ctdb_connect(const char *addr);
-/*
- srvid type : RECOVERY
-*/
-#define CTDB_SRVID_RECOVERY 0xF100000000000000LL
+int ctdb_get_fd(struct ctdb_connection *ctdb);
-/*
- a message handler ID meaning that the cluster has been reconfigured
- */
-#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
+int ctdb_which_events(struct ctdb_connection *ctdb);
-/*
- a message handler ID meaning that an IP address has been released
- */
-#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
+int ctdb_service(struct ctdb_connection *ctdb, int revents);
-/*
- a message ID to set the node flags in the recovery daemon
- */
-#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
+struct ctdb_request;
-/*
- a message ID to ask the recovery daemon to update the expected node
- assignment for a public ip
- */
-#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
+void ctdb_request_free(struct ctdb_request *req);
/*
- a message to tell the recovery daemon to fetch a set of records
+ * Callback for completed requests: it would normally unpack the request
+ * using ctdb_*_recv(). You must free the request using ctdb_request_free().
+ *
+ * Note that due to macro magic, your callback doesn't have to take void *,
+ * it can take a type which matches the actual private parameter.
*/
-#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
+typedef void (*ctdb_callback_t)(struct ctdb_connection *ctdb,
+ struct ctdb_request *req, void *private);
/*
- a message to tell the recovery daemon to write a talloc memdump
- to the log
+ * Special node addresses :
*/
-#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
-
-/*
- a message ID to get the recovery daemon to push the node flags out
- */
-#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
-
-/*
- a message ID to get the recovery daemon to reload the nodes file
- */
-#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
-
-/*
- a message ID to get the recovery daemon to perform a takeover run
- */
-#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
-
-/* A message id to ask the recovery daemon to temporarily disable the
- public ip checks
-*/
-#define CTDB_SRVID_DISABLE_IP_CHECK 0xFC00000000000000LL
-
-/* A dummy port used for sending back ipreallocate resposnes to the main
- daemon
--
CTDB repository
More information about the samba-cvs
mailing list