Whamcloud - gitweb
* Landed b_cray_portals_merge.
[fs/lustre-release.git] / lustre / portals / libcfs / debug.c
index d563a76..4e43aa5 100644 (file)
 
 #include <linux/kp30.h>
 #include <linux/portals_compat25.h>
+#include <linux/libcfs.h>
+
+unsigned int portal_subsystem_debug = ~0 - (S_PORTALS | S_QSWNAL | S_SOCKNAL |
+                                            S_GMNAL | S_IBNAL);
+EXPORT_SYMBOL(portal_subsystem_debug);
+
+unsigned int portal_debug = (D_WARNING | D_DLMTRACE | D_ERROR | D_EMERG | D_HA |
+                             D_RPCTRACE | D_VFSTRACE);
+EXPORT_SYMBOL(portal_debug);
+
+unsigned int portal_cerror = 1;
+EXPORT_SYMBOL(portal_cerror);
+
+unsigned int portal_printk;
+EXPORT_SYMBOL(portal_printk);
+
+unsigned int portal_stack;
+EXPORT_SYMBOL(portal_stack);
+
+#ifdef __KERNEL__
+atomic_t portal_kmemory = ATOMIC_INIT(0);
+EXPORT_SYMBOL(portal_kmemory);
+#endif
 
 #define DEBUG_OVERFLOW 1024
 static char *debug_buf = NULL;
@@ -569,7 +592,7 @@ int portals_debug_init(unsigned long bufsize)
         debug_buf = vmalloc(bufsize + DEBUG_OVERFLOW);
         if (debug_buf == NULL)
                 return -ENOMEM;
-        memset(debug_buf, 0, debug_size);
+        memset(debug_buf, 0, bufsize + DEBUG_OVERFLOW);
         debug_wrapped = 0;
 
         //printk(KERN_INFO "Portals: allocated %lu byte debug buffer at %p.\n",
@@ -633,9 +656,9 @@ int portals_debug_mark_buffer(char *text)
         if (debug_buf == NULL)
                 return -EINVAL;
 
-        CDEBUG(0, "********************************************************\n");
+        CDEBUG(D_TRACE,"***************************************************\n");
         CWARN("DEBUG MARKER: %s\n", text);
-        CDEBUG(0, "********************************************************\n");
+        CDEBUG(D_TRACE,"***************************************************\n");
 
         return 0;
 }
@@ -663,7 +686,7 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len)
                         rc = -ENOMEM;
                         goto cleanup;
                 }
-                list_add(&page->list, &my_pages);
+                list_add(&PAGE_LIST(page), &my_pages);
         }
 
         spin_lock_irqsave(&portals_debug_lock, flags);
@@ -686,9 +709,9 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len)
         copied = 0;
         list_for_each(pos, &my_pages) {
                 unsigned long to_copy;
-                page = list_entry(pos, struct page, list);
                 void *addr;
 
+                page = list_entry(pos, struct page, PAGE_LIST_ENTRY);
                 to_copy = min(total - off, PAGE_SIZE);
                 if (to_copy == 0) {
                         off = 0;
@@ -717,7 +740,7 @@ finish_partial:
         off = 0;
         list_for_each(pos, &my_pages) {
                 unsigned long to_copy;
-                page = list_entry(pos, struct page, list);
+                page = list_entry(pos, struct page, PAGE_LIST_ENTRY);
 
                 to_copy = min(copied - off, PAGE_SIZE);
                 rc = copy_to_user(buf + off, kmap(page), to_copy);
@@ -734,8 +757,8 @@ finish_partial:
 
 cleanup:
         list_for_each_safe(pos, n, &my_pages) {
-                page = list_entry(pos, struct page, list);
-                list_del(&page->list);
+                page = list_entry(pos, struct page, PAGE_LIST_ENTRY);
+                list_del(&PAGE_LIST(page));
                 __free_page(page);
         }
         return rc;
@@ -805,8 +828,10 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
                               subsys, mask, smp_processor_id(),
                               tv.tv_sec, tv.tv_usec, stack, current->pid);
         max_nob -= prefix_nob;
+
         if(*(format + strlen(format) - 1) != '\n')
-                *(format + strlen(format)) = '\n';
+                printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n",
+                       file, line, fn);
 
 #if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
         msg_nob = snprintf(debug_buf + debug_off + prefix_nob, max_nob,
@@ -924,28 +949,29 @@ void portals_run_lbug_upcall(char *file, const char *fn, const int line)
 char *portals_nid2str(int nal, ptl_nid_t nid, char *str)
 {
         switch(nal){
+/* XXX this could be a nal method of some sort, 'cept it's config
+ * dependent whether (say) socknal NIDs are actually IP addresses... */
+#ifndef CRAY_PORTALS 
         case TCPNAL:
                 /* userspace NAL */
         case SOCKNAL:
-                sprintf(str, "%u:%d.%d.%d.%d", (__u32)(nid >> 32),
-                        HIPQUAD(nid));
+                snprintf(str, PTL_NALFMT_SIZE-1,
+                         "%u:%d.%d.%d.%d", (__u32)(nid >> 32), HIPQUAD(nid));
                 break;
         case QSWNAL:
         case GMNAL:
         case IBNAL:
         case SCIMACNAL:
-                sprintf(str, "%u:%u", (__u32)(nid >> 32), (__u32)nid);
+                snprintf(str, PTL_NALFMT_SIZE-1, LPD64, nid);
                 break;
+#endif
         default:
-                return NULL;
+                snprintf(str, PTL_NALFMT_SIZE-1, "(?%llx)", (long long)nid);
         }
         return str;
 }
 
 #ifdef __KERNEL__
-#include <linux/lustre_version.h>
-#if (LUSTRE_KERNEL_VERSION >= 30)
-#warning "FIXME: remove workaround when l30 is widely used"
 char stack_backtrace[LUSTRE_TRACE_SIZE];
 spinlock_t stack_backtrace_lock = SPIN_LOCK_UNLOCKED;
 
@@ -956,7 +982,7 @@ extern int is_kernel_text_address(unsigned long addr);
 char *portals_debug_dumpstack(void)
 {
         asm("int $3");
-        return "dump stack";
+        return "dump stack\n";
 }
 
 #elif defined(__i386__)
@@ -1018,7 +1044,6 @@ char *portals_debug_dumpstack(void)
 #endif /* __arch_um__ */
 EXPORT_SYMBOL(stack_backtrace_lock);
 EXPORT_SYMBOL(portals_debug_dumpstack);
-#endif /* LUSTRE_KERNEL_VERSION < 30 */
 #endif /* __KERNEL__ */
 
 EXPORT_SYMBOL(portals_debug_dumplog);