[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.3-50-gc6f91dd

Amitay Isaacs amitay at samba.org
Fri Jun 13 01:23:03 MDT 2014


The branch, 2.5 has been updated
       via  c6f91dd3df0f8604a2eadef3c44025e07a1c1a03 (commit)
       via  515736c53eb87fd76a16a6fef59ab8255b07da24 (commit)
       via  ef604d51ee17d88727406425074f631c996bca0e (commit)
       via  904bb9b95625541c77ccda1f8e03057b9446b879 (commit)
       via  a3d3b994df3e51316bc355fba6402d62e0cbf519 (commit)
       via  262ec107e269a349baae3ca6b72b4a1a0a18f72d (commit)
       via  6a8c8a0029b1d1b7a8f80343666f30385c24223c (commit)
       via  6aabb15346e5be2470d95e96b6a36aa2317325b0 (commit)
       via  23561cca2b3496d5a47977d5ce2600e8951dec39 (commit)
       via  ba2f7b3ea67468f38f2f80266c20a3c29a1c1f79 (commit)
       via  2b41fd554889876b848c30790c0272e58dbd025c (commit)
       via  1a4433d0d620d8104bc75ba5d10e4394a0d37e5a (commit)
       via  d94e082ebcdfb6cb6e050fa2a5ace6ff13869cf4 (commit)
       via  57eb4e57beef2b5cde351e9634fb4afd70354ac0 (commit)
       via  b4bb7bfd2d4eaee57707a2716006337f2e594bee (commit)
       via  385d1ee07ad1f8476a2810be1f8551e9d28fc336 (commit)
       via  7d30073689fd6be1f284bd6e6423abc4a8fd882d (commit)
       via  25a6bfc9ddfd42b9fc3ee0069b793311b649eaf1 (commit)
       via  5c94a3b492b600265ddd3b85394f19c66a9b566a (commit)
       via  5821e5ebc4e2845947e60ca4c1751cdade389576 (commit)
       via  9d4f41da1282369ffca3ef9e4259d0b0d48eb1ad (commit)
       via  2b2b7941ccbd1a1ae0e8743ed63ea8ecebf031e2 (commit)
       via  e015f6643efc274c282d8d31e77aaa7c9470b3e3 (commit)
       via  8c95317efb9d673aef4c059b3fcbb75197fb046f (commit)
      from  31a4dde35d9037fe1bc48128186619b820358e8b (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=2.5


- Log -----------------------------------------------------------------
commit c6f91dd3df0f8604a2eadef3c44025e07a1c1a03
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 16:49:13 2014 +1000

    daemon: Reset scheduler policy for helper processes
    
    Do not run helper processes with real-time priority.
    
    This regression was caused when locking and eventscript code switched
    to use vfork() and helper instead of ctdb_fork().
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Thu Jun 12 08:10:36 CEST 2014 on sn-devel-104
    
    (Imported from commit 9e6e48750d1fad8ec7cd076f7ca7d2b028007258)

commit 515736c53eb87fd76a16a6fef59ab8255b07da24
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 12:17:32 2014 +1000

    daemon: Do not complain if node is inactive and db is not attached
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit e9eed41d7ffded2dfd1406f60ad08fe070fd52c1)

commit ef604d51ee17d88727406425074f631c996bca0e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 11:56:39 2014 +1000

    build: Remove duplicate library dependency
    
    LIB_FLAGS includes TDB_LIBS.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 79a6bd269291a4b4dabc57254b79bbfa82ac70e4)

commit 904bb9b95625541c77ccda1f8e03057b9446b879
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 16:46:15 2014 +1000

    daemon: Remove duplicate code from helper binaries
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 71ed758c72db36234209428fa54be82fe8f0899a)

commit a3d3b994df3e51316bc355fba6402d62e0cbf519
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 15:43:22 2014 +1000

    logging: Move controls handling functions from common to server
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit e7c72588d187f9505444f48a1c5b19e47b15ccd9)

commit 262ec107e269a349baae3ca6b72b4a1a0a18f72d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 14:52:19 2014 +1000

    logging: Split ringbuffer handling code from ctdb_collect_log
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 27d1137e26703d7fa5fba638e56961384a140eb2)

commit 6a8c8a0029b1d1b7a8f80343666f30385c24223c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 15:25:08 2014 +1000

    common: Move mkdir_p_or_die to system utilities
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 49e34651a95a336c9e410e4b52a8cfd491ca0a67)

