[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Fri Aug 7 06:38:04 UTC 2015


The branch, master has been updated
       via  eba1212 ctdb-tests: Add a policy routing test with misconfiguration
       via  5a6a932 ctdb-tests: Make fake gateway different to actual public IPs
       via  7d04778 ctdb-scripts: Improve error handling for 50.samba testparm failure
       via  6538ba5 ctdb-pmda: Add missing prototype declaration for non-static function
       via  7949ce1 ctdb-daemon: Reset database statistics when resetting statistics
       via  d9030d8 ctdb-system: Remove unused system specific calls
      from  e45b0d4 source3/rpc_client: Fix CID 1273041 Condition is redundant

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit eba12122ccce602aede7756b8f91d34fe927d2c0
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 4 17:03:50 2015 +1000

    ctdb-tests: Add a policy routing test with misconfiguration
    
    To support this, extend the "ip route add" stub to detect duplicate
    routes.
    
    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): Fri Aug  7 08:37:38 CEST 2015 on sn-devel-104

commit 5a6a9326e58c4ebabd351326493d5d320e0130e6
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 4 16:12:31 2015 +1000

    ctdb-tests: Make fake gateway different to actual public IPs
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7d04778c82a8f657b6ba0173c29529fa03ab7a25
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 30 16:49:35 2015 +1000

    ctdb-scripts: Improve error handling for 50.samba testparm failure
    
    Also add tests.  Update testparm stub to fake error and timeout.  Add
    timeout stub.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 6538ba5243a043bc727039a16a7a9d5d8027fa06
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 3 15:36:06 2015 +1000

    ctdb-pmda: Add missing prototype declaration for non-static function
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11434
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 7949ce103f2062aa703a24f72e11be96dc497a7a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Apr 2 13:53:09 2015 +1100

    ctdb-daemon: Reset database statistics when resetting statistics
    
    When the ctdb statistics is reset, reset per database statistics to keep
    it consistent with ctdb statistics.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit d9030d8c10ebe6f95f33cbc691b5756d97395b0f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 3 15:02:43 2015 +1000

    ctdb-system: Remove unused system specific calls
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/common/system_aix.c                         |  18 ---
 ctdb/common/system_freebsd.c                     |  32 ----
 ctdb/common/system_gnu.c                         |  18 ---
 ctdb/common/system_kfreebsd.c                    |  31 ----
 ctdb/common/system_linux.c                       | 177 -----------------------
 ctdb/config/events.d/50.samba                    |  45 ++++--
 ctdb/include/ctdb_private.h                      |   5 +-
 ctdb/server/ctdb_control.c                       |   7 +
 ctdb/server/ctdb_ltdb_server.c                   |  14 ++
 ctdb/tests/eventscripts/13.per_ip_routing.023.sh |  26 ++++
 ctdb/tests/eventscripts/50.samba.monitor.110.sh  |  20 +++
 ctdb/tests/eventscripts/50.samba.monitor.111.sh  |  25 ++++
 ctdb/tests/eventscripts/50.samba.monitor.112.sh  |  13 ++
 ctdb/tests/eventscripts/50.samba.monitor.113.sh  |  16 ++
 ctdb/tests/eventscripts/scripts/local.sh         |   4 +-
 ctdb/tests/eventscripts/stubs/ip                 |  10 ++
 ctdb/tests/eventscripts/stubs/testparm           |  36 ++++-
 ctdb/tests/eventscripts/stubs/timeout            |   8 +
 ctdb/tests/src/ctdb_porting_tests.c              |  18 ---
 ctdb/utils/pmda/pmda_ctdb.c                      |   3 +-
 20 files changed, 214 insertions(+), 312 deletions(-)
 create mode 100755 ctdb/tests/eventscripts/13.per_ip_routing.023.sh
 create mode 100755 ctdb/tests/eventscripts/50.samba.monitor.110.sh
 create mode 100755 ctdb/tests/eventscripts/50.samba.monitor.111.sh
 create mode 100755 ctdb/tests/eventscripts/50.samba.monitor.112.sh
 create mode 100755 ctdb/tests/eventscripts/50.samba.monitor.113.sh
 create mode 100755 ctdb/tests/eventscripts/stubs/timeout


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 41f61ae..a98d382 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -374,26 +374,8 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
 	return ret;
 }
 
