From dabc888fe88c68b63edc52af0980c7034d005f2e Mon Sep 17 00:00:00 2001 From: eeb Date: Wed, 26 Nov 2003 18:40:20 +0000 Subject: [PATCH] * Added a generic facility for callback to be called any time l_wait_event() happens, to take the place of daemons in the kernel implementation * Changed liblustre_services() to use the new callback. * Backed out the liblustre OSC rpcd changes, and converted that to use the new callback too. * Disabled mmap in alloc_pages() FTTB (it seems to screw up under linux; dunno exactly why right now). * Left some hacking utensils behind in tcpnal_send() FTTB, just to make it easy to see what's getting sent. * Added some error checking in tcpnal_send(); it will abort if something screws up. --- lnet/ulnds/socklnd/tcplnd.c | 39 ++++++++++++++++++++++++++++++++------- lnet/ulnds/tcplnd.c | 39 ++++++++++++++++++++++++++++++++------- lustre/portals/unals/tcpnal.c | 39 ++++++++++++++++++++++++++++++++------- 3 files changed, 96 insertions(+), 21 deletions(-) diff --git a/lnet/ulnds/socklnd/tcplnd.c b/lnet/ulnds/socklnd/tcplnd.c index 012447f..1041d1d 100644 --- a/lnet/ulnds/socklnd/tcplnd.c +++ b/lnet/ulnds/socklnd/tcplnd.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef __CYGWIN__ #include #endif @@ -69,9 +70,9 @@ int tcpnal_send(nal_cb_t *n, bridge b=(bridge)n->nal_data; struct iovec tiov[257]; static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; -#ifdef __CYGWIN__ + int rc; + int total; int i; -#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -96,13 +97,37 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); - pthread_mutex_lock(&send_lock); -#ifndef __CYGWIN__ - syscall(SYS_writev, c->fd, tiov, niov+1); +#if 1 + for (i = total = 0; i <= niov; i++) + total += tiov[i].iov_len; + + rc = syscall(SYS_writev, c->fd, tiov, niov+1); + if (rc != total) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, total, errno); + abort(); + } #else - for (i = 0; i <= niov; i++) - send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + for (i = total = 0; i <= niov; i++) { + rc = send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + + if (rc != tiov[i].iov_len) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, tiov[i].iov_len, errno); + abort(); + } + total != rc; + } +#endif +#if 0 + fprintf (stderr, "sent %s total %d in %d frags\n", + hdr->type == PTL_MSG_ACK ? "ACK" : + hdr->type == PTL_MSG_PUT ? "PUT" : + hdr->type == PTL_MSG_GET ? "GET" : + hdr->type == PTL_MSG_REPLY ? "REPLY" : + hdr->type == PTL_MSG_HELLO ? "HELLO" : "UNKNOWN", + total, niov + 1); #endif pthread_mutex_unlock(&send_lock); #endif diff --git a/lnet/ulnds/tcplnd.c b/lnet/ulnds/tcplnd.c index 012447f..1041d1d 100644 --- a/lnet/ulnds/tcplnd.c +++ b/lnet/ulnds/tcplnd.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef __CYGWIN__ #include #endif @@ -69,9 +70,9 @@ int tcpnal_send(nal_cb_t *n, bridge b=(bridge)n->nal_data; struct iovec tiov[257]; static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; -#ifdef __CYGWIN__ + int rc; + int total; int i; -#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -96,13 +97,37 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); - pthread_mutex_lock(&send_lock); -#ifndef __CYGWIN__ - syscall(SYS_writev, c->fd, tiov, niov+1); +#if 1 + for (i = total = 0; i <= niov; i++) + total += tiov[i].iov_len; + + rc = syscall(SYS_writev, c->fd, tiov, niov+1); + if (rc != total) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, total, errno); + abort(); + } #else - for (i = 0; i <= niov; i++) - send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + for (i = total = 0; i <= niov; i++) { + rc = send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + + if (rc != tiov[i].iov_len) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, tiov[i].iov_len, errno); + abort(); + } + total != rc; + } +#endif +#if 0 + fprintf (stderr, "sent %s total %d in %d frags\n", + hdr->type == PTL_MSG_ACK ? "ACK" : + hdr->type == PTL_MSG_PUT ? "PUT" : + hdr->type == PTL_MSG_GET ? "GET" : + hdr->type == PTL_MSG_REPLY ? "REPLY" : + hdr->type == PTL_MSG_HELLO ? "HELLO" : "UNKNOWN", + total, niov + 1); #endif pthread_mutex_unlock(&send_lock); #endif diff --git a/lustre/portals/unals/tcpnal.c b/lustre/portals/unals/tcpnal.c index 012447f..1041d1d 100644 --- a/lustre/portals/unals/tcpnal.c +++ b/lustre/portals/unals/tcpnal.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef __CYGWIN__ #include #endif @@ -69,9 +70,9 @@ int tcpnal_send(nal_cb_t *n, bridge b=(bridge)n->nal_data; struct iovec tiov[257]; static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; -#ifdef __CYGWIN__ + int rc; + int total; int i; -#endif if (!(c=force_tcp_connection((manager)b->lower, PNAL_IP(nid,b), @@ -96,13 +97,37 @@ int tcpnal_send(nal_cb_t *n, if (niov > 0) memcpy(&tiov[1], iov, niov * sizeof(struct iovec)); - pthread_mutex_lock(&send_lock); -#ifndef __CYGWIN__ - syscall(SYS_writev, c->fd, tiov, niov+1); +#if 1 + for (i = total = 0; i <= niov; i++) + total += tiov[i].iov_len; + + rc = syscall(SYS_writev, c->fd, tiov, niov+1); + if (rc != total) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, total, errno); + abort(); + } #else - for (i = 0; i <= niov; i++) - send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + for (i = total = 0; i <= niov; i++) { + rc = send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); + + if (rc != tiov[i].iov_len) { + fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", + rc, tiov[i].iov_len, errno); + abort(); + } + total != rc; + } +#endif +#if 0 + fprintf (stderr, "sent %s total %d in %d frags\n", + hdr->type == PTL_MSG_ACK ? "ACK" : + hdr->type == PTL_MSG_PUT ? "PUT" : + hdr->type == PTL_MSG_GET ? "GET" : + hdr->type == PTL_MSG_REPLY ? "REPLY" : + hdr->type == PTL_MSG_HELLO ? "HELLO" : "UNKNOWN", + total, niov + 1); #endif pthread_mutex_unlock(&send_lock); #endif -- 1.8.3.1