Add --valgringing flag instead of --nosetsched
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 16 Dec 2009 10:29:15 +0000 (20:59 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 16 Dec 2009 10:29:15 +0000 (20:59 +1030)
The do_setsched was being tested for whether to mmap tdbs: let's make it
explicit.  We can also happily move the kill-child eventscript hack under
this flag.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
client/ctdb_client.c
config/ctdb.init
include/ctdb_private.h
server/ctdb_ltdb_server.c
server/ctdb_recoverd.c
server/ctdb_vacuum.c
server/ctdbd.c
server/eventscript.c

index 0469ba7280764259a1c5199a3e99a1d2679804d3..75bc0a45fb65a6e83e47b6e855dfa83cff1fa3c0 100644 (file)
@@ -1683,7 +1683,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
        }
 
        tdb_flags = persistent?TDB_DEFAULT:TDB_NOSYNC;
-       if (!ctdb->do_setsched) {
+       if (ctdb->valgrinding) {
                tdb_flags |= TDB_NOMMAP;
        }
 
index 67747fd149da73f95a2d84d146b5fa4d1249cbdf..1bd329ea71fb8826e4e1089775ebdbd0ddfde283 100755 (executable)
@@ -153,7 +153,7 @@ start() {
     case $init_style in
        valgrind)
            valgrind -q --log-file=/var/log/ctdb_valgrind \
-               $ctdbd --nosetsched $CTDB_OPTIONS 
+               $ctdbd --valgrinding $CTDB_OPTIONS
            RETVAL=$?
            echo
            ;;
index feff0bc24eedace19e42ade814317077f919308d..e577abc9f8dd7f5d79bd86977217aa0bef8ff417 100644 (file)
@@ -447,6 +447,7 @@ struct ctdb_context {
        struct ctdb_log_state *log;
        int start_as_disabled;
        int start_as_stopped;
+       bool valgrinding;
        uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
        uint32_t *recd_ping_count;
        TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
index 37abe116daf82ebc90424bf100d43699fc17a2d7..6c204821dcb2485c177215d13a1c87e79a987ad1 100644 (file)
@@ -248,7 +248,7 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name, boo
                                           db_name, ctdb->pnn);
 
        tdb_flags = persistent? TDB_DEFAULT : TDB_CLEAR_IF_FIRST | TDB_NOSYNC;
-       if (!ctdb->do_setsched) {
+       if (ctdb->valgrinding) {
                tdb_flags |= TDB_NOMMAP;
        }
 
index 3e596da9ecad9d88c8aa99184e4c94dac10a7720..45b59d128a42a1b63bc7d54bb5e042d72576131e 100644 (file)
@@ -1017,7 +1017,7 @@ static struct tdb_wrap *create_recdb(struct ctdb_context *ctdb, TALLOC_CTX *mem_
        unlink(name);
 
        tdb_flags = TDB_NOLOCK;
-       if (!ctdb->do_setsched) {
+       if (ctdb->valgrinding) {
                tdb_flags |= TDB_NOMMAP;
        }
 
index d09c07d9ff266d9495265fb5f20090e238faa739..655ecca6cf4777335bdc72b6163a11327ba744ee 100644 (file)
@@ -514,6 +514,7 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
        struct vacuum_tuning_data tdata;
        struct vacuum_tuning_data *tptr;
        char *vac_dbname;
+       int flags;
 
        vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u",
                                        ctdb_db->ctdb->db_directory, 
@@ -524,7 +525,8 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
                return -1;
        }
 
-       tune_tdb = tdb_open(vac_dbname, 0, 0, O_RDWR|O_CREAT, 0644);
+       flags = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
+       tune_tdb = tdb_open(vac_dbname, 0, flags, O_RDWR|O_CREAT, 0644);
        if (tune_tdb == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to create/open %s\n", TUNINGDBNAME));
                talloc_free(tmp_ctx);
@@ -677,6 +679,7 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
        char *vac_dbname;
        uint interval = ctdb_db->ctdb->tunable.vacuum_default_interval;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
+       int flags;
 
        vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u", ctdb->db_directory, TUNINGDBNAME, ctdb->pnn);
        if (vac_dbname == NULL) {
@@ -685,7 +688,8 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
                return interval;
        }
 
-       tdb = tdb_open(vac_dbname, 0, 0, O_RDWR|O_CREAT, 0644);
+       flags = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
+       tdb = tdb_open(vac_dbname, 0, flags, O_RDWR|O_CREAT, 0644);
        if (!tdb) {
                DEBUG(DEBUG_ERR,("Unable to open/create database %s using default interval\n", vac_dbname));
                talloc_free(tmp_ctx);
index 8647aad189284c956e5c474f3e146217b1a7c50d..f38ed66d835d40944b7eadfe8ada4a12cf3beb86 100644 (file)
@@ -41,7 +41,7 @@ static struct {
        const char *public_interface;
        const char *single_public_ip;
        const char *node_ip;
-       int         no_setsched;
+       int         valgrinding;
        int         use_syslog;
        int         start_as_disabled;
        int         start_as_stopped;
@@ -127,7 +127,7 @@ int main(int argc, const char *argv[])
                { "dbdir", 0, POPT_ARG_STRING, &options.db_dir, 0, "directory for the tdb files", NULL },
                { "dbdir-persistent", 0, POPT_ARG_STRING, &options.db_dir_persistent, 0, "directory for persistent tdb files", NULL },
                { "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
-               { "nosetsched", 0, POPT_ARG_NONE, &options.no_setsched, 0, "disable setscheduler SCHED_FIFO call", NULL },
+               { "valgrinding", 0, POPT_ARG_NONE, &options.valgrinding, 0, "disable setscheduler SCHED_FIFO call, use mmap for tdbs", NULL },
                { "syslog", 0, POPT_ARG_NONE, &options.use_syslog, 0, "log messages to syslog", NULL },
                { "start-as-disabled", 0, POPT_ARG_NONE, &options.start_as_disabled, 0, "Node starts in disabled state", NULL },
                { "start-as-stopped", 0, POPT_ARG_NONE, &options.start_as_stopped, 0, "Node starts in stopped state", NULL },
@@ -311,7 +311,8 @@ int main(int argc, const char *argv[])
                }
        }
 
-       ctdb->do_setsched = !options.no_setsched;
+       ctdb->valgrinding = options.valgrinding;
+       ctdb->do_setsched = !ctdb->valgrinding;
 
        ctdb->do_checkpublicip = !options.no_publicipcheck;
 
index 59cb6a3006025a676d41d064e90994389ba3d298..803ac1daa004e14f5b23ffc578ee3eaaca5ffd70 100644 (file)
@@ -452,7 +452,10 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 
        /* valgrind gets overloaded if we run next script as it's still doing
         * post-execution analysis, so kill finished child here. */
-       kill(state->child, SIGKILL);
+       if (ctdb->valgrinding) {
+               kill(state->child, SIGKILL);
+       }
+
        state->child = 0;
 
        /* Aborted or finished all scripts?  We're done. */