commit 6aabb15346e5be2470d95e96b6a36aa2317325b0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 15:24:20 2014 +1000

    daemon: Rename ctdb_mkdir_p_or_die to mkdir_p_or_die
    
    This function does not require ctdb context.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 4736486188afb8ff6243bcc8a27daa9dbcc64b7a)

commit 23561cca2b3496d5a47977d5ce2600e8951dec39
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 17:04:34 2014 +1000

    common: Move lockdown_memory to system utilities
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 507207e40b193ba753604666c56dfa29c29b7145)

commit ba2f7b3ea67468f38f2f80266c20a3c29a1c1f79
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 17:00:38 2014 +1000

    daemon: Rename ctdb_lockdown_memory to lockdown_memory
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 8c8ef5640e17c1acbda99921277a41442bcc4801)

commit 2b41fd554889876b848c30790c0272e58dbd025c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 15:08:22 2014 +1000

    daemon: Instead of passing ctdb context, pass valgrinding boolean
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 22f71579a46203236bb6ec7e5bef3b2151700898)

commit 1a4433d0d620d8104bc75ba5d10e4394a0d37e5a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 15:00:08 2014 +1000

    common: Keep debug level related functions with logging code
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit e11483012460fd3654bd0a3640755f581d3fecf4)

commit d94e082ebcdfb6cb6e050fa2a5ace6ff13869cf4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 14:58:17 2014 +1000

    daemon: Rename block_signal to ignore_signal
    
    This function does not block signals, but ignores them.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit d09f8134c1a915ec59c502769b72a84d43a5c577)

commit 57eb4e57beef2b5cde351e9634fb4afd70354ac0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 14:55:23 2014 +1000

    common: Remove unused functions
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit da1a6a3d31f0a08492b723458b882aea48bb14ec)

commit b4bb7bfd2d4eaee57707a2716006337f2e594bee
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 14:52:02 2014 +1000

    daemon: No need to block SIGPIPE at startup
    
    Once CTDB is daemonized, it starts ignoring SIGPIPE anyway.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 0015b2a94a4c1682bc771ae265bb3764d2697a4e)

commit 385d1ee07ad1f8476a2810be1f8551e9d28fc336
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 13:52:15 2014 +1000

    common: Separate more system utilities that are independent of ctdb
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 7226618717644a6ba86e6da5afe92fdbc1cd0858)

commit 7d30073689fd6be1f284bd6e6423abc4a8fd882d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 12:55:56 2014 +1000

    common: Separate system utilties that are ctdb independent
    
    Routines in system_common and system_<os> are supposed to be ctdb
    functions with OS specific implementations.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 890bd9fb7f11b1236d493770fe635da9cfcad5f7)

commit 25a6bfc9ddfd42b9fc3ee0069b793311b649eaf1
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 11 16:58:20 2014 +1000

    common: No dynamic memory allocation in mkdir_p()
    
    Allocate an array of size PATH_MAX on the stack instead.  To stop
    unnecessary recursion, try to create the desired directory before
    creating ancestors and only create ancestors on ENOENT.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit dd672431c0b8a3a416f6c244b131074d868250cc)

commit 5c94a3b492b600265ddd3b85394f19c66a9b566a
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 11 16:04:55 2014 +1000

    common: Do not dynamically allocate memory when not necessary
    
    Copy these values onto the stack instead.  INET6_ADDRSTRLEN is 46, so
    64 is plenty for an IP address and a port number.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 8fa8b3b397853a29f12875454b890fa5c7b8cda8)

commit 5821e5ebc4e2845947e60ca4c1751cdade389576
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 16:48:03 2014 +1000

    common: Drop ctdb prefix from utility functions independent of ctdb
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 3a9d375328e78e58a20584cc138bd52f930f33b7)

commit 9d4f41da1282369ffca3ef9e4259d0b0d48eb1ad
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 10 16:44:59 2014 +1000

    common: Changing scheduler policy does not require ctdb context
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 5b580e5d65ac5dce9dc07aba4fe1f31226a66ed8)

commit 2b2b7941ccbd1a1ae0e8743ed63ea8ecebf031e2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 12:27:29 2014 +1000

    common: Do not abort if restoring scheduling policy fails
    
    This code is only executed in child processes, so aborting does not
    really achieve much.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit fb0b389dc17ee4626f07f2056edecddc51286281)

