From 29fd4ec84fa9d278e15b892f28d45bf26db4a7d5 Mon Sep 17 00:00:00 2001 From: pjkirner Date: Tue, 27 Sep 2005 13:51:27 +0000 Subject: [PATCH] Patch by Liang 1. lnet/ulnds/socklnd/debug.c will not be built anymore, lnet/libcfs/libcfs.a will be created while building of liblustre, functions in lnet/ulnds/socklnd/debug.c are moved to lnet/libcfs/debug.c. 2. LNET_SINGLE_THREADED will be assigned to 1 if no libpthread found. 3. usocklnd will not be built if no libpthread (I'm not sure if it's reasonable) --- lnet/autoconf/lustre-lnet.m4 | 16 +++++- lnet/libcfs/autoMakefile.am | 7 +++ lnet/libcfs/debug.c | 121 ++++++++++++++++++++++++++++++++++++++++- lnet/ulnds/Makefile.in | 2 +- lnet/ulnds/socklnd/Makefile.am | 2 +- 5 files changed, 142 insertions(+), 6 deletions(-) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 0041a98..e0f6ede 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -113,6 +113,17 @@ AC_ARG_ENABLE([usocklnd], [disable usocklnd]), [],[enable_usocklnd='yes']) +# disable usocklnd if no libpthread +if test x$enable_usocklnd = xyes ; then + AC_CHECK_LIB([pthread], [pthread_create], + [ + enable_usocklnd="yes" + ], + [ + enable_usocklnd="" + ]) +fi + AC_MSG_CHECKING([for usocklnd support]) if test x$enable_usocklnd = xyes ; then AC_MSG_RESULT([no (by request)]) @@ -826,7 +837,10 @@ if test x$enable_liblustre = xyes ; then PTHREAD_LIBS="-lpthread" AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread]) ], - [PTHREAD_LIBS=""]) + [ + PTHREAD_LIBS="" + AC_DEFINE([LNET_SINGLE_THREADED], 1, [lnet single threaded]) + ]) AC_SUBST(PTHREAD_LIBS) fi ]) diff --git a/lnet/libcfs/autoMakefile.am b/lnet/libcfs/autoMakefile.am index 41711d0..d00f1fd 100644 --- a/lnet/libcfs/autoMakefile.am +++ b/lnet/libcfs/autoMakefile.am @@ -9,6 +9,13 @@ SUBDIRS += darwin endif DIST_SUBDIRS := $(SUBDIRS) +if LIBLUSTRE +noinst_LIBRARIES= libcfs.a +libcfs_a_SOURCES= debug.c +libcfs_a_CPPFLAGS = $(LLCPPFLAGS) +libcfs_a_CFLAGS = $(LLCFLAGS) +endif + if MODULES if LINUX diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c index 462e36c..eb22691 100644 --- a/lnet/libcfs/debug.c +++ b/lnet/libcfs/debug.c @@ -26,11 +26,21 @@ # define DEBUG_SUBSYSTEM S_PORTALS +#ifdef __KERNEL__ #include #include - #include "tracefile.h" +#else +#include +#include +#include +#include +#include +#include +#include +#endif +#ifdef __KERNEL__ unsigned int libcfs_subsystem_debug = ~0 - (S_PORTALS | S_NAL); EXPORT_SYMBOL(libcfs_subsystem_debug); @@ -47,10 +57,8 @@ EXPORT_SYMBOL(libcfs_stack); unsigned int libcfs_catastrophe; EXPORT_SYMBOL(libcfs_catastrophe); -#ifdef __KERNEL__ atomic_t libcfs_kmemory = ATOMIC_INIT(0); EXPORT_SYMBOL(libcfs_kmemory); -#endif static cfs_waitq_t debug_ctlwq; @@ -187,3 +195,110 @@ void portals_debug_set_level(unsigned int debug_level) EXPORT_SYMBOL(libcfs_debug_dumplog); EXPORT_SYMBOL(portals_debug_set_level); + + +#else /* !__KERNEL__ */ + +#include + +int smp_processor_id = 1; +char debug_file_path[1024] = "/tmp/lustre-log"; +char debug_file_name[1024]; +FILE *debug_file_fd; + +int portals_do_debug_dumplog(void *arg) +{ + printf("Look in %s\n", debug_file_name); + return 0; +} + + +void portals_debug_print(void) +{ + return; +} + + +void libcfs_debug_dumplog(void) +{ + printf("Look in %s\n", debug_file_name); + return; +} + + +int portals_debug_init(unsigned long bufsize) +{ + debug_file_fd = stdout; + return 0; +} + +int portals_debug_cleanup(void) +{ + return 0; //close(portals_debug_fd); +} + +int portals_debug_clear_buffer(void) +{ + return 0; +} + +int portals_debug_mark_buffer(char *text) +{ + + fprintf(debug_file_fd, "*******************************************************************************\n"); + fprintf(debug_file_fd, "DEBUG MARKER: %s\n", text); + fprintf(debug_file_fd, "*******************************************************************************\n"); + + return 0; +} + +int portals_debug_copy_to_user(char *buf, unsigned long len) +{ + return 0; +} + +/* FIXME: I'm not very smart; someone smarter should make this better. */ +void +libcfs_debug_msg (int subsys, int mask, char *file, const char *fn, + const int line, unsigned long stack, char *format, ...) +{ + va_list ap; + unsigned long flags; + struct timeval tv; + int nob; + + + /* NB since we pass a non-zero sized buffer (at least) on the first + * print, we can be assured that by the end of all the snprinting, + * we _do_ have a terminated buffer, even if our message got truncated. + */ + + gettimeofday(&tv, NULL); + + nob += fprintf(debug_file_fd, + "%02x:%06x:%d:%lu.%06lu ", + subsys >> 24, mask, smp_processor_id, + tv.tv_sec, tv.tv_usec); + + nob += fprintf(debug_file_fd, + "(%s:%d:%s() %d+%ld): ", + file, line, fn, 0, + 8192 - ((unsigned long)&flags & 8191UL)); + + va_start (ap, format); + nob += fprintf(debug_file_fd, format, ap); + va_end (ap); + + +} + +void +libcfs_assertion_failed(char *expr, char *file, const char *func, + const int line) +{ + libcfs_debug_msg(0, D_EMERG, file, func, line, 0, + "ASSERTION(%s) failed\n", expr); + abort(); +} + +#endif diff --git a/lnet/ulnds/Makefile.in b/lnet/ulnds/Makefile.in index 5ea8eed..7709619 100644 --- a/lnet/ulnds/Makefile.in +++ b/lnet/ulnds/Makefile.in @@ -1,4 +1,4 @@ -subdir-m += socklnd +@BUILD_USOCKLND_TRUE@subdir-m += socklnd subdir-m += ptllnd @INCLUDE_RULES@ diff --git a/lnet/ulnds/socklnd/Makefile.am b/lnet/ulnds/socklnd/Makefile.am index ec80e05..f970be9 100644 --- a/lnet/ulnds/socklnd/Makefile.am +++ b/lnet/ulnds/socklnd/Makefile.am @@ -6,7 +6,7 @@ endif noinst_HEADERS = pqtimer.h dispatch.h table.h timer.h \ connection.h bridge.h procbridge.h -libsocklnd_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h \ +libsocklnd_a_SOURCES = pqtimer.c select.c table.c pqtimer.h \ dispatch.h table.h timer.h procapi.c proclib.c \ connection.c tcplnd.c connection.h libsocklnd_a_CPPFLAGS = $(LLCPPFLAGS) -- 1.8.3.1