-char *ctdb_get_process_name(pid_t pid)
-{
-	/* FIXME AIX: get_process_name not implemented */
-	return NULL;
-}
-
 int ctdb_set_process_name(const char *name)
 {
 	/* FIXME AIX: set_process_name not implemented */
 	return -ENOSYS;
 }
-
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
-	/* FIXME AIX: get_lock_info not implemented */
-	return false;
-}
-
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
-	/* FIXME AIX: get_blocker_pid not implemented */
-	return false;
-}
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 9597a7a..c5a816b 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -370,40 +370,8 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
 	return 1;
 }
 
-char *ctdb_get_process_name(pid_t pid)
-{
-	char path[32];
-	char buf[PATH_MAX];
-	char *ptr;
-	int n;
-
-	snprintf(path, sizeof(path), "/proc/%d/exe", pid);
-	n = readlink(path, buf, sizeof(buf));
-	if (n < 0) {
-		return NULL;
-	}
-
-	/* Remove any extra fields */
-	buf[n] = '\0';
-	ptr = strtok(buf, " ");
-	return strdup(ptr);
-	return NULL;
-}
-
 int ctdb_set_process_name(const char *name)
 {
 	/* FIXME FreeBSD: set_process_name not implemented */
 	return -ENOSYS;
 }
-
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
-	/* FIXME FreeBSD: get_lock_info not implemented */
-	return false;
-}
-
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
-	/* FIXME FreeBSD: get_blocker_pid not implemented */
-	return false;
-}
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index 2ab1399..bf8f43c 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -363,26 +363,8 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
 	return 1;
 }
 
-char *ctdb_get_process_name(pid_t pid)
-{
-	/* FIXME GNU/Hurd: get_process_name not implemented */
-	return NULL;
-}
-
 int ctdb_set_process_name(const char *name)
 {
 	/* FIXME GNU/Hurd: set_process_name not implemented */
 	return -ENOSYS;
 }
-
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
-	/* FIXME GNU/Hurd: get_lock_info not implemented */
-	return false;
-}
-
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
-	/* FIXME GNU/Hurd: get_blocker_pid not implemented */
-	return false;
-}
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index 41aa4d6..de7c891 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -363,39 +363,8 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
 	return 1;
 }
 
-char *ctdb_get_process_name(pid_t pid)
-{
-	char path[32];
-	char buf[PATH_MAX];
-	char *ptr;
-	int n;
-
-	snprintf(path, sizeof(path), "/proc/%d/exe", pid);
-	n = readlink(path, buf, sizeof(buf));
-	if (n < 0) {
-		return NULL;
-	}
-
-	/* Remove any extra fields */
-	buf[n] = '\0';
-	ptr = strtok(buf, " ");
-	return strdup(ptr);
-}
-
 int ctdb_set_process_name(const char *name)
 {
 	/* FIXME kFreeBSD: set_process_name not implemented */
 	return -ENOSYS;
 }
-
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
-	/* FIXME kFreeBSD: get_lock_info not implemented */
-	return false;
-}
-
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
-	/* FIXME kFreeBSD: get_blocker_pid not implemented */
-	return false;
-}
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index fdb8d12..79d1a83 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -598,28 +598,6 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
 }
 
 /*
- * Find the process name from process ID
- */
-char *ctdb_get_process_name(pid_t pid)
-{
-	char path[32];
-	char buf[PATH_MAX];
-	char *ptr;
-	int n;
-
-	snprintf(path, sizeof(path), "/proc/%d/exe", pid);
-	n = readlink(path, buf, sizeof(buf)-1);
-	if (n < 0) {
-		return NULL;
-	}
-
-	/* Remove any extra fields */
-	buf[n] = '\0';
-	ptr = strtok(buf, " ");
-	return (ptr == NULL ? ptr : strdup(ptr));
-}
-
-/*
  * Set process name
  */
 int ctdb_set_process_name(const char *name)
@@ -630,158 +608,3 @@ int ctdb_set_process_name(const char *name)
 	procname[15] = '\0';
 	return prctl(PR_SET_NAME, (unsigned long)procname, 0, 0, 0);
 }
