[SCM] CTDB repository - branch master updated - ctdb-1.0.79-29-ga87ef6a

Ronnie Sahlberg sahlberg at samba.org
Wed May 6 00:44:17 GMT 2009


The branch, master has been updated
       via  a87ef6a9206820d5110a7117240f743af010ff19 (commit)
       via  96c79bddf7895e57ccf90f0d250bd08b7c4daf40 (commit)
       via  fce851621fe2099c9692acfbfaade24c3d69727a (commit)
       via  300e84f7023e9194b313e96db943e4050bd64e68 (commit)
       via  200de8f299c8fa44d6dc696532f1a947132e7ec4 (commit)
       via  fe59ecb697fb4686ad8ea2fe4ec1cc7b4629e74f (commit)
       via  8a86f65826b58c2ee3f07f221a4fc82193beec81 (commit)
      from  48c011188c624f10c9a754d4ead27db558088fd4 (commit)

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


- Log -----------------------------------------------------------------
commit a87ef6a9206820d5110a7117240f743af010ff19
Author: Michael Adam <obnox at samba.org>
Date:   Tue May 5 13:16:38 2009 +0200

    ping_pong: add GPL comment header with Tridge's copyright
    
    Michael

commit 96c79bddf7895e57ccf90f0d250bd08b7c4daf40
Author: Michael Adam <obnox at samba.org>
Date:   Thu Apr 30 00:35:55 2009 +0200

    ping_pong: get pread/pwrite prototypes from unistd.h
    
    by defining _XOPEN_SOURCE to be 500 before including headers
    
    Michael

commit fce851621fe2099c9692acfbfaade24c3d69727a
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 18:03:03 2009 +0200

    ping_pong: reduce a couple of prototype warnings
    
    Michael

commit 300e84f7023e9194b313e96db943e4050bd64e68
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 17:58:17 2009 +0200

    packaging: also package ping_pong
    
    Michael

commit 200de8f299c8fa44d6dc696532f1a947132e7ec4
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 17:57:43 2009 +0200

    build: also build and install ping_pong
    
    Michael

commit fe59ecb697fb4686ad8ea2fe4ec1cc7b4629e74f
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 17:50:38 2009 +0200

    add tridge's ping_pong.c to the utils folder
    
    Michael

commit 8a86f65826b58c2ee3f07f221a4fc82193beec81
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed May 6 10:29:07 2009 +1000

    From Sumit Bose <sbose at redhat.com>
    
    add more 64bit plattforms to configure.ac and preserve cli settings

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

Summary of changes:
 Makefile.in                 |    8 ++-
 configure.ac                |   18 ++--
 packaging/RPM/ctdb.spec     |    1 +
 utils/ping_pong/ping_pong.c |  197 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 215 insertions(+), 9 deletions(-)
 create mode 100644 utils/ping_pong/ping_pong.c


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index f1c5f36..1288317 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -63,7 +63,7 @@ TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_store \
 	tests/bin/ctdb_traverse tests/bin/rb_test tests/bin/ctdb_transaction \
 	@INFINIBAND_BINS@
 
-BINS = bin/ctdb @CTDB_SCSI_IO@ bin/ctdb_ipmux bin/smnotify
+BINS = bin/ctdb @CTDB_SCSI_IO@ bin/ctdb_ipmux bin/smnotify bin/ping_pong
 SBINS = bin/ctdbd
 
 DIRS = lib bin tests/bin
@@ -130,6 +130,11 @@ utils/smnotify/gen_smnotify.c: utils/smnotify/smnotify.x utils/smnotify/smnotify
 	@echo Generating $@
 	rpcgen -l utils/smnotify/smnotify.x > utils/smnotify/gen_smnotify.c 
 
+bin/ping_pong: utils/ping_pong/ping_pong.o
+	@echo Linking $@
+	@$(CC) $(CFLAGS) -o $@ utils/ping_pong/ping_pong.o
+
+
 tests/bin/rb_test: $(CTDB_CLIENT_OBJ) tests/src/rb_test.o 
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ tests/src/rb_test.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
@@ -200,6 +205,7 @@ install: all
 	${INSTALLCMD} -m 755 bin/ctdb_ipmux $(DESTDIR)$(bindir)
 	${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir)
 	${INSTALLCMD} -m 755 bin/smnotify $(DESTDIR)$(bindir)
+	$(INSTALLCMD) -m 755 bin/ping_pong $(DESTDIR)$(bindir)
 	${INSTALLCMD} -m 644 include/ctdb.h $(DESTDIR)$(includedir)
 	${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
 	${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
diff --git a/configure.ac b/configure.ac
index a7bd2bb..0e8f150 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,14 +14,16 @@ AC_DEFUN([SMB_ENABLE], [echo -n ""])
 AC_INIT(ctdb.h)
 AC_CONFIG_SRCDIR([server/ctdbd.c])
 
-case `uname -m` in
-  x86_64)
-    libdir='${exec_prefix}/lib64'
-    ;;
-  *)
-    libdir='${exec_prefix}/lib'
-    ;;
-esac
+if test "${libdir}" = '${exec_prefix}/lib'; then
+  case `uname -m` in
+    x86_64|ppc64|powerpc64)
+      libdir='${exec_prefix}/lib64'
+      ;;
+    *)
+      libdir='${exec_prefix}/lib'
+      ;;
+  esac
+fi
 
 case `uname` in
   Linux*)
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index bbd467b..12f7bdc 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -120,6 +120,7 @@ fi
 %{_sbindir}/ctdbd
 %{_bindir}/ctdb
 %{_bindir}/smnotify
