[Pvfs2-cvs] commit by vilayann in pvfs2-1/test/posix: getdents.c
open.c openg-mpi.c openg-test openg.c stat.c xio_test.c
CVS commit program
cvs at parl.clemson.edu
Thu Aug 31 18:11:49 EDT 2006
Update of /projects/cvsroot/pvfs2-1/test/posix
In directory parlweb1:/tmp/cvs-serv7865/posix
Modified Files:
Tag: posix-extensions-branch
getdents.c open.c openg-mpi.c openg-test openg.c stat.c
xio_test.c
Log Message:
Fixed warnings, added iterations minor cleanups to the posix extensions branch programs
Index: getdents.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/getdents.c,v
diff -p -u -r1.1.2.4 -r1.1.2.5
--- getdents.c 19 May 2006 01:09:57 -0000 1.1.2.4
+++ getdents.c 31 Aug 2006 22:11:49 -0000 1.1.2.5
@@ -132,6 +132,11 @@ static inline struct files* clone_filp(s
return new_filp;
}
+static int getdents(uint, struct dirent *, uint);
+static int getdents64(uint, struct dirent64 *, uint);
+static int getdents_plus(uint, struct dirent_plus *, uint);
+static int getdents64_plus(uint, struct dirent64_plus *, uint);
+
/* glibc does not seem to provide a getdents() routine, so we provide one */
_syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
_syscall3(int, getdents64, uint, fd, struct dirent64 *, dirp, uint, count);
@@ -240,7 +245,7 @@ static inline void format_size_string(
free(buf);
}
-void print_entry_stat64(
+static void print_entry_stat64(
char *entry_name,
struct stat64 *attr,
const char *link_target)
@@ -371,7 +376,7 @@ void print_entry_stat64(
printf("%s\n",buf);
}
-void print_entry_stat(
+static void print_entry_stat(
char *entry_name,
struct stat *attr, const char *link_target)
{
@@ -501,7 +506,7 @@ void print_entry_stat(
printf("%s\n",buf);
}
-void print_entry_kernel_stat(
+static void print_entry_kernel_stat(
char *entry_name,
struct kernel_stat *attr, const char *link_target)
{
@@ -959,7 +964,7 @@ err:
}
-int do_flatten_hierarchy(void)
+static int do_flatten_hierarchy(void)
{
struct files *filp = NULL;
Index: open.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/open.c,v
diff -p -u -r1.1.2.2 -r1.1.2.3
--- open.c 29 Aug 2006 20:28:14 -0000 1.1.2.2
+++ open.c 31 Aug 2006 22:11:49 -0000 1.1.2.3
@@ -1,6 +1,6 @@
/*
* Simple test program to demonstrate
- * the functionality of the openg/openfh
+ * the functionality of the open
* system call!
*/
#include <stdio.h>
@@ -18,25 +18,6 @@
#include "crc32c.h"
#include "mpi.h"
-#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
-/* FIXME:
- * PLEASE CHANGE THIS SYSTEM
- * CALL NUMBER IN CASE YOUR
- * ARCHITECTURE IS NOT IA-32
- * OR IF YOUR KERNEL SYSCALL NUMBERS
- * ARE DIFFERENT. YOU HAVE BEEN WARNED!!!!!
- */
-#define __NR_openg 311
-#define __NR_openfh 312
-#elif defined (x86_64) || defined (__x86_64__)
-#define __NR_openg 273
-#define __NR_openfh 274
-#endif
-
-#define MAX_LENGTH 128
-_syscall2(long, openfh, const void *, uhandle, size_t, handle_len);
-_syscall5(long, openg, const char *, pathname, void *, uhandle, size_t *, uhandle_len, int, flags, int, mode);
-
static inline double msec_diff(double *end, double *begin)
{
return (*end - *begin);
@@ -49,12 +30,6 @@ static double Wtime(void)
return((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03);
}
-enum muck_options_t {
- DONT_MUCK = 0,
- DUMB_MUCK = 1,
- SMART_MUCK = 2,
-};
-
struct file_handle_generic {
/* Filled by VFS */
int32_t fhg_magic; /* magic number */
@@ -64,38 +39,14 @@ struct file_handle_generic {
unsigned char fhg_hmac_sha1[24]; /* hmac-sha1 message authentication code */
};
-static void muck_with_buffer(char *buffer, size_t len,
- enum muck_options_t muck_options)
-{
- if (muck_options == DONT_MUCK) {
- return;
- }
- else if (muck_options == DUMB_MUCK) {
- int pos = rand() % len;
- int cnt = rand() % (len - pos);
- memset(buffer + pos, 0, cnt);
- }
- else {
- struct file_handle_generic *fh = (struct file_handle_generic *) buffer;
-
- /* modify some fields and recalc crc32 */
- fh->fhg_flags = 1;
- fh->fhg_crc_csum = compute_check_sum((unsigned char *) buffer, 12);
- /* purpose is to show that HMACs will catch this kind of behavior */
- }
-}
-
int main(int argc, char *argv[])
{
int c, fd, err, a;
- size_t len = 0;
- void *ptr = NULL;
- struct stat sbuf;
- char opt[] = "f:m:c", *fname = NULL;
- double begin, end, tdiff, max_diff;
- enum muck_options_t muck_options = DONT_MUCK;
+ int niters = 10, do_unlink = 0;
+ char opt[] = "f:n:cu", *fname = NULL;
+ double begin, end, tdiff = 0.0, max_diff;
int open_flags = 0;
- int rank, np;
+ int i, rank, np;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -103,72 +54,58 @@ int main(int argc, char *argv[])
while ((c = getopt(argc, argv, opt)) != EOF) {
switch (c) {
+ case 'u':
+ do_unlink = 1;
+ break;
+ case 'n':
+ niters = atoi(optarg);
+ break;
case 'f':
fname = optarg;
break;
- case 'm':
- muck_options = atoi(optarg);
- break;
case 'c':
open_flags |= O_CREAT;
break;
case '?':
default:
fprintf(stderr, "Invalid arguments\n");
+ fprintf(stderr, "Usage: %s -f <fname> -c {create} -u {unlink} -n <num iterations>\n", argv[0]);
+ MPI_Finalize();
exit(1);
}
}
if (fname == NULL)
{
- fprintf(stderr, "Usage: %s -f <fname> -m {muck options 0,1,2}\n",
- argv[0]);
- exit(1);
- }
- if (muck_options != DONT_MUCK && muck_options != DUMB_MUCK
- && muck_options != SMART_MUCK)
- {
- fprintf(stderr, "Usage: %s -f <fname> -m {muck options 0,1,2}\n",
- argv[0]);
- MPI_Finalize();
- exit(1);
- }
- len = MAX_LENGTH;
- ptr = (void *) calloc(len, sizeof(char));
- if (ptr == NULL)
- {
- perror("calloc failed:");
+ fprintf(stderr, "Usage: %s -f <fname> -c {create} -u {unlink} -n <num iterations>\n", argv[0]);
MPI_Finalize();
exit(1);
}
- a = MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < niters; i++)
+ {
+ a = MPI_Barrier(MPI_COMM_WORLD);
+ open_flags |= O_RDONLY;
- begin = Wtime();
- open_flags |= O_RDONLY;
- err = open(fname, open_flags, 0775);
- if (err < 0) {
- perror("open(2) error:");
- MPI_Finalize();
- exit(1);
+ begin = Wtime();
+ err = open(fname, open_flags, 0775);
+ if (err < 0) {
+ perror("open(2) error:");
+ MPI_Finalize();
+ exit(1);
+ }
+ end = Wtime();
+ tdiff += (end - begin);
+ close(fd);
}
- end = Wtime();
- printf("open on %s yielded length %ld [Time %g msec]\n",
- fname, (unsigned long) len, msec_diff(&end, &begin));
-/* muck_with_buffer(ptr, len, muck_options);
- fstat(fd, &sbuf);
- printf("stat indicates file size %ld\n", (unsigned long) sbuf.st_size);
-*/
- tdiff = end - begin;
+ tdiff = tdiff / niters;
MPI_Allreduce(&tdiff, &max_diff, 1,
MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
if(rank == 0)
{
- printf("Total time for open: [Time %g msec]\n", max_diff);
+ printf("Total time for open: [Time %g msec niters %d]\n", max_diff, niters);
+ if (do_unlink)
+ unlink(fname);
}
-
-/* sha1_file_digest(fd); */
- close(fd);
- free(ptr);
MPI_Finalize();
return 0;
Index: openg-mpi.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/openg-mpi.c,v
diff -p -u -r1.1.2.5 -r1.1.2.6
--- openg-mpi.c 29 Aug 2006 20:28:14 -0000 1.1.2.5
+++ openg-mpi.c 31 Aug 2006 22:11:49 -0000 1.1.2.6
@@ -34,6 +34,9 @@
#define __NR_openfh 274
#endif
+static long openg(const char *, void *, size_t *, int, int);
+static long openfh(const void *, size_t);
+
_syscall2(long, openfh, const void *, uhandle, size_t, handle_len);
_syscall5(long, openg, const char *, pathname, void *, uhandle, size_t *, uhandle_len, int, flags, int, mode);
@@ -82,12 +85,6 @@ static double Wtime(void)
return((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03);
}
-enum muck_options_t {
- DONT_MUCK = 0,
- DUMB_MUCK = 1,
- SMART_MUCK = 2,
-};
-
struct file_handle_generic {
/* Filled by VFS */
int32_t fhg_magic; /* magic number */
@@ -97,39 +94,19 @@ struct file_handle_generic {
unsigned char fhg_hmac_sha1[24]; /* hmac-sha1 message authentication code */
};
-static void muck_with_buffer(char *buffer, size_t len,
- enum muck_options_t muck_options)
-{
- if (muck_options == DONT_MUCK) {
- return;
- }
- else if (muck_options == DUMB_MUCK) {
- int pos = rand() % len;
- int cnt = rand() % (len - pos);
- memset(buffer + pos, 0, cnt);
- }
- else {
- struct file_handle_generic *fh = (struct file_handle_generic *) buffer;
-
- /* modify some fields and recalc crc32 */
- fh->fhg_flags = 1;
- fh->fhg_crc_csum = compute_check_sum((unsigned char *) buffer, 12);
- /* purpose is to show that HMACs will catch this kind of behavior */
- }
-}
-
int main(int argc, char *argv[])
{
int c, fd, err;
- int rank, np;
+ int i, rank, np, do_unlink = 0;
size_t len;
- struct stat sbuf;
- char opt[] = "f:m:c", *fname = NULL;
- double begin_openg, end_openg, begin_openfh, end_openfh, max_end;
- enum muck_options_t muck_options = DONT_MUCK;
+ char opt[] = "n:f:cu", *fname = NULL;
+ double begin_openg, end_openg, begin_openfh, end_openfh, begin_bcast, end_bcast;
+ double openg_total = 0.0, openfh_total = 0.0, bcast_total = 0.0, total_time = 0.0;
+ double openg_final, openfh_final, bcast_final, total_final;
+
struct hbuf hb;
MPI_Datatype d;
- int openg_flags = 0;
+ int openg_flags = 0, niters = 10;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -137,33 +114,30 @@ int main(int argc, char *argv[])
while ((c = getopt(argc, argv, opt)) != EOF) {
switch (c) {
+ case 'n':
+ niters = atoi(optarg);
+ break;
case 'f':
fname = optarg;
break;
- case 'm':
- muck_options = atoi(optarg);
- break;
case 'c':
openg_flags |= O_CREAT;
break;
+ case 'u':
+ do_unlink = 1;
+ break;
case '?':
default:
fprintf(stderr, "Invalid arguments\n");
+ fprintf(stderr, "Usage: %s -f <fname> -c -n <number of iterations>\n",
+ argv[0]);
MPI_Finalize();
exit(1);
}
}
if (fname == NULL)
{
- fprintf(stderr, "Usage: %s -f <fname> -m {muck options 0,1,2} -c\n",
- argv[0]);
- MPI_Finalize();
- exit(1);
- }
- if (muck_options != DONT_MUCK && muck_options != DUMB_MUCK
- && muck_options != SMART_MUCK)
- {
- fprintf(stderr, "Usage: %s -f <fname> -m {muck options 0,1,2}\n",
+ fprintf(stderr, "Usage: %s -f <fname> -c -n <number of iterations>\n",
argv[0]);
MPI_Finalize();
exit(1);
@@ -174,55 +148,72 @@ int main(int argc, char *argv[])
exit(1);
}
hb.handle_length = MAX_LENGTH;
- /* Rank 0 does the openg */
- if (rank == 0)
+ for (i = 0; i < niters; i++)
{
- begin_openg = Wtime();
- openg_flags |= O_RDONLY;
- err = openg(fname, (void *) hb.handle, (size_t *) &hb.handle_length, openg_flags, 0775);
- if (err < 0) {
- perror("openg error:");
+ begin_openg = end_openg = 0;
+ /* Rank 0 does the openg */
+ if (rank == 0)
+ {
+ openg_flags |= O_RDONLY;
+ begin_openg = Wtime();
+ err = openg(fname, (void *) hb.handle, (size_t *) &hb.handle_length, openg_flags, 0775);
+ if (err < 0) {
+ perror("openg error:");
+ MPI_Finalize();
+ exit(1);
+ }
+ end_openg = Wtime();
+ openg_total += (end_openg - begin_openg);
+ }
+
+ begin_bcast = Wtime();
+ /* Broadcast the handle buffer to everyone */
+ if ((err = MPI_Bcast(&hb, 1, d, 0, MPI_COMM_WORLD)) != MPI_SUCCESS) {
+ char str[256];
+ len = 256;
+ MPI_Error_string(err, str, (int *) &len);
+ fprintf(stderr, "MPI_Bcast failed: %s\n", str);
MPI_Finalize();
exit(1);
}
- end_openg = Wtime();
- printf("Rank %d openg on %s yielded length %ld [Time %g msec]\n",
- rank, fname, (unsigned long) hb.handle_length, msec_diff(&end_openg, &begin_openg));
- }
+ end_bcast = Wtime();
+ bcast_total += (end_bcast - begin_bcast);
- /* Broadcast the handle buffer to everyone */
- if ((err = MPI_Bcast(&hb, 1, d, 0, MPI_COMM_WORLD)) != MPI_SUCCESS) {
- char str[256];
- len = 256;
- MPI_Error_string(err, str, (int *) &len);
- fprintf(stderr, "MPI_Bcast failed: %s\n", str);
- MPI_Finalize();
- exit(1);
- }
- /* muck with buffers if need be */
-/* muck_with_buffer(hb.handle, hb.handle_length, muck_options); */
- begin_openfh = Wtime();
- fd = openfh((void *) hb.handle, (size_t) hb.handle_length);
- if (fd < 0) {
- fprintf(stderr, "openfh on rank %d failed: %s\n",
- rank, strerror(errno));
- MPI_Finalize();
- exit(1);
+ begin_openfh = Wtime();
+ fd = openfh((void *) hb.handle, (size_t) hb.handle_length);
+ if (fd < 0) {
+ char h[256];
+ gethostname(h, 256);
+ fprintf(stderr, "openfh on rank %d (%s) failed: %s\n",
+ rank, h, strerror(errno));
+ MPI_Finalize();
+ exit(1);
+ }
+ end_openfh = Wtime();
+ openfh_total += (end_openfh - begin_openfh);
+
+ total_time += (end_openg - begin_openg + end_bcast - begin_bcast + end_openfh - begin_openfh);
+
+ close(fd);
}
- end_openfh = Wtime();
- printf("Rank %d: openfh returned fd: %d [Time %g msec]\n",
- rank, fd, msec_diff(&end_openfh, &begin_openfh));
-/* fstat(fd, &sbuf);
- printf("Rank %d: stat indicates file size %lu\n", rank, (unsigned long) sbuf.st_size);
- sha1_file_digest(fd); */
- close(fd);
- MPI_Allreduce(&end_openfh, &max_end, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ /* Average of niterations */
+ openg_total = openg_total / niters;
+ bcast_total = bcast_total / niters;
+ openfh_total = openfh_total / niters;
+ total_time = total_time / niters;
+
+ openg_final = openg_total;
+ MPI_Allreduce(&bcast_total, &bcast_final, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ MPI_Allreduce(&openfh_total, &openfh_final, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ MPI_Allreduce(&total_time, &total_final, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+
if(rank == 0)
{
- printf("Total time for openg/openfh: [Time %g msec]\n",
- msec_diff(&max_end, &begin_openg));
+ printf("Total time for openg/openfh: [Time ( %g %g %g ) %g msec niters %d]\n",
+ openg_final, bcast_final, openfh_final, total_final, niters);
+ if (do_unlink)
+ unlink(fname);
}
-
MPI_Finalize();
return 0;
}
Index: openg-test
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/openg-test,v
diff -p -u -r1.1.2.3 -r1.1.2.4
--- openg-test 29 Aug 2006 20:28:14 -0000 1.1.2.3
+++ openg-test 31 Aug 2006 22:11:49 -0000 1.1.2.4
@@ -42,7 +42,7 @@ openg_shallowfile=$PVFS2_MNT/openg-test
open_deepfile=$base/open-test
open_shallowfile=$PVFS2_MNT/open-test
-clients="1 10 20 30 40 50 60"
+clients="1 2 4 8 16 24"
for c in $clients; do
@@ -53,7 +53,7 @@ for c in $clients; do
echo " openg file (reopen): ${openg_shallowfile}-$c-clients"
${MPICH2_INSTALL}/bin/mpiexec -n $c $PVFS2_TOPDIR/test/posix/openg-mpi \
- -f ${openg_shallowfile}-$c-clients
+ -f ${openg_shallowfile}-$c-clients -u
echo " openg file (create); ${openg_deepfile}-$c-clients"
${MPICH2_INSTALL}/bin/mpiexec -n $c ${PVFS2_TOPDIR}/test/posix/openg-mpi \
@@ -61,7 +61,7 @@ for c in $clients; do
echo " openg file (reopen): ${openg_deepfile}-$c-clients"
${MPICH2_INSTALL}/bin/mpiexec -n $c ${PVFS2_TOPDIR}/test/posix/openg-mpi \
- -f ${openg_deepfile}-$c-clients
+ -f ${openg_deepfile}-$c-clients -u
echo "Running open with $c clients"
echo " open file (create): ${open_shallowfile}-$c-clients"
@@ -70,7 +70,7 @@ for c in $clients; do
echo " open file (reopen): ${open_shallowfile}-$c-clients"
${MPICH2_INSTALL}/bin/mpiexec -n $c $PVFS2_TOPDIR/test/posix/open \
- -f ${open_shallowfile}-$c-clients
+ -f ${open_shallowfile}-$c-clients -u
echo " open file (create); ${open_deepfile}-$c-clients"
${MPICH2_INSTALL}/bin/mpiexec -n $c ${PVFS2_TOPDIR}/test/posix/open \
Index: openg.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/openg.c,v
diff -p -u -r1.1.2.4 -r1.1.2.5
--- openg.c 29 Aug 2006 20:28:14 -0000 1.1.2.4
+++ openg.c 31 Aug 2006 22:11:49 -0000 1.1.2.5
@@ -149,7 +149,8 @@ int main(int argc, char *argv[])
printf("openfh returned %d [Time %g msec]\n", fd, msec_diff(&end, &begin));
fstat(fd, &sbuf);
printf("stat indicates file size %ld\n", (unsigned long) sbuf.st_size);
- sha1_file_digest(fd);
+ if (sbuf.st_size > 0)
+ sha1_file_digest(fd);
close(fd);
free(ptr);
return 0;
Index: stat.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/stat.c,v
diff -p -u -r1.1.2.1 -r1.1.2.2
--- stat.c 29 Aug 2006 23:28:53 -0000 1.1.2.1
+++ stat.c 31 Aug 2006 22:11:49 -0000 1.1.2.2
@@ -223,7 +223,7 @@ static inline void format_size_string(
free(buf);
}
-void print_entry_stat(
+static void print_entry_stat(
char *entry_name,
struct stat *attr, const char *link_target)
{
@@ -329,7 +329,7 @@ void print_entry_stat(
printf("%s\n",buf);
}
-void print_entry_kernel_stat_lite(
+static void print_entry_kernel_stat_lite(
char *entry_name,
struct kernel_stat_lite *attr, const char *link_target)
{
@@ -434,6 +434,11 @@ void print_entry_kernel_stat_lite(
printf("%s\n",buf);
}
+int newstatlite(const char *, struct kernel_stat_lite *);
+static int newfstatlite(int, struct kernel_stat_lite *);
+static int newlstatlite(const char *, struct kernel_stat_lite *);
+static int getdents(uint, struct dirent *, uint);
+
_syscall2(int, newstatlite, const char *, path, struct kernel_stat_lite *, buf);
_syscall2(int, newfstatlite, int, filedes, struct kernel_stat_lite *, buf);
_syscall2(int, newlstatlite, const char *, path, struct kernel_stat_lite *, buf);
@@ -588,7 +593,7 @@ err:
return ret;
}
-int do_flatten_hierarchy(void)
+static int do_flatten_hierarchy(void)
{
struct files *filp = NULL;
Index: xio_test.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/Attic/xio_test.c,v
diff -p -u -r1.1.2.2 -r1.1.2.3
--- xio_test.c 31 May 2006 03:34:49 -0000 1.1.2.2
+++ xio_test.c 31 Aug 2006 22:11:49 -0000 1.1.2.3
@@ -34,6 +34,13 @@ struct xtvec {
size_t xtv_len;
};
+static ssize_t readx(unsigned long fd,
+ const struct iovec * iov, unsigned long iovlen,
+ const struct xtvec * xtv, unsigned long xtvlen);
+static ssize_t writex(unsigned long fd,
+ const struct iovec * iov, unsigned long iovlen,
+ const struct xtvec * xtv, unsigned long xtvlen);
+
_syscall5(ssize_t, readx, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
_syscall5(ssize_t, writex, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
@@ -221,7 +228,7 @@ int main(int argc, char *argv[])
total += wvec[i].iov_len;
mem_total += wvec[i].iov_len;
printf("%ld) <%p,%p> WRITE %ld bytes\n", i, wvec[i].iov_base,
- wvec[i].iov_base + wvec[i].iov_len, (long) wvec[i].iov_len);
+ (char *) wvec[i].iov_base + wvec[i].iov_len, (long) wvec[i].iov_len);
}
xtnr_segs = str_ct;
xc = (struct xtvec *) malloc(xtnr_segs * sizeof(struct xtvec));
@@ -257,7 +264,7 @@ int main(int argc, char *argv[])
for (i = 0; i < nr_segs; i++)
{
printf("%ld) <%p,%p> READ %ld bytes\n", i, rvec[i].iov_base,
- rvec[i].iov_base + rvec[i].iov_len, (long) rvec[i].iov_len);
+ (char *) rvec[i].iov_base + rvec[i].iov_len, (long) rvec[i].iov_len);
mem_total += rvec[i].iov_len;
}
if (xt_total != mem_total)
More information about the Pvfs2-cvs
mailing list