[ctdb] added updated patch files

sbose sbose at fedoraproject.org
Mon Mar 25 13:05:42 UTC 2013


commit 283b7629ee6590f44e77830e506dca90ab214b9a
Author: Sumit Bose <sbose at redhat.com>
Date:   Mon Mar 25 14:05:28 2013 +0100

    added updated patch files

 ...-some-init-functions-into-a-separate-file.patch |  192 ++++++-------
 ...ixes-for-various-issues-found-by-Coverity.patch |   90 +++----
 0002-Add-systemd-support.patch                     |  294 ++++++++++++++++++--
 clean-up-systemd-integration.patch                 |   26 +-
 ctdb.spec                                          |    5 +-
 5 files changed, 423 insertions(+), 184 deletions(-)
---
diff --git a/0001-Extract-some-init-functions-into-a-separate-file.patch b/0001-Extract-some-init-functions-into-a-separate-file.patch
index 7606eea..62a5b9b 100644
--- a/0001-Extract-some-init-functions-into-a-separate-file.patch
+++ b/0001-Extract-some-init-functions-into-a-separate-file.patch
@@ -1,33 +1,33 @@
-From 118f329087089d03db9e2b48f4df141e2f94ed05 Mon Sep 17 00:00:00 2001
+From 2f50d3019580d98d3a7073d352c29c6541a4468e Mon Sep 17 00:00:00 2001
 From: Sumit Bose <sbose at redhat.com>
 Date: Tue, 10 Jan 2012 11:06:47 +0100
-Subject: [PATCH 1/2] Extract some init functions into a separate file
+Subject: [PATCH 1/3] Extract some init functions into a separate file
 
 ---
- Makefile.in                |    1 +
- config/ctdb.init           |  163 +-------------------------------------------
- config/init_functions      |  163 ++++++++++++++++++++++++++++++++++++++++++++
- packaging/RPM/ctdb.spec.in |    1 +
- 4 files changed, 166 insertions(+), 162 deletions(-)
+ Makefile.in                |   1 +
+ config/ctdb.init           | 157 +------------------------------------------
+ config/init_functions      | 163 +++++++++++++++++++++++++++++++++++++++++++++
+ packaging/RPM/ctdb.spec.in |   1 +
+ 4 Dateien geändert, 166 Zeilen hinzugefügt(+), 156 Zeilen entfernt(-)
  create mode 100644 config/init_functions
 
 diff --git a/Makefile.in b/Makefile.in
