Mon Dec 19 22:23:47 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  tagged 0.23
Mon Dec 19 22:23:34 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  * libjio 0.23
Sun Dec  4 16:38:00 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  * Add the tests directory to the repo.
  
  While the tests are far from complete, it's nice to have them on the repo
  (they've always been in the tarballs).
Sun Dec  4 16:34:39 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  * Fix check for read-only access in jopen().
  
  As a comment right above says, checking for read-only access can't be done by
  "if (flags & O_RDONLY)" since O_RDONLY is usually 0. We test jflags & J_RDONLY
  instead because we know it's properly defined.
  
  Thanks to Brian Moyle for reporting this bug and providing a slightly
  different patch.
Sun Dec  4 16:33:44 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  * Proper use of -fPIC.
Thu Mar 10 15:09:50 ART 2005  Alberto Bertogli (albertogli@telpin.com.ar)
  tagged 0.22
diff -rN -u old-libjio/Make.conf new-libjio/Make.conf
--- old-libjio/Make.conf	2005-12-19 22:26:27.000000000 -0300
+++ new-libjio/Make.conf	2005-12-19 22:26:27.000000000 -0300
@@ -1,8 +1,8 @@
 
-VERSION="0.22"
+VERSION="0.23"
 
 CC = gcc
-CFLAGS += -Wall -O3 \
+CFLAGS += -Wall -O3 -fPIC \
 	-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
 	-D_LFS_LARGEFILE=1 -D_LFS64_LARGEFILE=1 \
 	-D_FILE_OFFSET_BITS=64 `getconf LFS_CFLAGS 2>/dev/null` \
diff -rN -u old-libjio/tests/performance/Makefile new-libjio/tests/performance/Makefile
--- old-libjio/tests/performance/Makefile	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/performance/Makefile	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,24 @@
+
+LIBS = -ljio -lpthread
+CFLAGS = -Wall -O6
+
+default: all
+
+all: paralell streaming
+
+paralell: paralell.o
+	$(CC) $(LIBS) paralell.o -o paralell
+
+streaming: streaming.o
+	$(CC) $(LIBS) streaming.o -o streaming
+
+.c.o:
+	$(CC) $(CFLAGS) -c $< -o $@
+
+clean:
+	rm -f streaming.o streaming paralell.o paralell
+	rm -f *.bb *.bbg *.da *.gcov gmon.out
+
+
+.PHONY: default all clean
+
diff -rN -u old-libjio/tests/performance/paralell.c new-libjio/tests/performance/paralell.c
--- old-libjio/tests/performance/paralell.c	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/performance/paralell.c	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,122 @@
+
+/*
+ * streaming.c - A program to test speed of paralell writes using libjio.
+ * Alberto Bertogli (albertogli@telpin.com.ar)
+ */
+
+/*
+ * It creates a big file, extend it using truncate and fork N threads, which
+ * write the file in chunks (ie. if we have three threads, the first one
+ * writes the first 1/3rd of the file, and so on).
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <libjio.h>
+
+#define FILENAME "test_file-paralell"
+
+/* Declare here what's shared among threads
+ * It's not the cleanest design ever, but let's face it, it's a simple
+ * benchmarking program, who cares? */
+struct jfs fs;
+int blocksize, towrite, mb;
+
+
+void help(void)
+{
+	printf("Use: paralell MBs_to_write_per_thread blocksize nthreads\n");
+	exit(1);
+}
+
+void *worker(void *tno)
+{
+	void *buf;
+	int tid, work_done, rv;
+	off_t localoffset;
+	long secs, usecs;
+	double seconds, mb_per_sec;
+	struct timeval tv1, tv2;
+
+	tid = (int) tno;
+
+	localoffset = tid * towrite;
+	
+	buf = malloc(blocksize);
+	work_done = 0;
+
+	gettimeofday(&tv1, NULL);
+
+	while (work_done < towrite) {
+		rv = jpwrite(&fs, buf, blocksize, localoffset + work_done );
+		if (rv != blocksize) {
+			perror("jpwrite:");
+			break;
+		}
+
+		work_done += blocksize;
+	}
+
+	gettimeofday(&tv2, NULL);
+
+	secs = tv2.tv_sec - tv1.tv_sec;
+	usecs = tv2.tv_usec - tv1.tv_usec;
+
+	if (usecs < 0) {
+		secs -= 1;
+		usecs = 1000000 + usecs;
+	}
+	
+	seconds = secs + (usecs / 1000000.0);
+	mb_per_sec = mb / seconds;
+	
+	printf("%d %d %d %f %f\n", tid, mb, blocksize, seconds, mb_per_sec);
+
+	return NULL;
+
+}
+
+int main(int argc, char **argv)
+{
+	int rv, nthreads, i;
+	pthread_t *threads;
+
+	if (argc != 4)
+		help();
+
+	mb = atoi(argv[1]);
+	blocksize = atoi(argv[2]);
+	nthreads = atoi(argv[3]);
+	towrite = mb * 1024 * 1024;
+
+	threads = malloc(sizeof(pthread_t) * nthreads);
+	
+
+	rv = jopen(&fs, FILENAME, O_RDWR | O_CREAT | O_SYNC | O_TRUNC, 
+			0600, 0);
+	if (rv < 0) {
+		perror("jopen():");
+		exit(1);
+	}
+
+	/* extend the file */
+	jtruncate(&fs, towrite * nthreads);
+	
+	/* start the threads */
+	for (i = 0; i < nthreads; i++) {
+		pthread_create(threads + i, NULL, &worker, (void *) i);
+	}
+
+	for (i = 0; i < nthreads; i++) {
+		pthread_join(*(threads + i), NULL);
+	}
+
+	jclose(&fs);
+	return 0;
+}
+
diff -rN -u old-libjio/tests/performance/streaming.c new-libjio/tests/performance/streaming.c
--- old-libjio/tests/performance/streaming.c	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/performance/streaming.c	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,82 @@
+
+/*
+ * streaming.c - A program to test speed of a streaming write using libjio.
+ * Alberto Bertogli (albertogli@telpin.com.ar)
+ */
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <libjio.h>
+
+#define FILENAME "test_file-streaming"
+
+
+void help(void)
+{
+	printf("Use: streaming MBs_to_write blocksize\n");
+	exit(1);
+}
+
+
+int main(int argc, char **argv)
+{
+	int towrite, blocksize, rv, mb;
+	long secs, usecs;
+	double seconds, mb_per_sec;
+	void *buf;
+	struct jfs fs;
+	struct timeval tv1, tv2;
+
+	if (argc != 3)
+		help();
+
+	mb = atoi(argv[1]);
+	towrite = mb * 1024 * 1024;
+	blocksize = atoi(argv[2]);
+
+	rv = jopen(&fs, FILENAME, O_RDWR | O_CREAT | O_SYNC | O_TRUNC, 
+			0600, 0);
+	if (rv < 0) {
+		perror("jopen():");
+		exit(1);
+	}
+
+	buf = malloc(blocksize);
+
+	gettimeofday(&tv1, NULL);
+
+	while (towrite > 0) {
+		rv = jwrite(&fs, buf, blocksize);
+		if (rv != blocksize) {
+			perror("jwrite:");
+			break;
+		}
+
+		towrite -= blocksize;
+	}
+
+	gettimeofday(&tv2, NULL);
+
+	secs = tv2.tv_sec - tv1.tv_sec;
+	usecs = tv2.tv_usec - tv1.tv_usec;
+
+	if (usecs < 0) {
+		secs -= 1;
+		usecs = 1000000 + usecs;
+	}
+	
+	seconds = secs + (usecs / 1000000.0);
+	mb_per_sec = mb / seconds;
+	
+	printf("%d %d %f %f\n", mb, blocksize, seconds, mb_per_sec);
+
+	jclose(&fs);
+	return 0;
+}
+
diff -rN -u old-libjio/tests/README new-libjio/tests/README
--- old-libjio/tests/README	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/README	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,10 @@
+
+Here you will find a small set of testing utilities for libjio that cover
+performance testing and recovery testings. They're really simple so there's
+not much documentation besides the code.
+
+Another really useful way of doing testing is using some of the well known
+filesystem benchmarking applications and modify them to use libjio. I regulary
+use dbench, fsx, tiobench and the tdb test suite, the patches are available on
+the website.
+
diff -rN -u old-libjio/tests/recovery/1 new-libjio/tests/recovery/1
--- old-libjio/tests/recovery/1	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/1	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1 @@
+smaller
\ No newline at end of file
Files old-libjio/tests/recovery/.1.jio/2 and new-libjio/tests/recovery/.1.jio/2 differ
Files old-libjio/tests/recovery/.1.jio/3 and new-libjio/tests/recovery/.1.jio/3 differ
diff -rN -u old-libjio/tests/recovery/.1.jio/4 new-libjio/tests/recovery/.1.jio/4
--- old-libjio/tests/recovery/.1.jio/4	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/.1.jio/4	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1 @@
+ï,¿õû¸*6—@‡gi*œ7!2È	ó¯©„
\ No newline at end of file
diff -rN -u old-libjio/tests/recovery/.1.jio/5 new-libjio/tests/recovery/.1.jio/5
--- old-libjio/tests/recovery/.1.jio/5	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/.1.jio/5	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1 @@
+XUÁXP_,Ù`\¯ß‹(ÓR*ƒ¾ÞçCêÏ
\ No newline at end of file
diff -rN -u old-libjio/tests/recovery/.1.jio/6 new-libjio/tests/recovery/.1.jio/6
--- old-libjio/tests/recovery/.1.jio/6	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/.1.jio/6	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1 @@
+I¿æšbÌÇ¾Ì|X‹<[FH,âãê¸­©Z	»K<\
\ No newline at end of file
Files old-libjio/tests/recovery/.1.jio/7 and new-libjio/tests/recovery/.1.jio/7 differ
diff -rN -u old-libjio/tests/recovery/.1.jio/desc new-libjio/tests/recovery/.1.jio/desc
--- old-libjio/tests/recovery/.1.jio/desc	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/.1.jio/desc	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,9 @@
+
+1	valid					Rollbacked
+2	pdata too big				Broken body
+3	udata too big, pdata too small		Broken body
+4	random data, short header		Broken header
+5	random data, header lenght ok		Broken body
+6	random data, long file			Broken body
+7	valid, shorten the file via ftruncate	Rollbacked
+
Files old-libjio/tests/recovery/.1.jio/lock and new-libjio/tests/recovery/.1.jio/lock differ
diff -rN -u old-libjio/tests/recovery/mklock new-libjio/tests/recovery/mklock
--- old-libjio/tests/recovery/mklock	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/mklock	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+"Generate a lock file"
+
+import sys
+import struct
+
+if sys.argv < 3:
+	print "Use: mklock filename number"
+	sys.exit(1)
+
+try:
+	n = int(sys.argv[2])
+except:
+	print "Use: mlock filename number"
+	sys.exit(1)
+
+fd = open(sys.argv[1], "w");
+
+s = struct.pack("I", n)
+
+fd.write(s)
+
+fd.close()
+
diff -rN -u old-libjio/tests/recovery/mktrans new-libjio/tests/recovery/mktrans
--- old-libjio/tests/recovery/mktrans	1969-12-31 21:00:00.000000000 -0300
+++ new-libjio/tests/recovery/mktrans	2005-12-19 22:26:27.000000000 -0300
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+"Generate a transaction file"
+
+import sys
+import struct
+
+def help():
+	print "Use: mktrans tfile tid flags len plen ulen offset udata pdata"
+	sys.exit(1)
+
+
+if sys.argv < 10:
+	help()
+
+try:
+	file = sys.argv[1]
+	tid = int(sys.argv[2])
+	flags = int(sys.argv[3])
+	dlen = int(sys.argv[4])
+	plen = int(sys.argv[5])
+	ulen = int(sys.argv[6])
+	offset = int(sys.argv[7])
+	udata = sys.argv[8]
+	pdata = sys.argv[9]
+except:
+	help()
+
+fd = open(file, "w");
+
+s = struct.pack("IIIIIQ%ds%ds" % (len(udata), len(pdata)),\
+		tid, flags, dlen, plen, ulen, offset, \
+		udata, pdata)
+
+print 'tid:', tid
+print 'flags:', flags
+print 'dlen:', dlen
+print 'plen:', plen
+print 'ulen:', ulen
+print 'offset:', offset
+print 'udata: +%s+' % udata
+print 'pdata: +%s+' % pdata
+print 'total lenght:', len(s)
+
+fd.write(s)
+
+fd.close()
+
diff -rN -u old-libjio/trans.c new-libjio/trans.c
--- old-libjio/trans.c	2005-12-19 22:26:27.000000000 -0300
+++ new-libjio/trans.c	2005-12-19 22:26:27.000000000 -0300
@@ -594,7 +594,7 @@
 		goto error_exit;
 
 	/* nothing else to do for read-only access */
-	if (flags & O_RDONLY) {
+	if (jflags & J_RDONLY) {
 		return fs->fd;
 	}
 

