From d9ca3813b0cd8f7709990e92327b2fbbdccf3016 Mon Sep 17 00:00:00 2001 From: nic Date: Sat, 14 Feb 2004 07:24:17 +0000 Subject: [PATCH] update b_size from HEAD (20040213_2304) --- lnet/klnds/gmlnd/gmlnd.h | 4 +- lnet/klnds/gmlnd/gmlnd_cb.c | 13 - lnet/klnds/scimaclnd/scimacnal_cb.c | 34 +- lnet/lnet/api-eq.c | 49 ++- lnet/lnet/lib-md.c | 83 +++-- lnet/ulnds/connection.h | 4 +- lnet/ulnds/procbridge.h | 4 + lnet/ulnds/socklnd/connection.h | 4 +- lnet/ulnds/socklnd/procbridge.h | 4 + lnet/utils/Makefile.am | 12 +- lnet/utils/l_ioctl.c | 160 ++++++--- lnet/utils/wirecheck.c | 168 ++++----- .../kernel_configs/config-linux-2.4.20-uml | 1 + .../patches/vfs_intent-2.4.18-18-chaos65.patch | 16 +- .../patches/vfs_intent-2.4.20-hp.patch | 14 +- .../patches/vfs_intent_2.6.0-test1.patch | 12 +- lustre/kernel_patches/series/chaos-2.4.20 | 27 -- lustre/liblustre/llite_lib.c | 41 ++- lustre/liblustre/lltest.c | 386 --------------------- lustre/lov/lov_internal.h | 2 + lustre/portals/knals/gmnal/gmnal.h | 4 +- lustre/portals/knals/gmnal/gmnal_cb.c | 13 - lustre/portals/knals/scimacnal/scimacnal_cb.c | 34 +- lustre/portals/portals/api-eq.c | 49 ++- lustre/portals/portals/lib-md.c | 83 +++-- lustre/portals/unals/connection.h | 4 +- lustre/portals/unals/procbridge.h | 4 + lustre/portals/utils/Makefile.am | 12 +- lustre/portals/utils/l_ioctl.c | 160 ++++++--- lustre/portals/utils/wirecheck.c | 168 ++++----- lustre/tests/replay-single.sh | 4 +- 31 files changed, 724 insertions(+), 849 deletions(-) delete mode 100644 lustre/kernel_patches/series/chaos-2.4.20 delete mode 100644 lustre/liblustre/lltest.c diff --git a/lnet/klnds/gmlnd/gmlnd.h b/lnet/klnds/gmlnd/gmlnd.h index 53757ab..cdde5b7 100644 --- a/lnet/klnds/gmlnd/gmlnd.h +++ b/lnet/klnds/gmlnd/gmlnd.h @@ -353,8 +353,6 @@ int gmnal_cb_read(nal_cb_t *, void *private, void *, user_ptr, size_t); int gmnal_cb_write(nal_cb_t *, void *private, user_ptr, void *, size_t); -int gmnal_cb_callback(nal_cb_t *, void *, lib_eq_t *, ptl_event_t *); - void *gmnal_cb_malloc(nal_cb_t *, size_t); void gmnal_cb_free(nal_cb_t *, void *, size_t); @@ -384,7 +382,7 @@ void gmnal_fini(void); a->cb_recv_pages = gmnal_cb_recv_pages; \ a->cb_read = gmnal_cb_read; \ a->cb_write = gmnal_cb_write; \ - a->cb_callback = gmnal_cb_callback; \ + a->cb_callback = NULL; \ a->cb_malloc = gmnal_cb_malloc; \ a->cb_free = gmnal_cb_free; \ a->cb_map = NULL; \ diff --git a/lnet/klnds/gmlnd/gmlnd_cb.c b/lnet/klnds/gmlnd/gmlnd_cb.c index 6ae91db..e055242 100644 --- a/lnet/klnds/gmlnd/gmlnd_cb.c +++ b/lnet/klnds/gmlnd/gmlnd_cb.c @@ -126,7 +126,6 @@ int gmnal_cb_send(nal_cb_t *nal_cb, void *private, lib_msg_t *cookie, niov, iov, len); } else { CDEBUG(D_ERROR, "Large message send it is not supported\n"); - lib_finalize(nal_cb, private, cookie); return(PTL_FAIL); gmnal_large_tx(nal_cb, private, cookie, hdr, type, nid, pid, niov, iov, len); @@ -200,18 +199,6 @@ int gmnal_cb_write(nal_cb_t *nal_cb, void *private, user_ptr dst, return(PTL_OK); } -int gmnal_cb_callback(nal_cb_t *nal_cb, void *private, lib_eq_t *eq, - ptl_event_t *ev) -{ - - if (eq->event_callback != NULL) { - CDEBUG(D_INFO, "found callback\n"); - eq->event_callback(ev); - } - - return(PTL_OK); -} - void *gmnal_cb_malloc(nal_cb_t *nal_cb, size_t len) { void *ptr = NULL; diff --git a/lnet/klnds/scimaclnd/scimacnal_cb.c b/lnet/klnds/scimaclnd/scimacnal_cb.c index b31c2ea..52afb98 100644 --- a/lnet/klnds/scimaclnd/scimacnal_cb.c +++ b/lnet/klnds/scimaclnd/scimacnal_cb.c @@ -176,7 +176,8 @@ kscimacnal_txrelease(mac_mblk_t *msg, mac_msg_status_t status, void *context) break; } - lib_finalize(ktx->ktx_nal, ktx->ktx_private, ktx->ktx_cookie); + lib_finalize(ktx->ktx_nal, ktx->ktx_private, ktx->ktx_cookie, + (err == 0) ? PTL_OK : PTL_FAIL); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); } @@ -225,14 +226,14 @@ kscimacnal_sendmsg(nal_cb_t *nal, if (buf_len > mac_get_mtusize(ksci->ksci_machandle)) { CERROR("kscimacnal:request exceeds TX MTU size (%ld).\n", mac_get_mtusize(ksci->ksci_machandle)); - return -EINVAL; + return PTL_FAIL; } /* save transaction info for later finalize and cleanup */ PORTAL_ALLOC(ktx, (sizeof(kscimacnal_tx_t))); if (!ktx) { - return -ENOMEM; + return PTL_NOSPACE; } ktx->ktx_nmapped = 0; /* Start with no mapped pages :) */ @@ -247,7 +248,7 @@ kscimacnal_sendmsg(nal_cb_t *nal, kscimacnal_txrelease, ktx); if (!msg) { PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return -ENOMEM; + return PTL_NOSPACE; } mac_put_mblk(msg, sizeof(ptl_hdr_t)); lastblk=msg; @@ -284,7 +285,7 @@ kscimacnal_sendmsg(nal_cb_t *nal, if(!newblk) { mac_free_msg(msg); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return -ENOMEM; + return PTL_NOSPACE; } mac_put_mblk(newblk, nob); mac_link_mblk(lastblk, newblk); @@ -315,10 +316,10 @@ kscimacnal_sendmsg(nal_cb_t *nal, CERROR("kscimacnal: mac_send() failed, rc=%d\n", rc); mac_free_msg(msg); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return rc; + return PTL_FAIL; } - return 0; + return PTL_OK; } @@ -463,12 +464,15 @@ kscimacnal_recvmsg(nal_cb_t *nal, krx->msg, mlen, rlen, niov); /* What was actually received must be >= what sender claims to have - * sent. This is an LASSERT, since lib-move doesn't check cb return - * code yet. Also, rlen seems to be negative when mlen==0 so don't - * assert on that. - */ - LASSERT (mlen==0 || mac_msg_size(krx->msg) >= sizeof(ptl_hdr_t)+rlen); - LASSERT (mlen==0 || mlen <= rlen); + * sent. */ + LASSERT (mlen <= rlen); /* something is wrong if this isn't true */ + if (mac_msg_size(krx->msg) < sizeof(ptl_hdr_t)+mlen) { + /* We didn't receive everything lib thinks we did */ + CERROR("Bad message size: have %d, need %d + %d\n", + mac_msg_size(krx->msg), sizeof(ptl_hdr_t), mlen); + return (PTL_FAIL); + } + /* It must be OK to kmap() if required */ LASSERT (kiov == NULL || !in_interrupt ()); /* Either all pages or all vaddrs */ @@ -545,12 +549,12 @@ kscimacnal_recvmsg(nal_cb_t *nal, CDEBUG(D_NET, "Calling lib_finalize.\n"); PROF_START(lib_finalize); - lib_finalize(nal, private, cookie); + lib_finalize(nal, private, cookie, PTL_OK); PROF_FINISH(lib_finalize); CDEBUG(D_NET, "Done.\n"); - return rlen; + return PTL_OK; } diff --git a/lnet/lnet/api-eq.c b/lnet/lnet/api-eq.c index 9bc9c36..964b9d8 100644 --- a/lnet/lnet/api-eq.c +++ b/lnet/lnet/api-eq.c @@ -81,12 +81,6 @@ int PtlEQGet(ptl_handle_eq_t eventq, ptl_event_t * ev) *ev = *new_event; - /* Set the unlinked_me interface number if there is one to pass - * back, since the NAL hasn't a clue what it is and therefore can't - * set it. */ - if (!PtlHandleEqual (ev->unlinked_me, PTL_HANDLE_NONE)) - ev->unlinked_me.nal_idx = eventq.nal_idx; - /* ensure event is delivered correctly despite possible races with lib_finalize */ if (eq->sequence != new_event->sequence) { @@ -119,6 +113,7 @@ int PtlEQWait(ptl_handle_eq_t eventq_in, ptl_event_t *event_out) } #ifndef __KERNEL__ +#if 0 static jmp_buf eq_jumpbuf; static void eq_timeout(int signal) @@ -162,6 +157,46 @@ int PtlEQWait_timeout(ptl_handle_eq_t eventq_in, ptl_event_t * event_out, return rc; } +#else +#include -#endif +/* FIXME + * Here timeout need a trick with tcpnal, definitely unclean but OK for + * this moment. + */ + +/* global variables defined by tcpnal */ +extern int __tcpnal_eqwait_timeout_value; +extern int __tcpnal_eqwait_timedout; + +int PtlEQWait_timeout(ptl_handle_eq_t eventq_in, ptl_event_t * event_out, + int timeout) +{ + int rc; + if (!timeout) + return PtlEQWait(eventq_in, event_out); + + __tcpnal_eqwait_timeout_value = timeout; + + while ((rc = PtlEQGet(eventq_in, event_out)) == PTL_EQ_EMPTY) { + nal_t *nal = ptl_hndl2nal(&eventq_in); + + if (nal->yield) + nal->yield(nal); + + if (__tcpnal_eqwait_timedout) { + if (__tcpnal_eqwait_timedout != ETIMEDOUT) + printf("Warning: yield return error %d\n", + __tcpnal_eqwait_timedout); + rc = PTL_EQ_EMPTY; + break; + } + } + + __tcpnal_eqwait_timeout_value = 0; + + return rc; +} +#endif +#endif /* __KERNEL__ */ diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index be6949c..a1ed583 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -83,7 +83,7 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private, int rc; int i; - /* NB we are passes an allocated, but uninitialised/active md. + /* NB we are passed an allocated, but uninitialised/active md. * if we return success, caller may lib_md_unlink() it. * otherwise caller may only lib_md_free() it. */ @@ -94,9 +94,10 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private, return PTL_INV_EQ; } - if ((md->options & PTL_MD_IOV) != 0 && /* discontiguous MD */ - md->niov > PTL_MD_MAX_IOV) /* too many fragments */ - return PTL_IOV_TOO_MANY; + /* Must check this _before_ allocation. Also, note that non-iov + * MDs must set md_niov to 0. */ + LASSERT((md->options & (PTL_MD_IOV | PTL_MD_KIOV)) == 0 || + md->niov <= PTL_MD_MAX_IOV); if ((md->options & max_size_opts) != 0 && /* max size used */ (md->max_size < 0 || md->max_size > md->length)) // illegal max_size @@ -239,7 +240,11 @@ int do_PtlMDAttach(nal_cb_t * nal, void *private, void *v_args, void *v_ret) lib_md_t *md; unsigned long flags; - md = lib_md_alloc (nal); + if ((args->md_in.options & (PTL_MD_KIOV | PTL_MD_IOV)) != 0 && + args->md_in.niov > PTL_MD_MAX_IOV) /* too many fragments */ + return (ret->rc = PTL_IOV_TOO_MANY); + + md = lib_md_alloc(nal, &args->md_in); if (md == NULL) return (ret->rc = PTL_NOSPACE); @@ -287,7 +292,11 @@ int do_PtlMDBind(nal_cb_t * nal, void *private, void *v_args, void *v_ret) lib_md_t *md; unsigned long flags; - md = lib_md_alloc (nal); + if ((args->md_in.options & (PTL_MD_KIOV | PTL_MD_IOV)) != 0 && + args->md_in.niov > PTL_MD_MAX_IOV) /* too many fragments */ + return (ret->rc = PTL_IOV_TOO_MANY); + + md = lib_md_alloc(nal, &args->md_in); if (md == NULL) return (ret->rc = PTL_NOSPACE); @@ -311,34 +320,43 @@ int do_PtlMDBind(nal_cb_t * nal, void *private, void *v_args, void *v_ret) int do_PtlMDUnlink(nal_cb_t * nal, void *private, void *v_args, void *v_ret) { - PtlMDUnlink_in *args = v_args; + PtlMDUnlink_in *args = v_args; PtlMDUnlink_out *ret = v_ret; - - lib_md_t *md; - unsigned long flags; + ptl_event_t ev; + lib_md_t *md; + unsigned long flags; state_lock(nal, &flags); md = ptl_handle2md(&args->md_in, nal); if (md == NULL) { - ret->rc = PTL_INV_MD; - } else if (md->pending != 0) { /* being filled/spilled */ - ret->rc = PTL_MD_INUSE; - } else { - /* Callers attempting to unlink a busy MD which will get - * unlinked once the net op completes should see INUSE, - * before completion and INV_MD thereafter. LASSERT we've - * got that right... */ - LASSERT ((md->md_flags & PTL_MD_FLAG_UNLINK) == 0); - - lib_md_deconstruct(nal, md, &ret->status_out); - lib_md_unlink(nal, md); - ret->rc = PTL_OK; + state_unlock(nal, &flags); + return (ret->rc = PTL_INV_MD); + } + + /* If the MD is busy, lib_md_unlink just marks it for deletion, and + * when the NAL is done, the completion event flags that the MD was + * unlinked. Otherwise, we enqueue an event now... */ + + if (md->eq != NULL && + md->pending == 0) { + memset(&ev, 0, sizeof(ev)); + + ev.type = PTL_EVENT_UNLINK; + ev.status = PTL_OK; + ev.unlinked = 1; + lib_md_deconstruct(nal, md, &ev.mem_desc); + + lib_enq_event_locked(nal, private, md->eq, &ev); } + lib_md_deconstruct(nal, md, &ret->status_out); + lib_md_unlink(nal, md); + ret->rc = PTL_OK; + state_unlock(nal, &flags); - return (ret->rc); + return (PTL_OK); } int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, @@ -379,6 +397,23 @@ int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, goto out; } + /* XXX fttb, the new MD must be the same type wrt fragmentation */ + if (((new->options ^ md->options) & + (PTL_MD_IOV | PTL_MD_KIOV)) != 0) { + ret->rc = PTL_INV_MD; + goto out; + } + + if (new->niov > md->md_niov) { + ret->rc = PTL_IOV_TOO_MANY; + goto out; + } + + if (new->niov < md->md_niov) { + ret->rc = PTL_IOV_TOO_SMALL; + goto out; + } + if (!PtlHandleEqual (args->testq_in, PTL_EQ_NONE)) { test_eq = ptl_handle2eq(&args->testq_in, nal); if (test_eq == NULL) { diff --git a/lnet/ulnds/connection.h b/lnet/ulnds/connection.h index fb1eaab..343ffa6 100644 --- a/lnet/ulnds/connection.h +++ b/lnet/ulnds/connection.h @@ -7,6 +7,7 @@ */ #include +#include typedef struct manager { table connections; @@ -26,7 +27,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short, + procbridge pb); manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); diff --git a/lnet/ulnds/procbridge.h b/lnet/ulnds/procbridge.h index 317e22f..965f83d 100644 --- a/lnet/ulnds/procbridge.h +++ b/lnet/ulnds/procbridge.h @@ -25,6 +25,9 @@ typedef struct procbridge { pthread_cond_t cond; pthread_mutex_t mutex; + /* socket pair used to notify nal thread */ + int notifier[2]; + int nal_flags; pthread_mutex_t nal_cb_lock; @@ -51,5 +54,6 @@ extern nal_t *procbridge_interface(int num_interface, ptl_pt_index_t ptl_size, ptl_ac_index_t acl_size, ptl_pid_t requested_pid); +extern void procbridge_wakeup_nal(procbridge p); #endif diff --git a/lnet/ulnds/socklnd/connection.h b/lnet/ulnds/socklnd/connection.h index fb1eaab..343ffa6 100644 --- a/lnet/ulnds/socklnd/connection.h +++ b/lnet/ulnds/socklnd/connection.h @@ -7,6 +7,7 @@ */ #include +#include typedef struct manager { table connections; @@ -26,7 +27,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short, + procbridge pb); manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); diff --git a/lnet/ulnds/socklnd/procbridge.h b/lnet/ulnds/socklnd/procbridge.h index 317e22f..965f83d 100644 --- a/lnet/ulnds/socklnd/procbridge.h +++ b/lnet/ulnds/socklnd/procbridge.h @@ -25,6 +25,9 @@ typedef struct procbridge { pthread_cond_t cond; pthread_mutex_t mutex; + /* socket pair used to notify nal thread */ + int notifier[2]; + int nal_flags; pthread_mutex_t nal_cb_lock; @@ -51,5 +54,6 @@ extern nal_t *procbridge_interface(int num_interface, ptl_pt_index_t ptl_size, ptl_ac_index_t acl_size, ptl_pid_t requested_pid); +extern void procbridge_wakeup_nal(procbridge p); #endif diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am index f1878df..6c31b3d 100644 --- a/lnet/utils/Makefile.am +++ b/lnet/utils/Makefile.am @@ -3,17 +3,18 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution - COMPILE = $(CC) -Wall -g -I$(srcdir)/../include LINK = $(CC) -o $@ if LIBLUSTRE -tmp= + +noinst_LIBRARIES = libuptlctl.a +libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h +libuptlctl_a_CFLAGS = -fPIC + else -tmp=gmnalnid -endif -sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck $(tmp) +sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck gmnalnid lib_LIBRARIES = libptlctl.a acceptor_SOURCES = acceptor.c # -lefence @@ -33,3 +34,4 @@ debugctl_LDADD = -L. -lptlctl -lncurses # -lefence debugctl_DEPENDENCIES = libptlctl.a routerstat_SOURCES = routerstat.c +endif diff --git a/lnet/utils/l_ioctl.c b/lnet/utils/l_ioctl.c index c6628ff..58a408a 100644 --- a/lnet/utils/l_ioctl.c +++ b/lnet/utils/l_ioctl.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,16 @@ #include #include +#ifndef __CYGWIN__ + #include +#else + #include + #include +#endif + +static ioc_handler_t do_ioctl; /* forward ref */ +static ioc_handler_t *current_ioc_handler = &do_ioctl; + struct ioc_dev { const char * dev_name; int dev_fd; @@ -48,7 +57,16 @@ struct dump_hdr { int opc; }; -char * dump_filename; +char *dump_filename; + +void +set_ioc_handler (ioc_handler_t *handler) +{ + if (handler == NULL) + current_ioc_handler = do_ioctl; + else + current_ioc_handler = handler; +} static int open_ioc_dev(int dev_id) @@ -115,7 +133,7 @@ dump(int dev_id, int opc, void *buf) { FILE *fp; struct dump_hdr dump_hdr; - struct portal_ioctl_hdr * ioc_hdr = (struct portal_ioctl_hdr *) buf; + struct portal_ioctl_hdr * ioc_hdr = (struct portal_ioctl_hdr *) buf; int rc; printf("dumping opc %x to %s\n", opc, dump_filename); @@ -132,17 +150,17 @@ dump(int dev_id, int opc, void *buf) return -EINVAL; } - rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp); - if (rc == 1) - rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp); - fclose(fp); - if (rc != 1) { - fprintf(stderr, "%s: %s\n", dump_filename, - strerror(errno)); - return -EINVAL; - } - - return 0; + rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp); + if (rc == 1) + rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp); + fclose(fp); + if (rc != 1) { + fprintf(stderr, "%s: %s\n", dump_filename, + strerror(errno)); + return -EINVAL; + } + + return 0; } /* register a device to send ioctls to. */ @@ -184,16 +202,17 @@ set_ioctl_dump(char * file) free(dump_filename); dump_filename = strdup(file); + if (dump_filename == NULL) + abort(); + + set_ioc_handler(&dump); return 0; } int l_ioctl(int dev_id, int opc, void *buf) { - if (dump_filename) - return dump(dev_id, opc, buf); - else - return do_ioctl(dev_id, opc, buf); + return current_ioc_handler(dev_id, opc, buf); } /* Read an ioctl dump file, and call the ioc_func for each ioctl buffer @@ -207,16 +226,28 @@ l_ioctl(int dev_id, int opc, void *buf) int parse_dump(char * dump_file, int (*ioc_func)(int dev_id, int opc, void *)) { - int fd, line =0; + int line =0; struct stat st; - char *buf, *end; + char *start, *buf, *end; +#ifndef __CYGWIN__ + int fd; +#else + HANDLE fd, hmap; + DWORD size; +#endif +#ifndef __CYGWIN__ fd = syscall(SYS_open, dump_file, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "couldn't open %s: %s\n", dump_file, + strerror(errno)); + exit(1); + } #ifndef SYS_fstat64 -#define __SYS_fstat__ SYS_fstat +# define __SYS_fstat__ SYS_fstat #else -#define __SYS_fstat__ SYS_fstat64 +# define __SYS_fstat__ SYS_fstat64 #endif if (syscall(__SYS_fstat__, fd, &st)) { perror("stat fails"); @@ -228,41 +259,72 @@ parse_dump(char * dump_file, int (*ioc_func)(int dev_id, int opc, void *)) exit(1); } - buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0); - end = buf + st.st_size; + start = buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0); + end = start + st.st_size; close(fd); - while (buf < end) { - struct dump_hdr *dump_hdr = (struct dump_hdr *) buf; - struct portal_ioctl_hdr * data; - char tmp[8096]; - int rc; - - line++; + if (start == MAP_FAILED) { + fprintf(stderr, "can't create file mapping\n"); + exit(1); + } +#else + fd = CreateFile(dump_file, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + size = GetFileSize(fd, NULL); + if (size < 1) { + fprintf(stderr, "KML is empty\n"); + exit(1); + } - data = (struct portal_ioctl_hdr *) (buf + sizeof(*dump_hdr)); - if (buf + data->ioc_len > end ) { - fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf, - data->ioc_len, end); - return -1; - } + hmap = CreateFileMapping(fd, NULL, PAGE_READONLY, 0,0, NULL); + start = buf = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0); + end = buf + size; + CloseHandle(fd); + if (start == NULL) { + fprintf(stderr, "can't create file mapping\n"); + exit(1); + } +#endif /* __CYGWIN__ */ + + while (buf < end) { + struct dump_hdr *dump_hdr = (struct dump_hdr *) buf; + struct portal_ioctl_hdr * data; + char tmp[8096]; + int rc; + + line++; + + data = (struct portal_ioctl_hdr *) (buf + sizeof(*dump_hdr)); + if (buf + data->ioc_len > end ) { + fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf, + data->ioc_len, end); + return -1; + } #if 0 - printf ("dump_hdr: %lx data: %lx\n", - (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf); - - printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc, - data->ioc_len, data->ioc_version); + printf ("dump_hdr: %lx data: %lx\n", + (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf); + + printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc, + data->ioc_len, data->ioc_version); #endif - memcpy(tmp, data, data->ioc_len); + memcpy(tmp, data, data->ioc_len); - rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp); - if (rc) { - printf("failed: %d\n", rc); - exit(1); - } + rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp); + if (rc) { + printf("failed: %d\n", rc); + exit(1); + } - buf += data->ioc_len + sizeof(*dump_hdr); + buf += data->ioc_len + sizeof(*dump_hdr); } + +#ifndef __CYGWIN__ + munmap(start, end - start); +#else + UnmapViewOfFile(start); + CloseHandle(hmap); +#endif + return 0; } diff --git a/lnet/utils/wirecheck.c b/lnet/utils/wirecheck.c index 77ad126..a73a5217 100644 --- a/lnet/utils/wirecheck.c +++ b/lnet/utils/wirecheck.c @@ -10,80 +10,80 @@ extern size_t strnlen(const char *, size_t); -#define BLANK_LINE() \ -do { \ - printf ("\n"); \ +#define BLANK_LINE() \ +do { \ + printf ("\n"); \ } while (0) -#define COMMENT(c) \ -do { \ - printf (" /* "c" */\n"); \ +#define COMMENT(c) \ +do { \ + printf (" /* "c" */\n"); \ } while (0) #define STRINGIFY(a) #a -#define CHECK_DEFINE(a) \ -do { \ - printf (" LASSERT ("#a" == "STRINGIFY(a)");\n"); \ +#define CHECK_DEFINE(a) \ +do { \ + printf (" LASSERT ("#a" == "STRINGIFY(a)");\n"); \ } while (0) -#define CHECK_VALUE(a) \ -do { \ - printf (" LASSERT ("#a" == %d);\n", a); \ +#define CHECK_VALUE(a) \ +do { \ + printf (" LASSERT ("#a" == %d);\n", a); \ } while (0) -#define CHECK_MEMBER_OFFSET(s,m) \ -do { \ - CHECK_VALUE(offsetof(s, m)); \ +#define CHECK_MEMBER_OFFSET(s,m) \ +do { \ + CHECK_VALUE(offsetof(s, m)); \ } while (0) -#define CHECK_MEMBER_SIZEOF(s,m) \ -do { \ - CHECK_VALUE((int)sizeof(((s *)0)->m)); \ +#define CHECK_MEMBER_SIZEOF(s,m) \ +do { \ + CHECK_VALUE((int)sizeof(((s *)0)->m)); \ } while (0) -#define CHECK_MEMBER(s,m) \ -do { \ - CHECK_MEMBER_OFFSET(s, m); \ - CHECK_MEMBER_SIZEOF(s, m); \ +#define CHECK_MEMBER(s,m) \ +do { \ + CHECK_MEMBER_OFFSET(s, m); \ + CHECK_MEMBER_SIZEOF(s, m); \ } while (0) #define CHECK_STRUCT(s) \ do { \ BLANK_LINE (); \ COMMENT ("Checks for struct "#s); \ - CHECK_VALUE((int)sizeof(s)); \ + CHECK_VALUE((int)sizeof(s)); \ } while (0) void check_ptl_handle_wire (void) { - CHECK_STRUCT (ptl_handle_wire_t); - CHECK_MEMBER (ptl_handle_wire_t, wh_interface_cookie); - CHECK_MEMBER (ptl_handle_wire_t, wh_object_cookie); + CHECK_STRUCT (ptl_handle_wire_t); + CHECK_MEMBER (ptl_handle_wire_t, wh_interface_cookie); + CHECK_MEMBER (ptl_handle_wire_t, wh_object_cookie); } void check_ptl_magicversion (void) { - CHECK_STRUCT (ptl_magicversion_t); - CHECK_MEMBER (ptl_magicversion_t, magic); - CHECK_MEMBER (ptl_magicversion_t, version_major); - CHECK_MEMBER (ptl_magicversion_t, version_minor); + CHECK_STRUCT (ptl_magicversion_t); + CHECK_MEMBER (ptl_magicversion_t, magic); + CHECK_MEMBER (ptl_magicversion_t, version_major); + CHECK_MEMBER (ptl_magicversion_t, version_minor); } void check_ptl_hdr (void) { - CHECK_STRUCT (ptl_hdr_t); - CHECK_MEMBER (ptl_hdr_t, dest_nid); - CHECK_MEMBER (ptl_hdr_t, src_nid); - CHECK_MEMBER (ptl_hdr_t, dest_pid); - CHECK_MEMBER (ptl_hdr_t, src_pid); - CHECK_MEMBER (ptl_hdr_t, type); - CHECK_MEMBER (ptl_hdr_t, payload_length); + CHECK_STRUCT (ptl_hdr_t); + CHECK_MEMBER (ptl_hdr_t, dest_nid); + CHECK_MEMBER (ptl_hdr_t, src_nid); + CHECK_MEMBER (ptl_hdr_t, dest_pid); + CHECK_MEMBER (ptl_hdr_t, src_pid); + CHECK_MEMBER (ptl_hdr_t, type); + CHECK_MEMBER (ptl_hdr_t, payload_length); CHECK_MEMBER (ptl_hdr_t, msg); - + BLANK_LINE (); COMMENT ("Ack"); CHECK_MEMBER (ptl_hdr_t, msg.ack.dst_wmd); @@ -92,28 +92,28 @@ check_ptl_hdr (void) BLANK_LINE (); COMMENT ("Put"); - CHECK_MEMBER (ptl_hdr_t, msg.put.ack_wmd); - CHECK_MEMBER (ptl_hdr_t, msg.put.match_bits); - CHECK_MEMBER (ptl_hdr_t, msg.put.hdr_data); - CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index); - CHECK_MEMBER (ptl_hdr_t, msg.put.offset); + CHECK_MEMBER (ptl_hdr_t, msg.put.ack_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.put.match_bits); + CHECK_MEMBER (ptl_hdr_t, msg.put.hdr_data); + CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index); + CHECK_MEMBER (ptl_hdr_t, msg.put.offset); BLANK_LINE (); COMMENT ("Get"); - CHECK_MEMBER (ptl_hdr_t, msg.get.return_wmd); - CHECK_MEMBER (ptl_hdr_t, msg.get.match_bits); - CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index); - CHECK_MEMBER (ptl_hdr_t, msg.get.src_offset); - CHECK_MEMBER (ptl_hdr_t, msg.get.sink_length); + CHECK_MEMBER (ptl_hdr_t, msg.get.return_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.get.match_bits); + CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index); + CHECK_MEMBER (ptl_hdr_t, msg.get.src_offset); + CHECK_MEMBER (ptl_hdr_t, msg.get.sink_length); BLANK_LINE (); COMMENT ("Reply"); - CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_wmd); BLANK_LINE (); COMMENT ("Hello"); - CHECK_MEMBER (ptl_hdr_t, msg.hello.incarnation); - CHECK_MEMBER (ptl_hdr_t, msg.hello.type); + CHECK_MEMBER (ptl_hdr_t, msg.hello.incarnation); + CHECK_MEMBER (ptl_hdr_t, msg.hello.type); } void @@ -122,11 +122,11 @@ system_string (char *cmdline, char *str, int len) int fds[2]; int rc; pid_t pid; - + rc = pipe (fds); if (rc != 0) abort (); - + pid = fork (); if (pid == 0) { /* child */ @@ -145,25 +145,25 @@ system_string (char *cmdline, char *str, int len) if (f == NULL) abort(); - + close(fds[1]); - + if (fgets(str, len, f) == NULL) abort(); - + if (waitpid(pid, &rc, 0) != pid) abort(); - + if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0) abort(); if (strnlen(str, len) == len) str[len - 1] = 0; - + if (str[strlen(str) - 1] == '\n') str[strlen(str) - 1] = 0; - + fclose(f); } } @@ -173,35 +173,35 @@ main (int argc, char **argv) { char unameinfo[80]; char gccinfo[80]; - + system_string("uname -a", unameinfo, sizeof(unameinfo)); system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo)); - - printf ("void lib_assert_wire_constants (void)\n" - "{\n" + + printf ("void lib_assert_wire_constants (void)\n" + "{\n" " /* Wire protocol assertions generated by 'wirecheck'\n" " * running on %s\n" " * with %s */\n" "\n", unameinfo, gccinfo); - - BLANK_LINE (); - - COMMENT ("Constants..."); - CHECK_DEFINE (PORTALS_PROTO_MAGIC); - CHECK_DEFINE (PORTALS_PROTO_VERSION_MAJOR); - CHECK_DEFINE (PORTALS_PROTO_VERSION_MINOR); - - CHECK_VALUE (PTL_MSG_ACK); - CHECK_VALUE (PTL_MSG_PUT); - CHECK_VALUE (PTL_MSG_GET); - CHECK_VALUE (PTL_MSG_REPLY); - CHECK_VALUE (PTL_MSG_HELLO); - - check_ptl_handle_wire (); - check_ptl_magicversion (); - check_ptl_hdr (); - - printf ("}\n\n"); - - return (0); + + BLANK_LINE (); + + COMMENT ("Constants..."); + CHECK_DEFINE (PORTALS_PROTO_MAGIC); + CHECK_DEFINE (PORTALS_PROTO_VERSION_MAJOR); + CHECK_DEFINE (PORTALS_PROTO_VERSION_MINOR); + + CHECK_VALUE (PTL_MSG_ACK); + CHECK_VALUE (PTL_MSG_PUT); + CHECK_VALUE (PTL_MSG_GET); + CHECK_VALUE (PTL_MSG_REPLY); + CHECK_VALUE (PTL_MSG_HELLO); + + check_ptl_handle_wire (); + check_ptl_magicversion (); + check_ptl_hdr (); + + printf ("}\n\n"); + + return (0); } diff --git a/lustre/kernel_patches/kernel_configs/config-linux-2.4.20-uml b/lustre/kernel_patches/kernel_configs/config-linux-2.4.20-uml index 4a63c18..9934753 100644 --- a/lustre/kernel_patches/kernel_configs/config-linux-2.4.20-uml +++ b/lustre/kernel_patches/kernel_configs/config-linux-2.4.20-uml @@ -195,6 +195,7 @@ CONFIG_JBD=y # CONFIG_JFFS2_FS is not set # CONFIG_CRAMFS is not set CONFIG_TMPFS=y +CONFIG_TMPFS_XATTR=y CONFIG_RAMFS=y # CONFIG_ISO9660_FS is not set # CONFIG_JOLIET is not set diff --git a/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch b/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch index 2efed4f..e29ae29 100644 --- a/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch +++ b/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch @@ -275,10 +275,10 @@ { struct dentry * result; struct inode *dir = parent->d_inode; -+ int counter = 0; ++ int counter = 0; +again: -+ counter++; ++ counter++; down(&dir->i_sem); /* * First re-do the cached lookup just in case it was created @@ -300,10 +300,10 @@ + if (!result->d_op->d_revalidate_it(result, flags, it) && + !d_invalidate(result)) { + dput(result); -+ if (counter > 10) -+ result = ERR_PTR(-ESTALE); -+ if (!IS_ERR(result)) -+ goto again; ++ if (counter > 10) ++ result = ERR_PTR(-ESTALE); ++ if (!IS_ERR(result)) ++ goto again; + } } return result; @@ -1427,8 +1427,8 @@ { struct inode * inode = dentry->d_inode; - if (inode->i_op && inode->i_op->revalidate) -+ if (!inode) -+ return -ENOENT; ++ if (!inode) ++ return -ENOENT; + if (inode->i_op && inode->i_op->revalidate_it) + return inode->i_op->revalidate_it(dentry, it); + else if (inode->i_op && inode->i_op->revalidate) diff --git a/lustre/kernel_patches/patches/vfs_intent-2.4.20-hp.patch b/lustre/kernel_patches/patches/vfs_intent-2.4.20-hp.patch index a632e00..082b8b7 100644 --- a/lustre/kernel_patches/patches/vfs_intent-2.4.20-hp.patch +++ b/lustre/kernel_patches/patches/vfs_intent-2.4.20-hp.patch @@ -482,11 +482,11 @@ + &dentry->d_name, 0, NULL); + d_invalidate(dentry); + dput(dentry); -+ if (IS_ERR(new)) { -+ err = PTR_ERR(new); -+ break; -+ } -+ nd->dentry = new; ++ if (IS_ERR(new)) { ++ err = PTR_ERR(new); ++ break; ++ } ++ nd->dentry = new; + } + } else if (dentry && dentry->d_op && dentry->d_op->d_revalidate) { @@ -1450,8 +1450,8 @@ { struct inode * inode = dentry->d_inode; - if (inode->i_op && inode->i_op->revalidate) -+ if (!inode) -+ return -ENOENT; ++ if (!inode) ++ return -ENOENT; + if (inode->i_op && inode->i_op->revalidate_it) + return inode->i_op->revalidate_it(dentry, it); + else if (inode->i_op && inode->i_op->revalidate) diff --git a/lustre/kernel_patches/patches/vfs_intent_2.6.0-test1.patch b/lustre/kernel_patches/patches/vfs_intent_2.6.0-test1.patch index 1f840e8..3d75965 100644 --- a/lustre/kernel_patches/patches/vfs_intent_2.6.0-test1.patch +++ b/lustre/kernel_patches/patches/vfs_intent_2.6.0-test1.patch @@ -85,10 +85,10 @@ { struct dentry * result; struct inode *dir = parent->d_inode; -+ int counter = 0; ++ int counter = 0; +again: -+ counter++; ++ counter++; down(&dir->i_sem); /* * First re-do the cached lookup just in case it was created @@ -97,10 +97,10 @@ if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) { dput(result); - result = ERR_PTR(-ENOENT); -+ if (counter > 10) -+ result = ERR_PTR(-ESTALE); -+ if (!IS_ERR(result)) -+ goto again; ++ if (counter > 10) ++ result = ERR_PTR(-ESTALE); ++ if (!IS_ERR(result)) ++ goto again; } } return result; diff --git a/lustre/kernel_patches/series/chaos-2.4.20 b/lustre/kernel_patches/series/chaos-2.4.20 deleted file mode 100644 index f7a209f..0000000 --- a/lustre/kernel_patches/series/chaos-2.4.20 +++ /dev/null @@ -1,27 +0,0 @@ -dev_read_only_2.4.20-rh.patch -exports_2.4.20-rh-hp.patch -kmem_cache_validate_2.4.20-rh.patch -lustre_version.patch -vfs_intent_2.4.20_chaos.patch -invalidate_show_2.4.20_chaos.patch -iod-rmap-exports-2.4.20.patch -export-truncate.patch -ext-2.4-patch-1-chaos.patch -ext-2.4-patch-2.patch -ext-2.4-patch-3.patch -ext-2.4-patch-4.patch -linux-2.4.20-xattr-0.8.54-chaos.patch -ext3-2.4.20-fixes.patch -ext3_orphan_lock-2.4.20-rh.patch -ext3_delete_thread_2.4.20_chaos.patch -ext3-noread-2.4.20.patch -extN-wantedi.patch -ext3-san-2.4.20.patch -ext3-map_inode_page.patch -ext3-error-export.patch -iopen-2.4.20.patch -tcp_zero_copy_2.4.20_chaos.patch -gpl_header-chaos-2.4.20.patch -add_page_private.patch -jbd-flushtime.patch -jbd-get_write_access.patch diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index baf564a..1cb6a37 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -37,6 +37,11 @@ #include #include +/* both sys/queue.h (libsysio require it) and portals/lists.h have definition + * of 'LIST_HEAD'. undef it to suppress warnings + */ +#undef LIST_HEAD + #include /* needed for ptpctl.h */ #include /* needed for parse_dump */ #include @@ -45,8 +50,7 @@ ptl_handle_ni_t tcpnal_ni; -struct task_struct *current; -struct obd_class_user_state ocus; +struct task_struct *current; /* portals interfaces */ ptl_handle_ni_t * @@ -141,7 +145,7 @@ int init_lib_portals() PtlInit(); rc = PtlNIInit(procbridge_interface, 0, 0, 0, &tcpnal_ni); if (rc != 0) { - CERROR("ksocknal: PtlNIInit failed: error %d\n", rc); + CERROR("TCPNAL: PtlNIInit failed: error %d\n", rc); PtlFini(); RETURN (rc); } @@ -156,7 +160,7 @@ kportal_nal_cmd(struct portals_cfg *pcfg) return 0; } -extern int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd, unsigned long arg); +extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); int lib_ioctl_nalcmd(int dev_id, int opc, void * ptr) { @@ -190,7 +194,7 @@ int lib_ioctl(int dev_id, int opc, void * ptr) ioc->ioc_pbuf1 = ioc->ioc_bulk; //XXX - rc = class_handle_ioctl(&ocus, opc, (unsigned long)ptr); + rc = class_handle_ioctl(opc, (unsigned long)ptr); printf ("proccssing ioctl cmd: %x, rc %d\n", opc, rc); @@ -202,8 +206,6 @@ int lib_ioctl(int dev_id, int opc, void * ptr) int lllib_init(char *dumpfile) { - INIT_LIST_HEAD(&ocus.ocus_conns); - if (!g_zconf) { /* this parse only get my nid from config file * before initialize portals @@ -213,7 +215,7 @@ int lllib_init(char *dumpfile) } else { /* XXX need setup mynid before tcpnal initialize */ tcpnal_mynid = ((uint64_t)getpid() << 32) | time(0); - printf("set tcpnal mynid: %016llx\n", tcpnal_mynid); + printf("LibLustre: TCPNAL NID: %016llx\n", tcpnal_mynid); } init_current("dummy"); @@ -239,7 +241,7 @@ static void llu_check_request() } #endif -int liblustre_process_log(struct config_llog_instance *cfg) +int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) { struct lustre_cfg lcfg; char *peer = "MDS_PEER_UUID"; @@ -297,6 +299,11 @@ int liblustre_process_log(struct config_llog_instance *cfg) if (obd == NULL) GOTO(out_cleanup, err = -EINVAL); + /* Disable initial recovery on this import */ + err = obd_set_info(obd->obd_self_export, + strlen("initial_recov"), "initial_recov", + sizeof(allow_recov), &allow_recov); + err = obd_connect(&mdc_conn, obd, &mdc_uuid); if (err) { CERROR("cannot connect to %s: rc = %d\n", @@ -374,10 +381,13 @@ int ll_parse_mount_target(const char *target, char **mdsnid, /* env variables */ #define ENV_LUSTRE_MNTPNT "LIBLUSTRE_MOUNT_POINT" #define ENV_LUSTRE_MNTTGT "LIBLUSTRE_MOUNT_TARGET" +#define ENV_LUSTRE_TIMEOUT "LIBLUSTRE_TIMEOUT" #define ENV_LUSTRE_DUMPFILE "LIBLUSTRE_DUMPFILE" extern int _sysio_native_init(); +extern unsigned int obd_timeout; + /* global variables */ int g_zconf = 0; /* zeroconf or dumpfile */ char *g_zconf_mdsname = NULL; /* mdsname, for zeroconf */ @@ -389,6 +399,7 @@ void __liblustre_setup_(void) { char *lustre_path = NULL; char *target = NULL; + char *timeout = NULL; char *dumpfile = NULL; char *root_driver = "native"; char *lustre_driver = "llite"; @@ -397,7 +408,10 @@ void __liblustre_setup_(void) int err; - srand(time(NULL)); + /* consider tha case of starting multiple liblustre instances + * at a same time on single node. + */ + srand(time(NULL) + getpid()); signal(SIGUSR1, sighandler_USR1); @@ -429,6 +443,13 @@ void __liblustre_setup_(void) lustre_path, target); } + timeout = getenv(ENV_LUSTRE_TIMEOUT); + if (timeout) { + obd_timeout = (unsigned int) atoi(timeout); + printf("LibLustre: set obd timeout as %u seconds\n", + obd_timeout); + } + if (_sysio_init() != 0) { perror("init sysio"); exit(1); diff --git a/lustre/liblustre/lltest.c b/lustre/liblustre/lltest.c deleted file mode 100644 index ac6e8ad..0000000 --- a/lustre/liblustre/lltest.c +++ /dev/null @@ -1,386 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Lustre Light user test program - * - * Copyright (c) 2002, 2003 Cluster File Systems, Inc. - * - * This file is part of Lustre, http://www.lustre.org. - * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "test_common.h" - -#define ENTRY(str) \ - do { \ - char buf[100]; \ - int len; \ - sprintf(buf, "===== START: %s ", (str)); \ - len = strlen(buf); \ - if (len < 79) { \ - memset(buf+len, '=', 100-len); \ - buf[79] = '\n'; \ - buf[80] = 0; \ - } \ - printf("%s", buf); \ - } while (0) - -#define LEAVE() \ - do { \ - printf("----- END TEST successfully ---"); \ - printf("-----------------------------"); \ - printf("-------------------\n"); \ - } while (0) - -void t1() -{ - char *path="/mnt/lustre/test_t1"; - ENTRY("create/delete"); - - t_touch(path); - t_unlink(path); - LEAVE(); -} - -void t2() -{ - char *path="/mnt/lustre/test_t2"; - ENTRY("mkdir/rmdir"); - - t_mkdir(path); - t_rmdir(path); - LEAVE(); -} - -void t3() -{ - char *path="/mnt/lustre/test_t3"; - ENTRY("regular stat"); - - t_touch(path); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -void t4() -{ - char *path="/mnt/lustre/test_t4"; - ENTRY("dir stat"); - - t_mkdir(path); - t_check_stat(path, NULL); - t_rmdir(path); - LEAVE(); -} - -#define PAGE_SIZE (4096) -#define _npages (512) - -static int _buffer[_npages][PAGE_SIZE/sizeof(int)]; - -/* pos: i/o start from - * xfer: npages per transfer - */ -static void pages_io(int xfer, loff_t pos) -{ - char *path="/mnt/lustre/test_t5"; - int check_sum[_npages] = {0,}; - int fd, rc, i, j; - - memset(_buffer, 0, sizeof(_buffer)); - - /* create sample data */ - for (i = 0; i < _npages; i++) { - for (j = 0; j < PAGE_SIZE/sizeof(int); j++) { - _buffer[i][j] = rand(); - } - } - - /* compute checksum */ - for (i = 0; i < _npages; i++) { - for (j = 0; j < PAGE_SIZE/sizeof(int); j++) { - check_sum[i] += _buffer[i][j]; - } - } - - t_touch(path); - - fd = t_open(path); - - /* write */ - lseek(fd, pos, SEEK_SET); - for (i = 0; i < _npages; i += xfer) { - rc = write(fd, _buffer[i], PAGE_SIZE * xfer); - if (rc != PAGE_SIZE * xfer) { - printf("write error %d (i = %d)\n", rc, i); - exit(1); - } - } - printf("succefully write %d pages\n", _npages); - - memset(_buffer, 0, sizeof(_buffer)); - - /* read */ - lseek(fd, pos, SEEK_SET); - for (i = 0; i < _npages; i += xfer) { - rc = read(fd, _buffer[i], PAGE_SIZE * xfer); - if (rc != PAGE_SIZE * xfer) { - printf("read error %d (i = %d)\n", rc, i); - exit(1); - } - } - printf("succefully read %d pages\n", _npages); - - /* compute checksum */ - for (i = 0; i < _npages; i++) { - int sum = 0; - for (j = 0; j < PAGE_SIZE/sizeof(int); j++) { - sum += _buffer[i][j]; - } - if (sum != check_sum[i]) { - printf("chunk %d checksum error: expected 0x%x, get 0x%x\n", - i, check_sum[i], sum); - } - } - printf("checksum verified OK!\n"); - - t_close(fd); - t_unlink(path); -} - -void t5() -{ - char text[256]; - loff_t off_array[] = {1, 17, 255, 257, 4095, 4097, 8191, 1024*1024*1024}; - int np = 1, i; - loff_t offset = 0; - - while (np <= _npages) { - sprintf(text, "pages_io: %d per transfer, offset %lld", - np, offset); - ENTRY(text); - pages_io(np, offset); - LEAVE(); - np += np; - } - - for (i = 0; i < sizeof(off_array)/sizeof(loff_t); i++) { - offset = off_array[i]; - sprintf(text, "pages_io: 16 per transfer, offset %lld", - offset); - ENTRY(text); - pages_io(16, offset); - LEAVE(); - } -} - -void t6() -{ - char *path="/mnt/lustre/test_t6"; - char *path2="/mnt/lustre/test_t6_link"; - ENTRY("symlink"); - - t_touch(path); - t_symlink(path, path2); - t_check_stat(path2, NULL); - t_unlink(path2); - t_unlink(path); - LEAVE(); -} - -void t7() -{ - char *path="/mnt/lustre/test_t7"; - ENTRY("mknod"); - - t_mknod(path, S_IFCHR | 0644, 5, 4); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -void t8() -{ - char *path="/mnt/lustre/test_t8"; - ENTRY("chmod"); - - t_touch(path); - t_chmod_raw(path, 0700); - t_check_stat(path, NULL); - t_unlink(path); - LEAVE(); -} - -void t9() -{ - char *path="/mnt/lustre/test_t9"; - char *path2="/mnt/lustre/test_t9_link"; - ENTRY("hard link"); - - t_touch(path); - t_link(path, path2); - t_check_stat(path, NULL); - t_check_stat(path2, NULL); - t_unlink(path); - t_unlink(path2); - LEAVE(); -} - -void t10() -{ - char *dir1="/mnt/lustre/test_t10_dir1"; - char *dir2="/mnt/lustre/test_t10_dir2"; - char *path1="/mnt/lustre/test_t10_reg1"; - char *path2="/mnt/lustre/test_t10_reg2"; - char *rename1="/mnt/lustre/test_t10_dir1/rename1"; - char *rename2="/mnt/lustre/test_t10_dir2/rename2"; - char *rename3="/mnt/lustre/test_t10_dir2/rename3"; - ENTRY("rename"); - - t_mkdir(dir1); - t_mkdir(dir2); - t_touch(path1); - t_touch(path2); - t_rename(path1, rename1); - t_rename(path2, rename2); - t_rename(rename1, rename2); - t_rename(dir1, rename3); - t_unlink(rename2); - t_rmdir(rename3); - t_rmdir(dir2); - LEAVE(); -} - -void t100() -{ - char *base="/mnt/lustre"; - char path[4096], path2[4096]; - int i, j, level = 5, nreg = 5; - ENTRY("deep tree"); - - strcpy(path, base); - - for (i = 0; i < level; i++) { - for (j = 0; j < nreg; j++) { - sprintf(path2, "%s/file%d", path, j); - t_touch(path2); - } - - strcat(path, "/dir"); - t_mkdir(path); - } - - for (i = level; i > 0; i--) { - strcpy(path, base); - for (j = 1; j < i; j++) - strcat(path, "/dir"); - - for (j = 0; j < nreg; j++) { - sprintf(path2, "%s/file%d", path, j); - t_unlink(path2); - } - - strcat(path, "/dir"); - t_rmdir(path); - } - - LEAVE(); -} - -extern void __liblustre_setup_(void); -extern void __liblustre_cleanup_(void); - -void usage(char *cmd) -{ - printf("Usage: \t%s --target mdsnid:/mdsname/profile\n", cmd); - printf(" \t%s --dumpfile dumpfile\n", cmd); - exit(-1); -} - -int main(int argc, char * const argv[]) -{ - int opt_index, c; - static struct option long_opts[] = { - {"target", 1, 0, 0}, - {"dumpfile", 1, 0, 0}, - {0, 0, 0, 0} - }; - - if (argc <= 1) - usage(argv[0]); - - while ((c = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) { - switch (c) { - case 0: { - printf("optindex %d\n", opt_index); - if (!optarg[0]) - usage(argv[0]); - - if (!strcmp(long_opts[opt_index].name, "target")) { - setenv(ENV_LUSTRE_MNTTGT, optarg, 1); - } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { - setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); - } else - usage(argv[0]); - break; - } - default: - usage(argv[0]); - } - } - - if (optind != argc) - usage(argv[0]); - - __liblustre_setup_(); - -#ifndef __CYGWIN__ - t1(); - t2(); - t3(); - t4(); - t5(); - t6(); - t7(); - t8(); - t9(); - t10(); - - t100(); -#endif - - printf("liblustre is about shutdown\n"); - __liblustre_cleanup_(); - - printf("complete successfully\n"); - return 0; -} diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 6c26a16..a565f51 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -41,6 +41,8 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, struct lov_mds_md *lmm, int lmm_bytes); int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, struct lov_user_md *lump); +int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, + struct lov_user_md *lump); int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_user_md *lump); diff --git a/lustre/portals/knals/gmnal/gmnal.h b/lustre/portals/knals/gmnal/gmnal.h index 53757ab..cdde5b7 100644 --- a/lustre/portals/knals/gmnal/gmnal.h +++ b/lustre/portals/knals/gmnal/gmnal.h @@ -353,8 +353,6 @@ int gmnal_cb_read(nal_cb_t *, void *private, void *, user_ptr, size_t); int gmnal_cb_write(nal_cb_t *, void *private, user_ptr, void *, size_t); -int gmnal_cb_callback(nal_cb_t *, void *, lib_eq_t *, ptl_event_t *); - void *gmnal_cb_malloc(nal_cb_t *, size_t); void gmnal_cb_free(nal_cb_t *, void *, size_t); @@ -384,7 +382,7 @@ void gmnal_fini(void); a->cb_recv_pages = gmnal_cb_recv_pages; \ a->cb_read = gmnal_cb_read; \ a->cb_write = gmnal_cb_write; \ - a->cb_callback = gmnal_cb_callback; \ + a->cb_callback = NULL; \ a->cb_malloc = gmnal_cb_malloc; \ a->cb_free = gmnal_cb_free; \ a->cb_map = NULL; \ diff --git a/lustre/portals/knals/gmnal/gmnal_cb.c b/lustre/portals/knals/gmnal/gmnal_cb.c index 6ae91db..e055242 100644 --- a/lustre/portals/knals/gmnal/gmnal_cb.c +++ b/lustre/portals/knals/gmnal/gmnal_cb.c @@ -126,7 +126,6 @@ int gmnal_cb_send(nal_cb_t *nal_cb, void *private, lib_msg_t *cookie, niov, iov, len); } else { CDEBUG(D_ERROR, "Large message send it is not supported\n"); - lib_finalize(nal_cb, private, cookie); return(PTL_FAIL); gmnal_large_tx(nal_cb, private, cookie, hdr, type, nid, pid, niov, iov, len); @@ -200,18 +199,6 @@ int gmnal_cb_write(nal_cb_t *nal_cb, void *private, user_ptr dst, return(PTL_OK); } -int gmnal_cb_callback(nal_cb_t *nal_cb, void *private, lib_eq_t *eq, - ptl_event_t *ev) -{ - - if (eq->event_callback != NULL) { - CDEBUG(D_INFO, "found callback\n"); - eq->event_callback(ev); - } - - return(PTL_OK); -} - void *gmnal_cb_malloc(nal_cb_t *nal_cb, size_t len) { void *ptr = NULL; diff --git a/lustre/portals/knals/scimacnal/scimacnal_cb.c b/lustre/portals/knals/scimacnal/scimacnal_cb.c index b31c2ea..52afb98 100644 --- a/lustre/portals/knals/scimacnal/scimacnal_cb.c +++ b/lustre/portals/knals/scimacnal/scimacnal_cb.c @@ -176,7 +176,8 @@ kscimacnal_txrelease(mac_mblk_t *msg, mac_msg_status_t status, void *context) break; } - lib_finalize(ktx->ktx_nal, ktx->ktx_private, ktx->ktx_cookie); + lib_finalize(ktx->ktx_nal, ktx->ktx_private, ktx->ktx_cookie, + (err == 0) ? PTL_OK : PTL_FAIL); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); } @@ -225,14 +226,14 @@ kscimacnal_sendmsg(nal_cb_t *nal, if (buf_len > mac_get_mtusize(ksci->ksci_machandle)) { CERROR("kscimacnal:request exceeds TX MTU size (%ld).\n", mac_get_mtusize(ksci->ksci_machandle)); - return -EINVAL; + return PTL_FAIL; } /* save transaction info for later finalize and cleanup */ PORTAL_ALLOC(ktx, (sizeof(kscimacnal_tx_t))); if (!ktx) { - return -ENOMEM; + return PTL_NOSPACE; } ktx->ktx_nmapped = 0; /* Start with no mapped pages :) */ @@ -247,7 +248,7 @@ kscimacnal_sendmsg(nal_cb_t *nal, kscimacnal_txrelease, ktx); if (!msg) { PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return -ENOMEM; + return PTL_NOSPACE; } mac_put_mblk(msg, sizeof(ptl_hdr_t)); lastblk=msg; @@ -284,7 +285,7 @@ kscimacnal_sendmsg(nal_cb_t *nal, if(!newblk) { mac_free_msg(msg); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return -ENOMEM; + return PTL_NOSPACE; } mac_put_mblk(newblk, nob); mac_link_mblk(lastblk, newblk); @@ -315,10 +316,10 @@ kscimacnal_sendmsg(nal_cb_t *nal, CERROR("kscimacnal: mac_send() failed, rc=%d\n", rc); mac_free_msg(msg); PORTAL_FREE(ktx, (sizeof(kscimacnal_tx_t))); - return rc; + return PTL_FAIL; } - return 0; + return PTL_OK; } @@ -463,12 +464,15 @@ kscimacnal_recvmsg(nal_cb_t *nal, krx->msg, mlen, rlen, niov); /* What was actually received must be >= what sender claims to have - * sent. This is an LASSERT, since lib-move doesn't check cb return - * code yet. Also, rlen seems to be negative when mlen==0 so don't - * assert on that. - */ - LASSERT (mlen==0 || mac_msg_size(krx->msg) >= sizeof(ptl_hdr_t)+rlen); - LASSERT (mlen==0 || mlen <= rlen); + * sent. */ + LASSERT (mlen <= rlen); /* something is wrong if this isn't true */ + if (mac_msg_size(krx->msg) < sizeof(ptl_hdr_t)+mlen) { + /* We didn't receive everything lib thinks we did */ + CERROR("Bad message size: have %d, need %d + %d\n", + mac_msg_size(krx->msg), sizeof(ptl_hdr_t), mlen); + return (PTL_FAIL); + } + /* It must be OK to kmap() if required */ LASSERT (kiov == NULL || !in_interrupt ()); /* Either all pages or all vaddrs */ @@ -545,12 +549,12 @@ kscimacnal_recvmsg(nal_cb_t *nal, CDEBUG(D_NET, "Calling lib_finalize.\n"); PROF_START(lib_finalize); - lib_finalize(nal, private, cookie); + lib_finalize(nal, private, cookie, PTL_OK); PROF_FINISH(lib_finalize); CDEBUG(D_NET, "Done.\n"); - return rlen; + return PTL_OK; } diff --git a/lustre/portals/portals/api-eq.c b/lustre/portals/portals/api-eq.c index 9bc9c36..964b9d8 100644 --- a/lustre/portals/portals/api-eq.c +++ b/lustre/portals/portals/api-eq.c @@ -81,12 +81,6 @@ int PtlEQGet(ptl_handle_eq_t eventq, ptl_event_t * ev) *ev = *new_event; - /* Set the unlinked_me interface number if there is one to pass - * back, since the NAL hasn't a clue what it is and therefore can't - * set it. */ - if (!PtlHandleEqual (ev->unlinked_me, PTL_HANDLE_NONE)) - ev->unlinked_me.nal_idx = eventq.nal_idx; - /* ensure event is delivered correctly despite possible races with lib_finalize */ if (eq->sequence != new_event->sequence) { @@ -119,6 +113,7 @@ int PtlEQWait(ptl_handle_eq_t eventq_in, ptl_event_t *event_out) } #ifndef __KERNEL__ +#if 0 static jmp_buf eq_jumpbuf; static void eq_timeout(int signal) @@ -162,6 +157,46 @@ int PtlEQWait_timeout(ptl_handle_eq_t eventq_in, ptl_event_t * event_out, return rc; } +#else +#include -#endif +/* FIXME + * Here timeout need a trick with tcpnal, definitely unclean but OK for + * this moment. + */ + +/* global variables defined by tcpnal */ +extern int __tcpnal_eqwait_timeout_value; +extern int __tcpnal_eqwait_timedout; + +int PtlEQWait_timeout(ptl_handle_eq_t eventq_in, ptl_event_t * event_out, + int timeout) +{ + int rc; + if (!timeout) + return PtlEQWait(eventq_in, event_out); + + __tcpnal_eqwait_timeout_value = timeout; + + while ((rc = PtlEQGet(eventq_in, event_out)) == PTL_EQ_EMPTY) { + nal_t *nal = ptl_hndl2nal(&eventq_in); + + if (nal->yield) + nal->yield(nal); + + if (__tcpnal_eqwait_timedout) { + if (__tcpnal_eqwait_timedout != ETIMEDOUT) + printf("Warning: yield return error %d\n", + __tcpnal_eqwait_timedout); + rc = PTL_EQ_EMPTY; + break; + } + } + + __tcpnal_eqwait_timeout_value = 0; + + return rc; +} +#endif +#endif /* __KERNEL__ */ diff --git a/lustre/portals/portals/lib-md.c b/lustre/portals/portals/lib-md.c index be6949c..a1ed583 100644 --- a/lustre/portals/portals/lib-md.c +++ b/lustre/portals/portals/lib-md.c @@ -83,7 +83,7 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private, int rc; int i; - /* NB we are passes an allocated, but uninitialised/active md. + /* NB we are passed an allocated, but uninitialised/active md. * if we return success, caller may lib_md_unlink() it. * otherwise caller may only lib_md_free() it. */ @@ -94,9 +94,10 @@ static int lib_md_build(nal_cb_t *nal, lib_md_t *new, void *private, return PTL_INV_EQ; } - if ((md->options & PTL_MD_IOV) != 0 && /* discontiguous MD */ - md->niov > PTL_MD_MAX_IOV) /* too many fragments */ - return PTL_IOV_TOO_MANY; + /* Must check this _before_ allocation. Also, note that non-iov + * MDs must set md_niov to 0. */ + LASSERT((md->options & (PTL_MD_IOV | PTL_MD_KIOV)) == 0 || + md->niov <= PTL_MD_MAX_IOV); if ((md->options & max_size_opts) != 0 && /* max size used */ (md->max_size < 0 || md->max_size > md->length)) // illegal max_size @@ -239,7 +240,11 @@ int do_PtlMDAttach(nal_cb_t * nal, void *private, void *v_args, void *v_ret) lib_md_t *md; unsigned long flags; - md = lib_md_alloc (nal); + if ((args->md_in.options & (PTL_MD_KIOV | PTL_MD_IOV)) != 0 && + args->md_in.niov > PTL_MD_MAX_IOV) /* too many fragments */ + return (ret->rc = PTL_IOV_TOO_MANY); + + md = lib_md_alloc(nal, &args->md_in); if (md == NULL) return (ret->rc = PTL_NOSPACE); @@ -287,7 +292,11 @@ int do_PtlMDBind(nal_cb_t * nal, void *private, void *v_args, void *v_ret) lib_md_t *md; unsigned long flags; - md = lib_md_alloc (nal); + if ((args->md_in.options & (PTL_MD_KIOV | PTL_MD_IOV)) != 0 && + args->md_in.niov > PTL_MD_MAX_IOV) /* too many fragments */ + return (ret->rc = PTL_IOV_TOO_MANY); + + md = lib_md_alloc(nal, &args->md_in); if (md == NULL) return (ret->rc = PTL_NOSPACE); @@ -311,34 +320,43 @@ int do_PtlMDBind(nal_cb_t * nal, void *private, void *v_args, void *v_ret) int do_PtlMDUnlink(nal_cb_t * nal, void *private, void *v_args, void *v_ret) { - PtlMDUnlink_in *args = v_args; + PtlMDUnlink_in *args = v_args; PtlMDUnlink_out *ret = v_ret; - - lib_md_t *md; - unsigned long flags; + ptl_event_t ev; + lib_md_t *md; + unsigned long flags; state_lock(nal, &flags); md = ptl_handle2md(&args->md_in, nal); if (md == NULL) { - ret->rc = PTL_INV_MD; - } else if (md->pending != 0) { /* being filled/spilled */ - ret->rc = PTL_MD_INUSE; - } else { - /* Callers attempting to unlink a busy MD which will get - * unlinked once the net op completes should see INUSE, - * before completion and INV_MD thereafter. LASSERT we've - * got that right... */ - LASSERT ((md->md_flags & PTL_MD_FLAG_UNLINK) == 0); - - lib_md_deconstruct(nal, md, &ret->status_out); - lib_md_unlink(nal, md); - ret->rc = PTL_OK; + state_unlock(nal, &flags); + return (ret->rc = PTL_INV_MD); + } + + /* If the MD is busy, lib_md_unlink just marks it for deletion, and + * when the NAL is done, the completion event flags that the MD was + * unlinked. Otherwise, we enqueue an event now... */ + + if (md->eq != NULL && + md->pending == 0) { + memset(&ev, 0, sizeof(ev)); + + ev.type = PTL_EVENT_UNLINK; + ev.status = PTL_OK; + ev.unlinked = 1; + lib_md_deconstruct(nal, md, &ev.mem_desc); + + lib_enq_event_locked(nal, private, md->eq, &ev); } + lib_md_deconstruct(nal, md, &ret->status_out); + lib_md_unlink(nal, md); + ret->rc = PTL_OK; + state_unlock(nal, &flags); - return (ret->rc); + return (PTL_OK); } int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, @@ -379,6 +397,23 @@ int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, goto out; } + /* XXX fttb, the new MD must be the same type wrt fragmentation */ + if (((new->options ^ md->options) & + (PTL_MD_IOV | PTL_MD_KIOV)) != 0) { + ret->rc = PTL_INV_MD; + goto out; + } + + if (new->niov > md->md_niov) { + ret->rc = PTL_IOV_TOO_MANY; + goto out; + } + + if (new->niov < md->md_niov) { + ret->rc = PTL_IOV_TOO_SMALL; + goto out; + } + if (!PtlHandleEqual (args->testq_in, PTL_EQ_NONE)) { test_eq = ptl_handle2eq(&args->testq_in, nal); if (test_eq == NULL) { diff --git a/lustre/portals/unals/connection.h b/lustre/portals/unals/connection.h index fb1eaab..343ffa6 100644 --- a/lustre/portals/unals/connection.h +++ b/lustre/portals/unals/connection.h @@ -7,6 +7,7 @@ */ #include +#include typedef struct manager { table connections; @@ -26,7 +27,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short, + procbridge pb); manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); diff --git a/lustre/portals/unals/procbridge.h b/lustre/portals/unals/procbridge.h index 317e22f..965f83d 100644 --- a/lustre/portals/unals/procbridge.h +++ b/lustre/portals/unals/procbridge.h @@ -25,6 +25,9 @@ typedef struct procbridge { pthread_cond_t cond; pthread_mutex_t mutex; + /* socket pair used to notify nal thread */ + int notifier[2]; + int nal_flags; pthread_mutex_t nal_cb_lock; @@ -51,5 +54,6 @@ extern nal_t *procbridge_interface(int num_interface, ptl_pt_index_t ptl_size, ptl_ac_index_t acl_size, ptl_pid_t requested_pid); +extern void procbridge_wakeup_nal(procbridge p); #endif diff --git a/lustre/portals/utils/Makefile.am b/lustre/portals/utils/Makefile.am index f1878df..6c31b3d 100644 --- a/lustre/portals/utils/Makefile.am +++ b/lustre/portals/utils/Makefile.am @@ -3,17 +3,18 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution - COMPILE = $(CC) -Wall -g -I$(srcdir)/../include LINK = $(CC) -o $@ if LIBLUSTRE -tmp= + +noinst_LIBRARIES = libuptlctl.a +libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h +libuptlctl_a_CFLAGS = -fPIC + else -tmp=gmnalnid -endif -sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck $(tmp) +sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck gmnalnid lib_LIBRARIES = libptlctl.a acceptor_SOURCES = acceptor.c # -lefence @@ -33,3 +34,4 @@ debugctl_LDADD = -L. -lptlctl -lncurses # -lefence debugctl_DEPENDENCIES = libptlctl.a routerstat_SOURCES = routerstat.c +endif diff --git a/lustre/portals/utils/l_ioctl.c b/lustre/portals/utils/l_ioctl.c index c6628ff..58a408a 100644 --- a/lustre/portals/utils/l_ioctl.c +++ b/lustre/portals/utils/l_ioctl.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,16 @@ #include #include +#ifndef __CYGWIN__ + #include +#else + #include + #include +#endif + +static ioc_handler_t do_ioctl; /* forward ref */ +static ioc_handler_t *current_ioc_handler = &do_ioctl; + struct ioc_dev { const char * dev_name; int dev_fd; @@ -48,7 +57,16 @@ struct dump_hdr { int opc; }; -char * dump_filename; +char *dump_filename; + +void +set_ioc_handler (ioc_handler_t *handler) +{ + if (handler == NULL) + current_ioc_handler = do_ioctl; + else + current_ioc_handler = handler; +} static int open_ioc_dev(int dev_id) @@ -115,7 +133,7 @@ dump(int dev_id, int opc, void *buf) { FILE *fp; struct dump_hdr dump_hdr; - struct portal_ioctl_hdr * ioc_hdr = (struct portal_ioctl_hdr *) buf; + struct portal_ioctl_hdr * ioc_hdr = (struct portal_ioctl_hdr *) buf; int rc; printf("dumping opc %x to %s\n", opc, dump_filename); @@ -132,17 +150,17 @@ dump(int dev_id, int opc, void *buf) return -EINVAL; } - rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp); - if (rc == 1) - rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp); - fclose(fp); - if (rc != 1) { - fprintf(stderr, "%s: %s\n", dump_filename, - strerror(errno)); - return -EINVAL; - } - - return 0; + rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp); + if (rc == 1) + rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp); + fclose(fp); + if (rc != 1) { + fprintf(stderr, "%s: %s\n", dump_filename, + strerror(errno)); + return -EINVAL; + } + + return 0; } /* register a device to send ioctls to. */ @@ -184,16 +202,17 @@ set_ioctl_dump(char * file) free(dump_filename); dump_filename = strdup(file); + if (dump_filename == NULL) + abort(); + + set_ioc_handler(&dump); return 0; } int l_ioctl(int dev_id, int opc, void *buf) { - if (dump_filename) - return dump(dev_id, opc, buf); - else - return do_ioctl(dev_id, opc, buf); + return current_ioc_handler(dev_id, opc, buf); } /* Read an ioctl dump file, and call the ioc_func for each ioctl buffer @@ -207,16 +226,28 @@ l_ioctl(int dev_id, int opc, void *buf) int parse_dump(char * dump_file, int (*ioc_func)(int dev_id, int opc, void *)) { - int fd, line =0; + int line =0; struct stat st; - char *buf, *end; + char *start, *buf, *end; +#ifndef __CYGWIN__ + int fd; +#else + HANDLE fd, hmap; + DWORD size; +#endif +#ifndef __CYGWIN__ fd = syscall(SYS_open, dump_file, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "couldn't open %s: %s\n", dump_file, + strerror(errno)); + exit(1); + } #ifndef SYS_fstat64 -#define __SYS_fstat__ SYS_fstat +# define __SYS_fstat__ SYS_fstat #else -#define __SYS_fstat__ SYS_fstat64 +# define __SYS_fstat__ SYS_fstat64 #endif if (syscall(__SYS_fstat__, fd, &st)) { perror("stat fails"); @@ -228,41 +259,72 @@ parse_dump(char * dump_file, int (*ioc_func)(int dev_id, int opc, void *)) exit(1); } - buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0); - end = buf + st.st_size; + start = buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0); + end = start + st.st_size; close(fd); - while (buf < end) { - struct dump_hdr *dump_hdr = (struct dump_hdr *) buf; - struct portal_ioctl_hdr * data; - char tmp[8096]; - int rc; - - line++; + if (start == MAP_FAILED) { + fprintf(stderr, "can't create file mapping\n"); + exit(1); + } +#else + fd = CreateFile(dump_file, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + size = GetFileSize(fd, NULL); + if (size < 1) { + fprintf(stderr, "KML is empty\n"); + exit(1); + } - data = (struct portal_ioctl_hdr *) (buf + sizeof(*dump_hdr)); - if (buf + data->ioc_len > end ) { - fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf, - data->ioc_len, end); - return -1; - } + hmap = CreateFileMapping(fd, NULL, PAGE_READONLY, 0,0, NULL); + start = buf = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0); + end = buf + size; + CloseHandle(fd); + if (start == NULL) { + fprintf(stderr, "can't create file mapping\n"); + exit(1); + } +#endif /* __CYGWIN__ */ + + while (buf < end) { + struct dump_hdr *dump_hdr = (struct dump_hdr *) buf; + struct portal_ioctl_hdr * data; + char tmp[8096]; + int rc; + + line++; + + data = (struct portal_ioctl_hdr *) (buf + sizeof(*dump_hdr)); + if (buf + data->ioc_len > end ) { + fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf, + data->ioc_len, end); + return -1; + } #if 0 - printf ("dump_hdr: %lx data: %lx\n", - (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf); - - printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc, - data->ioc_len, data->ioc_version); + printf ("dump_hdr: %lx data: %lx\n", + (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf); + + printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc, + data->ioc_len, data->ioc_version); #endif - memcpy(tmp, data, data->ioc_len); + memcpy(tmp, data, data->ioc_len); - rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp); - if (rc) { - printf("failed: %d\n", rc); - exit(1); - } + rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp); + if (rc) { + printf("failed: %d\n", rc); + exit(1); + } - buf += data->ioc_len + sizeof(*dump_hdr); + buf += data->ioc_len + sizeof(*dump_hdr); } + +#ifndef __CYGWIN__ + munmap(start, end - start); +#else + UnmapViewOfFile(start); + CloseHandle(hmap); +#endif + return 0; } diff --git a/lustre/portals/utils/wirecheck.c b/lustre/portals/utils/wirecheck.c index 77ad126..a73a5217 100644 --- a/lustre/portals/utils/wirecheck.c +++ b/lustre/portals/utils/wirecheck.c @@ -10,80 +10,80 @@ extern size_t strnlen(const char *, size_t); -#define BLANK_LINE() \ -do { \ - printf ("\n"); \ +#define BLANK_LINE() \ +do { \ + printf ("\n"); \ } while (0) -#define COMMENT(c) \ -do { \ - printf (" /* "c" */\n"); \ +#define COMMENT(c) \ +do { \ + printf (" /* "c" */\n"); \ } while (0) #define STRINGIFY(a) #a -#define CHECK_DEFINE(a) \ -do { \ - printf (" LASSERT ("#a" == "STRINGIFY(a)");\n"); \ +#define CHECK_DEFINE(a) \ +do { \ + printf (" LASSERT ("#a" == "STRINGIFY(a)");\n"); \ } while (0) -#define CHECK_VALUE(a) \ -do { \ - printf (" LASSERT ("#a" == %d);\n", a); \ +#define CHECK_VALUE(a) \ +do { \ + printf (" LASSERT ("#a" == %d);\n", a); \ } while (0) -#define CHECK_MEMBER_OFFSET(s,m) \ -do { \ - CHECK_VALUE(offsetof(s, m)); \ +#define CHECK_MEMBER_OFFSET(s,m) \ +do { \ + CHECK_VALUE(offsetof(s, m)); \ } while (0) -#define CHECK_MEMBER_SIZEOF(s,m) \ -do { \ - CHECK_VALUE((int)sizeof(((s *)0)->m)); \ +#define CHECK_MEMBER_SIZEOF(s,m) \ +do { \ + CHECK_VALUE((int)sizeof(((s *)0)->m)); \ } while (0) -#define CHECK_MEMBER(s,m) \ -do { \ - CHECK_MEMBER_OFFSET(s, m); \ - CHECK_MEMBER_SIZEOF(s, m); \ +#define CHECK_MEMBER(s,m) \ +do { \ + CHECK_MEMBER_OFFSET(s, m); \ + CHECK_MEMBER_SIZEOF(s, m); \ } while (0) #define CHECK_STRUCT(s) \ do { \ BLANK_LINE (); \ COMMENT ("Checks for struct "#s); \ - CHECK_VALUE((int)sizeof(s)); \ + CHECK_VALUE((int)sizeof(s)); \ } while (0) void check_ptl_handle_wire (void) { - CHECK_STRUCT (ptl_handle_wire_t); - CHECK_MEMBER (ptl_handle_wire_t, wh_interface_cookie); - CHECK_MEMBER (ptl_handle_wire_t, wh_object_cookie); + CHECK_STRUCT (ptl_handle_wire_t); + CHECK_MEMBER (ptl_handle_wire_t, wh_interface_cookie); + CHECK_MEMBER (ptl_handle_wire_t, wh_object_cookie); } void check_ptl_magicversion (void) { - CHECK_STRUCT (ptl_magicversion_t); - CHECK_MEMBER (ptl_magicversion_t, magic); - CHECK_MEMBER (ptl_magicversion_t, version_major); - CHECK_MEMBER (ptl_magicversion_t, version_minor); + CHECK_STRUCT (ptl_magicversion_t); + CHECK_MEMBER (ptl_magicversion_t, magic); + CHECK_MEMBER (ptl_magicversion_t, version_major); + CHECK_MEMBER (ptl_magicversion_t, version_minor); } void check_ptl_hdr (void) { - CHECK_STRUCT (ptl_hdr_t); - CHECK_MEMBER (ptl_hdr_t, dest_nid); - CHECK_MEMBER (ptl_hdr_t, src_nid); - CHECK_MEMBER (ptl_hdr_t, dest_pid); - CHECK_MEMBER (ptl_hdr_t, src_pid); - CHECK_MEMBER (ptl_hdr_t, type); - CHECK_MEMBER (ptl_hdr_t, payload_length); + CHECK_STRUCT (ptl_hdr_t); + CHECK_MEMBER (ptl_hdr_t, dest_nid); + CHECK_MEMBER (ptl_hdr_t, src_nid); + CHECK_MEMBER (ptl_hdr_t, dest_pid); + CHECK_MEMBER (ptl_hdr_t, src_pid); + CHECK_MEMBER (ptl_hdr_t, type); + CHECK_MEMBER (ptl_hdr_t, payload_length); CHECK_MEMBER (ptl_hdr_t, msg); - + BLANK_LINE (); COMMENT ("Ack"); CHECK_MEMBER (ptl_hdr_t, msg.ack.dst_wmd); @@ -92,28 +92,28 @@ check_ptl_hdr (void) BLANK_LINE (); COMMENT ("Put"); - CHECK_MEMBER (ptl_hdr_t, msg.put.ack_wmd); - CHECK_MEMBER (ptl_hdr_t, msg.put.match_bits); - CHECK_MEMBER (ptl_hdr_t, msg.put.hdr_data); - CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index); - CHECK_MEMBER (ptl_hdr_t, msg.put.offset); + CHECK_MEMBER (ptl_hdr_t, msg.put.ack_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.put.match_bits); + CHECK_MEMBER (ptl_hdr_t, msg.put.hdr_data); + CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index); + CHECK_MEMBER (ptl_hdr_t, msg.put.offset); BLANK_LINE (); COMMENT ("Get"); - CHECK_MEMBER (ptl_hdr_t, msg.get.return_wmd); - CHECK_MEMBER (ptl_hdr_t, msg.get.match_bits); - CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index); - CHECK_MEMBER (ptl_hdr_t, msg.get.src_offset); - CHECK_MEMBER (ptl_hdr_t, msg.get.sink_length); + CHECK_MEMBER (ptl_hdr_t, msg.get.return_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.get.match_bits); + CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index); + CHECK_MEMBER (ptl_hdr_t, msg.get.src_offset); + CHECK_MEMBER (ptl_hdr_t, msg.get.sink_length); BLANK_LINE (); COMMENT ("Reply"); - CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_wmd); + CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_wmd); BLANK_LINE (); COMMENT ("Hello"); - CHECK_MEMBER (ptl_hdr_t, msg.hello.incarnation); - CHECK_MEMBER (ptl_hdr_t, msg.hello.type); + CHECK_MEMBER (ptl_hdr_t, msg.hello.incarnation); + CHECK_MEMBER (ptl_hdr_t, msg.hello.type); } void @@ -122,11 +122,11 @@ system_string (char *cmdline, char *str, int len) int fds[2]; int rc; pid_t pid; - + rc = pipe (fds); if (rc != 0) abort (); - + pid = fork (); if (pid == 0) { /* child */ @@ -145,25 +145,25 @@ system_string (char *cmdline, char *str, int len) if (f == NULL) abort(); - + close(fds[1]); - + if (fgets(str, len, f) == NULL) abort(); - + if (waitpid(pid, &rc, 0) != pid) abort(); - + if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0) abort(); if (strnlen(str, len) == len) str[len - 1] = 0; - + if (str[strlen(str) - 1] == '\n') str[strlen(str) - 1] = 0; - + fclose(f); } } @@ -173,35 +173,35 @@ main (int argc, char **argv) { char unameinfo[80]; char gccinfo[80]; - + system_string("uname -a", unameinfo, sizeof(unameinfo)); system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo)); - - printf ("void lib_assert_wire_constants (void)\n" - "{\n" + + printf ("void lib_assert_wire_constants (void)\n" + "{\n" " /* Wire protocol assertions generated by 'wirecheck'\n" " * running on %s\n" " * with %s */\n" "\n", unameinfo, gccinfo); - - BLANK_LINE (); - - COMMENT ("Constants..."); - CHECK_DEFINE (PORTALS_PROTO_MAGIC); - CHECK_DEFINE (PORTALS_PROTO_VERSION_MAJOR); - CHECK_DEFINE (PORTALS_PROTO_VERSION_MINOR); - - CHECK_VALUE (PTL_MSG_ACK); - CHECK_VALUE (PTL_MSG_PUT); - CHECK_VALUE (PTL_MSG_GET); - CHECK_VALUE (PTL_MSG_REPLY); - CHECK_VALUE (PTL_MSG_HELLO); - - check_ptl_handle_wire (); - check_ptl_magicversion (); - check_ptl_hdr (); - - printf ("}\n\n"); - - return (0); + + BLANK_LINE (); + + COMMENT ("Constants..."); + CHECK_DEFINE (PORTALS_PROTO_MAGIC); + CHECK_DEFINE (PORTALS_PROTO_VERSION_MAJOR); + CHECK_DEFINE (PORTALS_PROTO_VERSION_MINOR); + + CHECK_VALUE (PTL_MSG_ACK); + CHECK_VALUE (PTL_MSG_PUT); + CHECK_VALUE (PTL_MSG_GET); + CHECK_VALUE (PTL_MSG_REPLY); + CHECK_VALUE (PTL_MSG_HELLO); + + check_ptl_handle_wire (); + check_ptl_magicversion (); + check_ptl_hdr (); + + printf ("}\n\n"); + + return (0); } diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 8fdcb68..b516587 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -40,7 +40,7 @@ cleanup() { if [ $activemds != "mds" ]; then fail mds fi - zconf_umount $MOUNT + zconf_umount `hostname` $MOUNT stop mds ${FORCE} $MDSLCONFARGS stop ost2 ${FORCE} --dump cleanup.log stop ost ${FORCE} --dump cleanup.log @@ -62,7 +62,7 @@ setup() { start ost2 --reformat $OSTLCONFARGS [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE start mds $MDSLCONFARGS --reformat - zconf_mount $MOUNT + zconf_mount `hostname` $MOUNT } $SETUP -- 1.8.3.1