[Ocfstest-commits] mmatsuna commits r5 - in trunk: . Docs src src/aio_direct src/extendo

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Nov 18 15:27:22 CST 2004


Author: mmatsuna
Date: 2004-11-18 15:27:20 -0600 (Thu, 18 Nov 2004)
New Revision: 5

Added:
   trunk/Docs/
   trunk/Docs/OCFS2_Test_Plan.pdf
   trunk/Docs/OCFS2_Test_Plan.sxw
   trunk/bin/
   trunk/sql/
   trunk/src/
   trunk/src/aio_direct/
   trunk/src/aio_direct/partial_aio_direct.c
   trunk/src/extendo/
   trunk/src/extendo/Makefile
   trunk/src/extendo/extendo.c
   trunk/src/extendo/truncate.c
Log:
Loaded first files. Testplan, extendo/truncate/aio_direct sources.

Added: trunk/Docs/OCFS2_Test_Plan.pdf
===================================================================
(Binary files differ)


Property changes on: trunk/Docs/OCFS2_Test_Plan.pdf
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: trunk/Docs/OCFS2_Test_Plan.sxw
===================================================================
(Binary files differ)


Property changes on: trunk/Docs/OCFS2_Test_Plan.sxw
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/aio_direct/partial_aio_direct.c
===================================================================
--- trunk/src/aio_direct/partial_aio_direct.c	2004-11-18 21:20:31 UTC (rev 4)
+++ trunk/src/aio_direct/partial_aio_direct.c	2004-11-18 21:27:20 UTC (rev 5)
@@ -0,0 +1,115 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <stdint.h>
+
+#define __USE_GNU
+#include <fcntl.h>
+
+#include <libaio.h>
+
+#define BUFSIZE (128 * 1024)
+
+#define align_pow2(ptr, val) ( ptr + val - ((unsigned long)ptr & (val - 1)) )
+
+int main(int argc, char **argv)
+{
+	io_context_t ctx;
+	struct iocb iocb;
+	struct iocb *iocbs[1];
+	struct io_event event;
+	struct stat st;
+	char *ptr, *buf, one[PATH_MAX], two[PATH_MAX];
+	size_t buflen, ptrlen;
+	long rc;
+	int fd1, fd2;
+
+	if (argc < 2) {
+		printf("I'd like a filename prefix to write to.\n");
+		exit(1);
+	}
+
+	snprintf(one, sizeof(one), "%s-1", argv[1]);
+	snprintf(two, sizeof(two), "%s-2", argv[1]);
+
+	unlink(one);
+	unlink(two);
+
+	fd1 = open(one, O_CREAT|O_RDWR|O_DIRECT, 0644);
+	if (fd1 < 0) {
+		perror("open");
+		exit(1);
+	}
+
+	fd2 = open(two, O_CREAT|O_RDWR|O_DIRECT, 0644);
+	if (fd2 < 0) {
+		perror("open");
+		exit(1);
+	}
+
+	if (fstat(fd1, &st)) {
+		perror("open");
+		exit(1);
+	}
+
+	if (ftruncate(fd1, st.st_blksize)) {
+		perror("ftruncate()");
+		exit(1);
+	}
+	if (ftruncate(fd2, st.st_blksize)) {
+		perror("ftruncate()");
+		exit(1);
+	}
+	if (ftruncate(fd1, st.st_blksize * 2)) {
+		perror("ftruncate()");
+		exit(1);
+	}
+	if (ftruncate(fd2, st.st_blksize * 2)) {
+		perror("ftruncate()");
+		exit(1);
+	}
+
+	/* assumes this is a power of two */
+	buflen = st.st_blksize * 2;
+	ptrlen = st.st_blksize * 4;
+
+	/* some slop */
+	ptr = calloc(1, ptrlen);
+	if (ptr == NULL) {
+		perror("calloc");
+		exit(1);
+	}
+
+	/* align buf to the next natural buflen alignment after ptr */
+	buf = align_pow2(ptr, st.st_blksize);
+
+	rc = io_queue_init(100, &ctx);
+	if (rc) {
+		printf("queue_init: %ld\n", rc);
+		exit(1);
+	}
+
+	io_prep_pwrite(&iocb, fd1, buf, buflen, 0);
+
+	memset(ptr, 0x42, ptrlen);
+
+	printf("saw block size %lu, writing with buflen %lu\n", st.st_blksize,
+		buflen);
+
+	iocbs[0] = &iocb;
+
+	rc = io_submit(ctx, 1, iocbs);
+	if (rc != 1) {
+		printf("submit: %ld\n", rc);
+		exit(1);
+	}
+
+	rc = io_getevents(ctx, 1, 1, &event, NULL);
+	printf("got %ld: data %p iocb %p res %ld res2 %ld\n", rc,
+			event.data, event.obj, event.res, event.res2);
+
+	return 0;
+}