commit e015f6643efc274c282d8d31e77aaa7c9470b3e3
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 6 12:21:25 2014 +1000

    common: No need to save previous scheduler priority
    
    When calling sched_setscheduler() with SCHED_OTHER, the only valid
    priority is 0.  Nice value is "restored" anyway.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 19fcf6ff5206b14c481f078371f5b407d43900b7)

commit 8c95317efb9d673aef4c059b3fcbb75197fb046f
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 6 15:25:28 2014 +1000

    eventscripts: New configuration variable CTDB_GANESHA_REC_SUBDIR
    
    Backup and restore of the cluster filesystem can upset the operation
    of 60.ganesha by changing the contents of this subdirectory.
    
    Allow this subdirectory to be configured to a subdirectory that is
    ignored by backup and restore processes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Jun 11 09:29:22 CEST 2014 on sn-devel-104
    
    (Imported from commit 6da8126a115419587672d16e2440c322a837da6b)

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                |   15 +-
 common/ctdb_fork.c         |    2 +-
 common/ctdb_logging.c      |   87 ++++++-----
 common/ctdb_util.c         |  368 --------------------------------------------
 common/system_common.c     |   32 ----
 common/system_util.c       |  365 +++++++++++++++++++++++++++++++++++++++++++
 config/events.d/60.ganesha |    8 +-
 doc/ctdbd.conf.5.xml       |   15 ++
 include/ctdb_private.h     |   13 +-
 server/ctdb_daemon.c       |   10 +-
 server/ctdb_event_helper.c |   14 +--
 server/ctdb_lock_helper.c  |    4 +-
 server/ctdb_logging.c      |   41 +++++-
 server/ctdb_ltdb_server.c  |    7 +-
 server/ctdbd.c             |    7 +-
 tests/src/ctdb_test.c      |    1 +
 tests/src/ctdbd_test.c     |    1 +
 17 files changed, 512 insertions(+), 478 deletions(-)
 create mode 100644 common/system_util.c


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 84c6940..a8e74a4 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -87,7 +87,7 @@ 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.o common/ctdb_fork.o
+	common/ctdb_logging.o common/ctdb_fork.o common/system_util.o
 
 CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
 
@@ -174,15 +174,18 @@ bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o tools/ctdb_vacuum.o
 
 bin/ltdbtool: tools/ltdbtool.o $(TDB_OBJ)
 	@echo Linking $@
-	$(WRAPPER) $(CC) $(CFLAGS) -o $@ $+ $(TDB_LIBS) $(LIB_FLAGS)
+	$(WRAPPER) $(CC) $(CFLAGS) -o $@ $+ $(LIB_FLAGS)
 
-bin/ctdb_lock_helper: server/ctdb_lock_helper.o lib/util/util_file.o $(CTDB_EXTERNAL_OBJ)
+HELPER_COMMON_OBJ = common/system_util.o common/ctdb_logging.o \
+		    lib/util/debug.o lib/util/util_time.o lib/util/util_file.o
+
+bin/ctdb_lock_helper: server/ctdb_lock_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ)
 	@echo Linking $@
-	$(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_lock_helper.o lib/util/util_file.o $(CTDB_EXTERNAL_OBJ) $(TDB_LIBS) $(LIB_FLAGS)
+	$(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_lock_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS)
 
-bin/ctdb_event_helper: server/ctdb_event_helper.o $(REPLACE_OBJ) $(SOCKET_WRAPPER_OBJ)
+bin/ctdb_event_helper: server/ctdb_event_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ)
 	@echo Linking $@
-	$(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_event_helper.o $(REPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) $(LIB_FLAGS)
+	$(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_event_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS)
 
 bin/smnotify: utils/smnotify/gen_xdr.o utils/smnotify/gen_smnotify.o utils/smnotify/smnotify.o $(POPT_OBJ)
 	@echo Linking $@
diff --git a/common/ctdb_fork.c b/common/ctdb_fork.c
index 1d7d9aa..aa9bcf0 100644
--- a/common/ctdb_fork.c
+++ b/common/ctdb_fork.c
@@ -92,7 +92,7 @@ pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb)
 
 		/* The child does not need to be realtime */
 		if (ctdb->do_setsched) {
-			ctdb_restore_scheduler(ctdb);
+			reset_scheduler();
 		}
 		ctdb->can_send_controls = false;
 
diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index ba3e861..6dd1a38 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -23,6 +23,9 @@
 #include "../include/ctdb_private.h"
 #include "../include/ctdb_client.h"
 
+int LogLevel = DEBUG_NOTICE;
+int this_log_level = 0;
+
 int log_ringbuf_size;
 
 #define MAX_LOG_SIZE 128
@@ -100,7 +103,8 @@ void ctdb_log_ringbuffer_free(void)
 	log_ringbuf_size = 0;
 }
 
-void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr)
+TDB_DATA ctdb_log_ringbuffer_collect_log(TALLOC_CTX *mem_ctx,
+					 enum debug_level max_level)
 {
 	TDB_DATA data;
 	FILE *f;
@@ -115,14 +119,15 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
 	/* dump to a file, then send the file as a blob */
 	f = tmpfile();
 	if (f == NULL) {
-		DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s\n", strerror(errno)));
-		return;
+		DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s\n",
+				 strerror(errno)));
+		return tdb_null;
 	}
 
 	for (i=0; i<ringbuf_count; i++) {
 		tmp_entry = (first_entry + i) % log_ringbuf_size;
 
-		if (log_entries[tmp_entry].level > log_addr->level) {
+		if (log_entries[tmp_entry].level > max_level) {
 		 	continue;
 		}
 
@@ -140,50 +145,21 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
 	if (fsize < 0) {
 		fclose(f);
 		DEBUG(DEBUG_ERR, ("Cannot get file size for log entries\n"));
-		return;
+		return tdb_null;
 	}
 	rewind(f);
 	data.dptr = talloc_size(NULL, fsize);
 	if (data.dptr == NULL) {
 		fclose(f);
-		CTDB_NO_MEMORY_VOID(ctdb, data.dptr);
+		DEBUG(DEBUG_ERR, (__location__ " Memory allocation error\n"));
+		return tdb_null;
 	}
 	data.dsize = fread(data.dptr, 1, fsize, f);
 	fclose(f);
 
 	DEBUG(DEBUG_ERR,("Marshalling log entries into a blob of %d bytes\n", (int)data.dsize));
 
-	DEBUG(DEBUG_ERR,("Send log to %d:%d\n", (int)log_addr->pnn, (int)log_addr->srvid));
-	ctdb_client_send_message(ctdb, log_addr->pnn, log_addr->srvid, data);
-
-	talloc_free(data.dptr);
-}
-
-int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
-{
-	struct ctdb_get_log_addr *log_addr = (struct ctdb_get_log_addr *)addr.dptr;
-	pid_t child;
-
-	/* spawn a child process to marshall the huge log blob and send it back
-	   to the ctdb tool using a MESSAGE
-	*/
-	child = ctdb_fork_no_free_ringbuffer(ctdb);
-	if (child == (pid_t)-1) {
-		DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n"));
-		return -1;
-	}
-
-	if (child == 0) {
-		ctdb_set_process_name("ctdb_log_collector");
-		if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
-			DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
-			_exit(1);
-		}
-		ctdb_collect_log(ctdb, log_addr);
-		_exit(0);
-	}
-
-	return 0;
+	return data;
 }
 
 void ctdb_clear_log(struct ctdb_context *ctdb)
@@ -198,3 +174,40 @@ int32_t ctdb_control_clear_log(struct ctdb_context *ctdb)
 
 	return 0;
 }
+
+struct debug_levels debug_levels[] = {
+	{DEBUG_EMERG,	"EMERG"},
+	{DEBUG_ALERT,	"ALERT"},
+	{DEBUG_CRIT,	"CRIT"},
+	{DEBUG_ERR,	"ERR"},
+	{DEBUG_WARNING,	"WARNING"},
+	{DEBUG_NOTICE,	"NOTICE"},
+	{DEBUG_INFO,	"INFO"},
+	{DEBUG_DEBUG,	"DEBUG"},
+	{0, NULL}
+};
+
+const char *get_debug_by_level(int32_t level)
+{
+	int i;
+
+	for (i=0; debug_levels[i].description != NULL; i++) {
+		if (debug_levels[i].level == level) {
+			return debug_levels[i].description;
+		}
+	}
+	return "Unknown";
+}
+
+int32_t get_debug_by_desc(const char *desc)
+{
+	int i;
+
+	for (i=0; debug_levels[i].description != NULL; i++) {
+		if (!strcasecmp(debug_levels[i].description, desc)) {
+			return debug_levels[i].level;
+		}
+	}
+
+	return DEBUG_ERR;
+}
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index fd0d7da..f71f74a 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -22,12 +22,8 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/wait.h"
-#include "system/shmem.h"
 #include "../include/ctdb_private.h"
 
