Whamcloud - gitweb
b=19944 promise every cpu has at least 2MB debug memory.
[fs/lustre-release.git] / libcfs / libcfs / tracefile.c
index 5a29dfa..47f3ab5 100644 (file)
@@ -245,7 +245,7 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                        const char *format2, ...)
 {
         struct cfs_trace_cpu_data *tcd = NULL;
-        struct ptldebug_header     header;
+        struct ptldebug_header     header = {0};
         struct cfs_trace_page     *tage;
         /* string_buf is used only if tcd != NULL, and is always set then */
         char                      *string_buf = NULL;
@@ -268,6 +268,9 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
         if (tcd == NULL)                /* arch may not log in IRQ context */
                 goto console;
 
+        if (tcd->tcd_cur_pages == 0)
+                header.ph_flags |= PH_FLAG_FIRST_RECORD;
+
         if (tcd->tcd_shutting_down) {
                 cfs_trace_put_tcd(tcd);
                 tcd = NULL;
@@ -904,8 +907,11 @@ int cfs_trace_set_debug_mb(int mb)
         int limit = cfs_trace_max_debug_mb();
         struct cfs_trace_cpu_data *tcd;
 
-        if (mb < cfs_num_possible_cpus())
+        if (mb < cfs_num_possible_cpus()) {
+                printk(KERN_ERR "Cannot set debug_mb to %d, the value should be >= %d\n",
+                       mb, num_possible_cpus());
                 return -EINVAL;
+        }
 
         if (mb > limit) {
                 printk(CFS_KERN_ERR "Lustre: Refusing to set debug buffer size "
@@ -961,7 +967,6 @@ static int tracefiled(void *arg)
         struct tracefiled_ctl *tctl = arg;
         struct cfs_trace_page *tage;
         struct cfs_trace_page *tmp;
-        struct ptldebug_header *hdr;
         cfs_file_t *filp;
         int last_loop = 0;
         int rc;
@@ -1002,13 +1007,6 @@ static int tracefiled(void *arg)
 
                 CFS_MMSPACE_OPEN;
 
-                /* mark the first header, so we can sort in chunks */
-                tage = cfs_tage_from_list(pc.pc_pages.next);
-                __LASSERT_TAGE_INVARIANT(tage);
-
-                hdr = cfs_page_address(tage->page);
-                hdr->ph_flags |= PH_FLAG_FIRST_RECORD;
-
                 cfs_list_for_each_entry_safe_typed(tage, tmp, &pc.pc_pages,
                                                    struct cfs_trace_page,
                                                    linkage) {