+%{_bindir}/ping_pong
 %{_bindir}/ctdb_ipmux
 %{_bindir}/ctdb_diagnostics
 %{_bindir}/onnode
diff --git a/utils/ping_pong/ping_pong.c b/utils/ping_pong/ping_pong.c
new file mode 100644
index 0000000..fd0e99b
--- /dev/null
+++ b/utils/ping_pong/ping_pong.c
@@ -0,0 +1,197 @@
+/*
+   A ping-pong fcntl byte range lock test
+
+   Copyright (C) Andrew Tridgell 2002
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+  This measures the ping-pong byte range lock latency. It is
+  especially useful on a cluster of nodes sharing a common lock
+  manager as it will give some indication of the lock managers
+  performance under stress.
+
+  tridge at samba.org, February 2002
+
+*/
+
+#define _XOPEN_SOURCE 500
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <sys/mman.h>
+
+static struct timeval tp1,tp2;
+
+static int do_reads, do_writes, use_mmap;
+
+static void start_timer(void)
+{
+	gettimeofday(&tp1,NULL);
+}
+
+static double end_timer(void)
+{
+	gettimeofday(&tp2,NULL);
+	return (tp2.tv_sec + (tp2.tv_usec*1.0e-6)) - 
+		(tp1.tv_sec + (tp1.tv_usec*1.0e-6));
+}
+
+/* lock a byte range in a open file */
+static int lock_range(int fd, int offset, int len)
+{
+	struct flock lock;
+
+	lock.l_type = F_WRLCK;
+	lock.l_whence = SEEK_SET;
+	lock.l_start = offset;
+	lock.l_len = len;
+	lock.l_pid = 0;
+	
+	return fcntl(fd,F_SETLKW,&lock);
+}
+
+/* unlock a byte range in a open file */
+static int unlock_range(int fd, int offset, int len)
+{
+	struct flock lock;
+
+	lock.l_type = F_UNLCK;
+	lock.l_whence = SEEK_SET;
+	lock.l_start = offset;
+	lock.l_len = len;
+	lock.l_pid = 0;
+	
+	return fcntl(fd,F_SETLKW,&lock);
+}
+
+/* run the ping pong test on fd */
+static void ping_pong(int fd, int num_locks)
+{
+	unsigned count = 0;
+	int i=0, loops=0;
+	unsigned char *val;
+	unsigned char incr=0, last_incr=0;
+	unsigned char *p = NULL;
+
+	ftruncate(fd, num_locks+1);
+
+	if (use_mmap) {
+		p = mmap(NULL, num_locks+1, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+	}
+
+	val = (unsigned char *)calloc(num_locks+1, sizeof(unsigned char));
+
+	start_timer();	
+
+	lock_range(fd, 0, 1);
+	i = 0;
+
+	while (1) {
+		if (lock_range(fd, (i+1) % num_locks, 1) != 0) {
+			printf("lock at %d failed! - %s\n",
+			       (i+1) % num_locks, strerror(errno));
+		}
+		if (do_reads) {
+			unsigned char c;
+			if (use_mmap) {
+				c = p[i];
+			} if (pread(fd, &c, 1, i) != 1) {
+				printf("read failed at %d\n", i);
+			}
+			incr = c - val[i];
+			val[i] = c;
+		}
+		if (do_writes) {
+			char c = val[i] + 1;
+			if (use_mmap) {
+				p[i] = c;
+			} else if (pwrite(fd, &c, 1, i) != 1) {
+				printf("write failed at %d\n", i);
+			}
+		}
+		if (unlock_range(fd, i, 1) != 0) {
+			printf("unlock at %d failed! - %s\n",
+			       i, strerror(errno));
+		}
+		i = (i+1) % num_locks;
+		count++;
+		if (loops > num_locks && incr != last_incr) {
+			last_incr = incr;
+			printf("data increment = %u\n", incr);
+			fflush(stdout);
+		}
+		if (end_timer() > 1.0) {
+			printf("%8u locks/sec\r", 
+			       (unsigned)(2*count/end_timer()));
+			fflush(stdout);
+			start_timer();
+			count=0;
+		}
+		loops++;
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	char *fname;
+	int fd, num_locks;
+	int c;
+
+	while ((c = getopt(argc, argv, "rwm")) != -1) {
+		switch (c){
+		case 'w':
+			do_writes = 1;
+			break;
+		case 'r':
+			do_reads = 1;
+			break;
+		case 'm':
+			use_mmap = 1;
+			break;
+		default:
+			fprintf(stderr, "Unknown option '%c'\n", c);
+			exit(1);
+		}
+	}
+
+	argv += optind;
+	argc -= optind;
+
+	if (argc < 2) {
+		printf("ping_pong [options] <file> <num_locks>\n");
+		printf("           -r    do reads\n");
+		printf("           -w    do writes\n");
+		printf("           -m    use mmap\n");
+		exit(1);
+	}
+
+	fname = argv[0];
+	num_locks = atoi(argv[1]);
+
+	fd = open(fname, O_CREAT|O_RDWR, 0600);
+	if (fd == -1) exit(1);
+
+	ping_pong(fd, num_locks);
+
+	return 0;
+}


-- 
CTDB repository


More information about the samba-cvs mailing list