-int LogLevel = DEBUG_NOTICE;
-int this_log_level = 0;
-
 /*
   return error string for last error
 */
@@ -317,277 +313,6 @@ struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, st
 	return r;
 }
 
-
-#if HAVE_SCHED_H
-#include <sched.h>
-#endif
-
-#if HAVE_PROCINFO_H
-#include <procinfo.h>
-#endif
-
-/*
-  if possible, make this task real time
- */
-void ctdb_set_scheduler(struct ctdb_context *ctdb)
-{
-#ifdef _AIX_
-#if HAVE_THREAD_SETSCHED
-	struct thrdentry64 te;
-	tid64_t ti;
-
-	ti = 0ULL;
-	if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) {
-		DEBUG(DEBUG_ERR, ("Unable to get thread information\n"));
-		return;
-	}
-
-	if (ctdb->saved_scheduler_param == NULL) {
-		ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(te));
-	}
-	*(struct thrdentry64 *)ctdb->saved_scheduler_param = te;
-
-	if (thread_setsched(te.ti_tid, 0, SCHED_RR) == -1) {
-		DEBUG(DEBUG_ERR, ("Unable to set scheduler to SCHED_RR (%s)\n",
-				  strerror(errno)));
-	} else {
-		DEBUG(DEBUG_NOTICE, ("Set scheduler to SCHED_RR\n"));
-	}
-#endif
-#else /* no AIX */
-#if HAVE_SCHED_SETSCHEDULER
-	struct sched_param p;
-	if (ctdb->saved_scheduler_param == NULL) {
-		ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(p));
-	}
-
-	if (sched_getparam(0, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
-		DEBUG(DEBUG_ERR,("Unable to get old scheduler params\n"));
-		return;
-	}
-
-	p = *(struct sched_param *)ctdb->saved_scheduler_param;
-	p.sched_priority = 1;
-
-	if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) {
-		DEBUG(DEBUG_CRIT,("Unable to set scheduler to SCHED_FIFO (%s)\n", 
-			 strerror(errno)));
-	} else {
-		DEBUG(DEBUG_NOTICE,("Set scheduler to SCHED_FIFO\n"));
-	}
-#endif
-#endif
-}
-
-/*
-  restore previous scheduler parameters
- */
-void ctdb_restore_scheduler(struct ctdb_context *ctdb)
-{
-#ifdef _AIX_
-#if HAVE_THREAD_SETSCHED
-	struct thrdentry64 te, *saved;
-	tid64_t ti;
-
-	ti = 0ULL;
-	if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) {
-		ctdb_fatal(ctdb, "Unable to get thread information\n");
-	}
-	if (ctdb->saved_scheduler_param == NULL) {
-		ctdb_fatal(ctdb, "No saved scheduler parameters\n");
-	}
-	saved = (struct thrdentry64 *)ctdb->saved_scheduler_param;
-	if (thread_setsched(te.ti_tid, saved->ti_pri, saved->ti_policy) == -1) {
-		ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n");
-	}
-#endif
-#else /* no AIX */
-#if HAVE_SCHED_SETSCHEDULER
-	if (ctdb->saved_scheduler_param == NULL) {
-		ctdb_fatal(ctdb, "No saved scheduler parameters\n");
-	}
-	if (sched_setscheduler(0, SCHED_OTHER, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
-		ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n");
-	}
-#endif
-#endif
-}
-
-void set_nonblocking(int fd)
-{
-	int v;
-
-	v = fcntl(fd, F_GETFL, 0);
-	if (v == -1) {
-		DEBUG(DEBUG_WARNING, ("Failed to get file status flags - %s\n",
-				      strerror(errno)));
-		return;
-	}
-        if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
-		DEBUG(DEBUG_WARNING, ("Failed to set non_blocking on fd - %s\n",
-				      strerror(errno)));
-	}
-}
-
-void set_close_on_exec(int fd)
-{
-	int v;
-
-	v = fcntl(fd, F_GETFD, 0);
-	if (v == -1) {
-		DEBUG(DEBUG_WARNING, ("Failed to get file descriptor flags - %s\n",
-				      strerror(errno)));
-		return;
-	}
-	if (fcntl(fd, F_SETFD, v | FD_CLOEXEC) != 0) {
-		DEBUG(DEBUG_WARNING, ("Failed to set close_on_exec on fd - %s\n",
-				      strerror(errno)));
-	}
-}
-
-
-bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin)
-{
-	sin->sin_family = AF_INET;
-	sin->sin_port   = htons(port);
-
-	if (inet_pton(AF_INET, s, &sin->sin_addr) != 1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin_addr\n", s));
-		return false;
-	}
-
-	return true;
-}
-
-static bool parse_ipv6(const char *s, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
-{
-	saddr->ip6.sin6_family   = AF_INET6;
-	saddr->ip6.sin6_port     = htons(port);
-	saddr->ip6.sin6_flowinfo = 0;
-	saddr->ip6.sin6_scope_id = 0;
-
-	if (inet_pton(AF_INET6, s, &saddr->ip6.sin6_addr) != 1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin6_addr\n", s));
-		return false;
-	}
-
-	if (ifaces && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
-		if (strchr(ifaces, ',')) {
-			DEBUG(DEBUG_ERR, (__location__ " Link local address %s "
-					  "is specified for multiple ifaces %s\n",
-					  s, ifaces));
-			return false;
-		}
-		saddr->ip6.sin6_scope_id = if_nametoindex(ifaces);
-	}
-
-	return true;
-}
-/*
-  parse a ip:port pair
- */
-bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
-{
-	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-	char *s, *p;
-	unsigned port;
-	char *endp = NULL;
-	bool ret;
-
-	s = talloc_strdup(tmp_ctx, addr);
-	if (s == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed strdup()\n"));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-
-	p = rindex(s, ':');
-	if (p == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " This addr: %s does not contain a port number\n", s));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-
-	port = strtoul(p+1, &endp, 10);
-	if (endp == NULL || *endp != 0) {
-		/* trailing garbage */
-		DEBUG(DEBUG_ERR, (__location__ " Trailing garbage after the port in %s\n", s));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-	*p = 0;
-
-
-	/* now is this a ipv4 or ipv6 address ?*/
-	ret = parse_ip(s, NULL, port, saddr);
-
-	talloc_free(tmp_ctx);
-	return ret;
-}
-
-/*
-  parse an ip
- */
-bool parse_ip(const char *addr, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
-{
-	char *p;
-	bool ret;
-
-	ZERO_STRUCTP(saddr); /* valgrind :-) */
-
-	/* now is this a ipv4 or ipv6 address ?*/
-	p = index(addr, ':');
-	if (p == NULL) {
-		ret = parse_ipv4(addr, port, &saddr->ip);
-	} else {
-		ret = parse_ipv6(addr, ifaces, port, saddr);
-	}
-
-	return ret;
-}
-
-/*
-  parse a ip/mask pair
- */
-bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr, unsigned *mask)
-{
-	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-	char *s, *p;
-	char *endp = NULL;
-	bool ret;
-
-	ZERO_STRUCT(*addr);
-	s = talloc_strdup(tmp_ctx, str);
-	if (s == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed strdup()\n"));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-
-	p = rindex(s, '/');
-	if (p == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " This addr: %s does not contain a mask\n", s));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-
-	*mask = strtoul(p+1, &endp, 10);
-	if (endp == NULL || *endp != 0) {
-		/* trailing garbage */
-		DEBUG(DEBUG_ERR, (__location__ " Trailing garbage after the mask in %s\n", s));
-		talloc_free(tmp_ctx);
-		return false;
-	}
-	*p = 0;
-
-
-	/* now is this a ipv4 or ipv6 address ?*/
-	ret = parse_ip(s, ifaces, 0, addr);
-
-	talloc_free(tmp_ctx);
-	return ret;
-}
-
 /*
    This is used to canonicalize a ctdb_sock_addr structure.
 */
@@ -678,85 +403,6 @@ unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
 	return 0;
 }
 
-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);


-- 
CTDB repository


More information about the samba-cvs mailing list