persistent: add a ctdb_persistent_state member to the ctdb_db context.
[sahlberg/ctdb.git] / server / ctdbd.c
index 2e707f243a5b92377f9867e4634985771392c324..9eaba1d03808f6bb43eef71aab0f2758eb1d1006 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "system/time.h"
@@ -43,6 +43,7 @@ static struct {
        const char *single_public_ip;
        const char *node_ip;
        int         valgrinding;
+       int         nosetsched;
        int         use_syslog;
        int         start_as_disabled;
        int         start_as_stopped;
@@ -64,6 +65,7 @@ static struct {
 };
 
 int script_log_level;
+bool fast_start;
 
 /*
   called by the transport layer when a packet comes in
@@ -72,7 +74,7 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len
 {
        struct ctdb_req_header *hdr = (struct ctdb_req_header *)data;
 
-       ctdb->statistics.node_packets_recv++;
+       CTDB_INCREMENT_STAT(ctdb, node_packets_recv);
 
        /* up the counter for this source node, so we know its alive */
        if (ctdb_validate_pnn(ctdb, hdr->srcnode)) {
@@ -131,7 +133,8 @@ int main(int argc, const char *argv[])
                { "dbdir-persistent", 0, POPT_ARG_STRING, &options.db_dir_persistent, 0, "directory for persistent tdb files", NULL },
                { "dbdir-state", 0, POPT_ARG_STRING, &options.db_dir_state, 0, "directory for internal state tdb files", NULL },
                { "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
-               { "valgrinding", 0, POPT_ARG_NONE, &options.valgrinding, 0, "make valgrind more effective", NULL },
+               { "valgrinding", 0, POPT_ARG_NONE, &options.valgrinding, 0, "disable setscheduler SCHED_FIFO call, use mmap for tdbs", NULL },
+               { "nosetsched", 0, POPT_ARG_NONE, &options.nosetsched, 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 },
@@ -139,11 +142,12 @@ int main(int argc, const char *argv[])
                { "no-recmaster", 0, POPT_ARG_NONE, &options.no_recmaster, 0, "disable recmaster role on this node", NULL },
                { "lvs", 0, POPT_ARG_NONE, &options.lvs, 0, "lvs is enabled on this node", NULL },
                { "script-log-level", 0, POPT_ARG_INT, &options.script_log_level, DEBUG_ERR, "log level of event script output", NULL },
-               { "nopublicipcheck", 0, POPT_ARG_NONE, &options.no_publicipcheck, 0, "dont check we have/dont have the correct public ip addresses", NULL },
+               { "nopublicipcheck", 0, POPT_ARG_NONE, &options.no_publicipcheck, 0, "don't check we have/don't have the correct public ip addresses", NULL },
                { "max-persistent-check-errors", 0, POPT_ARG_INT,
                  &options.max_persistent_check_errors, 0,
                  "max allowed persistent check errors (default 0)", NULL },
                { "log-ringbuf-size", 0, POPT_ARG_INT, &log_ringbuf_size, DEBUG_ERR, "Number of log messages we can store in the memory ringbuffer", NULL },
+               { "sloppy-start", 0, POPT_ARG_NONE, &fast_start, 0, "Do not perform full recovery on start", NULL },
                POPT_TABLEEND
        };
        int opt, ret;
@@ -176,6 +180,7 @@ int main(int argc, const char *argv[])
        fault_setup("ctdbd");
 
        ev = event_context_init(NULL);
+       tevent_loop_allow_nesting(ev);
 
        ctdb = ctdb_cmdline_init(ev);
 
@@ -192,6 +197,7 @@ int main(int argc, const char *argv[])
        }
 
        DEBUG(DEBUG_NOTICE,("Starting CTDB daemon\n"));
+
        gettimeofday(&ctdb->ctdbd_start_time, NULL);
        gettimeofday(&ctdb->last_recovery_started, NULL);
        gettimeofday(&ctdb->last_recovery_finished, NULL);
@@ -203,6 +209,7 @@ int main(int argc, const char *argv[])
 
        ctdb_tunables_set_defaults(ctdb);
 
+       ctdb->tunable.disable_ip_failover = options.no_publicipcheck;
 
        ret = ctdb_set_recovery_lock_file(ctdb, options.recovery_lock_file);
        if (ret == -1) {
@@ -295,14 +302,6 @@ int main(int argc, const char *argv[])
                }
        }
 
-       if (options.public_address_list) {
-               ret = ctdb_set_public_addresses(ctdb, options.public_address_list);
-               if (ret == -1) {
-                       DEBUG(DEBUG_ALERT,("Unable to setup public address list\n"));
-                       exit(1);
-               }
-       }
-
        ret = ctdb_set_event_script_dir(ctdb, options.event_script_dir);
        if (ret == -1) {
                DEBUG(DEBUG_ALERT,("Unable to setup event script directory\n"));
@@ -318,8 +317,11 @@ int main(int argc, const char *argv[])
        }
 
        ctdb->valgrinding = options.valgrinding;
-
-       ctdb->do_checkpublicip = !options.no_publicipcheck;
+       if (options.valgrinding || options.nosetsched) {
+               ctdb->do_setsched = 0;
+       } else {
+               ctdb->do_setsched = 1;
+       }
 
        if (options.max_persistent_check_errors < 0) {
                ctdb->max_persistent_check_errors = 0xFFFFFFFFFFFFFFFFLL;
@@ -334,5 +336,5 @@ int main(int argc, const char *argv[])
        }
 
        /* start the protocol running (as a child) */
-       return ctdb_start_daemon(ctdb, interactive?False:True, options.use_syslog);
+       return ctdb_start_daemon(ctdb, interactive?False:True, options.use_syslog, options.public_address_list);
 }