From 5fcc317062ca6a11f9846129373294019e92060b Mon Sep 17 00:00:00 2001 From: eeb Date: Wed, 11 Jun 2003 18:04:56 +0000 Subject: [PATCH] * Merged latest b_devel * **** NOT TESTED **** --- lnet/Makefile.am | 2 +- lnet/archdep.m4 | 128 ++++++- lnet/build.m4 | 6 +- lnet/configure.in | 4 +- lnet/doc/ieee.bst | 2 - lnet/doc/portals3.lyx | 2 - lnet/include/linux/kp30.h | 74 +++-- lnet/include/lnet/defines.h | 1 - lnet/include/lnet/internal.h | 1 - lnet/include/lnet/lib-lnet.h | 27 +- lnet/include/lnet/lib-p30.h | 27 +- lnet/include/lnet/lib-types.h | 16 +- lnet/include/lnet/list.h | 9 +- lnet/include/lnet/lnetctl.h | 1 + lnet/include/lnet/myrnal.h | 1 - lnet/include/lnet/nal.h | 1 - lnet/include/lnet/ppid.h | 1 - lnet/include/lnet/ptlctl.h | 1 + lnet/include/lnet/stringtab.h | 1 - lnet/klnds/Makefile.am | 1 + lnet/klnds/qswlnd/qswlnd.c | 42 ++- lnet/klnds/qswlnd/qswlnd.h | 25 +- lnet/klnds/qswlnd/qswlnd_cb.c | 37 +-- lnet/klnds/socklnd/socklnd.c | 13 +- lnet/klnds/socklnd/socklnd.h | 9 +- lnet/klnds/socklnd/socklnd_cb.c | 25 +- lnet/klnds/toelnd/toenal.c | 2 +- lnet/klnds/toelnd/toenal.h | 4 +- lnet/klnds/toelnd/toenal_cb.c | 11 +- lnet/libcfs/debug.c | 21 +- lnet/libcfs/module.c | 18 +- lnet/libcfs/proc.c | 4 +- lnet/lnet/lib-init.c | 2 + lnet/lnet/lib-md.c | 2 +- lnet/lnet/lib-move.c | 92 +++++ lnet/portalsconf.m4 | 118 ------- lnet/router/router.c | 6 +- lnet/router/router.h | 4 +- lnet/ulnds/Makefile.am | 2 +- lnet/ulnds/connection.c | 7 +- lnet/ulnds/connection.h | 12 +- lnet/ulnds/socklnd/Makefile.am | 2 +- lnet/ulnds/socklnd/connection.c | 7 +- lnet/ulnds/socklnd/connection.h | 12 +- lnet/ulnds/socklnd/tcplnd.c | 18 +- lnet/ulnds/tcplnd.c | 18 +- lnet/utils/.cvsignore | 1 + lnet/utils/Makefile.am | 4 +- lnet/utils/portals.c | 130 +++----- lnet/utils/ptlctl.c | 1 + lustre/kernel_patches/patches/iopen-2.4.19.patch | 407 ----------------------- lustre/kernel_patches/pc/iopen-2.4.19.pc | 8 - lustre/portals/Makefile.am | 2 +- lustre/portals/archdep.m4 | 128 ++++++- lustre/portals/build.m4 | 6 +- lustre/portals/configure.in | 4 +- lustre/portals/doc/ieee.bst | 2 - lustre/portals/doc/portals3.lyx | 2 - lustre/portals/include/linux/kp30.h | 74 +++-- lustre/portals/include/portals/defines.h | 1 - lustre/portals/include/portals/lib-p30.h | 27 +- lustre/portals/include/portals/lib-types.h | 16 +- lustre/portals/include/portals/list.h | 9 +- lustre/portals/include/portals/myrnal.h | 1 - lustre/portals/include/portals/nal.h | 1 - lustre/portals/include/portals/ppid.h | 1 - lustre/portals/include/portals/ptlctl.h | 1 + lustre/portals/include/portals/stringtab.h | 1 - lustre/portals/knals/Makefile.am | 1 + lustre/portals/knals/qswnal/qswnal.c | 42 ++- lustre/portals/knals/qswnal/qswnal.h | 25 +- lustre/portals/knals/qswnal/qswnal_cb.c | 37 +-- lustre/portals/knals/socknal/socknal.c | 13 +- lustre/portals/knals/socknal/socknal.h | 9 +- lustre/portals/knals/socknal/socknal_cb.c | 25 +- lustre/portals/knals/toenal/toenal.c | 2 +- lustre/portals/knals/toenal/toenal.h | 4 +- lustre/portals/knals/toenal/toenal_cb.c | 11 +- lustre/portals/libcfs/debug.c | 21 +- lustre/portals/libcfs/module.c | 18 +- lustre/portals/libcfs/proc.c | 4 +- lustre/portals/portals/lib-init.c | 2 + lustre/portals/portals/lib-md.c | 2 +- lustre/portals/portals/lib-move.c | 92 +++++ lustre/portals/portalsconf.m4 | 118 ------- lustre/portals/router/router.c | 6 +- lustre/portals/router/router.h | 4 +- lustre/portals/unals/Makefile.am | 2 +- lustre/portals/unals/connection.c | 7 +- lustre/portals/unals/connection.h | 12 +- lustre/portals/unals/tcpnal.c | 18 +- lustre/portals/utils/.cvsignore | 1 + lustre/portals/utils/Makefile.am | 4 +- lustre/portals/utils/portals.c | 130 +++----- lustre/portals/utils/ptlctl.c | 1 + 95 files changed, 1051 insertions(+), 1206 deletions(-) delete mode 100644 lnet/portalsconf.m4 delete mode 100644 lustre/kernel_patches/patches/iopen-2.4.19.patch delete mode 100644 lustre/kernel_patches/pc/iopen-2.4.19.pc delete mode 100644 lustre/portals/portalsconf.m4 diff --git a/lnet/Makefile.am b/lnet/Makefile.am index 1c28b649..1a223f2 100644 --- a/lnet/Makefile.am +++ b/lnet/Makefile.am @@ -3,7 +3,7 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution -EXTRA_DIST = Rules.linux archdep.m4 MCP +EXTRA_DIST = Rules.linux archdep.m4 include DIST_SUBDIRS = libcfs portals knals unals utils tests doc router if LIBLUSTRE SUBDIRS = portals unals utils diff --git a/lnet/archdep.m4 b/lnet/archdep.m4 index 1062040..65ca1ada 100644 --- a/lnet/archdep.m4 +++ b/lnet/archdep.m4 @@ -145,7 +145,7 @@ fi # ------------ include paths ------------------ if test $host_cpu != "lib" ; then - KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include -I$(LINUX)/include' + KINCFLAGS="-I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include -I$LINUX/include" else KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include' fi @@ -190,19 +190,129 @@ if test $host_cpu != "lib" ; then fi fi -# ---------- SMP ------------------- -#AC_MSG_CHECKING(for SMP) -#if egrep -e SMP=y $LINUX/.config >/dev/null 2>&1; then -# SMPFLAG= -# AC_MSG_RESULT(yes) +# ---------- Portals flags -------------------- + +#AC_PREFIX_DEFAULT([]) +#if test "x$prefix" = xNONE || test "x$prefix" = x; then +# usrprefix=/usr #else -# SMPFLAG= -# AC_MSG_RESULT(no) +# usrprefix='${prefix}' #fi +#AC_SUBST(usrprefix) + +AC_MSG_CHECKING(if kernel has CPU affinity support) +if test "$target_cpu" != ia64 ; then + enable_affinity_temp="-DCPU_AFFINITY=1" + AC_MSG_RESULT(yes) +else + enable_affinity_temp="" + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(if kernel has zero-copy TCP support) +ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" +if test "$ZCCD" != 0 ; then + enable_zerocopy_temp="-DSOCKNAL_ZC=1" + AC_MSG_RESULT(yes) +else + enable_zerocopy_temp="" + AC_MSG_RESULT(no) +fi + +AC_ARG_ENABLE(zerocopy, [ --enable-zerocopy enable socknal zerocopy],enable_zerocopy=$enable_zerocopy_temp, enable_zerocopy="") + +AC_ARG_ENABLE(affinity, [ --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp) +##################################### + +AC_MSG_CHECKING(if quadrics kernel headers are present) +if test -d $LINUX/drivers/net/qsnet ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/net/qsnet/include" + : +elif test -d $LINUX/drivers/qsnet1 ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/qsnet1/include -DPROPRIETARY_ELAN" + : +elif test -d $LINUX/drivers/quadrics ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/quadrics/include -DPROPRIETARY_ELAN" + : +#elif test -d /usr/include/elan3 ; then +# AC_MSG_RESULT(yes) +# QSWNAL="qswnal" +# with_quadrics="" +# : +else + AC_MSG_RESULT(no) + QSWNAL="" + with_quadrics="" + : +fi +AC_SUBST(with_quadrics) +AC_SUBST(QSWNAL) + +# R. Read 5/02 +GMNAL="" +echo "checking with-gm=" ${with_gm} +if test "${with_gm+set}" = set; then + if test "${with_gm}" = yes; then + with_gm="-I/usr/local/gm/include" + else + with_gm=-I"$with_gm/include" + fi + GMNAL="gmnal" +else +# default case - no GM + with_gm="" +fi +AC_SUBST(with_gm) +AC_SUBST(GMNAL) + + +def_scamac=/opt/scali/include +AC_ARG_WITH(scamac, [ --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac) +AC_MSG_CHECKING(if ScaMAC headers are present) +if test "$with_scamac" = yes; then + with_scamac=$def_scamac +fi +if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then + AC_MSG_RESULT(yes) + SCIMACNAL="scimacnal" + with_scamac="-I${with_scamac} -I${with_scamac}/icm" +else + AC_MSG_RESULT(no) + SCIMACNAL="" + with_scamac="" +fi + +AC_SUBST(with_scamac) +AC_SUBST(SCIMACNAL) CFLAGS="$KCFLAGS" -CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS " +CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS $enable_zerocopy $enable_affinity $with_quadrics $with_gm $with_scamac " AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib) AC_SUBST(MOD_LINK) AC_SUBST(LINUX25) +AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib) + +# ---------- Red Hat 2.4.20 backports some 2.5 bits -------- +# This needs to run after we've defined the KCPPFLAGS + +AC_MSG_CHECKING(for kernel version) +AC_TRY_LINK([#define __KERNEL__ + #include ], + [struct task_struct p; + p.sighand = NULL;], + [RH_2_4_20=1], + [RH_2_4_20=0]) + +if test $RH_2_4_20 = 1; then + AC_MSG_RESULT(redhat-2.4.20) + CPPFLAGS="$CPPFLAGS -DCONFIG_RH_2_4_20" +else + AC_MSG_RESULT($RELEASE) +fi diff --git a/lnet/build.m4 b/lnet/build.m4 index 2f2b9e4..025f243 100644 --- a/lnet/build.m4 +++ b/lnet/build.m4 @@ -1,5 +1,4 @@ - -# ---------- directories --------- +# ---------- other tests and settings --------- # --------- unsigned long long sane? ------- @@ -94,6 +93,3 @@ fi AC_SUBST(LIBEFENCE) AC_SUBST(HAVE_LIBEFENCE) -# end -------- Kernel build environment. ----------------- - - diff --git a/lnet/configure.in b/lnet/configure.in index 2ee86b2..31d3492 100644 --- a/lnet/configure.in +++ b/lnet/configure.in @@ -13,7 +13,6 @@ AM_INIT_AUTOMAKE(portals, builtin([esyscmd], [sed -ne '/.*define IVERSION /{ s/. sinclude(build.m4) sinclude(archdep.m4) -sinclude(portalsconf.m4) if test x$enable_inkernel = xyes ; then cp Kernelenv.mk Kernelenv.in @@ -31,6 +30,5 @@ AC_OUTPUT([Makefile Kernelenv libcfs/Makefile portals/Makefile \ unals/Makefile knals/Makefile router/Makefile \ knals/socknal/Makefile knals/gmnal/Makefile knals/qswnal/Makefile \ knals/scimacnal/Makefile knals/toenal/Makefile \ - utils/Makefile tests/Makefile doc/Makefile \ - packaging/Makefile packaging/portals.spec ]) + utils/Makefile tests/Makefile doc/Makefile ]) diff --git a/lnet/doc/ieee.bst b/lnet/doc/ieee.bst index 0ef514e..4df7c50 100644 --- a/lnet/doc/ieee.bst +++ b/lnet/doc/ieee.bst @@ -1,7 +1,5 @@ % --------------------------------------------------------------- % -% $Id: ieee.bst,v 1.1.4.1 2003/05/19 17:04:11 meijia Exp $ -% % by Paolo.Ienne@di.epfl.ch % % --------------------------------------------------------------- diff --git a/lnet/doc/portals3.lyx b/lnet/doc/portals3.lyx index b59eb1f..8429280 100644 --- a/lnet/doc/portals3.lyx +++ b/lnet/doc/portals3.lyx @@ -7,8 +7,6 @@ {\begin{quote}\textbf{Discussion}: \slshape}% {\end{quote}} \pagestyle{myheadings} -\markboth{$Revision: 1.1.4.1 $\hfil$Date: 2003/05/19 17:04:12 $}% -{$Date: 2003/05/19 17:04:12 $\hfil$Revision: 1.1.4.1 $} \end_preamble \language american \inputencoding auto diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index 46d9406..afb2104 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -4,6 +4,9 @@ #ifndef _KP30_INCLUDED #define _KP30_INCLUDED +#ifdef __KERNEL__ +#include +#endif #define PORTAL_DEBUG @@ -83,45 +86,42 @@ extern unsigned int portal_printk; #ifndef __KERNEL__ #define THREAD_SIZE 8192 #endif -#ifdef __arch_ia64__ -#define CDEBUG_STACK(var) (&var & (THREAD_SIZE - 1)) +#ifdef __ia64__ +#define CDEBUG_STACK() (THREAD_SIZE - \ + ((unsigned long)__builtin_dwarf_cfa() & \ + (THREAD_SIZE - 1))) #else -#define CDEBUG_STACK(var) (THREAD_SIZE - \ - ((unsigned long)__builtin_frame_address(0)& \ - (THREAD_SIZE - 1))) +#define CDEBUG_STACK() (THREAD_SIZE - \ + ((unsigned long)__builtin_frame_address(0) & \ + (THREAD_SIZE - 1))) #endif #ifdef __KERNEL__ #define CHECK_STACK(stack) \ do { \ - if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) \ + if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \ portals_debug_msg(DEBUG_SUBSYSTEM, D_ERROR, \ __FILE__, __FUNCTION__, __LINE__, \ (stack), \ "maximum lustre stack %u\n", \ portal_stack = (stack)); \ + /*panic("LBUG");*/ \ + } \ } while (0) #else -#define CHECK_STACK(stack) do{}while(0) +#define CHECK_STACK(stack) do { } while(0) #endif +#if 1 #define CDEBUG(mask, format, a...) \ do { \ - unsigned long stack = CDEBUG_STACK(stack); \ - int match = 0; \ - \ - CHECK_STACK(stack); \ - if (!(mask)) \ - match = 1; \ - else if ((mask) & (D_ERROR | D_EMERG)) \ - match = 1; \ - else if (portal_debug & (mask) && \ - portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))) \ - match = 1; \ - if (match) \ + CHECK_STACK(CDEBUG_STACK()); \ + if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) || \ + (portal_debug & (mask) && \ + portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24)))) \ portals_debug_msg(DEBUG_SUBSYSTEM, mask, \ __FILE__, __FUNCTION__, __LINE__, \ - stack, format , ## a); \ + CDEBUG_STACK(), format , ## a); \ } while (0) #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a) @@ -140,10 +140,8 @@ do { \ #define RETURN(rc) \ do { \ typeof(rc) RETURN__ret = (rc); \ - long tmp = (long)RETURN__ret; \ CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \ - (unsigned long)tmp, (signed long)tmp, \ - (signed long)tmp); \ + (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\ return RETURN__ret; \ } while (0) @@ -156,6 +154,16 @@ do { \ do { \ CDEBUG(D_TRACE, "Process leaving\n"); \ } while(0) +#else +#define CDEBUG(mask, format, a...) do { } while (0) +#define CWARN(format, a...) do { } while (0) +#define CERROR(format, a...) printk("<3>" format, ## a) +#define CEMERG(format, a...) printk("<0>" format, ## a) +#define GOTO(label, rc) do { (void)(rc); goto label; } while (0) +#define RETURN(rc) return (rc) +#define ENTRY do { } while (0) +#define EXIT do { } while (0) +#endif #ifdef __KERNEL__ @@ -213,24 +221,26 @@ extern void kportal_assertion_failed(char *expr,char *file,char *func,int line); #endif #ifdef __arch_um__ -#define LBUG() \ +#define LBUG_WITH_LOC(file, func, line) \ do { \ CEMERG("LBUG - trying to dump log to /tmp/lustre-log\n"); \ portals_debug_dumplog(); \ - portals_run_lbug_upcall(__FILE__, __FUNCTION__, __LINE__); \ + portals_run_lbug_upcall(file, func, line); \ panic("LBUG"); \ } while (0) #else -#define LBUG() \ +#define LBUG_WITH_LOC(file, func, line) \ do { \ CEMERG("LBUG\n"); \ portals_debug_dumplog(); \ - portals_run_lbug_upcall(__FILE__, __FUNCTION__, __LINE__); \ + portals_run_lbug_upcall(file, func, line); \ set_task_state(current, TASK_UNINTERRUPTIBLE); \ schedule(); \ } while (0) #endif /* __arch_um__ */ +#define LBUG() LBUG_WITH_LOC(__FILE__, __FUNCTION__, __LINE__) + /* * Memory */ @@ -260,7 +270,7 @@ do { \ if (s > PORTAL_VMALLOC_SIZE) \ (ptr) = vmalloc(s); \ else \ - (ptr) = kmalloc(s, GFP_KERNEL); \ + (ptr) = kmalloc(s, GFP_NOFS); \ if ((ptr) == NULL) \ CERROR("PORTALS: out of memory at %s:%d (tried to alloc" \ " '" #ptr "' = %ld)\n", __FILE__, __LINE__, s); \ @@ -460,8 +470,8 @@ kpr_lookup (kpr_router_t *router, ptl_nid_t nid, ptl_nid_t *gateway_nid) } static inline void -kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, - int nob, int niov, struct iovec *iov, +kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, + int nob, int niov, struct iovec *iov, kpr_fwd_callback_t callback, void *callback_arg) { fwd->kprfd_target_nid = nid; @@ -605,7 +615,7 @@ extern void kportal_blockallsigs (void); # ifdef PORTAL_DEBUG # undef NDEBUG # include -# define LASSERT(e) assert(e) +# define LASSERT(e) assert(e) # else # define LASSERT(e) # endif @@ -909,7 +919,7 @@ void kportal_put_ni (int nal); #ifndef BITS_PER_LONG #if (~0UL) == 0xffffffffUL #define BITS_PER_LONG 32 -#else +#else #define BITS_PER_LONG 64 #endif #endif diff --git a/lnet/include/lnet/defines.h b/lnet/include/lnet/defines.h index a7580b5..785ce73 100644 --- a/lnet/include/lnet/defines.h +++ b/lnet/include/lnet/defines.h @@ -1,5 +1,4 @@ /* -** $Id: defines.h,v 1.1.4.1 2003/05/19 17:04:13 meijia Exp $ ** ** This files contains definitions that are used throughout the cplant code. */ diff --git a/lnet/include/lnet/internal.h b/lnet/include/lnet/internal.h index 813e835..d78cad4 100644 --- a/lnet/include/lnet/internal.h +++ b/lnet/include/lnet/internal.h @@ -1,5 +1,4 @@ /* -** $Id: internal.h,v 1.1.4.1 2003/05/19 17:04:13 meijia Exp $ */ #ifndef _P30_INTERNAL_H_ #define _P30_INTERNAL_H_ diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index b70e128..b623b93 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -170,10 +170,10 @@ lib_msg_free (nal_cb_t *nal, lib_msg_t *msg) #else -extern kmem_cache_t *ptl_md_slab; -extern kmem_cache_t *ptl_msg_slab; -extern kmem_cache_t *ptl_me_slab; -extern kmem_cache_t *ptl_eq_slab; +extern kmem_cache_t *ptl_md_slab; +extern kmem_cache_t *ptl_msg_slab; +extern kmem_cache_t *ptl_me_slab; +extern kmem_cache_t *ptl_eq_slab; extern atomic_t md_in_use_count; extern atomic_t msg_in_use_count; extern atomic_t me_in_use_count; @@ -183,28 +183,28 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL); - + lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + if (eq == NULL) return (NULL); - + atomic_inc (&eq_in_use_count); return (eq); } -static inline void +static inline void lib_eq_free (nal_cb_t *nal, lib_eq_t *eq) { /* ALWAYS called with statelock held */ atomic_dec (&eq_in_use_count); - kmem_cache_free(ptl_eq_slab, eq); + kmem_cache_free(ptl_eq_slab, eq); } static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); + lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); if (md == NULL) return (NULL); @@ -225,11 +225,11 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL); + lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); if (me == NULL) return (NULL); - + atomic_inc (&me_in_use_count); return (me); } @@ -246,7 +246,7 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); if (msg == NULL) return (NULL); @@ -370,6 +370,7 @@ extern void lib_copy_buf2iov (int niov, struct iovec *iov, char *dest, ptl_size_ extern ptl_size_t lib_kiov_nob (int niov, ptl_kiov_t *iov); extern void lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *iov, ptl_size_t len); extern void lib_copy_buf2kiov (int niov, ptl_kiov_t *iov, char *src, ptl_size_t len); +extern void lib_assert_wire_constants (void); extern void lib_recv (nal_cb_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen); diff --git a/lnet/include/lnet/lib-p30.h b/lnet/include/lnet/lib-p30.h index b70e128..b623b93 100644 --- a/lnet/include/lnet/lib-p30.h +++ b/lnet/include/lnet/lib-p30.h @@ -170,10 +170,10 @@ lib_msg_free (nal_cb_t *nal, lib_msg_t *msg) #else -extern kmem_cache_t *ptl_md_slab; -extern kmem_cache_t *ptl_msg_slab; -extern kmem_cache_t *ptl_me_slab; -extern kmem_cache_t *ptl_eq_slab; +extern kmem_cache_t *ptl_md_slab; +extern kmem_cache_t *ptl_msg_slab; +extern kmem_cache_t *ptl_me_slab; +extern kmem_cache_t *ptl_eq_slab; extern atomic_t md_in_use_count; extern atomic_t msg_in_use_count; extern atomic_t me_in_use_count; @@ -183,28 +183,28 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL); - + lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + if (eq == NULL) return (NULL); - + atomic_inc (&eq_in_use_count); return (eq); } -static inline void +static inline void lib_eq_free (nal_cb_t *nal, lib_eq_t *eq) { /* ALWAYS called with statelock held */ atomic_dec (&eq_in_use_count); - kmem_cache_free(ptl_eq_slab, eq); + kmem_cache_free(ptl_eq_slab, eq); } static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); + lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); if (md == NULL) return (NULL); @@ -225,11 +225,11 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL); + lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); if (me == NULL) return (NULL); - + atomic_inc (&me_in_use_count); return (me); } @@ -246,7 +246,7 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); if (msg == NULL) return (NULL); @@ -370,6 +370,7 @@ extern void lib_copy_buf2iov (int niov, struct iovec *iov, char *dest, ptl_size_ extern ptl_size_t lib_kiov_nob (int niov, ptl_kiov_t *iov); extern void lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *iov, ptl_size_t len); extern void lib_copy_buf2kiov (int niov, ptl_kiov_t *iov, char *src, ptl_size_t len); +extern void lib_assert_wire_constants (void); extern void lib_recv (nal_cb_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen); diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index bece0a30..47c0dd2 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -31,6 +31,8 @@ typedef struct lib_me_t lib_me_t; typedef struct lib_md_t lib_md_t; typedef struct lib_eq_t lib_eq_t; +#define WIRE_ATTR __attribute__((packed)) + /* The wire handle's interface cookie only matches one network interface in * one epoch (i.e. new cookie when the interface restarts or the node * reboots). The object cookie only matches one object on that interface @@ -38,7 +40,7 @@ typedef struct lib_eq_t lib_eq_t; typedef struct { __u64 wh_interface_cookie; __u64 wh_object_cookie; -} ptl_handle_wire_t; +} WIRE_ATTR ptl_handle_wire_t; /* byte-flip insensitive! */ #define PTL_WIRE_HANDLE_NONE \ @@ -63,7 +65,7 @@ typedef struct ptl_ack { ptl_handle_wire_t dst_wmd; ptl_match_bits_t match_bits; ptl_size_t length; /* common length (0 for acks) moving out RSN */ -} ptl_ack_t; +} WIRE_ATTR ptl_ack_t; typedef struct ptl_put { ptl_pt_index_t ptl_index; @@ -72,7 +74,7 @@ typedef struct ptl_put { ptl_size_t length; /* common length moving out RSN */ ptl_size_t offset; ptl_hdr_data_t hdr_data; -} ptl_put_t; +} WIRE_ATTR ptl_put_t; typedef struct ptl_get { ptl_pt_index_t ptl_index; @@ -82,7 +84,7 @@ typedef struct ptl_get { ptl_size_t src_offset; ptl_size_t return_offset; /* unused: going RSN */ ptl_size_t sink_length; -} ptl_get_t; +} WIRE_ATTR ptl_get_t; typedef struct ptl_reply { __u32 unused1; /* unused fields going RSN */ @@ -90,7 +92,7 @@ typedef struct ptl_reply { ptl_size_t dst_offset; /* unused: going RSN */ __u32 unused2; ptl_size_t length; /* common length moving out RSN */ -} ptl_reply_t; +} WIRE_ATTR ptl_reply_t; typedef struct { ptl_nid_t dest_nid; @@ -104,7 +106,7 @@ typedef struct { ptl_get_t get; ptl_reply_t reply; } msg; -} ptl_hdr_t; +} WIRE_ATTR ptl_hdr_t; /* All length fields in individual unions at same offset */ /* LASSERT for same in lib-move.c */ @@ -122,7 +124,7 @@ typedef struct { __u32 magic; /* PORTALS_PROTO_MAGIC */ __u16 version_major; /* increment on incompatible change */ __u16 version_minor; /* increment on compatible change */ -} ptl_magicversion_t; +} WIRE_ATTR ptl_magicversion_t; #define PORTALS_PROTO_MAGIC 0xeebc0ded diff --git a/lnet/include/lnet/list.h b/lnet/include/lnet/list.h index 41613ab..2b63312 100644 --- a/lnet/include/lnet/list.h +++ b/lnet/include/lnet/list.h @@ -233,14 +233,13 @@ static inline void list_splice_init(struct list_head *list, /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop counter. - * @n: the &struct list_head to use as temporary storage + * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry_safe(pos, n, head, member) \ +#define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = pos->member.next; \ + n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ - pos = list_entry(n, typeof(*pos), member), \ - n = pos->member.next) + pos = n, n = list_entry(n->member.next, typeof(*n), member)) #endif diff --git a/lnet/include/lnet/lnetctl.h b/lnet/include/lnet/lnetctl.h index fdaae69..dc02780 100644 --- a/lnet/include/lnet/lnetctl.h +++ b/lnet/include/lnet/lnetctl.h @@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv); int jt_ptl_disconnect(int argc, char **argv); int jt_ptl_push_connection(int argc, char **argv); int jt_ptl_ping(int argc, char **argv); +int jt_ptl_shownid(int argc, char **argv); int jt_ptl_mynid(int argc, char **argv); int jt_ptl_add_uuid(int argc, char **argv); int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility */ diff --git a/lnet/include/lnet/myrnal.h b/lnet/include/lnet/myrnal.h index d3337218..12b1925 100644 --- a/lnet/include/lnet/myrnal.h +++ b/lnet/include/lnet/myrnal.h @@ -1,5 +1,4 @@ /* -** $Id: myrnal.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ #ifndef MYRNAL_H diff --git a/lnet/include/lnet/nal.h b/lnet/include/lnet/nal.h index 8c035f7..88be63c 100644 --- a/lnet/include/lnet/nal.h +++ b/lnet/include/lnet/nal.h @@ -1,5 +1,4 @@ /* -** $Id: nal.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ #ifndef _NAL_H_ #define _NAL_H_ diff --git a/lnet/include/lnet/ppid.h b/lnet/include/lnet/ppid.h index 28f74e3..4727599 100644 --- a/lnet/include/lnet/ppid.h +++ b/lnet/include/lnet/ppid.h @@ -1,5 +1,4 @@ /* - * TITLE(ppid_h, "@(#) $Id: ppid.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $"); */ #ifndef _INCppidh_ diff --git a/lnet/include/lnet/ptlctl.h b/lnet/include/lnet/ptlctl.h index fdaae69..dc02780 100644 --- a/lnet/include/lnet/ptlctl.h +++ b/lnet/include/lnet/ptlctl.h @@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv); int jt_ptl_disconnect(int argc, char **argv); int jt_ptl_push_connection(int argc, char **argv); int jt_ptl_ping(int argc, char **argv); +int jt_ptl_shownid(int argc, char **argv); int jt_ptl_mynid(int argc, char **argv); int jt_ptl_add_uuid(int argc, char **argv); int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility */ diff --git a/lnet/include/lnet/stringtab.h b/lnet/include/lnet/stringtab.h index 7d3675f..c9683f7 100644 --- a/lnet/include/lnet/stringtab.h +++ b/lnet/include/lnet/stringtab.h @@ -1,5 +1,4 @@ /* -** $Id: stringtab.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ /* * stringtab.h diff --git a/lnet/klnds/Makefile.am b/lnet/klnds/Makefile.am index 5c6085e..fed2785 100644 --- a/lnet/klnds/Makefile.am +++ b/lnet/klnds/Makefile.am @@ -3,4 +3,5 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution +DIST_SUBDIRS= socknal toenal qswnal gmnal scimacnal SUBDIRS= socknal toenal @QSWNAL@ @GMNAL@ @SCIMACNAL@ diff --git a/lnet/klnds/qswlnd/qswlnd.c b/lnet/klnds/qswlnd/qswlnd.c index d64b7ad..1a8fb74 100644 --- a/lnet/klnds/qswlnd/qswlnd.c +++ b/lnet/klnds/qswlnd/qswlnd.c @@ -101,16 +101,36 @@ static nal_t * kqswnal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size, ptl_pid_t requested_pid) { - ptl_nid_t mynid = ep_nodeid (kqswnal_data.kqn_epdev); - int nnids = ep_numnodes (kqswnal_data.kqn_epdev); + ptl_nid_t mynid = kqswnal_elanid2nid (kqswnal_data.kqn_elanid); + int nnids = kqswnal_data.kqn_nnodes; - CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid,nnids); + CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid, nnids); lib_init(&kqswnal_lib, mynid, 0, nnids, ptl_size, ac_size); return (&kqswnal_api); } +int +kqswnal_cmd (struct portal_ioctl_data *data, void *private) +{ + LASSERT (data != NULL); + + switch (data->ioc_nal_cmd) { + case NAL_CMD_REGISTER_MYNID: + CDEBUG (D_IOCTL, "setting NID offset to "LPX64" (was "LPX64")\n", + data->ioc_nid - kqswnal_data.kqn_elanid, + kqswnal_data.kqn_nid_offset); + kqswnal_data.kqn_nid_offset = + data->ioc_nid - kqswnal_data.kqn_elanid; + kqswnal_lib.ni.nid = data->ioc_nid; + return (0); + + default: + return (-EINVAL); + } +} + void __exit kqswnal_finalise (void) { @@ -324,6 +344,10 @@ kqswnal_initialise (void) return (-ENOMEM); } + kqswnal_data.kqn_nid_offset = 0; + kqswnal_data.kqn_nnodes = ep_numnodes (kqswnal_data.kqn_epdev); + kqswnal_data.kqn_elanid = ep_nodeid (kqswnal_data.kqn_epdev); + /**********************************************************************/ /* Get the transmitter */ @@ -477,7 +501,7 @@ kqswnal_initialise (void) LASSERT (krx->krx_npages > 0); for (j = 0; j < krx->krx_npages; j++) { - krx->krx_pages[j] = alloc_page (GFP_KERNEL); + krx->krx_pages[j] = alloc_page(GFP_KERNEL); if (krx->krx_pages[j] == NULL) { kqswnal_finalise (); @@ -554,13 +578,19 @@ kqswnal_initialise (void) rc = kpr_register (&kqswnal_data.kqn_router, &kqswnal_router_interface); CDEBUG(D_NET, "Can't initialise routing interface (rc = %d): not routing\n",rc); + rc = kportal_nal_register (QSWNAL, &kqswnal_cmd, NULL); + if (rc != 0) { + CERROR ("Can't initialise command interface (rc = %d)\n", rc); + kqswnal_finalise (); + return (rc); + } + PORTAL_SYMBOL_REGISTER(kqswnal_ni); kqswnal_data.kqn_init = KQN_INIT_ALL; printk(KERN_INFO "Routing QSW NAL loaded on node %d of %d " "(Routing %s, initial mem %d)\n", - ep_nodeid (kqswnal_data.kqn_epdev), - ep_numnodes (kqswnal_data.kqn_epdev), + kqswnal_data.kqn_elanid, kqswnal_data.kqn_nnodes, kpr_routing (&kqswnal_data.kqn_router) ? "enabled" : "disabled", pkmem); diff --git a/lnet/klnds/qswlnd/qswlnd.h b/lnet/klnds/qswlnd/qswlnd.h index 657b02b..ceb7c8c 100644 --- a/lnet/klnds/qswlnd/qswlnd.h +++ b/lnet/klnds/qswlnd/qswlnd.h @@ -24,7 +24,9 @@ #ifndef _QSWNAL_H #define _QSWNAL_H -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #ifdef PROPRIETARY_ELAN # include @@ -200,6 +202,10 @@ typedef struct ELAN3_DMA_HANDLE *kqn_eptxdmahandle; /* elan reserved tx vaddrs */ ELAN3_DMA_HANDLE *kqn_eprxdmahandle; /* elan reserved rx vaddrs */ kpr_router_t kqn_router; /* connection to Kernel Portals Router module */ + + ptl_nid_t kqn_nid_offset; /* this cluster's NID offset */ + int kqn_nnodes; /* this cluster's size */ + int kqn_elanid; /* this nodes's elan ID */ } kqswnal_data_t; /* kqn_init state */ @@ -217,6 +223,23 @@ extern void kqswnal_rxhandler(EP_RXD *rxd); extern int kqswnal_scheduler (void *); extern void kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd); +static inline ptl_nid_t +kqswnal_elanid2nid (int elanid) +{ + return (kqswnal_data.kqn_nid_offset + elanid); +} + +static inline int +kqswnal_nid2elanid (ptl_nid_t nid) +{ + /* not in this cluster? */ + if (nid < kqswnal_data.kqn_nid_offset || + nid >= kqswnal_data.kqn_nid_offset + kqswnal_data.kqn_nnodes) + return (-1); + + return (nid - kqswnal_data.kqn_nid_offset); +} + static inline void kqswnal_requeue_rx (kqswnal_rx_t *krx) { diff --git a/lnet/klnds/qswlnd/qswlnd_cb.c b/lnet/klnds/qswlnd/qswlnd_cb.c index 5979885..3b47a25 100644 --- a/lnet/klnds/qswlnd/qswlnd_cb.c +++ b/lnet/klnds/qswlnd/qswlnd_cb.c @@ -109,21 +109,15 @@ kqswnal_sti(nal_cb_t *nal, unsigned long *flags) static int kqswnal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist) { - /* network distance doesn't mean much for this nal */ - *dist = (nid == nal->ni.nid) ? 0 : 1; + if (nid == nal->ni.nid) + *dist = 0; /* it's me */ + else if (kqswnal_nid2elanid (nid) >= 0) + *dist = 1; /* it's my peer */ + else + *dist = 2; /* via router */ return (0); } -int -kqswnal_ispeer (ptl_nid_t nid) -{ - unsigned int elanid = (unsigned int)nid; - - /* didn't lose high bits on conversion and it's in this machine? */ - return ((ptl_nid_t)elanid == nid && - elanid < ep_numnodes (kqswnal_data.kqn_epdev)); -} - void kqswnal_unmap_tx (kqswnal_tx_t *ktx) { @@ -453,11 +447,14 @@ kqswnal_launch (kqswnal_tx_t *ktx) { /* Don't block for transmit descriptor if we're in interrupt context */ int attr = in_interrupt() ? (EP_NO_SLEEP | EP_NO_ALLOC) : 0; - int rc = ep_transmit_large(kqswnal_data.kqn_eptx, ktx->ktx_nid, - ktx->ktx_port, attr, kqswnal_txhandler, - ktx, ktx->ktx_iov, ktx->ktx_niov); + int dest = kqswnal_nid2elanid (ktx->ktx_nid); long flags; - + int rc; + + LASSERT (dest >= 0); /* must be a peer */ + rc = ep_transmit_large(kqswnal_data.kqn_eptx, dest, + ktx->ktx_port, attr, kqswnal_txhandler, + ktx, ktx->ktx_iov, ktx->ktx_niov); if (rc == 0) atomic_inc (&kqswnal_packets_launched); @@ -595,7 +592,7 @@ kqswnal_sendmsg (nal_cb_t *nal, return (-1); } - if (!kqswnal_ispeer (nid)) { /* Can't send direct: find gateway? */ + if (kqswnal_nid2elanid (nid) < 0) { /* Can't send direct: find gateway? */ rc = kpr_lookup (&kqswnal_data.kqn_router, nid, &gatewaynid); if (rc != 0) { CERROR("Can't route to "LPX64": router error %d\n", @@ -603,7 +600,7 @@ kqswnal_sendmsg (nal_cb_t *nal, lib_finalize (&kqswnal_lib, private, cookie); return (-1); } - if (!kqswnal_ispeer (gatewaynid)) { + if (kqswnal_nid2elanid (gatewaynid) < 0) { CERROR("Bad gateway "LPX64" for "LPX64"\n", gatewaynid, nid); lib_finalize (&kqswnal_lib, private, cookie); @@ -757,7 +754,7 @@ kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd) if (nid == kqswnal_lib.ni.nid) /* gateway is me */ nid = fwd->kprfd_target_nid; /* target is final dest */ - if (!kqswnal_ispeer (nid)) { + if (kqswnal_nid2elanid (nid) < 0) { CERROR("Can't forward [%p] to "LPX64": not a peer\n", fwd, nid); rc = -EHOSTUNREACH; goto failed; @@ -844,7 +841,7 @@ kqswnal_rx (kqswnal_rx_t *krx) CERROR ("checksums for forwarded packets not implemented\n"); LBUG (); #endif - if (kqswnal_ispeer (dest_nid)) /* should have gone direct to peer */ + if (kqswnal_nid2elanid (dest_nid) >= 0) /* should have gone direct to peer */ { CERROR("dropping packet from "LPX64" for "LPX64 ": target is peer\n", NTOH__u64(hdr->src_nid), dest_nid); diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c index d15d8c8..3e65faa 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -95,10 +95,8 @@ nal_t * ksocknal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size, ptl_pid_t requested_pid) { - CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", - ksocknal_data.ksnd_mynid); - lib_init(&ksocknal_lib, ksocknal_data.ksnd_mynid, 0, 10, ptl_size, - ac_size); + CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", (ptl_nid_t)0); + lib_init(&ksocknal_lib, (ptl_nid_t)0, 0, 10, ptl_size, ac_size); return (&ksocknal_api); } @@ -129,7 +127,6 @@ ksocknal_set_mynid(ptl_nid_t nid) CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n", nid, ni->nid); - ksocknal_data.ksnd_mynid = nid; ni->nid = nid; return (0); } @@ -190,7 +187,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq) if (!conn) GOTO(error, ret); - memset (conn, 0, sizeof (conn)); /* zero for consistency */ + sock->sk->allocation = GFP_NOFS; /* don't call info fs for alloc */ conn->ksnc_file = file; conn->ksnc_sock = sock; @@ -207,7 +204,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq) conn->ksnc_tx_ready = 0; conn->ksnc_tx_scheduled = 0; -#warning check it is OK to derefence sk->dst_cache->dev like this... + /* XXX check it is OK to derefence sk->dst_cache->dev like this... */ lock_sock (conn->ksnc_sock->sk); if (conn->ksnc_sock->sk->dst_cache != NULL) { @@ -818,7 +815,7 @@ ksocknal_module_init (void) LASSERT (fmb->fmb_npages > 0); for (j = 0; j < fmb->fmb_npages; j++) { - fmb->fmb_pages[j] = alloc_page (GFP_KERNEL); + fmb->fmb_pages[j] = alloc_page(GFP_KERNEL); if (fmb->fmb_pages[j] == NULL) { ksocknal_module_fini (); diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h index 46ee3b7..62f9265 100644 --- a/lnet/klnds/socklnd/socklnd.h +++ b/lnet/klnds/socklnd/socklnd.h @@ -25,7 +25,9 @@ */ #define DEBUG_PORTAL_ALLOC -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include @@ -106,7 +108,6 @@ typedef struct { struct list_head ksnd_socklist; /* all my connections */ rwlock_t ksnd_socklist_lock; /* stabilise add/find/remove */ - ptl_nid_t ksnd_mynid; nal_cb_t *ksnd_nal_cb; spinlock_t ksnd_nal_cb_lock; /* lib cli/sti lock */ @@ -273,9 +274,9 @@ extern void ksocknal_close_conn (ksock_conn_t *conn); static inline void ksocknal_put_conn (ksock_conn_t *conn) { - CDEBUG (D_OTHER, "putting conn[%p] -> "LPX64" (%d)\n", + CDEBUG (D_OTHER, "putting conn[%p] -> "LPX64" (%d)\n", conn, conn->ksnc_peernid, atomic_read (&conn->ksnc_refcount)); - + if (atomic_dec_and_test (&conn->ksnc_refcount)) _ksocknal_put_conn (conn); } diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c index 6cf3cc4..3e7d206 100644 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ b/lnet/klnds/socklnd/socklnd_cb.c @@ -589,7 +589,6 @@ ksocknal_process_transmit (ksock_sched_t *sched, long *irq_flags) CDEBUG (D_NET, "send(%d) %d\n", tx->tx_nob, rc); if (rc != 0) { -#warning FIXME: handle socket errors properly CERROR("Error socknal send(%d) %p: %d\n", tx->tx_nob, conn, rc); /* kid on for now the whole packet went. * NB when we handle the error better, we'll still need to @@ -740,15 +739,16 @@ ksocknal_setup_hdr (nal_cb_t *nal, void *private, lib_msg_t *cookie, } int -ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, +ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, struct iovec *payload_iov, size_t payload_len) + unsigned int payload_niov, struct iovec *payload_iov, + size_t payload_len) { ksock_ltx_t *ltx; ksock_conn_t *conn; - + /* NB 'private' is different depending on what we're sending. - * Just ignore it until we can rely on it + * Just ignore it until we can rely on it * * Also, the return code from this procedure is ignored. * If we can't send, we must still complete with lib_finalize(). @@ -756,31 +756,31 @@ ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, */ CDEBUG(D_NET, - "sending "LPSZ" bytes in %d mapped frags to nid: "LPX64" pid %d\n", - payload_len, payload_niov, nid, pid); + "sending "LPSZ" bytes in %d mapped frags to nid: "LPX64 + " pid %d\n", payload_len, payload_niov, nid, pid); conn = ksocknal_send_target (nid); if (conn == NULL) { lib_finalize (&ksocknal_lib, private, cookie); return (-1); } - + ltx = ksocknal_setup_hdr (nal, private, cookie, hdr, type); if (ltx == NULL) { ksocknal_put_conn (conn); lib_finalize (&ksocknal_lib, private, cookie); return (-1); } - + /* append the payload_iovs to the one pointing at the header */ LASSERT (ltx->ltx_tx.tx_niov == 1 && ltx->ltx_tx.tx_nkiov == 0); LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - memcpy (ltx->ltx_tx.tx_iov + 1, payload_iov, + + memcpy (ltx->ltx_tx.tx_iov + 1, payload_iov, payload_niov * sizeof (*payload_iov)); ltx->ltx_tx.tx_niov = 1 + payload_niov; ltx->ltx_tx.tx_nob = sizeof (*hdr) + payload_len; - + ksocknal_launch_packet (conn, <x->ltx_tx); return (0); } @@ -1224,7 +1224,6 @@ ksocknal_process_receive (ksock_sched_t *sched, long *irq_flags) if (rc == 0) goto out; if (rc < 0) { -#warning FIXME: handle socket errors properly CERROR ("Error socknal read %p: %d\n", conn, rc); goto out; } diff --git a/lnet/klnds/toelnd/toenal.c b/lnet/klnds/toelnd/toenal.c index 178ea41..1f5dc38 100644 --- a/lnet/klnds/toelnd/toenal.c +++ b/lnet/klnds/toelnd/toenal.c @@ -522,7 +522,7 @@ ktoenal_module_init (void) LASSERT (fmb->fmb_npages > 0); for (j = 0; j < fmb->fmb_npages; j++) { - fmb->fmb_pages[j] = alloc_page (GFP_KERNEL); + fmb->fmb_pages[j] = alloc_page(GFP_KERNEL); if (fmb->fmb_pages[j] == NULL) { diff --git a/lnet/klnds/toelnd/toenal.h b/lnet/klnds/toelnd/toenal.h index f793d3b..3654848 100644 --- a/lnet/klnds/toelnd/toenal.h +++ b/lnet/klnds/toelnd/toenal.h @@ -27,7 +27,9 @@ */ #define DEBUG_PORTAL_ALLOC -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lnet/klnds/toelnd/toenal_cb.c b/lnet/klnds/toelnd/toenal_cb.c index 7dfb0fa..5388f4b 100644 --- a/lnet/klnds/toelnd/toenal_cb.c +++ b/lnet/klnds/toelnd/toenal_cb.c @@ -300,7 +300,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) rc = 0; /* nothing sent */ else { -#warning FIXME: handle socket errors properly + /* FIXME: handle socket errors properly */ CERROR ("Error socknal send(%d) %p: %d\n", tx->tx_nob, conn, rc); rc = tx->tx_nob; /* kid on for now whole packet went */ } @@ -423,11 +423,10 @@ ktoenal_send(nal_cb_t *nal, void *private, lib_msg_t *cookie, * packet as a side-effect of another packet, such as when an ACK has * been requested. -phil */ - CDEBUG(D_NET, "sending "LPSZ" bytes from [%d](%p,%d)... to nid: "LPX64" pid %d\n", - payload_len, payload_niov, + CDEBUG(D_NET, "sending %d bytes from [%d](%p,%d)... to nid: " + LPX64" pid %d\n", (int)payload_len, payload_niov, payload_niov > 0 ? payload_iov[0].iov_base : NULL, - payload_niov > 0 ? payload_iov[0].iov_len : 0, - nid, pid); + (int)(payload_niov > 0 ? payload_iov[0].iov_len : 0), nid, pid); if ((conn = ktoenal_get_conn (nid)) == NULL) { @@ -862,7 +861,7 @@ ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags) if (len != -EAGAIN && /* ! nothing to read now */ len != 0) /* ! nothing to read ever */ { -#warning FIXME: handle socket errors properly + /* FIXME: handle socket errors properly */ CERROR ("Error socknal read(%d) %p: %d\n", conn->ksnc_rx_nob_wanted, conn, len); } diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c index 6233b8d..491c954 100644 --- a/lnet/libcfs/debug.c +++ b/lnet/libcfs/debug.c @@ -20,7 +20,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include @@ -237,7 +239,8 @@ int portals_do_debug_dumplog(void *arg) file = filp_open(debug_file_name, O_CREAT|O_TRUNC|O_RDWR, 0644); if (!file || IS_ERR(file)) { - CERROR("cannot open %s for dumping", debug_file_name); + CERROR("cannot open %s for dumping: %ld\n", debug_file_name, + PTR_ERR(file)); GOTO(out, PTR_ERR(file)); } else { printk(KERN_ALERT "dumping log to %s ... writing ...\n", @@ -274,7 +277,7 @@ int portals_debug_daemon(void *arg) void *journal_info; mm_segment_t oldfs; unsigned long force_flush = 0; - unsigned long size; + unsigned long size, off, flags; int rc; kportal_daemonize("ldebug_daemon"); @@ -295,7 +298,17 @@ int portals_debug_daemon(void *arg) debug_daemon_state.overlapped = 0; debug_daemon_state.stopped = 0; + + spin_lock_irqsave(&portals_debug_lock, flags); + off = atomic_read(&debug_off_a) + 1; + if (debug_wrapped) + off = (off >= debug_size)? 0 : off; + else + off = 0; + atomic_set(&debug_daemon_next_write, off); atomic_set(&debug_daemon_state.paused, 0); + spin_unlock_irqrestore(&portals_debug_lock, flags); + oldfs = get_fs(); set_fs(KERNEL_DS); while (1) { @@ -431,8 +444,6 @@ int portals_debug_daemon_start(char *file, unsigned int size) init_waitqueue_head(&debug_daemon_state.lctl); init_waitqueue_head(&debug_daemon_state.daemon); - atomic_set(&debug_daemon_next_write, atomic_read(&debug_off_a)); - daemon_file_size_limit = size << 20; debug_daemon_state.lctl_event = 0; diff --git a/lnet/libcfs/module.c b/lnet/libcfs/module.c index 1b9e5bb..5e3fcb5 100644 --- a/lnet/libcfs/module.c +++ b/lnet/libcfs/module.c @@ -19,7 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #define DEBUG_SUBSYSTEM S_PORTALS #include @@ -45,6 +47,7 @@ #include #include #include +#include #define PORTAL_MINOR 240 @@ -62,10 +65,9 @@ struct semaphore nal_cmd_sem; void kportal_assertion_failed (char *expr, char *file, char *func, int line) { - unsigned long stack = CDEBUG_STACK(stack); - portals_debug_msg(0, D_EMERG, file, func, line, stack, + portals_debug_msg(0, D_EMERG, file, func, line, CDEBUG_STACK(), "ASSERTION(%s) failed\n", expr); - LBUG(); + LBUG_WITH_LOC(file, func, line); } #endif @@ -85,10 +87,10 @@ kportal_blockallsigs () { unsigned long flags; - spin_lock_irqsave (¤t->sigmask_lock, flags); - siginitsetinv (¤t->blocked, 0); - recalc_sigpending (current); - spin_unlock_irqrestore (¤t->sigmask_lock, flags); + SIGNAL_MASK_LOCK(current, flags); + sigfillset(¤t->blocked); + RECALC_SIGPENDING; + SIGNAL_MASK_UNLOCK(current, flags); } /* called when opening /dev/device */ diff --git a/lnet/libcfs/proc.c b/lnet/libcfs/proc.c index 2fa739a..bb6c377 100644 --- a/lnet/libcfs/proc.c +++ b/lnet/libcfs/proc.c @@ -22,7 +22,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lnet/lnet/lib-init.c b/lnet/lnet/lib-init.c index d6315c6..99c4d32 100644 --- a/lnet/lnet/lib-init.c +++ b/lnet/lnet/lib-init.c @@ -357,6 +357,8 @@ lib_init(nal_cb_t * nal, ptl_nid_t nid, ptl_pid_t pid, int gsize, goto out; } + lib_assert_wire_constants (); + /* * Allocate the portal table for this interface * and all per-interface objects. diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index a79e2be..415eda6 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -396,7 +396,7 @@ int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, test_eq->sequence == args->sequence_in) { lib_me_t *me = md->me; -#warning this does not track eq refcounts properly + /* XXX this does not track eq refcounts properly */ ret->rc = lib_md_build(nal, md, private, new, &new->eventq, md->unlink); diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index a04e961..fde4f16 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -1285,3 +1285,95 @@ int do_PtlGet(nal_cb_t * nal, void *private, void *v_args, void *v_ret) return ret->rc = PTL_OK; } + +void lib_assert_wire_constants (void) +{ + /* Wire protocol assertions generated by 'wirecheck' */ + + /* Constants... */ + LASSERT (PORTALS_PROTO_MAGIC == 0xeebc0ded); + LASSERT (PORTALS_PROTO_VERSION_MAJOR == 0); + LASSERT (PORTALS_PROTO_VERSION_MINOR == 1); + LASSERT (PTL_MSG_ACK == 0); + LASSERT (PTL_MSG_PUT == 1); + LASSERT (PTL_MSG_GET == 2); + LASSERT (PTL_MSG_REPLY == 3); + LASSERT (PTL_MSG_HELLO == 4); + + /* Checks for struct ptl_handle_wire_t */ + LASSERT (sizeof (ptl_handle_wire_t) == 16); + LASSERT (offsetof (ptl_handle_wire_t, wh_interface_cookie) == 0); + LASSERT (sizeof (((ptl_handle_wire_t *)0)->wh_interface_cookie) == 8); + LASSERT (offsetof (ptl_handle_wire_t, wh_object_cookie) == 8); + LASSERT (sizeof (((ptl_handle_wire_t *)0)->wh_object_cookie) == 8); + + /* Checks for struct ptl_magicversion_t */ + LASSERT (sizeof (ptl_magicversion_t) == 8); + LASSERT (offsetof (ptl_magicversion_t, magic) == 0); + LASSERT (sizeof (((ptl_magicversion_t *)0)->magic) == 4); + LASSERT (offsetof (ptl_magicversion_t, version_major) == 4); + LASSERT (sizeof (((ptl_magicversion_t *)0)->version_major) == 2); + LASSERT (offsetof (ptl_magicversion_t, version_minor) == 6); + LASSERT (sizeof (((ptl_magicversion_t *)0)->version_minor) == 2); + + /* Checks for struct ptl_hdr_t */ + LASSERT (sizeof (ptl_hdr_t) == 72); + LASSERT (offsetof (ptl_hdr_t, dest_nid) == 0); + LASSERT (sizeof (((ptl_hdr_t *)0)->dest_nid) == 8); + LASSERT (offsetof (ptl_hdr_t, src_nid) == 8); + LASSERT (sizeof (((ptl_hdr_t *)0)->src_nid) == 8); + LASSERT (offsetof (ptl_hdr_t, dest_pid) == 16); + LASSERT (sizeof (((ptl_hdr_t *)0)->dest_pid) == 4); + LASSERT (offsetof (ptl_hdr_t, src_pid) == 20); + LASSERT (sizeof (((ptl_hdr_t *)0)->src_pid) == 4); + LASSERT (offsetof (ptl_hdr_t, type) == 24); + LASSERT (sizeof (((ptl_hdr_t *)0)->type) == 4); + + /* Ack */ + LASSERT (offsetof (ptl_hdr_t, msg.ack.mlength) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.mlength) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.ack.dst_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.dst_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.ack.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.ack.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.length) == 4); + + /* Put */ + LASSERT (offsetof (ptl_hdr_t, msg.put.ptl_index) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.ptl_index) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.ack_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.ack_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.put.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.put.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.length) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.offset) == 60); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.hdr_data) == 64); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.hdr_data) == 8); + + /* Get */ + LASSERT (offsetof (ptl_hdr_t, msg.get.ptl_index) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.ptl_index) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.return_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.return_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.get.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.get.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.length) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.src_offset) == 60); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.src_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.return_offset) == 64); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.return_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.sink_length) == 68); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.sink_length) == 4); + + /* Reply */ + LASSERT (offsetof (ptl_hdr_t, msg.reply.dst_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.dst_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.reply.dst_offset) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.dst_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.reply.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.length) == 4); +} diff --git a/lnet/portalsconf.m4 b/lnet/portalsconf.m4 deleted file mode 100644 index 7bd3919..0000000 --- a/lnet/portalsconf.m4 +++ /dev/null @@ -1,118 +0,0 @@ -AC_PREFIX_DEFAULT([]) -if test "x$prefix" = xNONE || test "x$prefix" = x; then - usrprefix=/usr -else - usrprefix='${prefix}' -fi -AC_SUBST(usrprefix) - -AC_ARG_ENABLE(rtscts-myrinet, [ --enable-rtscts-myrinet enable rtscts over myrinet support]) -AM_CONDITIONAL(RTSCTS_MYRINET, test "$enable_rtscts_myrinet" = yes) - - -CPLANT_ARCH=${target_cpu} -case ${CPLANT_ARCH} in -alpha*) - RTSCTSLIB_CFLAGS='-O4 -mno-fp-regs' - RTSCTSLIB_DEFS=-Ddec_linux - ;; -i*86) - RTSCTSLIB_CFLAGS=-O4 - RTSCTSLIB_DEFS=-Dintel_linux - ;; -#*) -# AC_MSG_ERROR([Unrecognized architecture '$CPLANT_ARCH' for rtscts]) -# ;; -esac -AC_SUBST(CPLANT_ARCH) -AC_SUBST(RTSCTSLIB_CFLAGS) -AC_SUBST(RTSCTSLIB_DEFS) - -AC_MSG_CHECKING(if kernel has CPU affinity support) -if test "$target_cpu" != ia64 ; then - enable_affinity_temp="-DCPU_AFFINITY=1" - AC_MSG_RESULT(yes) -else - enable_affinity_temp="" - AC_MSG_RESULT(no) -fi -AC_MSG_CHECKING(if kernel has zero-copy TCP support) -ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" -if test "$ZCCD" != 0 ; then - enable_zerocopy_temp="-DSOCKNAL_ZC=1" - AC_MSG_RESULT(yes) -else - enable_zerocopy_temp="" - AC_MSG_RESULT(no) -fi - -AC_ARG_ENABLE(zerocopy, [ --enable-zerocopy enable socknal zerocopy],enable_zerocopy="-DSOCKNAL_ZC=1", enable_zercopy=$enable_zerocopy_temp) - -AC_ARG_ENABLE(affinity, [ --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp) -##################################### - -AC_MSG_CHECKING(if quadrics kernel headers are present) -if test -d $LINUX/drivers/net/qsnet ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/net/qsnet/include" - : -elif test -d $LINUX/drivers/qsnet1 ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/qsnet1/include -DPROPRIETARY_ELAN" - : -elif test -d $LINUX/drivers/quadrics ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/quadrics/include -DPROPRIETARY_ELAN" - : -#elif test -d /usr/include/elan3 ; then -# AC_MSG_RESULT(yes) -# QSWNAL="qswnal" -# with_quadrics="" -# : -else - AC_MSG_RESULT(no) - QSWNAL="" - with_quadrics="" - : -fi -AC_SUBST(with_quadrics) -AC_SUBST(QSWNAL) - -# R. Read 5/02 -GMNAL="" -echo "checking with-gm=" ${with_gm} -if test "${with_gm+set}" = set; then - if test "${with_gm}" = yes; then - with_gm="-I/usr/local/gm/include" - else - with_gm=-I"$with_gm/include" - fi - GMNAL="gmnal" -else -# default case - no GM - with_gm="" -fi -AC_SUBST(with_gm) -AC_SUBST(GMNAL) - - -def_scamac=/opt/scali/include -AC_ARG_WITH(scamac, [ --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac) -AC_MSG_CHECKING(if ScaMAC headers are present) -if test "$with_scamac" = yes; then - with_scamac=$def_scamac -fi -if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then - AC_MSG_RESULT(yes) - SCIMACNAL="scimacnal" - with_scamac="-I${with_scamac} -I${with_scamac}/icm" -else - AC_MSG_RESULT(no) - SCIMACNAL="" - with_scamac="" -fi -AC_SUBST(with_scamac) -AC_SUBST(SCIMACNAL) diff --git a/lnet/router/router.c b/lnet/router/router.c index 8a1de08..6074c3c 100644 --- a/lnet/router/router.c +++ b/lnet/router/router.c @@ -202,15 +202,15 @@ kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd) LASSERT (nob == lib_iov_nob (fwd->kprfd_niov, fwd->kprfd_iov)); atomic_inc (&kpr_queue_depth); + atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */ kpr_fwd_packets++; /* (loose) stats accounting */ kpr_fwd_bytes += nob; - if (src_ne->kpne_shutdown) /* caller is shutting down */ + if (src_ne->kpne_shutdown) /* caller is shutting down */ goto out; - fwd->kprfd_router_arg = src_ne; /* stash caller's nal entry */ - atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */ + fwd->kprfd_router_arg = src_ne; /* stash caller's nal entry */ read_lock (&kpr_rwlock); diff --git a/lnet/router/router.h b/lnet/router/router.h index b8c3bec..19159ab 100644 --- a/lnet/router/router.h +++ b/lnet/router/router.h @@ -23,7 +23,9 @@ #ifndef _KPTLROUTER_H #define _KPTLROUTER_H -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lnet/ulnds/Makefile.am b/lnet/ulnds/Makefile.am index b62b401..dc427b0 100644 --- a/lnet/ulnds/Makefile.am +++ b/lnet/ulnds/Makefile.am @@ -1,5 +1,5 @@ CPPFLAGS= INCLUDES=-I$(top_srcdir)/portals/include -I$(top_srcdir)/include -I$(srcdir) lib_LIBRARIES = libtcpnal.a -pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h +pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h diff --git a/lnet/ulnds/connection.c b/lnet/ulnds/connection.c index 89c9f78..310e899 100644 --- a/lnet/ulnds/connection.c +++ b/lnet/ulnds/connection.c @@ -120,9 +120,10 @@ int read_connection(connection c, return(1); } -static int connection_input(connection c) +static int connection_input(void *d) { - return((*c->m->handler)(c->m->handler_arg,c)); + connection c = d; + return((*c->m->handler)(c->m->handler_arg,c)); } @@ -280,7 +281,7 @@ void shutdown_connections(manager m) * zero if the fixed port could not be bound */ manager init_connections(unsigned short pid, - int (*input)(), + int (*input)(void *, void *), void *a) { manager m=(manager)malloc(sizeof(struct manager)); diff --git a/lnet/ulnds/connection.h b/lnet/ulnds/connection.h index f6b2994..6f57287 100644 --- a/lnet/ulnds/connection.h +++ b/lnet/ulnds/connection.h @@ -25,14 +25,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, - unsigned int ip, - unsigned int short); -manager init_connections(unsigned short, - int (*f)(void *,connection), - void *); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); -int read_connection(connection c, - unsigned char *dest, - int len); +int read_connection(connection c, unsigned char *dest, int len); diff --git a/lnet/ulnds/socklnd/Makefile.am b/lnet/ulnds/socklnd/Makefile.am index b62b401..dc427b0 100644 --- a/lnet/ulnds/socklnd/Makefile.am +++ b/lnet/ulnds/socklnd/Makefile.am @@ -1,5 +1,5 @@ CPPFLAGS= INCLUDES=-I$(top_srcdir)/portals/include -I$(top_srcdir)/include -I$(srcdir) lib_LIBRARIES = libtcpnal.a -pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h +pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h diff --git a/lnet/ulnds/socklnd/connection.c b/lnet/ulnds/socklnd/connection.c index 89c9f78..310e899 100644 --- a/lnet/ulnds/socklnd/connection.c +++ b/lnet/ulnds/socklnd/connection.c @@ -120,9 +120,10 @@ int read_connection(connection c, return(1); } -static int connection_input(connection c) +static int connection_input(void *d) { - return((*c->m->handler)(c->m->handler_arg,c)); + connection c = d; + return((*c->m->handler)(c->m->handler_arg,c)); } @@ -280,7 +281,7 @@ void shutdown_connections(manager m) * zero if the fixed port could not be bound */ manager init_connections(unsigned short pid, - int (*input)(), + int (*input)(void *, void *), void *a) { manager m=(manager)malloc(sizeof(struct manager)); diff --git a/lnet/ulnds/socklnd/connection.h b/lnet/ulnds/socklnd/connection.h index f6b2994..6f57287 100644 --- a/lnet/ulnds/socklnd/connection.h +++ b/lnet/ulnds/socklnd/connection.h @@ -25,14 +25,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, - unsigned int ip, - unsigned int short); -manager init_connections(unsigned short, - int (*f)(void *,connection), - void *); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); -int read_connection(connection c, - unsigned char *dest, - int len); +int read_connection(connection c, unsigned char *dest, int len); diff --git a/lnet/ulnds/socklnd/tcplnd.c b/lnet/ulnds/socklnd/tcplnd.c index fac9c44..5854b01 100644 --- a/lnet/ulnds/socklnd/tcplnd.c +++ b/lnet/ulnds/socklnd/tcplnd.c @@ -160,15 +160,17 @@ check_len: * available. It attempts to read the portals header and * pass it to the generic library for processing. */ -static int from_connection(void *a,connection c) +static int from_connection(void *a, void *d) { - bridge b=a; - ptl_hdr_t hdr; - if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ - lib_parse(b->nal_cb, &hdr, c); - return(1); - } - return(0); + connection c = d; + bridge b=a; + ptl_hdr_t hdr; + + if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ + lib_parse(b->nal_cb, &hdr, c); + return(1); + } + return(0); } diff --git a/lnet/ulnds/tcplnd.c b/lnet/ulnds/tcplnd.c index fac9c44..5854b01 100644 --- a/lnet/ulnds/tcplnd.c +++ b/lnet/ulnds/tcplnd.c @@ -160,15 +160,17 @@ check_len: * available. It attempts to read the portals header and * pass it to the generic library for processing. */ -static int from_connection(void *a,connection c) +static int from_connection(void *a, void *d) { - bridge b=a; - ptl_hdr_t hdr; - if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ - lib_parse(b->nal_cb, &hdr, c); - return(1); - } - return(0); + connection c = d; + bridge b=a; + ptl_hdr_t hdr; + + if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ + lib_parse(b->nal_cb, &hdr, c); + return(1); + } + return(0); } diff --git a/lnet/utils/.cvsignore b/lnet/utils/.cvsignore index 041cd6b..148310a 100644 --- a/lnet/utils/.cvsignore +++ b/lnet/utils/.cvsignore @@ -5,3 +5,4 @@ debugctl ptlctl .deps routerstat +wirecheck \ No newline at end of file diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am index 065fcf9..05af598 100644 --- a/lnet/utils/Makefile.am +++ b/lnet/utils/Makefile.am @@ -7,11 +7,13 @@ COMPILE = gcc -Wall -g -I$(srcdir)/../include LINK = gcc -o $@ -sbin_PROGRAMS = acceptor ptlctl debugctl routerstat +sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck lib_LIBRARIES = libptlctl.a acceptor_SOURCES = acceptor.c # -lefence +wirecheck_SOURCES = wirecheck.c + libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h ptlctl_SOURCES = ptlctl.c diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 8235271..90d66f5 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -106,13 +106,6 @@ nal2name (int nal) return ((e == NULL) ? "???" : e->name); } -static int -nid2nal (ptl_nid_t nid) -{ - /* BIG pragmatic assumption */ - return ((((__u32)nid) & 0xffff0000) != 0 ? SOCKNAL : QSWNAL); -} - int ptl_parse_nid (ptl_nid_t *nidp, char *str) { @@ -160,35 +153,15 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str) char * ptl_nid2str (char *buffer, ptl_nid_t nid) { - switch (nid2nal(nid)) - { - case QSWNAL: - sprintf (buffer, LPD64, nid); - return (buffer); + __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */ + struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET); - case SCIMACNAL: - sprintf (buffer, LPX64, nid); - return (buffer); - - case SOCKNAL: { - __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */ - struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET); - - if (he != NULL) - strcpy (buffer, he->h_name); - else - { - addr = (__u32)nid; - sprintf (buffer, "%d.%d.%d.%d", - (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff); - } - return (buffer); - } + if (he != NULL) + strcpy (buffer, he->h_name); + else + sprintf (buffer, "0x"LPX64, nid); - default: - sprintf (buffer, "nid2nal broken"); - return (buffer); - } + return (buffer); } int @@ -704,18 +677,43 @@ int jt_ptl_ping(int argc, char **argv) return 0; } +int jt_ptl_shownid(int argc, char **argv) +{ + struct portal_ioctl_data data; + int rc; + + if (argc > 1) { + fprintf(stderr, "usage: %s\n", argv[0]); + return 0; + } + + if (g_nal == 0) { + fprintf(stderr, "Error: you must run the 'network' command first\n"); + return -1; + } + + PORTAL_IOC_INIT (data); + data.ioc_nal = g_nal; + rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data); + if (rc < 0) + fprintf(stderr, "getting my NID failed: %s\n", + strerror (errno)); + else + printf(LPX64"\n", data.ioc_nid); + return 0; +} + int jt_ptl_mynid(int argc, char **argv) { int rc; - struct hostent *h; - char buf[1024], *hostname; + char hostname[1024]; + char *nidstr; struct portal_ioctl_data data; ptl_nid_t mynid; if (argc > 2) { - fprintf(stderr, "usage: %s [hostname]\n", argv[0]); - fprintf(stderr, "hostname defaults to the hostname of the " - "machine.\n"); + fprintf(stderr, "usage: %s [NID]\n", argv[0]); + fprintf(stderr, "NID defaults to the primary IP address of the machine.\n"); return 0; } @@ -725,42 +723,21 @@ int jt_ptl_mynid(int argc, char **argv) return -1; } - if (g_nal == QSWNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for elan.\n"); - return -1; - } else if (g_nal == GMNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for GM.\n"); - return -1; - } else if (g_nal == SCIMACNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for SCI.\n"); - return -1; - } - - if (g_nal != SOCKNAL && g_nal != TOENAL) { - fprintf(stderr, "This should never happen. Also it is very " - "bad.\n"); + if (argc >= 2) + nidstr = argv[1]; + else if (gethostname(hostname, sizeof(hostname)) != 0) { + fprintf(stderr, "gethostname failed: %s\n", + strerror(errno)); return -1; } + else + nidstr = hostname; - if (argc == 1) { - if (gethostname(buf, sizeof(buf)) != 0) { - fprintf(stderr, "gethostname failed: %s\n", - strerror(errno)); - return -1; - } - hostname = buf; - } else { - hostname = argv[1]; - } - - h = gethostbyname(hostname); - - if (!h) { - fprintf(stderr, "cannot get address for host '%s': %d\n", - hostname, h_errno); + rc = ptl_parse_nid (&mynid, nidstr); + if (rc != 0) { + fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr); return -1; } - mynid = (ptl_nid_t)ntohl (*(__u32 *)h->h_addr); /* HOST byte order */ PORTAL_IOC_INIT(data); data.ioc_nid = mynid; @@ -769,7 +746,7 @@ int jt_ptl_mynid(int argc, char **argv) rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data); if (rc < 0) - fprintf(stderr, "IOC_PORTAL_REGISTER_MYNID failed: %s\n", + fprintf(stderr, "setting my NID failed: %s\n", strerror(errno)); else printf("registered my nid "LPX64" (%s)\n", mynid, hostname); @@ -888,7 +865,6 @@ jt_ptl_add_route (int argc, char **argv) ptl_nid_t nid1; ptl_nid_t nid2; ptl_nid_t gateway_nid; - int gateway_nal; int rc; if (argc < 3) @@ -897,14 +873,18 @@ jt_ptl_add_route (int argc, char **argv) return (0); } + if (g_nal == 0) { + fprintf(stderr, "Error: you must run the 'network' command " + "first.\n"); + return (-1); + } + if (ptl_parse_nid (&gateway_nid, argv[1]) != 0) { fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]); return (-1); } - gateway_nal = nid2nal (gateway_nid); - if (ptl_parse_nid (&nid1, argv[2]) != 0) { fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]); @@ -921,7 +901,7 @@ jt_ptl_add_route (int argc, char **argv) PORTAL_IOC_INIT(data); data.ioc_nid = gateway_nid; - data.ioc_nal = gateway_nal; + data.ioc_nal = g_nal; data.ioc_nid2 = MIN (nid1, nid2); data.ioc_nid3 = MAX (nid1, nid2); diff --git a/lnet/utils/ptlctl.c b/lnet/utils/ptlctl.c index d38bd4a..8c56d93 100644 --- a/lnet/utils/ptlctl.c +++ b/lnet/utils/ptlctl.c @@ -34,6 +34,7 @@ command_t list[] = { {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid (args: [hostname]"}, {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid (args: [hostname]"}, {"ping", jt_ptl_ping, 0, "do a ping test (args: nid [count] [size] [timeout])"}, + {"shownid", jt_ptl_shownid, 0, "print the local NID"}, {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local NID (args: [hostname])"}, {"add_route", jt_ptl_add_route, 0, "add an entry to the routing table (args: gatewayNID targetNID [targetNID])"}, {"del_route", jt_ptl_del_route, 0, "delete an entry from the routing table (args: targetNID"}, diff --git a/lustre/kernel_patches/patches/iopen-2.4.19.patch b/lustre/kernel_patches/patches/iopen-2.4.19.patch deleted file mode 100644 index 580d38b..0000000 --- a/lustre/kernel_patches/patches/iopen-2.4.19.patch +++ /dev/null @@ -1,407 +0,0 @@ - Documentation/filesystems/ext2.txt | 16 ++ - fs/ext3/Makefile | 2 - fs/ext3/inode.c | 4 - fs/ext3/iopen.c | 240 +++++++++++++++++++++++++++++++++++++ - fs/ext3/iopen.h | 15 ++ - fs/ext3/namei.c | 15 ++ - fs/ext3/super.c | 11 + - include/linux/ext3_fs.h | 3 - 8 files changed, 303 insertions(+), 3 deletions(-) - ---- linux-2.4.19-hp3_pnnl1/Documentation/filesystems/ext2.txt~iopen-2.4.19 2001-07-12 06:44:45.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/Documentation/filesystems/ext2.txt 2003-05-19 14:45:51.000000000 +0800 -@@ -35,6 +35,22 @@ resgid=n The group ID which may use th - - sb=n Use alternate superblock at this location. - -+iopen Makes an invisible pseudo-directory called -+ __iopen__ available in the root directory -+ of the filesystem. Allows open-by-inode- -+ number. i.e., inode 3145 can be accessed -+ via /mntpt/__iopen__/3145 -+ -+iopen_nopriv This option makes the iopen directory be -+ world-readable. This may be safer since it -+ allows daemons to run as an unprivileged user, -+ however it significantly changes the security -+ model of a Unix filesystem, since previously -+ all files under a mode 700 directory were not -+ generally avilable even if the -+ permissions on the file itself is -+ world-readable. -+ - grpquota,noquota,quota,usrquota Quota options are silently ignored by ext2. - - ---- linux-2.4.19-hp3_pnnl1/fs/ext3/Makefile~iopen-2.4.19 2003-05-19 14:36:42.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/Makefile 2003-05-19 14:46:34.000000000 +0800 -@@ -11,7 +11,7 @@ O_TARGET := ext3.o - - export-objs := super.o inode.o - --obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ -+obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ - ioctl.o namei.o super.o symlink.o hash.o - obj-m := $(O_TARGET) - ---- linux-2.4.19-hp3_pnnl1/fs/ext3/inode.c~iopen-2.4.19 2003-05-19 14:36:50.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/inode.c 2003-05-19 14:45:51.000000000 +0800 -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include "iopen.h" - - /* - * SEARCH_FROM_ZERO forces each block allocation to search from the start -@@ -2073,6 +2074,9 @@ void ext3_read_inode(struct inode * inod - struct buffer_head *bh; - int block; - -+ if (ext3_iopen_get_inode(inode)) -+ return; -+ - if(ext3_get_inode_loc(inode, &iloc)) - goto bad_inode; - bh = iloc.bh; ---- /dev/null 2003-01-30 18:24:37.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/iopen.c 2003-05-19 14:45:51.000000000 +0800 -@@ -0,0 +1,240 @@ -+ -+ -+/* -+ * linux/fs/ext3/iopen.c -+ * -+ * Special support for open by inode number -+ * -+ * Copyright (C) 2001 by Theodore Ts'o (tytso@alum.mit.edu). -+ * -+ * This file may be redistributed under the terms of the GNU General -+ * Public License. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "iopen.h" -+ -+#ifndef assert -+#define assert(test) J_ASSERT(test) -+#endif -+ -+#define IOPEN_NAME_LEN 32 -+ -+/* -+ * This implements looking up an inode by number. -+ */ -+static struct dentry *iopen_lookup(struct inode * dir, struct dentry *dentry) -+{ -+ struct inode * inode; -+ unsigned long ino; -+ struct list_head *lp; -+ struct dentry *alternate; -+ char buf[IOPEN_NAME_LEN]; -+ -+ if (dentry->d_name.len >= IOPEN_NAME_LEN) -+ return ERR_PTR(-ENAMETOOLONG); -+ -+ memcpy(buf, dentry->d_name.name, dentry->d_name.len); -+ buf[dentry->d_name.len] = 0; -+ -+ if (strcmp(buf, ".") == 0) -+ ino = dir->i_ino; -+ else if (strcmp(buf, "..") == 0) -+ ino = EXT3_ROOT_INO; -+ else -+ ino = simple_strtoul(buf, 0, 0); -+ -+ if ((ino != EXT3_ROOT_INO && -+ //ino != EXT3_ACL_IDX_INO && -+ //ino != EXT3_ACL_DATA_INO && -+ ino < EXT3_FIRST_INO(dir->i_sb)) || -+ ino > le32_to_cpu(dir->i_sb->u.ext3_sb.s_es->s_inodes_count)) -+ return ERR_PTR(-ENOENT); -+ -+ inode = iget(dir->i_sb, ino); -+ if (!inode) -+ return ERR_PTR(-EACCES); -+ if (is_bad_inode(inode)) { -+ iput(inode); -+ return ERR_PTR(-ENOENT); -+ } -+ -+ /* preferrably return a connected dentry */ -+ spin_lock(&dcache_lock); -+ list_for_each(lp, &inode->i_dentry) { -+ alternate = list_entry(lp, struct dentry, d_alias); -+ assert(!(alternate->d_flags & DCACHE_NFSD_DISCONNECTED)); -+ } -+ -+ if (!list_empty(&inode->i_dentry)) { -+ alternate = list_entry(inode->i_dentry.next, -+ struct dentry, d_alias); -+ dget_locked(alternate); -+ alternate->d_vfs_flags |= DCACHE_REFERENCED; -+ iput(inode); -+ spin_unlock(&dcache_lock); -+ return alternate; -+ } -+ dentry->d_flags |= DCACHE_NFSD_DISCONNECTED; -+ spin_unlock(&dcache_lock); -+ -+ d_add(dentry, inode); -+ return NULL; -+} -+ -+#define do_switch(x,y) do { \ -+ __typeof__ (x) __tmp = x; \ -+ x = y; y = __tmp; } while (0) -+ -+static inline void switch_names(struct dentry * dentry, struct dentry * target) -+{ -+ const unsigned char *old_name, *new_name; -+ -+ memcpy(dentry->d_iname, target->d_iname, DNAME_INLINE_LEN); -+ old_name = target->d_name.name; -+ new_name = dentry->d_name.name; -+ if (old_name == target->d_iname) -+ old_name = dentry->d_iname; -+ if (new_name == dentry->d_iname) -+ new_name = target->d_iname; -+ target->d_name.name = new_name; -+ dentry->d_name.name = old_name; -+} -+ -+ -+struct dentry *iopen_connect_dentry(struct dentry *de, struct inode *inode) -+{ -+ struct dentry *tmp, *goal = NULL; -+ struct list_head *lp; -+ -+ /* preferrably return a connected dentry */ -+ spin_lock(&dcache_lock); -+ /* verify this dentry is really new */ -+ assert(!de->d_inode); -+ assert(list_empty(&de->d_subdirs)); -+ assert(list_empty(&de->d_alias)); -+ -+ -+ list_for_each(lp, &inode->i_dentry) { -+ tmp = list_entry(lp, struct dentry, d_alias); -+ if (tmp->d_flags & DCACHE_NFSD_DISCONNECTED) { -+ assert(tmp->d_alias.next == &inode->i_dentry); -+ assert(tmp->d_alias.prev == &inode->i_dentry); -+ goal = tmp; -+ dget_locked(goal); -+ break; -+ } -+ } -+ -+ if (!goal) { -+ spin_unlock(&dcache_lock); -+ return NULL; -+ } -+ -+ /* Move the goal to the de hash queue */ -+ goal->d_flags &= ~DCACHE_NFSD_DISCONNECTED; -+ list_del(&goal->d_hash); -+ list_add(&goal->d_hash, &de->d_hash); -+ -+ list_del(&goal->d_child); -+ list_del(&de->d_child); -+ -+ /* Switch the parents and the names.. */ -+ switch_names(goal, de); -+ do_switch(goal->d_parent, de->d_parent); -+ do_switch(goal->d_name.len, de->d_name.len); -+ do_switch(goal->d_name.hash, de->d_name.hash); -+ -+ /* And add them back to the (new) parent lists */ -+ list_add(&goal->d_child, &goal->d_parent->d_subdirs); -+ list_add(&de->d_child, &de->d_parent->d_subdirs); -+ -+ spin_unlock(&dcache_lock); -+ return goal; -+} -+ -+/* -+ * These are the special structures for the iopen pseudo directory. -+ */ -+ -+static struct inode_operations iopen_inode_operations = { -+ lookup: iopen_lookup, /* BKL held */ -+}; -+ -+static struct file_operations iopen_file_operations = { -+ read: generic_read_dir, -+}; -+ -+static int match_dentry(struct dentry *dentry, const char *name) -+{ -+ int len; -+ -+ len = strlen(name); -+ if (dentry->d_name.len != len) -+ return 0; -+ if (strncmp(dentry->d_name.name, name, len)) -+ return 0; -+ return 1; -+} -+ -+/* -+ * This function is spliced into ext3_lookup and returns 1 the file -+ * name is __iopen__ and dentry has been filled in appropriately. -+ */ -+int ext3_check_for_iopen(struct inode * dir, struct dentry *dentry) -+{ -+ struct inode * inode; -+ -+ if (dir->i_ino != EXT3_ROOT_INO || -+ !test_opt(dir->i_sb, IOPEN) || -+ !match_dentry(dentry, "__iopen__")) -+ return 0; -+ -+ inode = iget(dir->i_sb, EXT3_BAD_INO); -+ -+ if (!inode) -+ return 0; -+ d_add(dentry, inode); -+ return 1; -+} -+ -+/* -+ * This function is spliced into read_inode; it returns 1 if inode -+ * number is the one for /__iopen__, in which case the inode is filled -+ * in appropriately. Otherwise, this fuction returns 0. -+ */ -+int ext3_iopen_get_inode(struct inode * inode) -+{ -+ if (inode->i_ino != EXT3_BAD_INO) -+ return 0; -+ -+ inode->i_mode = S_IFDIR | S_IRUSR | S_IXUSR; -+ if (test_opt(inode->i_sb, IOPEN_NOPRIV)) -+ inode->i_mode |= 0777; -+ inode->i_uid = 0; -+ inode->i_gid = 0; -+ inode->i_nlink = 1; -+ inode->i_size = 4096; -+ inode->i_atime = CURRENT_TIME; -+ inode->i_ctime = CURRENT_TIME; -+ inode->i_mtime = CURRENT_TIME; -+ inode->u.ext3_i.i_dtime = 0; -+ inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size -+ * (for stat), not the fs block -+ * size */ -+ inode->i_blocks = 0; -+ inode->i_version = 1; -+ inode->i_generation = 0; -+ -+ inode->i_op = &iopen_inode_operations; -+ inode->i_fop = &iopen_file_operations; -+ inode->i_mapping->a_ops = 0; -+ -+ return 1; -+} ---- /dev/null 2003-01-30 18:24:37.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/iopen.h 2003-05-19 14:45:51.000000000 +0800 -@@ -0,0 +1,15 @@ -+/* -+ * iopen.h -+ * -+ * Special support for opening files by inode number. -+ * -+ * Copyright (C) 2001 by Theodore Ts'o (tytso@alum.mit.edu). -+ * -+ * This file may be redistributed under the terms of the GNU General -+ * Public License. -+ */ -+ -+extern int ext3_check_for_iopen(struct inode * dir, struct dentry *dentry); -+extern int ext3_iopen_get_inode(struct inode * inode); -+ -+ ---- linux-2.4.19-hp3_pnnl1/fs/ext3/namei.c~iopen-2.4.19 2003-05-19 14:36:47.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/namei.c 2003-05-19 14:49:40.000000000 +0800 -@@ -35,7 +35,7 @@ - #include - #include - #include -- -+#include "iopen.h" - - /* - * define how far ahead to read directories while searching them. -@@ -922,15 +922,20 @@ errout: - } - #endif - -+struct dentry *iopen_connect_dentry(struct dentry *de, struct inode *inode); - static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry) - { - struct inode * inode; - struct ext3_dir_entry_2 * de; - struct buffer_head * bh; -- -+ struct dentry *alternate = NULL; -+ - if (dentry->d_name.len > EXT3_NAME_LEN) - return ERR_PTR(-ENAMETOOLONG); - -+ if (ext3_check_for_iopen(dir, dentry)) -+ return NULL; -+ - bh = ext3_find_entry(dentry, &de); - inode = NULL; - if (bh) { -@@ -942,6 +947,12 @@ static struct dentry *ext3_lookup(struct - return ERR_PTR(-EACCES); - } - } -+ -+ if (inode && (alternate = iopen_connect_dentry(dentry, inode))) { -+ iput(inode); -+ return alternate; -+ } -+ - d_add(dentry, inode); - return NULL; - } ---- linux-2.4.19-hp3_pnnl1/fs/ext3/super.c~iopen-2.4.19 2003-05-19 14:36:50.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/fs/ext3/super.c 2003-05-19 14:45:51.000000000 +0800 -@@ -606,6 +606,17 @@ static int parse_options (char * options - || !strcmp (this_char, "quota") - || !strcmp (this_char, "usrquota")) - /* Don't do anything ;-) */ ; -+ else if (!strcmp (this_char, "iopen")) { -+ set_opt (sbi->s_mount_opt, IOPEN); -+ clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ } else if (!strcmp (this_char, "noiopen")) { -+ clear_opt (sbi->s_mount_opt, IOPEN); -+ clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ } -+ else if (!strcmp (this_char, "iopen_nopriv")) { -+ set_opt (sbi->s_mount_opt, IOPEN); -+ set_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ } - else if (!strcmp (this_char, "journal")) { - /* @@@ FIXME */ - /* Eventually we will want to be able to create ---- linux-2.4.19-hp3_pnnl1/include/linux/ext3_fs.h~iopen-2.4.19 2003-05-19 14:36:47.000000000 +0800 -+++ linux-2.4.19-hp3_pnnl1-root/include/linux/ext3_fs.h 2003-05-19 14:51:26.000000000 +0800 -@@ -322,6 +322,9 @@ struct ext3_inode { - #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */ - #define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */ - -+#define EXT3_MOUNT_IOPEN 0x8000 /* Allow access via iopen */ -+#define EXT3_MOUNT_IOPEN_NOPRIV 0x10000 /* Make iopen world-readable */ -+ - /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ - #ifndef _LINUX_EXT2_FS_H - #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt - -_ diff --git a/lustre/kernel_patches/pc/iopen-2.4.19.pc b/lustre/kernel_patches/pc/iopen-2.4.19.pc deleted file mode 100644 index b40b1f3..0000000 --- a/lustre/kernel_patches/pc/iopen-2.4.19.pc +++ /dev/null @@ -1,8 +0,0 @@ -Documentation/filesystems/ext2.txt -fs/ext3/Makefile -fs/ext3/inode.c -fs/ext3/iopen.c -fs/ext3/iopen.h -fs/ext3/namei.c -fs/ext3/super.c -include/linux/ext3_fs.h diff --git a/lustre/portals/Makefile.am b/lustre/portals/Makefile.am index 1c28b649..1a223f2 100644 --- a/lustre/portals/Makefile.am +++ b/lustre/portals/Makefile.am @@ -3,7 +3,7 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution -EXTRA_DIST = Rules.linux archdep.m4 MCP +EXTRA_DIST = Rules.linux archdep.m4 include DIST_SUBDIRS = libcfs portals knals unals utils tests doc router if LIBLUSTRE SUBDIRS = portals unals utils diff --git a/lustre/portals/archdep.m4 b/lustre/portals/archdep.m4 index 1062040..65ca1ada 100644 --- a/lustre/portals/archdep.m4 +++ b/lustre/portals/archdep.m4 @@ -145,7 +145,7 @@ fi # ------------ include paths ------------------ if test $host_cpu != "lib" ; then - KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include -I$(LINUX)/include' + KINCFLAGS="-I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include -I$LINUX/include" else KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include' fi @@ -190,19 +190,129 @@ if test $host_cpu != "lib" ; then fi fi -# ---------- SMP ------------------- -#AC_MSG_CHECKING(for SMP) -#if egrep -e SMP=y $LINUX/.config >/dev/null 2>&1; then -# SMPFLAG= -# AC_MSG_RESULT(yes) +# ---------- Portals flags -------------------- + +#AC_PREFIX_DEFAULT([]) +#if test "x$prefix" = xNONE || test "x$prefix" = x; then +# usrprefix=/usr #else -# SMPFLAG= -# AC_MSG_RESULT(no) +# usrprefix='${prefix}' #fi +#AC_SUBST(usrprefix) + +AC_MSG_CHECKING(if kernel has CPU affinity support) +if test "$target_cpu" != ia64 ; then + enable_affinity_temp="-DCPU_AFFINITY=1" + AC_MSG_RESULT(yes) +else + enable_affinity_temp="" + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(if kernel has zero-copy TCP support) +ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" +if test "$ZCCD" != 0 ; then + enable_zerocopy_temp="-DSOCKNAL_ZC=1" + AC_MSG_RESULT(yes) +else + enable_zerocopy_temp="" + AC_MSG_RESULT(no) +fi + +AC_ARG_ENABLE(zerocopy, [ --enable-zerocopy enable socknal zerocopy],enable_zerocopy=$enable_zerocopy_temp, enable_zerocopy="") + +AC_ARG_ENABLE(affinity, [ --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp) +##################################### + +AC_MSG_CHECKING(if quadrics kernel headers are present) +if test -d $LINUX/drivers/net/qsnet ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/net/qsnet/include" + : +elif test -d $LINUX/drivers/qsnet1 ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/qsnet1/include -DPROPRIETARY_ELAN" + : +elif test -d $LINUX/drivers/quadrics ; then + AC_MSG_RESULT(yes) + QSWNAL="qswnal" + with_quadrics="-I$LINUX/drivers/quadrics/include -DPROPRIETARY_ELAN" + : +#elif test -d /usr/include/elan3 ; then +# AC_MSG_RESULT(yes) +# QSWNAL="qswnal" +# with_quadrics="" +# : +else + AC_MSG_RESULT(no) + QSWNAL="" + with_quadrics="" + : +fi +AC_SUBST(with_quadrics) +AC_SUBST(QSWNAL) + +# R. Read 5/02 +GMNAL="" +echo "checking with-gm=" ${with_gm} +if test "${with_gm+set}" = set; then + if test "${with_gm}" = yes; then + with_gm="-I/usr/local/gm/include" + else + with_gm=-I"$with_gm/include" + fi + GMNAL="gmnal" +else +# default case - no GM + with_gm="" +fi +AC_SUBST(with_gm) +AC_SUBST(GMNAL) + + +def_scamac=/opt/scali/include +AC_ARG_WITH(scamac, [ --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac) +AC_MSG_CHECKING(if ScaMAC headers are present) +if test "$with_scamac" = yes; then + with_scamac=$def_scamac +fi +if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then + AC_MSG_RESULT(yes) + SCIMACNAL="scimacnal" + with_scamac="-I${with_scamac} -I${with_scamac}/icm" +else + AC_MSG_RESULT(no) + SCIMACNAL="" + with_scamac="" +fi + +AC_SUBST(with_scamac) +AC_SUBST(SCIMACNAL) CFLAGS="$KCFLAGS" -CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS " +CPPFLAGS="$KINCFLAGS $KCPPFLAGS $MFLAGS $enable_zerocopy $enable_affinity $with_quadrics $with_gm $with_scamac " AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib) AC_SUBST(MOD_LINK) AC_SUBST(LINUX25) +AM_CONDITIONAL(LIBLUSTRE, test x$host_cpu = xlib) + +# ---------- Red Hat 2.4.20 backports some 2.5 bits -------- +# This needs to run after we've defined the KCPPFLAGS + +AC_MSG_CHECKING(for kernel version) +AC_TRY_LINK([#define __KERNEL__ + #include ], + [struct task_struct p; + p.sighand = NULL;], + [RH_2_4_20=1], + [RH_2_4_20=0]) + +if test $RH_2_4_20 = 1; then + AC_MSG_RESULT(redhat-2.4.20) + CPPFLAGS="$CPPFLAGS -DCONFIG_RH_2_4_20" +else + AC_MSG_RESULT($RELEASE) +fi diff --git a/lustre/portals/build.m4 b/lustre/portals/build.m4 index 2f2b9e4..025f243 100644 --- a/lustre/portals/build.m4 +++ b/lustre/portals/build.m4 @@ -1,5 +1,4 @@ - -# ---------- directories --------- +# ---------- other tests and settings --------- # --------- unsigned long long sane? ------- @@ -94,6 +93,3 @@ fi AC_SUBST(LIBEFENCE) AC_SUBST(HAVE_LIBEFENCE) -# end -------- Kernel build environment. ----------------- - - diff --git a/lustre/portals/configure.in b/lustre/portals/configure.in index 2ee86b2..31d3492 100644 --- a/lustre/portals/configure.in +++ b/lustre/portals/configure.in @@ -13,7 +13,6 @@ AM_INIT_AUTOMAKE(portals, builtin([esyscmd], [sed -ne '/.*define IVERSION /{ s/. sinclude(build.m4) sinclude(archdep.m4) -sinclude(portalsconf.m4) if test x$enable_inkernel = xyes ; then cp Kernelenv.mk Kernelenv.in @@ -31,6 +30,5 @@ AC_OUTPUT([Makefile Kernelenv libcfs/Makefile portals/Makefile \ unals/Makefile knals/Makefile router/Makefile \ knals/socknal/Makefile knals/gmnal/Makefile knals/qswnal/Makefile \ knals/scimacnal/Makefile knals/toenal/Makefile \ - utils/Makefile tests/Makefile doc/Makefile \ - packaging/Makefile packaging/portals.spec ]) + utils/Makefile tests/Makefile doc/Makefile ]) diff --git a/lustre/portals/doc/ieee.bst b/lustre/portals/doc/ieee.bst index 0ef514e..4df7c50 100644 --- a/lustre/portals/doc/ieee.bst +++ b/lustre/portals/doc/ieee.bst @@ -1,7 +1,5 @@ % --------------------------------------------------------------- % -% $Id: ieee.bst,v 1.1.4.1 2003/05/19 17:04:11 meijia Exp $ -% % by Paolo.Ienne@di.epfl.ch % % --------------------------------------------------------------- diff --git a/lustre/portals/doc/portals3.lyx b/lustre/portals/doc/portals3.lyx index b59eb1f..8429280 100644 --- a/lustre/portals/doc/portals3.lyx +++ b/lustre/portals/doc/portals3.lyx @@ -7,8 +7,6 @@ {\begin{quote}\textbf{Discussion}: \slshape}% {\end{quote}} \pagestyle{myheadings} -\markboth{$Revision: 1.1.4.1 $\hfil$Date: 2003/05/19 17:04:12 $}% -{$Date: 2003/05/19 17:04:12 $\hfil$Revision: 1.1.4.1 $} \end_preamble \language american \inputencoding auto diff --git a/lustre/portals/include/linux/kp30.h b/lustre/portals/include/linux/kp30.h index 46d9406..afb2104 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -4,6 +4,9 @@ #ifndef _KP30_INCLUDED #define _KP30_INCLUDED +#ifdef __KERNEL__ +#include +#endif #define PORTAL_DEBUG @@ -83,45 +86,42 @@ extern unsigned int portal_printk; #ifndef __KERNEL__ #define THREAD_SIZE 8192 #endif -#ifdef __arch_ia64__ -#define CDEBUG_STACK(var) (&var & (THREAD_SIZE - 1)) +#ifdef __ia64__ +#define CDEBUG_STACK() (THREAD_SIZE - \ + ((unsigned long)__builtin_dwarf_cfa() & \ + (THREAD_SIZE - 1))) #else -#define CDEBUG_STACK(var) (THREAD_SIZE - \ - ((unsigned long)__builtin_frame_address(0)& \ - (THREAD_SIZE - 1))) +#define CDEBUG_STACK() (THREAD_SIZE - \ + ((unsigned long)__builtin_frame_address(0) & \ + (THREAD_SIZE - 1))) #endif #ifdef __KERNEL__ #define CHECK_STACK(stack) \ do { \ - if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) \ + if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \ portals_debug_msg(DEBUG_SUBSYSTEM, D_ERROR, \ __FILE__, __FUNCTION__, __LINE__, \ (stack), \ "maximum lustre stack %u\n", \ portal_stack = (stack)); \ + /*panic("LBUG");*/ \ + } \ } while (0) #else -#define CHECK_STACK(stack) do{}while(0) +#define CHECK_STACK(stack) do { } while(0) #endif +#if 1 #define CDEBUG(mask, format, a...) \ do { \ - unsigned long stack = CDEBUG_STACK(stack); \ - int match = 0; \ - \ - CHECK_STACK(stack); \ - if (!(mask)) \ - match = 1; \ - else if ((mask) & (D_ERROR | D_EMERG)) \ - match = 1; \ - else if (portal_debug & (mask) && \ - portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))) \ - match = 1; \ - if (match) \ + CHECK_STACK(CDEBUG_STACK()); \ + if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) || \ + (portal_debug & (mask) && \ + portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24)))) \ portals_debug_msg(DEBUG_SUBSYSTEM, mask, \ __FILE__, __FUNCTION__, __LINE__, \ - stack, format , ## a); \ + CDEBUG_STACK(), format , ## a); \ } while (0) #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a) @@ -140,10 +140,8 @@ do { \ #define RETURN(rc) \ do { \ typeof(rc) RETURN__ret = (rc); \ - long tmp = (long)RETURN__ret; \ CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \ - (unsigned long)tmp, (signed long)tmp, \ - (signed long)tmp); \ + (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\ return RETURN__ret; \ } while (0) @@ -156,6 +154,16 @@ do { \ do { \ CDEBUG(D_TRACE, "Process leaving\n"); \ } while(0) +#else +#define CDEBUG(mask, format, a...) do { } while (0) +#define CWARN(format, a...) do { } while (0) +#define CERROR(format, a...) printk("<3>" format, ## a) +#define CEMERG(format, a...) printk("<0>" format, ## a) +#define GOTO(label, rc) do { (void)(rc); goto label; } while (0) +#define RETURN(rc) return (rc) +#define ENTRY do { } while (0) +#define EXIT do { } while (0) +#endif #ifdef __KERNEL__ @@ -213,24 +221,26 @@ extern void kportal_assertion_failed(char *expr,char *file,char *func,int line); #endif #ifdef __arch_um__ -#define LBUG() \ +#define LBUG_WITH_LOC(file, func, line) \ do { \ CEMERG("LBUG - trying to dump log to /tmp/lustre-log\n"); \ portals_debug_dumplog(); \ - portals_run_lbug_upcall(__FILE__, __FUNCTION__, __LINE__); \ + portals_run_lbug_upcall(file, func, line); \ panic("LBUG"); \ } while (0) #else -#define LBUG() \ +#define LBUG_WITH_LOC(file, func, line) \ do { \ CEMERG("LBUG\n"); \ portals_debug_dumplog(); \ - portals_run_lbug_upcall(__FILE__, __FUNCTION__, __LINE__); \ + portals_run_lbug_upcall(file, func, line); \ set_task_state(current, TASK_UNINTERRUPTIBLE); \ schedule(); \ } while (0) #endif /* __arch_um__ */ +#define LBUG() LBUG_WITH_LOC(__FILE__, __FUNCTION__, __LINE__) + /* * Memory */ @@ -260,7 +270,7 @@ do { \ if (s > PORTAL_VMALLOC_SIZE) \ (ptr) = vmalloc(s); \ else \ - (ptr) = kmalloc(s, GFP_KERNEL); \ + (ptr) = kmalloc(s, GFP_NOFS); \ if ((ptr) == NULL) \ CERROR("PORTALS: out of memory at %s:%d (tried to alloc" \ " '" #ptr "' = %ld)\n", __FILE__, __LINE__, s); \ @@ -460,8 +470,8 @@ kpr_lookup (kpr_router_t *router, ptl_nid_t nid, ptl_nid_t *gateway_nid) } static inline void -kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, - int nob, int niov, struct iovec *iov, +kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, + int nob, int niov, struct iovec *iov, kpr_fwd_callback_t callback, void *callback_arg) { fwd->kprfd_target_nid = nid; @@ -605,7 +615,7 @@ extern void kportal_blockallsigs (void); # ifdef PORTAL_DEBUG # undef NDEBUG # include -# define LASSERT(e) assert(e) +# define LASSERT(e) assert(e) # else # define LASSERT(e) # endif @@ -909,7 +919,7 @@ void kportal_put_ni (int nal); #ifndef BITS_PER_LONG #if (~0UL) == 0xffffffffUL #define BITS_PER_LONG 32 -#else +#else #define BITS_PER_LONG 64 #endif #endif diff --git a/lustre/portals/include/portals/defines.h b/lustre/portals/include/portals/defines.h index a7580b5..785ce73 100644 --- a/lustre/portals/include/portals/defines.h +++ b/lustre/portals/include/portals/defines.h @@ -1,5 +1,4 @@ /* -** $Id: defines.h,v 1.1.4.1 2003/05/19 17:04:13 meijia Exp $ ** ** This files contains definitions that are used throughout the cplant code. */ diff --git a/lustre/portals/include/portals/lib-p30.h b/lustre/portals/include/portals/lib-p30.h index b70e128..b623b93 100644 --- a/lustre/portals/include/portals/lib-p30.h +++ b/lustre/portals/include/portals/lib-p30.h @@ -170,10 +170,10 @@ lib_msg_free (nal_cb_t *nal, lib_msg_t *msg) #else -extern kmem_cache_t *ptl_md_slab; -extern kmem_cache_t *ptl_msg_slab; -extern kmem_cache_t *ptl_me_slab; -extern kmem_cache_t *ptl_eq_slab; +extern kmem_cache_t *ptl_md_slab; +extern kmem_cache_t *ptl_msg_slab; +extern kmem_cache_t *ptl_me_slab; +extern kmem_cache_t *ptl_eq_slab; extern atomic_t md_in_use_count; extern atomic_t msg_in_use_count; extern atomic_t me_in_use_count; @@ -183,28 +183,28 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL); - + lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + if (eq == NULL) return (NULL); - + atomic_inc (&eq_in_use_count); return (eq); } -static inline void +static inline void lib_eq_free (nal_cb_t *nal, lib_eq_t *eq) { /* ALWAYS called with statelock held */ atomic_dec (&eq_in_use_count); - kmem_cache_free(ptl_eq_slab, eq); + kmem_cache_free(ptl_eq_slab, eq); } static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); + lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); if (md == NULL) return (NULL); @@ -225,11 +225,11 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL); + lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); if (me == NULL) return (NULL); - + atomic_inc (&me_in_use_count); return (me); } @@ -246,7 +246,7 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); if (msg == NULL) return (NULL); @@ -370,6 +370,7 @@ extern void lib_copy_buf2iov (int niov, struct iovec *iov, char *dest, ptl_size_ extern ptl_size_t lib_kiov_nob (int niov, ptl_kiov_t *iov); extern void lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *iov, ptl_size_t len); extern void lib_copy_buf2kiov (int niov, ptl_kiov_t *iov, char *src, ptl_size_t len); +extern void lib_assert_wire_constants (void); extern void lib_recv (nal_cb_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen); diff --git a/lustre/portals/include/portals/lib-types.h b/lustre/portals/include/portals/lib-types.h index bece0a30..47c0dd2 100644 --- a/lustre/portals/include/portals/lib-types.h +++ b/lustre/portals/include/portals/lib-types.h @@ -31,6 +31,8 @@ typedef struct lib_me_t lib_me_t; typedef struct lib_md_t lib_md_t; typedef struct lib_eq_t lib_eq_t; +#define WIRE_ATTR __attribute__((packed)) + /* The wire handle's interface cookie only matches one network interface in * one epoch (i.e. new cookie when the interface restarts or the node * reboots). The object cookie only matches one object on that interface @@ -38,7 +40,7 @@ typedef struct lib_eq_t lib_eq_t; typedef struct { __u64 wh_interface_cookie; __u64 wh_object_cookie; -} ptl_handle_wire_t; +} WIRE_ATTR ptl_handle_wire_t; /* byte-flip insensitive! */ #define PTL_WIRE_HANDLE_NONE \ @@ -63,7 +65,7 @@ typedef struct ptl_ack { ptl_handle_wire_t dst_wmd; ptl_match_bits_t match_bits; ptl_size_t length; /* common length (0 for acks) moving out RSN */ -} ptl_ack_t; +} WIRE_ATTR ptl_ack_t; typedef struct ptl_put { ptl_pt_index_t ptl_index; @@ -72,7 +74,7 @@ typedef struct ptl_put { ptl_size_t length; /* common length moving out RSN */ ptl_size_t offset; ptl_hdr_data_t hdr_data; -} ptl_put_t; +} WIRE_ATTR ptl_put_t; typedef struct ptl_get { ptl_pt_index_t ptl_index; @@ -82,7 +84,7 @@ typedef struct ptl_get { ptl_size_t src_offset; ptl_size_t return_offset; /* unused: going RSN */ ptl_size_t sink_length; -} ptl_get_t; +} WIRE_ATTR ptl_get_t; typedef struct ptl_reply { __u32 unused1; /* unused fields going RSN */ @@ -90,7 +92,7 @@ typedef struct ptl_reply { ptl_size_t dst_offset; /* unused: going RSN */ __u32 unused2; ptl_size_t length; /* common length moving out RSN */ -} ptl_reply_t; +} WIRE_ATTR ptl_reply_t; typedef struct { ptl_nid_t dest_nid; @@ -104,7 +106,7 @@ typedef struct { ptl_get_t get; ptl_reply_t reply; } msg; -} ptl_hdr_t; +} WIRE_ATTR ptl_hdr_t; /* All length fields in individual unions at same offset */ /* LASSERT for same in lib-move.c */ @@ -122,7 +124,7 @@ typedef struct { __u32 magic; /* PORTALS_PROTO_MAGIC */ __u16 version_major; /* increment on incompatible change */ __u16 version_minor; /* increment on compatible change */ -} ptl_magicversion_t; +} WIRE_ATTR ptl_magicversion_t; #define PORTALS_PROTO_MAGIC 0xeebc0ded diff --git a/lustre/portals/include/portals/list.h b/lustre/portals/include/portals/list.h index 41613ab..2b63312 100644 --- a/lustre/portals/include/portals/list.h +++ b/lustre/portals/include/portals/list.h @@ -233,14 +233,13 @@ static inline void list_splice_init(struct list_head *list, /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop counter. - * @n: the &struct list_head to use as temporary storage + * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry_safe(pos, n, head, member) \ +#define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = pos->member.next; \ + n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ - pos = list_entry(n, typeof(*pos), member), \ - n = pos->member.next) + pos = n, n = list_entry(n->member.next, typeof(*n), member)) #endif diff --git a/lustre/portals/include/portals/myrnal.h b/lustre/portals/include/portals/myrnal.h index d3337218..12b1925 100644 --- a/lustre/portals/include/portals/myrnal.h +++ b/lustre/portals/include/portals/myrnal.h @@ -1,5 +1,4 @@ /* -** $Id: myrnal.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ #ifndef MYRNAL_H diff --git a/lustre/portals/include/portals/nal.h b/lustre/portals/include/portals/nal.h index 8c035f7..88be63c 100644 --- a/lustre/portals/include/portals/nal.h +++ b/lustre/portals/include/portals/nal.h @@ -1,5 +1,4 @@ /* -** $Id: nal.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ #ifndef _NAL_H_ #define _NAL_H_ diff --git a/lustre/portals/include/portals/ppid.h b/lustre/portals/include/portals/ppid.h index 28f74e3..4727599 100644 --- a/lustre/portals/include/portals/ppid.h +++ b/lustre/portals/include/portals/ppid.h @@ -1,5 +1,4 @@ /* - * TITLE(ppid_h, "@(#) $Id: ppid.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $"); */ #ifndef _INCppidh_ diff --git a/lustre/portals/include/portals/ptlctl.h b/lustre/portals/include/portals/ptlctl.h index fdaae69..dc02780 100644 --- a/lustre/portals/include/portals/ptlctl.h +++ b/lustre/portals/include/portals/ptlctl.h @@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv); int jt_ptl_disconnect(int argc, char **argv); int jt_ptl_push_connection(int argc, char **argv); int jt_ptl_ping(int argc, char **argv); +int jt_ptl_shownid(int argc, char **argv); int jt_ptl_mynid(int argc, char **argv); int jt_ptl_add_uuid(int argc, char **argv); int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility */ diff --git a/lustre/portals/include/portals/stringtab.h b/lustre/portals/include/portals/stringtab.h index 7d3675f..c9683f7 100644 --- a/lustre/portals/include/portals/stringtab.h +++ b/lustre/portals/include/portals/stringtab.h @@ -1,5 +1,4 @@ /* -** $Id: stringtab.h,v 1.1.4.1 2003/05/19 17:04:14 meijia Exp $ */ /* * stringtab.h diff --git a/lustre/portals/knals/Makefile.am b/lustre/portals/knals/Makefile.am index 5c6085e..fed2785 100644 --- a/lustre/portals/knals/Makefile.am +++ b/lustre/portals/knals/Makefile.am @@ -3,4 +3,5 @@ # This code is issued under the GNU General Public License. # See the file COPYING in this distribution +DIST_SUBDIRS= socknal toenal qswnal gmnal scimacnal SUBDIRS= socknal toenal @QSWNAL@ @GMNAL@ @SCIMACNAL@ diff --git a/lustre/portals/knals/qswnal/qswnal.c b/lustre/portals/knals/qswnal/qswnal.c index d64b7ad..1a8fb74 100644 --- a/lustre/portals/knals/qswnal/qswnal.c +++ b/lustre/portals/knals/qswnal/qswnal.c @@ -101,16 +101,36 @@ static nal_t * kqswnal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size, ptl_pid_t requested_pid) { - ptl_nid_t mynid = ep_nodeid (kqswnal_data.kqn_epdev); - int nnids = ep_numnodes (kqswnal_data.kqn_epdev); + ptl_nid_t mynid = kqswnal_elanid2nid (kqswnal_data.kqn_elanid); + int nnids = kqswnal_data.kqn_nnodes; - CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid,nnids); + CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid, nnids); lib_init(&kqswnal_lib, mynid, 0, nnids, ptl_size, ac_size); return (&kqswnal_api); } +int +kqswnal_cmd (struct portal_ioctl_data *data, void *private) +{ + LASSERT (data != NULL); + + switch (data->ioc_nal_cmd) { + case NAL_CMD_REGISTER_MYNID: + CDEBUG (D_IOCTL, "setting NID offset to "LPX64" (was "LPX64")\n", + data->ioc_nid - kqswnal_data.kqn_elanid, + kqswnal_data.kqn_nid_offset); + kqswnal_data.kqn_nid_offset = + data->ioc_nid - kqswnal_data.kqn_elanid; + kqswnal_lib.ni.nid = data->ioc_nid; + return (0); + + default: + return (-EINVAL); + } +} + void __exit kqswnal_finalise (void) { @@ -324,6 +344,10 @@ kqswnal_initialise (void) return (-ENOMEM); } + kqswnal_data.kqn_nid_offset = 0; + kqswnal_data.kqn_nnodes = ep_numnodes (kqswnal_data.kqn_epdev); + kqswnal_data.kqn_elanid = ep_nodeid (kqswnal_data.kqn_epdev); + /**********************************************************************/ /* Get the transmitter */ @@ -477,7 +501,7 @@ kqswnal_initialise (void) LASSERT (krx->krx_npages > 0); for (j = 0; j < krx->krx_npages; j++) { - krx->krx_pages[j] = alloc_page (GFP_KERNEL); + krx->krx_pages[j] = alloc_page(GFP_KERNEL); if (krx->krx_pages[j] == NULL) { kqswnal_finalise (); @@ -554,13 +578,19 @@ kqswnal_initialise (void) rc = kpr_register (&kqswnal_data.kqn_router, &kqswnal_router_interface); CDEBUG(D_NET, "Can't initialise routing interface (rc = %d): not routing\n",rc); + rc = kportal_nal_register (QSWNAL, &kqswnal_cmd, NULL); + if (rc != 0) { + CERROR ("Can't initialise command interface (rc = %d)\n", rc); + kqswnal_finalise (); + return (rc); + } + PORTAL_SYMBOL_REGISTER(kqswnal_ni); kqswnal_data.kqn_init = KQN_INIT_ALL; printk(KERN_INFO "Routing QSW NAL loaded on node %d of %d " "(Routing %s, initial mem %d)\n", - ep_nodeid (kqswnal_data.kqn_epdev), - ep_numnodes (kqswnal_data.kqn_epdev), + kqswnal_data.kqn_elanid, kqswnal_data.kqn_nnodes, kpr_routing (&kqswnal_data.kqn_router) ? "enabled" : "disabled", pkmem); diff --git a/lustre/portals/knals/qswnal/qswnal.h b/lustre/portals/knals/qswnal/qswnal.h index 657b02b..ceb7c8c 100644 --- a/lustre/portals/knals/qswnal/qswnal.h +++ b/lustre/portals/knals/qswnal/qswnal.h @@ -24,7 +24,9 @@ #ifndef _QSWNAL_H #define _QSWNAL_H -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #ifdef PROPRIETARY_ELAN # include @@ -200,6 +202,10 @@ typedef struct ELAN3_DMA_HANDLE *kqn_eptxdmahandle; /* elan reserved tx vaddrs */ ELAN3_DMA_HANDLE *kqn_eprxdmahandle; /* elan reserved rx vaddrs */ kpr_router_t kqn_router; /* connection to Kernel Portals Router module */ + + ptl_nid_t kqn_nid_offset; /* this cluster's NID offset */ + int kqn_nnodes; /* this cluster's size */ + int kqn_elanid; /* this nodes's elan ID */ } kqswnal_data_t; /* kqn_init state */ @@ -217,6 +223,23 @@ extern void kqswnal_rxhandler(EP_RXD *rxd); extern int kqswnal_scheduler (void *); extern void kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd); +static inline ptl_nid_t +kqswnal_elanid2nid (int elanid) +{ + return (kqswnal_data.kqn_nid_offset + elanid); +} + +static inline int +kqswnal_nid2elanid (ptl_nid_t nid) +{ + /* not in this cluster? */ + if (nid < kqswnal_data.kqn_nid_offset || + nid >= kqswnal_data.kqn_nid_offset + kqswnal_data.kqn_nnodes) + return (-1); + + return (nid - kqswnal_data.kqn_nid_offset); +} + static inline void kqswnal_requeue_rx (kqswnal_rx_t *krx) { diff --git a/lustre/portals/knals/qswnal/qswnal_cb.c b/lustre/portals/knals/qswnal/qswnal_cb.c index 5979885..3b47a25 100644 --- a/lustre/portals/knals/qswnal/qswnal_cb.c +++ b/lustre/portals/knals/qswnal/qswnal_cb.c @@ -109,21 +109,15 @@ kqswnal_sti(nal_cb_t *nal, unsigned long *flags) static int kqswnal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist) { - /* network distance doesn't mean much for this nal */ - *dist = (nid == nal->ni.nid) ? 0 : 1; + if (nid == nal->ni.nid) + *dist = 0; /* it's me */ + else if (kqswnal_nid2elanid (nid) >= 0) + *dist = 1; /* it's my peer */ + else + *dist = 2; /* via router */ return (0); } -int -kqswnal_ispeer (ptl_nid_t nid) -{ - unsigned int elanid = (unsigned int)nid; - - /* didn't lose high bits on conversion and it's in this machine? */ - return ((ptl_nid_t)elanid == nid && - elanid < ep_numnodes (kqswnal_data.kqn_epdev)); -} - void kqswnal_unmap_tx (kqswnal_tx_t *ktx) { @@ -453,11 +447,14 @@ kqswnal_launch (kqswnal_tx_t *ktx) { /* Don't block for transmit descriptor if we're in interrupt context */ int attr = in_interrupt() ? (EP_NO_SLEEP | EP_NO_ALLOC) : 0; - int rc = ep_transmit_large(kqswnal_data.kqn_eptx, ktx->ktx_nid, - ktx->ktx_port, attr, kqswnal_txhandler, - ktx, ktx->ktx_iov, ktx->ktx_niov); + int dest = kqswnal_nid2elanid (ktx->ktx_nid); long flags; - + int rc; + + LASSERT (dest >= 0); /* must be a peer */ + rc = ep_transmit_large(kqswnal_data.kqn_eptx, dest, + ktx->ktx_port, attr, kqswnal_txhandler, + ktx, ktx->ktx_iov, ktx->ktx_niov); if (rc == 0) atomic_inc (&kqswnal_packets_launched); @@ -595,7 +592,7 @@ kqswnal_sendmsg (nal_cb_t *nal, return (-1); } - if (!kqswnal_ispeer (nid)) { /* Can't send direct: find gateway? */ + if (kqswnal_nid2elanid (nid) < 0) { /* Can't send direct: find gateway? */ rc = kpr_lookup (&kqswnal_data.kqn_router, nid, &gatewaynid); if (rc != 0) { CERROR("Can't route to "LPX64": router error %d\n", @@ -603,7 +600,7 @@ kqswnal_sendmsg (nal_cb_t *nal, lib_finalize (&kqswnal_lib, private, cookie); return (-1); } - if (!kqswnal_ispeer (gatewaynid)) { + if (kqswnal_nid2elanid (gatewaynid) < 0) { CERROR("Bad gateway "LPX64" for "LPX64"\n", gatewaynid, nid); lib_finalize (&kqswnal_lib, private, cookie); @@ -757,7 +754,7 @@ kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd) if (nid == kqswnal_lib.ni.nid) /* gateway is me */ nid = fwd->kprfd_target_nid; /* target is final dest */ - if (!kqswnal_ispeer (nid)) { + if (kqswnal_nid2elanid (nid) < 0) { CERROR("Can't forward [%p] to "LPX64": not a peer\n", fwd, nid); rc = -EHOSTUNREACH; goto failed; @@ -844,7 +841,7 @@ kqswnal_rx (kqswnal_rx_t *krx) CERROR ("checksums for forwarded packets not implemented\n"); LBUG (); #endif - if (kqswnal_ispeer (dest_nid)) /* should have gone direct to peer */ + if (kqswnal_nid2elanid (dest_nid) >= 0) /* should have gone direct to peer */ { CERROR("dropping packet from "LPX64" for "LPX64 ": target is peer\n", NTOH__u64(hdr->src_nid), dest_nid); diff --git a/lustre/portals/knals/socknal/socknal.c b/lustre/portals/knals/socknal/socknal.c index d15d8c8..3e65faa 100644 --- a/lustre/portals/knals/socknal/socknal.c +++ b/lustre/portals/knals/socknal/socknal.c @@ -95,10 +95,8 @@ nal_t * ksocknal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size, ptl_pid_t requested_pid) { - CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", - ksocknal_data.ksnd_mynid); - lib_init(&ksocknal_lib, ksocknal_data.ksnd_mynid, 0, 10, ptl_size, - ac_size); + CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", (ptl_nid_t)0); + lib_init(&ksocknal_lib, (ptl_nid_t)0, 0, 10, ptl_size, ac_size); return (&ksocknal_api); } @@ -129,7 +127,6 @@ ksocknal_set_mynid(ptl_nid_t nid) CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n", nid, ni->nid); - ksocknal_data.ksnd_mynid = nid; ni->nid = nid; return (0); } @@ -190,7 +187,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq) if (!conn) GOTO(error, ret); - memset (conn, 0, sizeof (conn)); /* zero for consistency */ + sock->sk->allocation = GFP_NOFS; /* don't call info fs for alloc */ conn->ksnc_file = file; conn->ksnc_sock = sock; @@ -207,7 +204,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq) conn->ksnc_tx_ready = 0; conn->ksnc_tx_scheduled = 0; -#warning check it is OK to derefence sk->dst_cache->dev like this... + /* XXX check it is OK to derefence sk->dst_cache->dev like this... */ lock_sock (conn->ksnc_sock->sk); if (conn->ksnc_sock->sk->dst_cache != NULL) { @@ -818,7 +815,7 @@ ksocknal_module_init (void) LASSERT (fmb->fmb_npages > 0); for (j = 0; j < fmb->fmb_npages; j++) { - fmb->fmb_pages[j] = alloc_page (GFP_KERNEL); + fmb->fmb_pages[j] = alloc_page(GFP_KERNEL); if (fmb->fmb_pages[j] == NULL) { ksocknal_module_fini (); diff --git a/lustre/portals/knals/socknal/socknal.h b/lustre/portals/knals/socknal/socknal.h index 46ee3b7..62f9265 100644 --- a/lustre/portals/knals/socknal/socknal.h +++ b/lustre/portals/knals/socknal/socknal.h @@ -25,7 +25,9 @@ */ #define DEBUG_PORTAL_ALLOC -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include @@ -106,7 +108,6 @@ typedef struct { struct list_head ksnd_socklist; /* all my connections */ rwlock_t ksnd_socklist_lock; /* stabilise add/find/remove */ - ptl_nid_t ksnd_mynid; nal_cb_t *ksnd_nal_cb; spinlock_t ksnd_nal_cb_lock; /* lib cli/sti lock */ @@ -273,9 +274,9 @@ extern void ksocknal_close_conn (ksock_conn_t *conn); static inline void ksocknal_put_conn (ksock_conn_t *conn) { - CDEBUG (D_OTHER, "putting conn[%p] -> "LPX64" (%d)\n", + CDEBUG (D_OTHER, "putting conn[%p] -> "LPX64" (%d)\n", conn, conn->ksnc_peernid, atomic_read (&conn->ksnc_refcount)); - + if (atomic_dec_and_test (&conn->ksnc_refcount)) _ksocknal_put_conn (conn); } diff --git a/lustre/portals/knals/socknal/socknal_cb.c b/lustre/portals/knals/socknal/socknal_cb.c index 6cf3cc4..3e7d206 100644 --- a/lustre/portals/knals/socknal/socknal_cb.c +++ b/lustre/portals/knals/socknal/socknal_cb.c @@ -589,7 +589,6 @@ ksocknal_process_transmit (ksock_sched_t *sched, long *irq_flags) CDEBUG (D_NET, "send(%d) %d\n", tx->tx_nob, rc); if (rc != 0) { -#warning FIXME: handle socket errors properly CERROR("Error socknal send(%d) %p: %d\n", tx->tx_nob, conn, rc); /* kid on for now the whole packet went. * NB when we handle the error better, we'll still need to @@ -740,15 +739,16 @@ ksocknal_setup_hdr (nal_cb_t *nal, void *private, lib_msg_t *cookie, } int -ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, +ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, struct iovec *payload_iov, size_t payload_len) + unsigned int payload_niov, struct iovec *payload_iov, + size_t payload_len) { ksock_ltx_t *ltx; ksock_conn_t *conn; - + /* NB 'private' is different depending on what we're sending. - * Just ignore it until we can rely on it + * Just ignore it until we can rely on it * * Also, the return code from this procedure is ignored. * If we can't send, we must still complete with lib_finalize(). @@ -756,31 +756,31 @@ ksocknal_send (nal_cb_t *nal, void *private, lib_msg_t *cookie, */ CDEBUG(D_NET, - "sending "LPSZ" bytes in %d mapped frags to nid: "LPX64" pid %d\n", - payload_len, payload_niov, nid, pid); + "sending "LPSZ" bytes in %d mapped frags to nid: "LPX64 + " pid %d\n", payload_len, payload_niov, nid, pid); conn = ksocknal_send_target (nid); if (conn == NULL) { lib_finalize (&ksocknal_lib, private, cookie); return (-1); } - + ltx = ksocknal_setup_hdr (nal, private, cookie, hdr, type); if (ltx == NULL) { ksocknal_put_conn (conn); lib_finalize (&ksocknal_lib, private, cookie); return (-1); } - + /* append the payload_iovs to the one pointing at the header */ LASSERT (ltx->ltx_tx.tx_niov == 1 && ltx->ltx_tx.tx_nkiov == 0); LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - memcpy (ltx->ltx_tx.tx_iov + 1, payload_iov, + + memcpy (ltx->ltx_tx.tx_iov + 1, payload_iov, payload_niov * sizeof (*payload_iov)); ltx->ltx_tx.tx_niov = 1 + payload_niov; ltx->ltx_tx.tx_nob = sizeof (*hdr) + payload_len; - + ksocknal_launch_packet (conn, <x->ltx_tx); return (0); } @@ -1224,7 +1224,6 @@ ksocknal_process_receive (ksock_sched_t *sched, long *irq_flags) if (rc == 0) goto out; if (rc < 0) { -#warning FIXME: handle socket errors properly CERROR ("Error socknal read %p: %d\n", conn, rc); goto out; } diff --git a/lustre/portals/knals/toenal/toenal.c b/lustre/portals/knals/toenal/toenal.c index 178ea41..1f5dc38 100644 --- a/lustre/portals/knals/toenal/toenal.c +++ b/lustre/portals/knals/toenal/toenal.c @@ -522,7 +522,7 @@ ktoenal_module_init (void) LASSERT (fmb->fmb_npages > 0); for (j = 0; j < fmb->fmb_npages; j++) { - fmb->fmb_pages[j] = alloc_page (GFP_KERNEL); + fmb->fmb_pages[j] = alloc_page(GFP_KERNEL); if (fmb->fmb_pages[j] == NULL) { diff --git a/lustre/portals/knals/toenal/toenal.h b/lustre/portals/knals/toenal/toenal.h index f793d3b..3654848 100644 --- a/lustre/portals/knals/toenal/toenal.h +++ b/lustre/portals/knals/toenal/toenal.h @@ -27,7 +27,9 @@ */ #define DEBUG_PORTAL_ALLOC -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lustre/portals/knals/toenal/toenal_cb.c b/lustre/portals/knals/toenal/toenal_cb.c index 7dfb0fa..5388f4b 100644 --- a/lustre/portals/knals/toenal/toenal_cb.c +++ b/lustre/portals/knals/toenal/toenal_cb.c @@ -300,7 +300,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) rc = 0; /* nothing sent */ else { -#warning FIXME: handle socket errors properly + /* FIXME: handle socket errors properly */ CERROR ("Error socknal send(%d) %p: %d\n", tx->tx_nob, conn, rc); rc = tx->tx_nob; /* kid on for now whole packet went */ } @@ -423,11 +423,10 @@ ktoenal_send(nal_cb_t *nal, void *private, lib_msg_t *cookie, * packet as a side-effect of another packet, such as when an ACK has * been requested. -phil */ - CDEBUG(D_NET, "sending "LPSZ" bytes from [%d](%p,%d)... to nid: "LPX64" pid %d\n", - payload_len, payload_niov, + CDEBUG(D_NET, "sending %d bytes from [%d](%p,%d)... to nid: " + LPX64" pid %d\n", (int)payload_len, payload_niov, payload_niov > 0 ? payload_iov[0].iov_base : NULL, - payload_niov > 0 ? payload_iov[0].iov_len : 0, - nid, pid); + (int)(payload_niov > 0 ? payload_iov[0].iov_len : 0), nid, pid); if ((conn = ktoenal_get_conn (nid)) == NULL) { @@ -862,7 +861,7 @@ ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags) if (len != -EAGAIN && /* ! nothing to read now */ len != 0) /* ! nothing to read ever */ { -#warning FIXME: handle socket errors properly + /* FIXME: handle socket errors properly */ CERROR ("Error socknal read(%d) %p: %d\n", conn->ksnc_rx_nob_wanted, conn, len); } diff --git a/lustre/portals/libcfs/debug.c b/lustre/portals/libcfs/debug.c index 6233b8d..491c954 100644 --- a/lustre/portals/libcfs/debug.c +++ b/lustre/portals/libcfs/debug.c @@ -20,7 +20,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include @@ -237,7 +239,8 @@ int portals_do_debug_dumplog(void *arg) file = filp_open(debug_file_name, O_CREAT|O_TRUNC|O_RDWR, 0644); if (!file || IS_ERR(file)) { - CERROR("cannot open %s for dumping", debug_file_name); + CERROR("cannot open %s for dumping: %ld\n", debug_file_name, + PTR_ERR(file)); GOTO(out, PTR_ERR(file)); } else { printk(KERN_ALERT "dumping log to %s ... writing ...\n", @@ -274,7 +277,7 @@ int portals_debug_daemon(void *arg) void *journal_info; mm_segment_t oldfs; unsigned long force_flush = 0; - unsigned long size; + unsigned long size, off, flags; int rc; kportal_daemonize("ldebug_daemon"); @@ -295,7 +298,17 @@ int portals_debug_daemon(void *arg) debug_daemon_state.overlapped = 0; debug_daemon_state.stopped = 0; + + spin_lock_irqsave(&portals_debug_lock, flags); + off = atomic_read(&debug_off_a) + 1; + if (debug_wrapped) + off = (off >= debug_size)? 0 : off; + else + off = 0; + atomic_set(&debug_daemon_next_write, off); atomic_set(&debug_daemon_state.paused, 0); + spin_unlock_irqrestore(&portals_debug_lock, flags); + oldfs = get_fs(); set_fs(KERNEL_DS); while (1) { @@ -431,8 +444,6 @@ int portals_debug_daemon_start(char *file, unsigned int size) init_waitqueue_head(&debug_daemon_state.lctl); init_waitqueue_head(&debug_daemon_state.daemon); - atomic_set(&debug_daemon_next_write, atomic_read(&debug_off_a)); - daemon_file_size_limit = size << 20; debug_daemon_state.lctl_event = 0; diff --git a/lustre/portals/libcfs/module.c b/lustre/portals/libcfs/module.c index 1b9e5bb..5e3fcb5 100644 --- a/lustre/portals/libcfs/module.c +++ b/lustre/portals/libcfs/module.c @@ -19,7 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #define DEBUG_SUBSYSTEM S_PORTALS #include @@ -45,6 +47,7 @@ #include #include #include +#include #define PORTAL_MINOR 240 @@ -62,10 +65,9 @@ struct semaphore nal_cmd_sem; void kportal_assertion_failed (char *expr, char *file, char *func, int line) { - unsigned long stack = CDEBUG_STACK(stack); - portals_debug_msg(0, D_EMERG, file, func, line, stack, + portals_debug_msg(0, D_EMERG, file, func, line, CDEBUG_STACK(), "ASSERTION(%s) failed\n", expr); - LBUG(); + LBUG_WITH_LOC(file, func, line); } #endif @@ -85,10 +87,10 @@ kportal_blockallsigs () { unsigned long flags; - spin_lock_irqsave (¤t->sigmask_lock, flags); - siginitsetinv (¤t->blocked, 0); - recalc_sigpending (current); - spin_unlock_irqrestore (¤t->sigmask_lock, flags); + SIGNAL_MASK_LOCK(current, flags); + sigfillset(¤t->blocked); + RECALC_SIGPENDING; + SIGNAL_MASK_UNLOCK(current, flags); } /* called when opening /dev/device */ diff --git a/lustre/portals/libcfs/proc.c b/lustre/portals/libcfs/proc.c index 2fa739a..bb6c377 100644 --- a/lustre/portals/libcfs/proc.c +++ b/lustre/portals/libcfs/proc.c @@ -22,7 +22,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lustre/portals/portals/lib-init.c b/lustre/portals/portals/lib-init.c index d6315c6..99c4d32 100644 --- a/lustre/portals/portals/lib-init.c +++ b/lustre/portals/portals/lib-init.c @@ -357,6 +357,8 @@ lib_init(nal_cb_t * nal, ptl_nid_t nid, ptl_pid_t pid, int gsize, goto out; } + lib_assert_wire_constants (); + /* * Allocate the portal table for this interface * and all per-interface objects. diff --git a/lustre/portals/portals/lib-md.c b/lustre/portals/portals/lib-md.c index a79e2be..415eda6 100644 --- a/lustre/portals/portals/lib-md.c +++ b/lustre/portals/portals/lib-md.c @@ -396,7 +396,7 @@ int do_PtlMDUpdate_internal(nal_cb_t * nal, void *private, void *v_args, test_eq->sequence == args->sequence_in) { lib_me_t *me = md->me; -#warning this does not track eq refcounts properly + /* XXX this does not track eq refcounts properly */ ret->rc = lib_md_build(nal, md, private, new, &new->eventq, md->unlink); diff --git a/lustre/portals/portals/lib-move.c b/lustre/portals/portals/lib-move.c index a04e961..fde4f16 100644 --- a/lustre/portals/portals/lib-move.c +++ b/lustre/portals/portals/lib-move.c @@ -1285,3 +1285,95 @@ int do_PtlGet(nal_cb_t * nal, void *private, void *v_args, void *v_ret) return ret->rc = PTL_OK; } + +void lib_assert_wire_constants (void) +{ + /* Wire protocol assertions generated by 'wirecheck' */ + + /* Constants... */ + LASSERT (PORTALS_PROTO_MAGIC == 0xeebc0ded); + LASSERT (PORTALS_PROTO_VERSION_MAJOR == 0); + LASSERT (PORTALS_PROTO_VERSION_MINOR == 1); + LASSERT (PTL_MSG_ACK == 0); + LASSERT (PTL_MSG_PUT == 1); + LASSERT (PTL_MSG_GET == 2); + LASSERT (PTL_MSG_REPLY == 3); + LASSERT (PTL_MSG_HELLO == 4); + + /* Checks for struct ptl_handle_wire_t */ + LASSERT (sizeof (ptl_handle_wire_t) == 16); + LASSERT (offsetof (ptl_handle_wire_t, wh_interface_cookie) == 0); + LASSERT (sizeof (((ptl_handle_wire_t *)0)->wh_interface_cookie) == 8); + LASSERT (offsetof (ptl_handle_wire_t, wh_object_cookie) == 8); + LASSERT (sizeof (((ptl_handle_wire_t *)0)->wh_object_cookie) == 8); + + /* Checks for struct ptl_magicversion_t */ + LASSERT (sizeof (ptl_magicversion_t) == 8); + LASSERT (offsetof (ptl_magicversion_t, magic) == 0); + LASSERT (sizeof (((ptl_magicversion_t *)0)->magic) == 4); + LASSERT (offsetof (ptl_magicversion_t, version_major) == 4); + LASSERT (sizeof (((ptl_magicversion_t *)0)->version_major) == 2); + LASSERT (offsetof (ptl_magicversion_t, version_minor) == 6); + LASSERT (sizeof (((ptl_magicversion_t *)0)->version_minor) == 2); + + /* Checks for struct ptl_hdr_t */ + LASSERT (sizeof (ptl_hdr_t) == 72); + LASSERT (offsetof (ptl_hdr_t, dest_nid) == 0); + LASSERT (sizeof (((ptl_hdr_t *)0)->dest_nid) == 8); + LASSERT (offsetof (ptl_hdr_t, src_nid) == 8); + LASSERT (sizeof (((ptl_hdr_t *)0)->src_nid) == 8); + LASSERT (offsetof (ptl_hdr_t, dest_pid) == 16); + LASSERT (sizeof (((ptl_hdr_t *)0)->dest_pid) == 4); + LASSERT (offsetof (ptl_hdr_t, src_pid) == 20); + LASSERT (sizeof (((ptl_hdr_t *)0)->src_pid) == 4); + LASSERT (offsetof (ptl_hdr_t, type) == 24); + LASSERT (sizeof (((ptl_hdr_t *)0)->type) == 4); + + /* Ack */ + LASSERT (offsetof (ptl_hdr_t, msg.ack.mlength) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.mlength) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.ack.dst_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.dst_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.ack.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.ack.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.ack.length) == 4); + + /* Put */ + LASSERT (offsetof (ptl_hdr_t, msg.put.ptl_index) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.ptl_index) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.ack_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.ack_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.put.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.put.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.length) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.offset) == 60); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.put.hdr_data) == 64); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.put.hdr_data) == 8); + + /* Get */ + LASSERT (offsetof (ptl_hdr_t, msg.get.ptl_index) == 28); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.ptl_index) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.return_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.return_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.get.match_bits) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.match_bits) == 8); + LASSERT (offsetof (ptl_hdr_t, msg.get.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.length) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.src_offset) == 60); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.src_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.return_offset) == 64); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.return_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.get.sink_length) == 68); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.get.sink_length) == 4); + + /* Reply */ + LASSERT (offsetof (ptl_hdr_t, msg.reply.dst_wmd) == 32); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.dst_wmd) == 16); + LASSERT (offsetof (ptl_hdr_t, msg.reply.dst_offset) == 48); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.dst_offset) == 4); + LASSERT (offsetof (ptl_hdr_t, msg.reply.length) == 56); + LASSERT (sizeof (((ptl_hdr_t *)0)->msg.reply.length) == 4); +} diff --git a/lustre/portals/portalsconf.m4 b/lustre/portals/portalsconf.m4 deleted file mode 100644 index 7bd3919..0000000 --- a/lustre/portals/portalsconf.m4 +++ /dev/null @@ -1,118 +0,0 @@ -AC_PREFIX_DEFAULT([]) -if test "x$prefix" = xNONE || test "x$prefix" = x; then - usrprefix=/usr -else - usrprefix='${prefix}' -fi -AC_SUBST(usrprefix) - -AC_ARG_ENABLE(rtscts-myrinet, [ --enable-rtscts-myrinet enable rtscts over myrinet support]) -AM_CONDITIONAL(RTSCTS_MYRINET, test "$enable_rtscts_myrinet" = yes) - - -CPLANT_ARCH=${target_cpu} -case ${CPLANT_ARCH} in -alpha*) - RTSCTSLIB_CFLAGS='-O4 -mno-fp-regs' - RTSCTSLIB_DEFS=-Ddec_linux - ;; -i*86) - RTSCTSLIB_CFLAGS=-O4 - RTSCTSLIB_DEFS=-Dintel_linux - ;; -#*) -# AC_MSG_ERROR([Unrecognized architecture '$CPLANT_ARCH' for rtscts]) -# ;; -esac -AC_SUBST(CPLANT_ARCH) -AC_SUBST(RTSCTSLIB_CFLAGS) -AC_SUBST(RTSCTSLIB_DEFS) - -AC_MSG_CHECKING(if kernel has CPU affinity support) -if test "$target_cpu" != ia64 ; then - enable_affinity_temp="-DCPU_AFFINITY=1" - AC_MSG_RESULT(yes) -else - enable_affinity_temp="" - AC_MSG_RESULT(no) -fi -AC_MSG_CHECKING(if kernel has zero-copy TCP support) -ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" -if test "$ZCCD" != 0 ; then - enable_zerocopy_temp="-DSOCKNAL_ZC=1" - AC_MSG_RESULT(yes) -else - enable_zerocopy_temp="" - AC_MSG_RESULT(no) -fi - -AC_ARG_ENABLE(zerocopy, [ --enable-zerocopy enable socknal zerocopy],enable_zerocopy="-DSOCKNAL_ZC=1", enable_zercopy=$enable_zerocopy_temp) - -AC_ARG_ENABLE(affinity, [ --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp) -##################################### - -AC_MSG_CHECKING(if quadrics kernel headers are present) -if test -d $LINUX/drivers/net/qsnet ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/net/qsnet/include" - : -elif test -d $LINUX/drivers/qsnet1 ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/qsnet1/include -DPROPRIETARY_ELAN" - : -elif test -d $LINUX/drivers/quadrics ; then - AC_MSG_RESULT(yes) - QSWNAL="qswnal" - with_quadrics="-I$LINUX/drivers/quadrics/include -DPROPRIETARY_ELAN" - : -#elif test -d /usr/include/elan3 ; then -# AC_MSG_RESULT(yes) -# QSWNAL="qswnal" -# with_quadrics="" -# : -else - AC_MSG_RESULT(no) - QSWNAL="" - with_quadrics="" - : -fi -AC_SUBST(with_quadrics) -AC_SUBST(QSWNAL) - -# R. Read 5/02 -GMNAL="" -echo "checking with-gm=" ${with_gm} -if test "${with_gm+set}" = set; then - if test "${with_gm}" = yes; then - with_gm="-I/usr/local/gm/include" - else - with_gm=-I"$with_gm/include" - fi - GMNAL="gmnal" -else -# default case - no GM - with_gm="" -fi -AC_SUBST(with_gm) -AC_SUBST(GMNAL) - - -def_scamac=/opt/scali/include -AC_ARG_WITH(scamac, [ --with-scamac=[yes/no/path] Path to ScaMAC includes (default=/opt/scali/include)], with_scamac=$withval, with_scamac=$def_scamac) -AC_MSG_CHECKING(if ScaMAC headers are present) -if test "$with_scamac" = yes; then - with_scamac=$def_scamac -fi -if test "$with_scamac" != no -a -f ${with_scamac}/scamac.h; then - AC_MSG_RESULT(yes) - SCIMACNAL="scimacnal" - with_scamac="-I${with_scamac} -I${with_scamac}/icm" -else - AC_MSG_RESULT(no) - SCIMACNAL="" - with_scamac="" -fi -AC_SUBST(with_scamac) -AC_SUBST(SCIMACNAL) diff --git a/lustre/portals/router/router.c b/lustre/portals/router/router.c index 8a1de08..6074c3c 100644 --- a/lustre/portals/router/router.c +++ b/lustre/portals/router/router.c @@ -202,15 +202,15 @@ kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd) LASSERT (nob == lib_iov_nob (fwd->kprfd_niov, fwd->kprfd_iov)); atomic_inc (&kpr_queue_depth); + atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */ kpr_fwd_packets++; /* (loose) stats accounting */ kpr_fwd_bytes += nob; - if (src_ne->kpne_shutdown) /* caller is shutting down */ + if (src_ne->kpne_shutdown) /* caller is shutting down */ goto out; - fwd->kprfd_router_arg = src_ne; /* stash caller's nal entry */ - atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */ + fwd->kprfd_router_arg = src_ne; /* stash caller's nal entry */ read_lock (&kpr_rwlock); diff --git a/lustre/portals/router/router.h b/lustre/portals/router/router.h index b8c3bec..19159ab 100644 --- a/lustre/portals/router/router.h +++ b/lustre/portals/router/router.h @@ -23,7 +23,9 @@ #ifndef _KPTLROUTER_H #define _KPTLROUTER_H -#define EXPORT_SYMTAB +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #include #include diff --git a/lustre/portals/unals/Makefile.am b/lustre/portals/unals/Makefile.am index b62b401..dc427b0 100644 --- a/lustre/portals/unals/Makefile.am +++ b/lustre/portals/unals/Makefile.am @@ -1,5 +1,5 @@ CPPFLAGS= INCLUDES=-I$(top_srcdir)/portals/include -I$(top_srcdir)/include -I$(srcdir) lib_LIBRARIES = libtcpnal.a -pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h +pkginclude_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h diff --git a/lustre/portals/unals/connection.c b/lustre/portals/unals/connection.c index 89c9f78..310e899 100644 --- a/lustre/portals/unals/connection.c +++ b/lustre/portals/unals/connection.c @@ -120,9 +120,10 @@ int read_connection(connection c, return(1); } -static int connection_input(connection c) +static int connection_input(void *d) { - return((*c->m->handler)(c->m->handler_arg,c)); + connection c = d; + return((*c->m->handler)(c->m->handler_arg,c)); } @@ -280,7 +281,7 @@ void shutdown_connections(manager m) * zero if the fixed port could not be bound */ manager init_connections(unsigned short pid, - int (*input)(), + int (*input)(void *, void *), void *a) { manager m=(manager)malloc(sizeof(struct manager)); diff --git a/lustre/portals/unals/connection.h b/lustre/portals/unals/connection.h index f6b2994..6f57287 100644 --- a/lustre/portals/unals/connection.h +++ b/lustre/portals/unals/connection.h @@ -25,14 +25,8 @@ typedef struct connection { manager m; } *connection; -connection force_tcp_connection(manager m, - unsigned int ip, - unsigned int short); -manager init_connections(unsigned short, - int (*f)(void *,connection), - void *); +connection force_tcp_connection(manager m, unsigned int ip, unsigned int short); +manager init_connections(unsigned short, int (*f)(void *, void *), void *); void remove_connection(void *arg); void shutdown_connections(manager m); -int read_connection(connection c, - unsigned char *dest, - int len); +int read_connection(connection c, unsigned char *dest, int len); diff --git a/lustre/portals/unals/tcpnal.c b/lustre/portals/unals/tcpnal.c index fac9c44..5854b01 100644 --- a/lustre/portals/unals/tcpnal.c +++ b/lustre/portals/unals/tcpnal.c @@ -160,15 +160,17 @@ check_len: * available. It attempts to read the portals header and * pass it to the generic library for processing. */ -static int from_connection(void *a,connection c) +static int from_connection(void *a, void *d) { - bridge b=a; - ptl_hdr_t hdr; - if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ - lib_parse(b->nal_cb, &hdr, c); - return(1); - } - return(0); + connection c = d; + bridge b=a; + ptl_hdr_t hdr; + + if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ + lib_parse(b->nal_cb, &hdr, c); + return(1); + } + return(0); } diff --git a/lustre/portals/utils/.cvsignore b/lustre/portals/utils/.cvsignore index 041cd6b..148310a 100644 --- a/lustre/portals/utils/.cvsignore +++ b/lustre/portals/utils/.cvsignore @@ -5,3 +5,4 @@ debugctl ptlctl .deps routerstat +wirecheck \ No newline at end of file diff --git a/lustre/portals/utils/Makefile.am b/lustre/portals/utils/Makefile.am index 065fcf9..05af598 100644 --- a/lustre/portals/utils/Makefile.am +++ b/lustre/portals/utils/Makefile.am @@ -7,11 +7,13 @@ COMPILE = gcc -Wall -g -I$(srcdir)/../include LINK = gcc -o $@ -sbin_PROGRAMS = acceptor ptlctl debugctl routerstat +sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck lib_LIBRARIES = libptlctl.a acceptor_SOURCES = acceptor.c # -lefence +wirecheck_SOURCES = wirecheck.c + libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h ptlctl_SOURCES = ptlctl.c diff --git a/lustre/portals/utils/portals.c b/lustre/portals/utils/portals.c index 8235271..90d66f5 100644 --- a/lustre/portals/utils/portals.c +++ b/lustre/portals/utils/portals.c @@ -106,13 +106,6 @@ nal2name (int nal) return ((e == NULL) ? "???" : e->name); } -static int -nid2nal (ptl_nid_t nid) -{ - /* BIG pragmatic assumption */ - return ((((__u32)nid) & 0xffff0000) != 0 ? SOCKNAL : QSWNAL); -} - int ptl_parse_nid (ptl_nid_t *nidp, char *str) { @@ -160,35 +153,15 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str) char * ptl_nid2str (char *buffer, ptl_nid_t nid) { - switch (nid2nal(nid)) - { - case QSWNAL: - sprintf (buffer, LPD64, nid); - return (buffer); + __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */ + struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET); - case SCIMACNAL: - sprintf (buffer, LPX64, nid); - return (buffer); - - case SOCKNAL: { - __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */ - struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET); - - if (he != NULL) - strcpy (buffer, he->h_name); - else - { - addr = (__u32)nid; - sprintf (buffer, "%d.%d.%d.%d", - (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff); - } - return (buffer); - } + if (he != NULL) + strcpy (buffer, he->h_name); + else + sprintf (buffer, "0x"LPX64, nid); - default: - sprintf (buffer, "nid2nal broken"); - return (buffer); - } + return (buffer); } int @@ -704,18 +677,43 @@ int jt_ptl_ping(int argc, char **argv) return 0; } +int jt_ptl_shownid(int argc, char **argv) +{ + struct portal_ioctl_data data; + int rc; + + if (argc > 1) { + fprintf(stderr, "usage: %s\n", argv[0]); + return 0; + } + + if (g_nal == 0) { + fprintf(stderr, "Error: you must run the 'network' command first\n"); + return -1; + } + + PORTAL_IOC_INIT (data); + data.ioc_nal = g_nal; + rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data); + if (rc < 0) + fprintf(stderr, "getting my NID failed: %s\n", + strerror (errno)); + else + printf(LPX64"\n", data.ioc_nid); + return 0; +} + int jt_ptl_mynid(int argc, char **argv) { int rc; - struct hostent *h; - char buf[1024], *hostname; + char hostname[1024]; + char *nidstr; struct portal_ioctl_data data; ptl_nid_t mynid; if (argc > 2) { - fprintf(stderr, "usage: %s [hostname]\n", argv[0]); - fprintf(stderr, "hostname defaults to the hostname of the " - "machine.\n"); + fprintf(stderr, "usage: %s [NID]\n", argv[0]); + fprintf(stderr, "NID defaults to the primary IP address of the machine.\n"); return 0; } @@ -725,42 +723,21 @@ int jt_ptl_mynid(int argc, char **argv) return -1; } - if (g_nal == QSWNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for elan.\n"); - return -1; - } else if (g_nal == GMNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for GM.\n"); - return -1; - } else if (g_nal == SCIMACNAL) { - fprintf(stderr, "'mynid' doesn't make any sense for SCI.\n"); - return -1; - } - - if (g_nal != SOCKNAL && g_nal != TOENAL) { - fprintf(stderr, "This should never happen. Also it is very " - "bad.\n"); + if (argc >= 2) + nidstr = argv[1]; + else if (gethostname(hostname, sizeof(hostname)) != 0) { + fprintf(stderr, "gethostname failed: %s\n", + strerror(errno)); return -1; } + else + nidstr = hostname; - if (argc == 1) { - if (gethostname(buf, sizeof(buf)) != 0) { - fprintf(stderr, "gethostname failed: %s\n", - strerror(errno)); - return -1; - } - hostname = buf; - } else { - hostname = argv[1]; - } - - h = gethostbyname(hostname); - - if (!h) { - fprintf(stderr, "cannot get address for host '%s': %d\n", - hostname, h_errno); + rc = ptl_parse_nid (&mynid, nidstr); + if (rc != 0) { + fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr); return -1; } - mynid = (ptl_nid_t)ntohl (*(__u32 *)h->h_addr); /* HOST byte order */ PORTAL_IOC_INIT(data); data.ioc_nid = mynid; @@ -769,7 +746,7 @@ int jt_ptl_mynid(int argc, char **argv) rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data); if (rc < 0) - fprintf(stderr, "IOC_PORTAL_REGISTER_MYNID failed: %s\n", + fprintf(stderr, "setting my NID failed: %s\n", strerror(errno)); else printf("registered my nid "LPX64" (%s)\n", mynid, hostname); @@ -888,7 +865,6 @@ jt_ptl_add_route (int argc, char **argv) ptl_nid_t nid1; ptl_nid_t nid2; ptl_nid_t gateway_nid; - int gateway_nal; int rc; if (argc < 3) @@ -897,14 +873,18 @@ jt_ptl_add_route (int argc, char **argv) return (0); } + if (g_nal == 0) { + fprintf(stderr, "Error: you must run the 'network' command " + "first.\n"); + return (-1); + } + if (ptl_parse_nid (&gateway_nid, argv[1]) != 0) { fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]); return (-1); } - gateway_nal = nid2nal (gateway_nid); - if (ptl_parse_nid (&nid1, argv[2]) != 0) { fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]); @@ -921,7 +901,7 @@ jt_ptl_add_route (int argc, char **argv) PORTAL_IOC_INIT(data); data.ioc_nid = gateway_nid; - data.ioc_nal = gateway_nal; + data.ioc_nal = g_nal; data.ioc_nid2 = MIN (nid1, nid2); data.ioc_nid3 = MAX (nid1, nid2); diff --git a/lustre/portals/utils/ptlctl.c b/lustre/portals/utils/ptlctl.c index d38bd4a..8c56d93 100644 --- a/lustre/portals/utils/ptlctl.c +++ b/lustre/portals/utils/ptlctl.c @@ -34,6 +34,7 @@ command_t list[] = { {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid (args: [hostname]"}, {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid (args: [hostname]"}, {"ping", jt_ptl_ping, 0, "do a ping test (args: nid [count] [size] [timeout])"}, + {"shownid", jt_ptl_shownid, 0, "print the local NID"}, {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local NID (args: [hostname])"}, {"add_route", jt_ptl_add_route, 0, "add an entry to the routing table (args: gatewayNID targetNID [targetNID])"}, {"del_route", jt_ptl_del_route, 0, "delete an entry from the routing table (args: targetNID"}, -- 1.8.3.1