-index 5fa9e98..bc43074 100755
+index fef2e45..d8835f8 100755
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -244,6 +244,7 @@ install: all
+@@ -326,6 +326,7 @@ install: all manpages $(PMDA_INSTALL)
  	${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
  	${INSTALLCMD} -m 644 include/ctdb_typesafe_cb.h $(DESTDIR)$(includedir)
  	${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
 +	${INSTALLCMD} -m 644 config/init_functions $(DESTDIR)$(etcdir)/ctdb
  	${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
- 	${INSTALLCMD} -m 755 config/interface_modify.sh $(DESTDIR)$(etcdir)/ctdb
- 	${INSTALLCMD} -m 644 config/events.d/README $(DESTDIR)$(docdir)/ctdb/README.eventscripts
+ 	${INSTALLCMD} -m 644 README $(DESTDIR)$(docdir)/ctdb/README
+ 	${INSTALLCMD} -m 644 COPYING $(DESTDIR)$(docdir)/ctdb/COPYING
 diff --git a/config/ctdb.init b/config/ctdb.init
-index d6493bd..0e15b77 100755
+index 9f9b686..804cb6a 100755
 --- a/config/ctdb.init
 +++ b/config/ctdb.init
-@@ -44,6 +44,7 @@ unset TMPDIR
+@@ -40,6 +40,7 @@ unset TMPDIR
  }
  
  . $CTDB_BASE/functions
@@ -35,7 +35,7 @@ index d6493bd..0e15b77 100755
  loadconfig network
  loadconfig ctdb
  
-@@ -61,174 +62,12 @@ else
+@@ -57,166 +58,10 @@ else
      init_style="$CTDB_INIT_STYLE"
  fi
  
@@ -77,6 +77,7 @@ index d6493bd..0e15b77 100755
 -    maybe_set "--event-script-dir"       "$CTDB_EVENT_SCRIPT_DIR"
 -    maybe_set "--transport"              "$CTDB_TRANSPORT"
 -    maybe_set "-d"                       "$CTDB_DEBUGLEVEL"
+-    maybe_set "--debug-hung-script"      "$CTDB_DEBUG_HUNG_SCRIPT"
 -    maybe_set "--notification-script"    "$CTDB_NOTIFY_SCRIPT"
 -    maybe_set "--start-as-disabled"      "$CTDB_START_AS_DISABLED"    "yes"
 -    maybe_set "--start-as-stopped "      "$CTDB_START_AS_STOPPED"     "yes"
@@ -89,93 +90,96 @@ index d6493bd..0e15b77 100755
 -    maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
 -}
 -
--check_tdb () {
--	local PDBASE=$1
--
--	test x"$TDBTOOL_HAS_CHECK" = x"1" && {
--		#
--		# Note tdbtool always exits with 0
--		#
--		local OK=`/usr/bin/tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
--		test x"$OK" = x"1" || {
--			return 1;
--		}
--
--		return 0;
--	}
--
--	/usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
--		return $?;
--	}
--
--	return 0;
+-# Log given message or stdin to either syslog or a CTDB log file
+-do_log ()
+-{
+-    script_log "ctdb.init" "$@"
 -}
 -
--check_persistent_databases () {
--    PERSISTENT_DB_DIR="${CTDB_DBDIR:-/var/ctdb}/persistent"
--    mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
--    local ERRCOUNT=$CTDB_MAX_PERSISTENT_CHECK_ERRORS
--
--    test -z "$ERRCOUNT" && {
--	ERRCOUNT="0"
--    }
--    test x"$ERRCOUNT" != x"0" && {
--	return 0;
--    }
+-select_tdb_checker ()
+-{
+-    # Find the best TDB consistency check available.
+-    use_tdb_tool_check=false
+-    if [ -x /usr/bin/tdbtool ] && \
+-	echo "help" | /usr/bin/tdbtool | grep -q check ; then
 -
--    if test -x /usr/bin/tdbtool ; then
--        HAVE_TDBTOOL=1
+-	use_tdb_tool_check=true
+-    elif [ -x /usr/bin/tdbtool -a -x /usr/bin/tdbdump ] ; then
+-	    do_log <<EOF
+-WARNING: The installed 'tdbtool' does not offer the 'check' subcommand.
+- Using 'tdbdump' for database checks.
+- Consider updating 'tdbtool' for better checks!
+-EOF
+-    elif [ -x /usr/bin/tdbdump ] ; then
+-	do_log <<EOF
+-WARNING: 'tdbtool' is not available.
+- Using 'tdbdump' to check the databases.
+- Consider installing a recent 'tdbtool' for better checks!
+-EOF
 -    else
--        HAVE_TDBTOOL=0
+-	do_log <<EOF
+-WARNING: Cannot check databases since neither
+- 'tdbdump' nor 'tdbtool check' is available.
+- Consider installing tdbtool or at least tdbdump!
+-EOF
+-        return 1
 -    fi
+-}
 -
--    if test x"$HAVE_TDBTOOL" = x"1" ; then
--        TDBTOOL_HAS_CHECK=`echo "help" | /usr/bin/tdbtool | grep check | wc -l`
--    else
--        TDBTOOL_HAS_CHECK=0
--    fi
+-check_tdb ()
+-{
+-    _db="$1"
 -
--    if test -x /usr/bin/tdbdump ; then
--        HAVE_TDBDUMP=1
+-    if $use_tdb_tool_check ; then
+-	# tdbtool always exits with 0  :-(
+-	if tdbtool "$_db" check 2>/dev/null |
+-	    grep -q "Database integrity is OK" ; then
+-	    return 0
+-	else
+-	    return 1
+-	fi
 -    else
--        HAVE_TDBDUMP=0
+-	tdbdump "$_db" >/dev/null 2>/dev/null
+-	return $?
 -    fi
+-}
 -
--    if test x"$HAVE_TDBDUMP" = x"0" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
--        echo "WARNING: Cannot check persistent databases since"
--        echo "neither 'tdbdump' nor 'tdbtool check' is available."
--        echo "Consider installing tdbtool or at least tdbdump!"
--        return 0
--    fi
+-check_persistent_databases ()
+-{
+-    _dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_DBDIR:-/var/ctdb}/persistent}"
+-    mkdir -p "$_dir" 2>/dev/null
 -
--    if test x"$HAVE_TDBDUMP" = x"1" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
--        if test x"$HAVE_TDBTOOL" = x"0"; then
--            echo "WARNING: 'tdbtool' is not available. Using 'tdbdump' to"
--            echo "check the persistent databases."
--            echo "Consider installing a recent 'tdbtool' for better checks!"
--        else
--            echo "WARNING: The installed 'tdbtool' does not offer the 'check'"
--            echo "subcommand. Using 'tdbdump' for persistent database checks."
--            echo "Consider updating 'tdbtool' for better checks!"
--        fi
--    fi
+-    [ "${CTDB_MAX_PERSISTENT_CHECK_ERRORS:-0}" = "0" ] || return 0
 -
--    for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
--	check_tdb $PDBASE || {
--	    echo "Persistent database $PDBASE is corrupted! CTDB will not start."
+-    for _db in $(ls "$_dir/"*.tdb.*[0-9] 2>/dev/null) ; do
+-	check_tdb $_db || {
+-	    do_log "Persistent database $_db is corrupted! CTDB will not start."
 -	    return 1
 -	}
 -    done
 -}
 -
--set_ctdb_variables () {
--    # set any tunables from the config file
--    set | grep ^CTDB_SET_ | cut -d_ -f3- | 
--    while read v; do
--	varname=`echo $v | cut -d= -f1`
--	value=`echo $v | cut -d= -f2`
--	ctdb setvar $varname $value || RETVAL=1
--    done || exit 1
+-check_non_persistent_databases ()
+-{
+-    _dir="${CTDB_DBDIR:-/var/ctdb}"
+-    mkdir -p "$_dir" 2>/dev/null
+-
+-    for _db in $(ls "${_dir}/"*.tdb.*[0-9] 2>/dev/null) ; do
+-	check_tdb $_db || {
+-	    _backup="${_db}.$(date +'%Y%m%d.%H%M%S.%N').corrupt"
+-	    do_log <<EOF
+-WARNING: database ${_db} is corrupted.
+- Moving to backup ${_backup} for later analysis.
+-EOF
+-	    mv "$_db" "$_backup"
+-
+-	    # Now remove excess backups
+-	    ls -td "${_db}."*".corrupt" |
+-	    tail -n +$((${CTDB_MAX_CORRUPT_DB_BACKUPS:-10} + 1)) |
+-	    xargs rm -f
+-	    
+-	}
+-    done
 -}
 -
  set_retval() {
@@ -197,19 +201,7 @@ index d6493bd..0e15b77 100755
 -
  ctdbd=${CTDBD:-/usr/sbin/ctdbd}
  
--drop_all_public_ips() {
--    [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
--	return
--    }
--
--    cat $CTDB_PUBLIC_ADDRESSES | while read IP IFACE REST; do
--	ip addr del $IP dev $IFACE >/dev/null 2>/dev/null
--    done
--}
--
  start() {
-     echo -n $"Starting ctdbd service: "
- 
 diff --git a/config/init_functions b/config/init_functions
 new file mode 100644
 index 0000000..6d3e789
@@ -380,17 +372,17 @@ index 0000000..6d3e789
 +    done
 +}
 diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
-index 08719d0..53c6080 100644
+index 50287ab..5bcf005 100644
 --- a/packaging/RPM/ctdb.spec.in
 +++ b/packaging/RPM/ctdb.spec.in
-@@ -112,6 +112,7 @@ rm -rf $RPM_BUILD_ROOT
+@@ -155,6 +155,7 @@ rm -rf $RPM_BUILD_ROOT
+ %{_sysconfdir}/ctdb/events.d/70.iscsi
  %{_sysconfdir}/ctdb/events.d/91.lvs
  %{_sysconfdir}/ctdb/statd-callout
- %{_sysconfdir}/ctdb/interface_modify.sh
 +%{_sysconfdir}/ctdb/init_functions
  %{_sbindir}/ctdbd
  %{_bindir}/ctdb
  %{_bindir}/smnotify
 -- 
-1.7.7.6
+1.7.11.7
 
diff --git a/0001-Fixes-for-various-issues-found-by-Coverity.patch b/0001-Fixes-for-various-issues-found-by-Coverity.patch
index fb12959..e832098 100644
--- a/0001-Fixes-for-various-issues-found-by-Coverity.patch
+++ b/0001-Fixes-for-various-issues-found-by-Coverity.patch
@@ -1,27 +1,26 @@
-From a4c154a0e279575042940f3b84cf1910031b8482 Mon Sep 17 00:00:00 2001
+From 0e46186db136744ee15c55c8792ab947f9baf455 Mon Sep 17 00:00:00 2001
 From: Sumit Bose <sbose at redhat.com>
 Date: Wed, 1 Feb 2012 12:31:59 +0100
 Subject: [PATCH] Fixes for various issues found by Coverity
 
 ---
- client/ctdb_client.c      |    2 +-
- common/ctdb_logging.c     |   13 +++++++++++--
- lib/tdb/common/tdb.c      |    2 +-
- server/ctdb_banning.c     |    2 +-
- server/ctdb_daemon.c      |    4 ++++
- server/ctdb_logging.c     |    4 ++++
- server/ctdb_ltdb_server.c |    5 ++++-
- server/ctdb_recoverd.c    |    4 ++--
- server/eventscript.c      |    4 +++-
- tcp/tcp_connect.c         |   10 +++++++++-
- tests/src/ctdb_fetch.c    |    5 +++++
- 11 files changed, 45 insertions(+), 10 deletions(-)
+ client/ctdb_client.c      |  2 +-
+ common/ctdb_logging.c     | 13 +++++++++++--
+ server/ctdb_banning.c     |  2 +-
+ server/ctdb_daemon.c      |  4 ++++
+ server/ctdb_logging.c     |  4 ++++
+ server/ctdb_ltdb_server.c |  5 ++++-
+ server/ctdb_recoverd.c    |  4 ++--
+ server/eventscript.c      |  4 +++-
+ tcp/tcp_connect.c         | 10 +++++++++-
+ tests/src/ctdb_fetch.c    |  5 +++++
+ 10 Dateien geändert, 44 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
 
 diff --git a/client/ctdb_client.c b/client/ctdb_client.c
-index 5e06604..23ed24b 100644
+index d7c3031..746b297 100644
 --- a/client/ctdb_client.c
 +++ b/client/ctdb_client.c
-@@ -3024,7 +3024,7 @@ static void async_callback(struct ctdb_client_control_state *state)
+@@ -3299,7 +3299,7 @@ static void async_callback(struct ctdb_client_control_state *state)
  	struct ctdb_context *ctdb = talloc_get_type(state->ctdb, struct ctdb_context);
  	int ret;
  	TDB_DATA outdata;
@@ -31,10 +30,10 @@ index 5e06604..23ed24b 100644
  
  	/* one more node has responded with recmode data */
 diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
-index dee4dfd..98beb08 100644
+index 09b1df2..5ed7321 100644
 --- a/common/ctdb_logging.c
 +++ b/common/ctdb_logging.c
-@@ -124,7 +124,7 @@ static void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr
+@@ -123,7 +123,7 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
  		tm = localtime(&log_entries[tmp_entry].t.tv_sec);
  		strftime(tbuf, sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
  
@@ -43,7 +42,7 @@ index dee4dfd..98beb08 100644
  			count += fprintf(f, "%s:%s %s", tbuf, get_debug_by_level(log_entries[tmp_entry].level), log_entries[tmp_entry].message);
  		}
  
-@@ -135,9 +135,18 @@ static void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr
+@@ -134,9 +134,18 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
  	}
  
  	fsize = ftell(f);
@@ -63,24 +62,11 @@ index dee4dfd..98beb08 100644
  	data.dsize = fread(data.dptr, 1, fsize, f);
  	fclose(f);
  
-diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
-index 4d8c5fc..eeadf2f 100644
---- a/lib/tdb/common/tdb.c
-+++ b/lib/tdb/common/tdb.c
-@@ -993,7 +993,7 @@ int tdb_repack(struct tdb_context *tdb)
- bool tdb_write_all(int fd, const void *buf, size_t count)
- {
- 	while (count) {
--		size_t ret;
-+		ssize_t ret;
- 		ret = write(fd, buf, count);
- 		if (ret < 0)
- 			return false;
 diff --git a/server/ctdb_banning.c b/server/ctdb_banning.c
-index 3d5f216..d6304e3 100644
+index 4e6db31..1892565 100644
 --- a/server/ctdb_banning.c
 +++ b/server/ctdb_banning.c
-@@ -49,7 +49,7 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
+@@ -73,7 +73,7 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
  	DEBUG(DEBUG_INFO,("SET BAN STATE\n"));
  
  	if (bantime->pnn != ctdb->pnn) {
@@ -90,10 +76,10 @@ index 3d5f216..d6304e3 100644
  			return -1;
  		}
 diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
-index f0c7ec9..d4e1782 100644
+index fdfd5de..33e265a 100644
 --- a/server/ctdb_daemon.c
 +++ b/server/ctdb_daemon.c
-@@ -862,6 +862,10 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog,
+@@ -1240,6 +1240,10 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog,
  	fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd, 
  			   EVENT_FD_READ,
  			   ctdb_accept_client, ctdb);
@@ -105,10 +91,10 @@ index f0c7ec9..d4e1782 100644
  
  	/* release any IPs we hold from previous runs of the daemon */
 diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
-index 27b990e..f952449 100644
+index 7cf8b9f..058a9bb 100644
 --- a/server/ctdb_logging.c
 +++ b/server/ctdb_logging.c
-@@ -512,6 +512,10 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
+@@ -520,6 +520,10 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
  	/* We'll fail if stderr/stdout not already open; it's simpler. */
  	old_stdout = dup(STDOUT_FILENO);
  	old_stderr = dup(STDERR_FILENO);
@@ -120,10 +106,10 @@ index 27b990e..f952449 100644
  		int saved_errno = errno;
  		dup2(old_stdout, STDOUT_FILENO);
 diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
-index 3d18e06..7a3ecd8 100644
+index 0432e49..4156a5d 100644
 --- a/server/ctdb_ltdb_server.c
 +++ b/server/ctdb_ltdb_server.c
-@@ -1125,7 +1125,10 @@ static int ctdb_attach_persistent(struct ctdb_context *ctdb,
+@@ -1180,7 +1180,10 @@ static int ctdb_attach_persistent(struct ctdb_context *ctdb,
  		int invalid_name = 0;
  		
  		s = talloc_strdup(ctdb, de->d_name);
@@ -136,12 +122,12 @@ index 3d18e06..7a3ecd8 100644
  		/* only accept names ending in .tdb */
  		p = strstr(s, ".tdb.");
 diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
-index 4963c3f..277550c 100644
+index 0f8aa91..7c06efc 100644
 --- a/server/ctdb_recoverd.c
 +++ b/server/ctdb_recoverd.c
-@@ -1078,8 +1078,8 @@ static int traverse_recdb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
+@@ -1254,8 +1254,8 @@ static int traverse_recdb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
+ 		params->recdata = talloc_realloc_size(NULL, params->recdata, params->allocated_len);
  	}
- 	params->recdata = talloc_realloc_size(NULL, params->recdata, rec->length + params->len);
  	if (params->recdata == NULL) {
 -		DEBUG(DEBUG_CRIT,(__location__ " Failed to expand recdata to %u (%u records)\n", 
 -			 rec->length + params->len, params->recdata->count));
@@ -151,10 +137,10 @@ index 4963c3f..277550c 100644
  		return -1;
  	}
 diff --git a/server/eventscript.c b/server/eventscript.c
-index 17cc3d4..5c91e44 100644
+index 762f950..1e8583e 100644
 --- a/server/eventscript.c
 +++ b/server/eventscript.c
-@@ -210,6 +210,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
+@@ -211,6 +211,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
  		tree_item = talloc(tree, struct ctdb_script_tree_item);
  		if (tree_item == NULL) {
  			DEBUG(DEBUG_ERR, (__location__ " Failed to allocate new tree item\n"));
@@ -162,7 +148,7 @@ index 17cc3d4..5c91e44 100644
  			talloc_free(tmp_ctx);
  			return NULL;
  		}
-@@ -222,6 +223,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
+@@ -223,6 +224,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
  		tree_item->name = talloc_strdup(tree_item, de->d_name);
  		if (tree_item->name == NULL) {
  			DEBUG(DEBUG_ERR,(__location__ " Failed to allocate script name.\n"));
@@ -170,7 +156,7 @@ index 17cc3d4..5c91e44 100644
  			talloc_free(tmp_ctx);
  			return NULL;
  		}
-@@ -853,10 +855,10 @@ int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_eventscript_call
+@@ -891,10 +893,10 @@ int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_eventscript_call
  	va_start(ap, fmt);
  	ret = ctdb_event_script_callback_v(ctdb, ctdb,
  			event_script_callback, &status, false, call, fmt, ap);
@@ -183,10 +169,10 @@ index 17cc3d4..5c91e44 100644
  	status.status = -1;
  	status.done = false;
 diff --git a/tcp/tcp_connect.c b/tcp/tcp_connect.c
-index d7a0b33..1a580c3 100644
+index 93111f3..d3c7033 100644
 --- a/tcp/tcp_connect.c
 +++ b/tcp/tcp_connect.c
-@@ -155,6 +155,10 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
+@@ -154,6 +154,10 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
  	}
  
  	tnode->fd = socket(sock_out.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
@@ -197,7 +183,7 @@ index d7a0b33..1a580c3 100644
  	set_nonblocking(tnode->fd);
  	set_close_on_exec(tnode->fd);
  
-@@ -197,7 +201,11 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
+@@ -196,7 +200,11 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
  	sock_in.ip.sin_len = sockin_size;
  	sock_out.ip.sin_len = sockout_size;
  #endif
@@ -211,10 +197,10 @@ index d7a0b33..1a580c3 100644
  	if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 &&
  	    errno != EINPROGRESS) {
 diff --git a/tests/src/ctdb_fetch.c b/tests/src/ctdb_fetch.c
-index a8f38ee..6fddbf6 100644
+index db84f5d..b900efa 100644
 --- a/tests/src/ctdb_fetch.c
 +++ b/tests/src/ctdb_fetch.c
-@@ -84,6 +84,11 @@ static void bench_fetch_1node(struct ctdb_context *ctdb)
+@@ -83,6 +83,11 @@ static void bench_fetch_1node(struct ctdb_context *ctdb)
  	data.dptr = (uint8_t *)talloc_asprintf_append((char *)data.dptr, 
  						      "msg_count=%d on node %d\n",
  						      msg_count, ctdb_get_pnn(ctdb));
@@ -227,5 +213,5 @@ index a8f38ee..6fddbf6 100644
  
  	ret = ctdb_record_store(h, data);
 -- 
-1.7.7.6
+1.7.11.7
 
diff --git a/0002-Add-systemd-support.patch b/0002-Add-systemd-support.patch
index 7de8447..a810148 100644
--- a/0002-Add-systemd-support.patch
+++ b/0002-Add-systemd-support.patch
@@ -1,16 +1,17 @@
-From 113101f50f17b29758dc26ac8f0a7e29b2b3be92 Mon Sep 17 00:00:00 2001
+From f632065bf22b3c057a478aac7b04b1904bad2993 Mon Sep 17 00:00:00 2001
 From: Sumit Bose <sbose at redhat.com>
 Date: Tue, 10 Jan 2012 10:20:35 +0100
-Subject: [PATCH 2/2] Add systemd support
+Subject: [PATCH 2/3] Add systemd support
 
 ---
- config/ctdb.service                                |   19 ++++++++++++
- config/systemd/ctdb.systemd                        |   32 ++++++++++++++++++++
- config/systemd/ctdb_check_persistent_databases.pre |   20 ++++++++++++
- config/systemd/ctdb_drop_all_public_ips            |   22 +++++++++++++
- config/systemd/ctdb_set_ctdb_variables.post        |   26 ++++++++++++++++
- packaging/RPM/ctdb.spec.in                         |   22 +++++++++++++-
- 6 files changed, 140 insertions(+), 1 deletions(-)
+ config/ctdb.service                                |  19 ++
+ config/init_functions                              | 209 +++++++++++----------
+ config/systemd/ctdb.systemd                        |  32 ++++
+ config/systemd/ctdb_check_persistent_databases.pre |  20 ++
+ config/systemd/ctdb_drop_all_public_ips            |  22 +++
+ config/systemd/ctdb_set_ctdb_variables.post        |  26 +++
+ packaging/RPM/ctdb.spec.in                         |  22 ++-
+ 7 Dateien geändert, 247 Zeilen hinzugefügt(+), 103 Zeilen entfernt(-)
  create mode 100644 config/ctdb.service
  create mode 100755 config/systemd/ctdb.systemd
  create mode 100755 config/systemd/ctdb_check_persistent_databases.pre
@@ -19,7 +20,7 @@ Subject: [PATCH 2/2] Add systemd support
 
 diff --git a/config/ctdb.service b/config/ctdb.service
 new file mode 100644
-index 0000000..76b47bd
+index 0000000..c3423a6
 --- /dev/null
 +++ b/config/ctdb.service
 @@ -0,0 +1,19 @@
@@ -42,6 +43,263 @@ index 0000000..76b47bd
 +
 +[Install]
 +WantedBy=multi-user.target
+diff --git a/config/init_functions b/config/init_functions
+index 6d3e789..db0646b 100644
+--- a/config/init_functions
++++ b/config/init_functions
+@@ -3,23 +3,23 @@
+ build_ctdb_options () {
+ 
+     maybe_set () {
+-        # If the 2nd arg is null then return - don't set anything.
+-        # Else if the 3rd arg is set and it doesn't match the 2nd arg
+-        # then return
+-        [ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
+-
+-        val="'$2'"
+-        case "$1" in
+-            --*) sep="=" ;;
+-            -*)  sep=" " ;;
+-        esac
+-        # For these options we're only passing a value-less flag.
+-        [ -n "$3" ] && {
+-            val=""
+-            sep=""
+-        }
+-
+-        CTDB_OPTIONS="${CTDB_OPTIONS}${CTDB_OPTIONS:+ }${1}${sep}${val}"
++	# If the 2nd arg is null then return - don't set anything.
++	# Else if the 3rd arg is set and it doesn't match the 2nd arg
++	# then return
++	[ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
++
++	val="'$2'"
++	case "$1" in
++	    --*) sep="=" ;;
++	    -*)  sep=" " ;;
++	esac
++	# For these options we're only passing a value-less flag.
++	[ -n "$3" ] && {
++	    val=""
++	    sep=""
++	}
++
++	CTDB_OPTIONS="${CTDB_OPTIONS}${CTDB_OPTIONS:+ }${1}${sep}${val}"
+     }
+ 
+     [ -z "$CTDB_RECOVERY_LOCK" ] && {
+@@ -38,6 +38,7 @@ build_ctdb_options () {
+     maybe_set "--event-script-dir"       "$CTDB_EVENT_SCRIPT_DIR"
+     maybe_set "--transport"              "$CTDB_TRANSPORT"
+     maybe_set "-d"                       "$CTDB_DEBUGLEVEL"
++    maybe_set "--debug-hung-script"      "$CTDB_DEBUG_HUNG_SCRIPT"
+     maybe_set "--notification-script"    "$CTDB_NOTIFY_SCRIPT"
+     maybe_set "--start-as-disabled"      "$CTDB_START_AS_DISABLED"    "yes"
+     maybe_set "--start-as-stopped "      "$CTDB_START_AS_STOPPED"     "yes"
+@@ -50,93 +51,107 @@ build_ctdb_options () {
+     maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
+ }
+ 
+-check_tdb () {
+-    local PDBASE=$1
+-
+-    test x"$TDBTOOL_HAS_CHECK" = x"1" && {
+-        #
+-        # Note tdbtool always exits with 0
+-        #
+-        local OK=`/usr/bin/tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
+-        test x"$OK" = x"1" || {
+-            return 1;
+-        }
+-
+-        return 0;
+-    }
+-
+-    /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
+-        return $?;
+-    }
+-
+-    return 0;
++# Log given message or stdin to either syslog or a CTDB log file
++do_log ()
++{
++    script_log "ctdb.init" "$@"
+ }
+ 
+-check_persistent_databases () {
+-    PERSISTENT_DB_DIR="${CTDB_DBDIR:-/var/ctdb}/persistent"
+-    mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
+-    local ERRCOUNT=$CTDB_MAX_PERSISTENT_CHECK_ERRORS
+-
+-    test -z "$ERRCOUNT" && {
+-        ERRCOUNT="0"
+-    }
+-    test x"$ERRCOUNT" != x"0" && {
+-        return 0;
+-    }
+-
+-    if test -x /usr/bin/tdbtool ; then
+-        HAVE_TDBTOOL=1
++select_tdb_checker ()
++{
++    # Find the best TDB consistency check available.
++    use_tdb_tool_check=false
++    if [ -x /usr/bin/tdbtool ] && \
++	echo "help" | /usr/bin/tdbtool | grep -q check ; then
++
++	use_tdb_tool_check=true
++    elif [ -x /usr/bin/tdbtool -a -x /usr/bin/tdbdump ] ; then
++	    do_log <<EOF
++WARNING: The installed 'tdbtool' does not offer the 'check' subcommand.
++ Using 'tdbdump' for database checks.
++ Consider updating 'tdbtool' for better checks!
++EOF
++    elif [ -x /usr/bin/tdbdump ] ; then
++	do_log <<EOF
++WARNING: 'tdbtool' is not available.
++ Using 'tdbdump' to check the databases.
++ Consider installing a recent 'tdbtool' for better checks!
++EOF
+     else
+-        HAVE_TDBTOOL=0
++	do_log <<EOF
++WARNING: Cannot check databases since neither
++ 'tdbdump' nor 'tdbtool check' is available.
++ Consider installing tdbtool or at least tdbdump!
++EOF
++        return 1
+     fi
++}
+ 
+-    if test x"$HAVE_TDBTOOL" = x"1" ; then
+-        TDBTOOL_HAS_CHECK=`echo "help" | /usr/bin/tdbtool | grep check | wc -l`
++check_tdb ()
++{
++    _db="$1"
++
++    if $use_tdb_tool_check ; then
++	# tdbtool always exits with 0  :-(
++	if tdbtool "$_db" check 2>/dev/null |
++	    grep -q "Database integrity is OK" ; then
++	    return 0
++	else
++	    return 1
++	fi
+     else
+-        TDBTOOL_HAS_CHECK=0
++	tdbdump "$_db" >/dev/null 2>/dev/null
++	return $?
+     fi
++}
+ 
+-    if test -x /usr/bin/tdbdump ; then
+-        HAVE_TDBDUMP=1
+-    else
+-        HAVE_TDBDUMP=0
+-    fi
++check_persistent_databases ()
++{
++    _dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_DBDIR:-/var/ctdb}/persistent}"
++    mkdir -p "$_dir" 2>/dev/null
+ 
+-    if test x"$HAVE_TDBDUMP" = x"0" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+-        echo "WARNING: Cannot check persistent databases since"
+-        echo "neither 'tdbdump' nor 'tdbtool check' is available."
+-        echo "Consider installing tdbtool or at least tdbdump!"
+-        return 0
+-    fi
++    [ "${CTDB_MAX_PERSISTENT_CHECK_ERRORS:-0}" = "0" ] || return 0
+ 
+-    if test x"$HAVE_TDBDUMP" = x"1" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+-        if test x"$HAVE_TDBTOOL" = x"0"; then
+-            echo "WARNING: 'tdbtool' is not available. Using 'tdbdump' to"
+-            echo "check the persistent databases."
+-            echo "Consider installing a recent 'tdbtool' for better checks!"
+-        else
+-            echo "WARNING: The installed 'tdbtool' does not offer the 'check'"
+-            echo "subcommand. Using 'tdbdump' for persistent database checks."
+-            echo "Consider updating 'tdbtool' for better checks!"
+-        fi
+-    fi
++    for _db in $(ls "$_dir/"*.tdb.*[0-9] 2>/dev/null) ; do
++	check_tdb $_db || {
++	    do_log "Persistent database $_db is corrupted! CTDB will not start."
++	    return 1
++	}
++    done
++}
+ 
+-    for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
+-        check_tdb $PDBASE || {
+-            echo "Persistent database $PDBASE is corrupted! CTDB will not start."
+-            return 1
+-        }
++check_non_persistent_databases ()
++{
++    _dir="${CTDB_DBDIR:-/var/ctdb}"
++    mkdir -p "$_dir" 2>/dev/null
++
++    for _db in $(ls "${_dir}/"*.tdb.*[0-9] 2>/dev/null) ; do
++	check_tdb $_db || {
++	    _backup="${_db}.$(date +'%Y%m%d.%H%M%S.%N').corrupt"
++	    do_log <<EOF
++WARNING: database ${_db} is corrupted.
++ Moving to backup ${_backup} for later analysis.
++EOF
++	    mv "$_db" "$_backup"
++
++	    # Now remove excess backups
++	    ls -td "${_db}."*".corrupt" |
++	    tail -n +$((${CTDB_MAX_CORRUPT_DB_BACKUPS:-10} + 1)) |
++	    xargs rm -f
++	    
++	}
+     done
+ }
+ 
+ set_ctdb_variables () {
+     # set any tunables from the config file
+-    set | grep ^CTDB_SET_ | cut -d_ -f3- |
++    set | grep ^CTDB_SET_ | cut -d_ -f3- | 
+     while read v; do
+-        varname=`echo $v | cut -d= -f1`
+-        value=`echo $v | cut -d= -f2`
+-        ctdb setvar $varname $value || RETVAL=1
+-    done || exit 1
++	varname=`echo $v | cut -d= -f1`
++	value=`echo $v | cut -d= -f2`
++	ctdb setvar $varname $value || return 1
++	echo "Set $varname to $value"
++    done
+ }
+ 
+ wait_until_ready () {
+@@ -144,20 +159,10 @@ wait_until_ready () {
+ 
+     _count=0
+     while ! ctdb ping >/dev/null 2>&1 ; do
+-        if [ $_count -ge $_timeout ] ; then
+-            return 1
+-        fi
+-        sleep 1
+-        _count=$(($_count + 1))
+-    done
+-}
+-
+-drop_all_public_ips() {
+-    [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
+-        return
+-    }
+-
+-    cat $CTDB_PUBLIC_ADDRESSES | while read IP IFACE REST; do
+-        ip addr del $IP dev $IFACE >/dev/null 2>/dev/null
++	if [ $_count -ge $_timeout ] ; then
++	    return 1
++	fi
++	sleep 1
++	_count=$(($_count + 1))
+     done
+ }
 diff --git a/config/systemd/ctdb.systemd b/config/systemd/ctdb.systemd
 new file mode 100755
 index 0000000..6f29e85
@@ -167,7 +425,7 @@ index 0000000..f02ca5d
 +
 +exit 0
 diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
-index 53c6080..a7ef034 100644
+index 5bcf005..ad3b118 100644
 --- a/packaging/RPM/ctdb.spec.in
 +++ b/packaging/RPM/ctdb.spec.in
 @@ -1,3 +1,4 @@
@@ -175,13 +433,13 @@ index 53c6080..a7ef034 100644
  %define initdir %{_sysconfdir}/init.d
  Name: ctdb
  Summary: Clustered TDB
-@@ -62,12 +63,23 @@ rm -rf $RPM_BUILD_ROOT
+@@ -95,12 +96,23 @@ rm -rf $RPM_BUILD_ROOT
  
  # Create the target build directory hierarchy
  mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
 -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
  
- make DESTDIR=$RPM_BUILD_ROOT docdir=%{_docdir} install
+ make DESTDIR=$RPM_BUILD_ROOT docdir=%{_docdir} install install_tests
  
  install -m644 config/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
 +
@@ -200,9 +458,9 @@ index 53c6080..a7ef034 100644
  
  mkdir -p $RPM_BUILD_ROOT%{_docdir}/ctdb/tests/bin
  install -m755 tests/bin/ctdb_transaction $RPM_BUILD_ROOT%{_docdir}/ctdb/tests/bin
-@@ -90,7 +102,15 @@ rm -rf $RPM_BUILD_ROOT
- %config(noreplace) %{_sysconfdir}/ctdb/notify.sh
+@@ -125,7 +137,15 @@ rm -rf $RPM_BUILD_ROOT
  %config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh
+ %config(noreplace) %{_sysconfdir}/ctdb/gcore_trace.sh
  %config(noreplace) %{_sysconfdir}/ctdb/functions
 +%if %{with_systemd}
 +%{_sysconfdir}/ctdb/systemd/ctdb_check_persistent_databases.pre
@@ -214,8 +472,8 @@ index 53c6080..a7ef034 100644
  %attr(755,root,root) %{initdir}/ctdb
 +%endif
  
- %{_docdir}/ctdb/README.eventscripts
- %{_docdir}/ctdb/recovery-process.txt
+ %{_docdir}/ctdb/README
+ %{_docdir}/ctdb/COPYING
 -- 
-1.7.7.6
+1.7.11.7
 
diff --git a/clean-up-systemd-integration.patch b/clean-up-systemd-integration.patch
index ff88a13..ecb411e 100644
--- a/clean-up-systemd-integration.patch
+++ b/clean-up-systemd-integration.patch
@@ -1,7 +1,7 @@
-From 89846a826443745e5b4911cd478d93251fef7de5 Mon Sep 17 00:00:00 2001
+From 746218fc106fb7c9b86c32e5dc92e881844e6212 Mon Sep 17 00:00:00 2001
 From: Jeff Layton <jlayton at redhat.com>
 Date: Wed, 22 Aug 2012 11:51:40 -0400
-Subject: [PATCH] ctdb: clean up systemd integration
+Subject: [PATCH 3/3] ctdb: clean up systemd integration
 
 This fixes a number of problems:
 
@@ -20,7 +20,7 @@ Signed-off-by: Jeff Layton <jlayton at redhat.com>
  config/ctdb.service         | 1 -
  config/init_functions       | 2 +-
  config/systemd/ctdb.systemd | 2 +-
- 3 files changed, 2 insertions(+), 3 deletions(-)
+ 3 Dateien geändert, 2 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
 
 diff --git a/config/ctdb.service b/config/ctdb.service
 index c3423a6..d6a2c22 100644
@@ -35,20 +35,20 @@ index c3423a6..d6a2c22 100644
  ExecStartPre=/etc/ctdb/systemd/ctdb_check_persistent_databases.pre
  ExecStart=/etc/ctdb/systemd/ctdb.systemd
 diff --git a/config/init_functions b/config/init_functions
-index 6d3e789..36a5fb4 100644
+index db0646b..70784f0 100644
 --- a/config/init_functions
 +++ b/config/init_functions
 @@ -8,7 +8,7 @@ build_ctdb_options () {
-         # then return
-         [ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
+ 	# then return
+ 	[ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
  
--        val="'$2'"
-+        val="$2"
-         case "$1" in
-             --*) sep="=" ;;
-             -*)  sep=" " ;;
+-	val="'$2'"
++	val="$2"
+ 	case "$1" in
+ 	    --*) sep="=" ;;
+ 	    -*)  sep=" " ;;
 diff --git a/config/systemd/ctdb.systemd b/config/systemd/ctdb.systemd
-index 6f29e85..5c1eb3f 100644
+index 6f29e85..5c1eb3f 100755
 --- a/config/systemd/ctdb.systemd
 +++ b/config/systemd/ctdb.systemd
 @@ -27,6 +27,6 @@ fi
@@ -60,5 +60,5 @@ index 6f29e85..5c1eb3f 100644
  
  exit 1
 -- 
-1.7.11.4
+1.7.11.7
 
diff --git a/ctdb.spec b/ctdb.spec
index b75428d..47700b6 100644
--- a/ctdb.spec
+++ b/ctdb.spec
@@ -4,7 +4,7 @@
 Summary: A Clustered Database based on Samba's Trivial Database (TDB)
 Name: ctdb
 Version: 2.1
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv3+
 Group: System Environment/Daemons
 URL: http://ctdb.samba.org/
@@ -267,6 +267,9 @@ fi
 %doc tests/README
 
 %changelog
+* Mon Mar 25 2013 Sumit Bose <sbose at redhat.com> - 2.1-2
+- added updated patch files
+
 * Mon Mar 25 2013 Sumit Bose <sbose at redhat.com> - 2.1-1
 - Update to ctdb version  2.1
 - added fix for tevent configure check


More information about the scm-commits mailing list