Added: trunk/src/extendo/Makefile
===================================================================
--- trunk/src/extendo/Makefile	2004-11-18 21:20:31 UTC (rev 4)
+++ trunk/src/extendo/Makefile	2004-11-18 21:27:20 UTC (rev 5)
@@ -0,0 +1,13 @@
+
+CFLAGS = -g -Wall
+
+all: extendo truncate
+
+extendo: extendo.o
+	gcc $(CFLAGS) -o extendo extendo.o
+
+truncate: truncate.o
+	gcc $(CFLAGS) -o truncate truncate.o
+
+clean:
+	rm *.o core extendo truncate 2>/dev/null

Added: trunk/src/extendo/extendo.c
===================================================================
--- trunk/src/extendo/extendo.c	2004-11-18 21:20:31 UTC (rev 4)
+++ trunk/src/extendo/extendo.c	2004-11-18 21:27:20 UTC (rev 5)
@@ -0,0 +1,124 @@
+
+#define _LARGEFILE64_SOURCE
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+
+#define __u32 	unsigned long
+
+#define HI(val)            ((__u32)((val) >> 32))
+#define LO(val)            ((__u32)((val) & 0x00000000FFFFFFFFUL))
+#define HILO(val)	   HI(val), LO(val)
+
+
+int main(int argc, char **argv)
+{
+	int wait;
+#ifdef __LP64__
+	off_t bytes;
+#else
+	__off64_t bytes;
+#endif
+	int fd, ret;
+	char *fname;
+	char buf[10];
+#ifdef __LP64__
+	off_t off;
+#else
+	__off64_t off;
+#endif
+	struct timespec ts,rem;
+	int loops = 1;
+//	char tmpbuf[100];
+
+	if (argc < 5) {
+		printf("usage: %s fname KB wait(in ms) loops\n", argv[0]);
+		exit(1);
+	}
+
+	fname = argv[1];
+	bytes =  1024 * atoi(argv[2]);
+	wait = atoi(argv[3]);
+	loops = atoi(argv[4]);
+
+	fd = open(fname, O_RDWR|O_CREAT|O_LARGEFILE, 0666);
+	if (fd == -1) {
+		printf("open failed.\n");
+		printf("error %d: %s\n", errno, strerror(errno));
+		exit(1);
+	}
+
+	off = lseek64(fd, 0, SEEK_END);
+	if (off == -1)
+	{
+		printf("lseek failed to seek to 0!\n");
+		printf("error %d: %s\n", errno, strerror(errno));
+		exit(1);
+	}
+	printf("seek to end at offset %u.%u\n", HILO(off));
+
+	strcpy(buf, "123456789");
+	ts.tv_sec = (wait/1000);
+	ts.tv_nsec = (wait%1000)*(1000*1000);
+
+	while (1) {
+		off = lseek64(fd, bytes, SEEK_END);
+		if (off == -1) {
+			printf("lseek failed!\n");
+			printf("error %d: %s\n", errno, strerror(errno));
+			exit(1);
+		}
+
+//		printf("seek to offset %u.%u...\n", HILO(off));
+//		fflush(stdout);
+
+		ret = write(fd, buf, 10);
+		if (ret == -1) {
+			printf("write failed!\n");
+			printf("error %d: %s\n", errno, strerror(errno));
+			exit(1);
+		}
+
+		printf("write succeeded at offset %u.%u  sleeping %d ms...\n",
+		       HILO(off), wait);
+		fflush(stdout);
+
+		ret = nanosleep(&ts, &rem);
+		if (ret == -1) {
+			printf("nanosleep failed!\n");
+			printf("error %d: %s\n", errno, strerror(errno));
+			exit(1);
+		}
+
+//		close(fd);
+
+		if (--loops <= 0)
+			break;
+#if 0
+		if (--loops <= 0) {
+			printf("How many more loops ? ");
+			gets(tmpbuf);
+			loops = atoi(tmpbuf);
+			printf("%d\n", loops);
+		}
+#endif
+
+//		fd = open(fname, O_RDWR|O_LARGEFILE);
+//		if (fd == -1) {
+//			printf("open failed.\n");
+//			printf("error %d: %s\n", errno, strerror(errno));
+//			exit(1);
+//		}
+	}
+
+	close(fd);
+
+	return 0;
+}

Added: trunk/src/extendo/truncate.c
===================================================================
--- trunk/src/extendo/truncate.c	2004-11-18 21:20:31 UTC (rev 4)
+++ trunk/src/extendo/truncate.c	2004-11-18 21:27:20 UTC (rev 5)
@@ -0,0 +1,30 @@
+
+#define _LARGEFILE64_SOURCE
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+
+int main(int argc, char ** argv) {
+	__off64_t newsize = 0;
+
+	if (argc < 3) {
+		printf("Usage: truncate FILENAME NEWSIZE\n");
+		printf("  NEWSIZE is expected to be in bytes\n");
+		return(0);
+	}
+
+	newsize = strtoull(argv[2], NULL, 0);
+
+	printf("Truncating %s to %llu\n", argv[1], newsize);
+	if (truncate64(argv[1], newsize) == -1) {
+		fprintf(stderr, "Could not truncate %s to %llu bytes: %s\n", 
+			argv[1], newsize, strerror(errno));
+		return(1);
+	}
+
+	return(0);
+}



More information about the Ocfstest-commits mailing list