From: Peter C. <pc...@us...> - 2010-02-09 01:03:34
|
Update of /cvsroot/ipbench/ipbench2/src/tests/nfs_latency In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10376/src/tests/nfs_latency Modified Files: Makefile.am nfs_glue.c nfs_latency.c Log Message: Use ipbench utility for debug output; allow pathnames in nfs_lookup(); slightly better error reporting. Index: nfs_latency.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_latency.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** nfs_latency.c 8 Mar 2006 01:32:00 -0000 1.14 --- nfs_latency.c 9 Feb 2010 00:24:16 -0000 1.15 *************** *** 102,108 **** x = init_and_open(hostname, nfs_options.path, nfs_options.filename); ! assert(x==0); ! return 0; } --- 102,108 ---- x = init_and_open(hostname, nfs_options.path, nfs_options.filename); ! ! return x; } Index: nfs_glue.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_glue.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** nfs_glue.c 14 Sep 2005 02:39:45 -0000 1.6 --- nfs_glue.c 9 Feb 2010 00:24:16 -0000 1.7 *************** *** 188,193 **** struct hostent *hp; ! if((hp = gethostbyname(name))==NULL) return -1; memset(sock, 0, sizeof(struct sockaddr_in)); --- 188,195 ---- struct hostent *hp; ! if ((hp = gethostbyname(name)) == NULL) { ! dbprintf("Cannot resolve %s\n", name); return -1; + } memset(sock, 0, sizeof(struct sockaddr_in)); *************** *** 209,216 **** idem = 1; ! if(status==NFS_OK){ nfs_file_handle = *fh; initialised = 1; ! }else{ initialised = -1; } --- 211,218 ---- idem = 1; ! if (status == NFS_OK){ nfs_file_handle = *fh; initialised = 1; ! } else { initialised = -1; } *************** *** 219,222 **** --- 221,277 ---- } + struct lookup_dir { + char *tail; + char *linkname; + struct cookie cwd; + int ok; + }; + + static void + dir_cb(uintptr_t token, int status, struct cookie *fh, fattr_t *pattrs){ + struct lookup_dir *ldp = (struct lookup_dir *)token; + + if (status == NFS_OK) { + ldp->cwd = *fh; + ldp->ok = 1; + } else { + ldp->ok = -11; + } + } + + + void + recursive_lookup(struct cookie *cwd, char *name, + void (*func) (uintptr_t, int, struct cookie *, fattr_t *), + uintptr_t token) + { + struct lookup_dir ld; + char *slashp; + char *s; + s = ld.tail = strdup(name); + ld.cwd = *cwd; + do { + ld.ok = 0; + ld.linkname = ld.tail; + while (*ld.linkname == '/') + ld.linkname++; + slashp = strchr(ld.linkname, '/'); + if (slashp) { + *slashp= '\0'; + ld.tail = slashp + 1; + dbprintf("Looking up %s\n", ld.linkname); + nfs_lookup(&ld.cwd, ld.linkname, dir_cb, (uintptr_t)&ld); + do { + struct pbuf buf; + rpc_recv(&buf, nfs_fd, -1); + } while (!ld.ok); + } else { + dbprintf("Final component: %s\n", ld.linkname); + nfs_lookup(&ld.cwd, ld.linkname, func, token); + } + } while (slashp && ld.ok >= 0); + free(s); + } + int init_and_open(char *hostname, char *mountpoint, char *filename){ *************** *** 226,231 **** microuptime_calibrate(); ! if(resolve(hostname, &addr) < 0){ ! printf("error resolving \"%s\"\n", hostname); exit(-1); } --- 281,286 ---- microuptime_calibrate(); ! if (resolve(hostname, &addr) < 0){ ! dbprintf("error resolving \"%s\"\n", hostname); exit(-1); } *************** *** 239,251 **** mnt_get_export_list(); ! mnt_mount(mountpoint, &pfh); ! nfs_lookup(&pfh, filename, open_cb, 0); ! while(initialised==0){ struct pbuf buf; rpc_recv(&buf, nfs_fd, -1); } ! if(initialised < 0){ return -1; } --- 294,309 ---- mnt_get_export_list(); ! if (mnt_mount(mountpoint, &pfh)) { ! printf("Can't mount\n"); ! return -1; ! } ! recursive_lookup(&pfh, filename, open_cb, 0); ! while (initialised == 0){ struct pbuf buf; rpc_recv(&buf, nfs_fd, -1); } ! if (initialised < 0){ return -1; } Index: Makefile.am =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 23 Jun 2005 04:27:33 -0000 1.4 --- Makefile.am 9 Feb 2010 00:24:06 -0000 1.5 *************** *** 1,3 **** ! AM_CFLAGS = $(WARNINGCFLAGS) plugindir=$(libdir)/ipbench --- 1,3 ---- ! AM_CFLAGS = $(WARNINGCFLAGS) plugindir=$(libdir)/ipbench *************** *** 9,11 **** libnfs_latency_la_SOURCES=nfs_glue.c nfs_latency.c plugin.c nfs_glue.h nfs_latency.h $(LIBNFS_FILES) libnfs_latency_la_LIBADD = ../../lib/libipbench.la ! --- 9,11 ---- libnfs_latency_la_SOURCES=nfs_glue.c nfs_latency.c plugin.c nfs_glue.h nfs_latency.h $(LIBNFS_FILES) libnfs_latency_la_LIBADD = ../../lib/libipbench.la ! libnfs_latency_la_CPPFLAGS = -DIPBENCH_TEST_CLIENT \ No newline at end of file |