-
-/*
- * Parsing a line from /proc/locks,
- */
-static bool parse_proc_locks_line(char *line, pid_t *pid,
-				  struct ctdb_lock_info *curlock)
-{
-	char *ptr, *saveptr;
-
-	/* output of /proc/locks
-	 *
-	 * lock assigned
-	 * 1: POSIX  ADVISORY  WRITE 25945 fd:00:6424820 212 212
-	 *
-	 * lock waiting
-	 * 1: -> POSIX  ADVISORY  WRITE 25946 fd:00:6424820 212 212
-	 */
-
-	/* Id: */
-	ptr = strtok_r(line, " ", &saveptr);
-	if (ptr == NULL) return false;
-
-	/* -> */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-	if (strcmp(ptr, "->") == 0) {
-		curlock->waiting = true;
-		ptr = strtok_r(NULL, " ", &saveptr);
-	} else {
-		curlock->waiting = false;
-	}
-
-	/* POSIX */
-	if (ptr == NULL || strcmp(ptr, "POSIX") != 0) {
-		return false;
-	}
-
-	/* ADVISORY */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-
-	/* WRITE */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-	if (strcmp(ptr, "READ") == 0) {
-		curlock->read_only = true;
-	} else if (strcmp(ptr, "WRITE") == 0) {
-		curlock->read_only = false;
-	} else {
-		return false;
-	}
-
-	/* PID */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-	*pid = atoi(ptr);
-
-	/* MAJOR:MINOR:INODE */
-	ptr = strtok_r(NULL, " :", &saveptr);
-	if (ptr == NULL) return false;
-	ptr = strtok_r(NULL, " :", &saveptr);
-	if (ptr == NULL) return false;
-	ptr = strtok_r(NULL, " :", &saveptr);
-	if (ptr == NULL) return false;
-	curlock->inode = atol(ptr);
-
-	/* START OFFSET */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-	curlock->start = atol(ptr);
-
-	/* END OFFSET */
-	ptr = strtok_r(NULL, " ", &saveptr);
-	if (ptr == NULL) return false;
-	if (strncmp(ptr, "EOF", 3) == 0) {
-		curlock->end = (off_t)-1;
-	} else {
-		curlock->end = atol(ptr);
-	}
-
-	return true;
-}
-
-/*
- * Find information of lock being waited on for given process ID
- */
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
-	FILE *fp;
-	struct ctdb_lock_info curlock;
-	pid_t pid;
-	char buf[1024];
-	bool status = false;
-
-	if ((fp = fopen("/proc/locks", "r")) == NULL) {
-		DEBUG(DEBUG_ERR, ("Failed to read locks information"));
-		return false;
-	}
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		if (! parse_proc_locks_line(buf, &pid, &curlock)) {
-			continue;
-		}
-		if (pid == req_pid && curlock.waiting) {
-			*lock_info = curlock;
-			status = true;
-			break;
-		}
-	}
-	fclose(fp);
-
-	return status;
-}
-
-/*
- * Find process ID which holds an overlapping byte lock for required
- * inode and byte range.
- */
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
-	FILE *fp;
-	struct ctdb_lock_info curlock;
-	pid_t pid;
-	char buf[1024];
-	bool status = false;
-
-	if ((fp = fopen("/proc/locks", "r")) == NULL) {
-		DEBUG(DEBUG_ERR, ("Failed to read locks information"));
-		return false;
-	}
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		if (! parse_proc_locks_line(buf, &pid, &curlock)) {
-			continue;
-		}
-
-		if (curlock.waiting) {
-			continue;
-		}
-
-		if (curlock.inode != reqlock->inode) {
-			continue;
-		}
-
-		if (curlock.start > reqlock->end ||
-		    curlock.end < reqlock->start) {
-			/* Outside the required range */
-			continue;
-		}
-		*blocker_pid = pid;
-		status = true;
-		break;
-	}
-	fclose(fp);
-
-	return status;
-}
diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba
index 4b53cba..1742ff1 100755
--- a/ctdb/config/events.d/50.samba
+++ b/ctdb/config/events.d/50.samba
@@ -78,19 +78,42 @@ testparm_foreground_update ()
 {
     _timeout="$1"
 
-    if ! _out=$(timeout $_timeout testparm -v -s 2>/dev/null) ; then
-	if [ -f "$smbconf_cache" ] ; then
-	    echo "WARNING: smb.conf cache update failed - using old cache file"
-	    return 1
-	else
-	    die "ERROR: smb.conf cache create failed"
-	fi
-    fi
-
+    # No need to remove these temporary files, since there are only 2
+    # of them.
+    _out="${smbconf_cache}.out"
+    _err="${smbconf_cache}.err"
+
+    timeout $_timeout testparm -v -s >"$_out" 2>"$_err"
+    case $? in
+	0) : ;;
+	124)
+	    if [ -f "$smbconf_cache" ] ; then
+		echo "WARNING: smb.conf cache update timed out - using old cache file"
+		return 1
+	    else
+		echo "ERROR: smb.conf cache create failed - testparm command timed out"
+		exit 1
+	    fi
+	    ;;
+	*)
+	    if [ -f "$smbconf_cache" ] ; then
+		echo "WARNING: smb.conf cache update failed - using old cache file"
+		cat "$_err"
+		return 1
+	    else
+		echo "ERROR: smb.conf cache create failed - testparm failed with:"
+		cat "$_err"
+		exit 1
+	    fi
+    esac
+
+    # Only using $$ here to avoid a collision.  This is written into
+    # CTDB's own state directory so there is no real need for a secure
+    # temporary file.
     _tmpfile="${smbconf_cache}.$$"
     # Patterns to exclude...
