diff options
author | Ronnie Sahlberg <sahlberg@ronnie> | 2008-01-10 10:10:37 +1100 |
---|---|---|
committer | Ronnie Sahlberg <sahlberg@ronnie> | 2008-01-10 10:10:37 +1100 |
commit | 6c61bcdf4bc83181d26b41cdf40dcebd08ac6ef7 (patch) | |
tree | a05a03ff9d24e06a51e6a3d7b282d8c8fa9eb1df /ctdb | |
parent | 73ca357662c881d074f3a0eb84a1a7c69080354d (diff) | |
parent | bccfdc0838bf501eb1d18a694a0aac9a0ab692b4 (diff) | |
download | samba-6c61bcdf4bc83181d26b41cdf40dcebd08ac6ef7.tar.gz samba-6c61bcdf4bc83181d26b41cdf40dcebd08ac6ef7.tar.xz samba-6c61bcdf4bc83181d26b41cdf40dcebd08ac6ef7.zip |
merge from tridge
(This used to be ctdb commit 9d21fddc67a6f010420d2b21a40992ac678d542a)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/common/ctdb_util.c | 19 | ||||
-rwxr-xr-x | ctdb/config/events.d/00.ctdb | 25 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 2 | ||||
-rw-r--r-- | ctdb/lib/tdb/common/freelist.c | 3 | ||||
-rw-r--r-- | ctdb/packaging/RPM/ctdb.spec | 4 | ||||
-rw-r--r-- | ctdb/server/ctdbd.c | 14 | ||||
-rw-r--r-- | ctdb/tools/ctdb.c | 14 | ||||
-rw-r--r-- | ctdb/tools/ctdb_vacuum.c | 2 |
8 files changed, 67 insertions, 16 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index 90489a7a71..7f7c1a0c8a 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -22,6 +22,7 @@ #include "lib/tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" +#include "system/wait.h" #include "../include/ctdb_private.h" int LogLevel; @@ -340,3 +341,21 @@ bool ctdb_same_sockaddr(const struct sockaddr_in *ip1, const struct sockaddr_in { return ctdb_same_ip(ip1, ip2) && ip1->sin_port == ip2->sin_port; } + + + +void ctdb_block_signal(int signum) +{ + sigset_t set; + sigemptyset(&set); + sigaddset(&set,signum); + sigprocmask(SIG_BLOCK,&set,NULL); +} + +void ctdb_unblock_signal(int signum) +{ + sigset_t set; + sigemptyset(&set); + sigaddset(&set,signum); + sigprocmask(SIG_UNBLOCK,&set,NULL); +} diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index fc82dbfac9..001544e5e8 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -18,6 +18,18 @@ PATH=/bin:/usr/bin:$PATH cmd="$1" shift +# set default samba cleanup period - in minutes +[ -z "$CTDB_VACUUM_PERIOD" ] && { + CTDB_VACUUM_PERIOD=5 +} + +########################### +# periodic vacuum function +periodic_vacuum() { + # this cleans up dead records and repacks the databases + ( time ctdb vacuum 200000 -T 30; time ctdb repack -T 30 ) > $CTDB_BASE/state/vacuum.log 2>&1 & +} + case $cmd in startup) # make sure we have a blank state directory for the scripts to work with @@ -33,6 +45,19 @@ case $cmd in echo "`date` Set $varname to $value" done || exit 1 ;; + + monitor) + # Create a dummy file to track when we need to do periodic cleanup + # of samba databases + [ -f $CTDB_BASE/state/periodic_vacuum ] || { + touch $CTDB_BASE/state/periodic_vacuum + } + [ `/usr/bin/find $CTDB_BASE/state/periodic_vacuum -mmin +$CTDB_VACUUM_PERIOD | wc -l` -eq 1 ] && { + # vacuum the databases + touch $CTDB_BASE/state/periodic_vacuum + periodic_vacuum + } + esac # all OK diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index f59ffeeed0..a876100d41 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1209,5 +1209,7 @@ int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv); int32_t ctdb_control_delete_record(struct ctdb_context *ctdb, TDB_DATA indata); +void ctdb_block_signal(int signum); +void ctdb_unblock_signal(int signum); #endif diff --git a/ctdb/lib/tdb/common/freelist.c b/ctdb/lib/tdb/common/freelist.c index da4586ff54..c086c151fa 100644 --- a/ctdb/lib/tdb/common/freelist.c +++ b/ctdb/lib/tdb/common/freelist.c @@ -372,9 +372,8 @@ int tdb_freelist_size(struct tdb_context *tdb) } ptr = FREELIST_TOP; - while (ptr != 0 && tdb_ofs_read(tdb, ptr, &ptr) == 0) { + while (tdb_ofs_read(tdb, ptr, &ptr) == 0 && ptr != 0) { count++; - } tdb_unlock(tdb, -1, F_RDLCK); diff --git a/ctdb/packaging/RPM/ctdb.spec b/ctdb/packaging/RPM/ctdb.spec index 410a1044e8..10224d09d6 100644 --- a/ctdb/packaging/RPM/ctdb.spec +++ b/ctdb/packaging/RPM/ctdb.spec @@ -5,7 +5,7 @@ Vendor: Samba Team Packager: Samba Team <samba@samba.org> Name: ctdb Version: 1.0 -Release: 21 +Release: 22 Epoch: 0 License: GNU GPL version 3 Group: System Environment/Daemons @@ -118,6 +118,8 @@ fi %{_includedir}/ctdb_private.h %changelog +* Thu Jan 10 2008 : Version 1.0.22 + - auto-run vacuum and repack ops * Wed Jan 09 2008 : Version 1.0.21 - added ctdb vacuum and ctdb repack code * Sun Jan 06 2008 : Version 1.0.20 diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 5613ea91b7..a386cea8ae 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -26,18 +26,6 @@ #include "cmdline.h" #include "../include/ctdb_private.h" -static void block_signal(int signum) -{ - struct sigaction act; - - memset(&act, 0, sizeof(act)); - - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask, signum); - sigaction(signum, &act, NULL); -} - static struct { const char *nlist; const char *transport; @@ -149,7 +137,7 @@ int main(int argc, const char *argv[]) exit(1); } - block_signal(SIGPIPE); + ctdb_block_signal(SIGPIPE); ev = event_context_init(NULL); diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index bbd2f0ec28..75b9749b61 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -33,6 +33,7 @@ static struct { int timelimit; uint32_t pnn; int machinereadable; + int maxruntime; } options; #define TIMELIMIT() timeval_current_ofs(options.timelimit, 0) @@ -1094,6 +1095,12 @@ static void usage(void) } +static void ctdb_alarm(int sig) +{ + printf("Maximum runtime exceeded - exiting\n"); + _exit(0); +} + /* main program */ @@ -1107,6 +1114,7 @@ int main(int argc, const char *argv[]) { "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0, "timelimit", "integer" }, { "node", 'n', POPT_ARG_STRING, &nodestring, 0, "node", "integer|all" }, { "machinereadable", 'Y', POPT_ARG_NONE, &options.machinereadable, 0, "enable machinereadable output", NULL }, + { "maxruntime", 'T', POPT_ARG_INT, &options.maxruntime, 0, "die if runtime exceeds this limit (in seconds)", "integer" }, POPT_TABLEEND }; int opt; @@ -1120,6 +1128,7 @@ int main(int argc, const char *argv[]) setlinebuf(stdout); /* set some defaults */ + options.maxruntime = 0; options.timelimit = 3; options.pnn = CTDB_CURRENT_NODE; @@ -1145,6 +1154,11 @@ int main(int argc, const char *argv[]) usage(); } + if (options.maxruntime != 0) { + signal(SIGALRM, ctdb_alarm); + alarm(options.maxruntime); + } + /* setup the node number to contact */ if (nodestring != NULL) { if (strcmp(nodestring, "all") == 0) { diff --git a/ctdb/tools/ctdb_vacuum.c b/ctdb/tools/ctdb_vacuum.c index 86d9c4c5f1..c3a69f7fa8 100644 --- a/ctdb/tools/ctdb_vacuum.c +++ b/ctdb/tools/ctdb_vacuum.c @@ -208,7 +208,9 @@ static int ctdb_vacuum_one(struct ctdb_context *ctdb, TDB_DATA key, return 0; } + ctdb_block_signal(SIGALRM); tdb_delete(ctdb_db->ltdb->tdb, key); + ctdb_unblock_signal(SIGALRM); tdb_chainunlock(ctdb_db->ltdb->tdb, key); free(data.dptr); |