-    pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+='    
-    echo "$_out" | grep -Ev "$pat" >"$_tmpfile"
+    _pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+='
+    grep -Ev "$_pat" <"$_out" >"$_tmpfile"
     mv "$_tmpfile" "$smbconf_cache" # atomic
 
     return 0
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 4cb0fe6..1d91923 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -1136,10 +1136,7 @@ struct ctdb_lock_info {
 	bool read_only;
 };
 
-char *ctdb_get_process_name(pid_t pid);
 int ctdb_set_process_name(const char *name);
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info);
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid);
 
 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
 
@@ -1449,6 +1446,8 @@ int ctdb_fetch_func(struct ctdb_call_info *call);
 
 int ctdb_fetch_with_header_func(struct ctdb_call_info *call);
 
+void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db);
+
 int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
 				uint32_t db_id,
 				TDB_DATA *outdata);
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index fda4c29..59b7d09 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -151,8 +151,15 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 	}
 
 	case CTDB_CONTROL_STATISTICS_RESET: {
+		struct ctdb_db_context *ctdb_db;
+
 		CHECK_CONTROL_DATA_SIZE(0);
 		ZERO_STRUCT(ctdb->statistics);
+		for (ctdb_db = ctdb->db_list;
+		     ctdb_db != NULL;
+		     ctdb_db = ctdb_db->next) {
+			ctdb_db_statistics_reset(ctdb_db);
+		}
 		ctdb->statistics.statistics_start_time = timeval_current();
 		return 0;
 	}
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 5357c6c..ad61f14 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -1600,6 +1600,20 @@ int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_d
 	return 0;
 }
 
+void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db)
+{
+	struct ctdb_db_statistics *s = &ctdb_db->statistics;
+	int i;
+
+	for (i=0; i<MAX_HOT_KEYS; i++) {
+		if (s->hot_keys[i].key.dsize > 0) {
+			talloc_free(s->hot_keys[i].key.dptr);
+		}
+	}
+
+	ZERO_STRUCT(ctdb_db->statistics);
+}
+
 int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
 				uint32_t db_id,
 				TDB_DATA *outdata)
diff --git a/ctdb/tests/eventscripts/13.per_ip_routing.023.sh b/ctdb/tests/eventscripts/13.per_ip_routing.023.sh
new file mode 100755
index 0000000..336e129
--- /dev/null
+++ b/ctdb/tests/eventscripts/13.per_ip_routing.023.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "1 IP configured, broken configuration, takeip"
+
+setup_ctdb
+setup_ctdb_policy_routing
+
+# Configuration for 1 IP
+create_policy_routing_config 1 default
+
+# takeip should add routes for the given address
+ctdb_get_1_public_address |
+while read dev ip bits ; do
+    # Now add configuration breakage by changing default route into a
+    # link local route with a gateway
+    net=$(ipv4_host_addr_to_net "$ip" "$bits")
+    sed -i -e "s at 0\.0\.0\.0/0@${net}@" "$CTDB_PER_IP_ROUTING_CONF"
+
+    ok <<EOF
+RTNETLINK answers: File exists
+add_routing_for_ip: failed to add route: ${net} via ${net%.*}.254 dev ${dev} table ctdb.${ip}
+EOF


-- 
Samba Shared Repository



More information about the samba-cvs mailing list