- struct cfs_trace_cpu_data *tcd = NULL;
- 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;
- char *debug_buf;
- int known_size;
- int needed = 85; /* average message length */
- int max_nob;
- va_list ap;
- int depth;
- int i;
- int remain;
- int mask = msgdata->msg_mask;
- char *file = (char *)msgdata->msg_file;
- cfs_debug_limit_state_t *cdls = msgdata->msg_cdls;
-
- if (strchr(file, '/'))
- file = strrchr(file, '/') + 1;
-
- tcd = cfs_trace_get_tcd();
-
- /* cfs_trace_get_tcd() grabs a lock, which disables preemption and
- * pins us to a particular CPU. This avoids an smp_processor_id()
- * warning on Linux when debugging is enabled. */
- cfs_set_ptldebug_header(&header, msgdata, CDEBUG_STACK());
-
- 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;
- goto console;
- }
+ char *prefix = "Lustre";
+
+ if (hdr->ph_subsys == S_LND || hdr->ph_subsys == S_LNET)
+ prefix = "LNet";
+
+ if (mask & D_CONSOLE) {
+ if (mask & D_EMERG)
+ pr_emerg("%sError: %pV", prefix, vaf);
+ else if (mask & D_ERROR)
+ pr_err("%sError: %pV", prefix, vaf);
+ else if (mask & D_WARNING)
+ pr_warn("%s: %pV", prefix, vaf);
+ else if (mask & libcfs_printk)
+ pr_info("%s: %pV", prefix, vaf);
+ } else {
+ if (mask & D_EMERG)
+ pr_emerg("%sError: %d:%d:(%s:%d:%s()) %pV", prefix,
+ hdr->ph_pid, hdr->ph_extern_pid, file,
+ hdr->ph_line_num, fn, vaf);
+ else if (mask & D_ERROR)
+ pr_err("%sError: %d:%d:(%s:%d:%s()) %pV", prefix,
+ hdr->ph_pid, hdr->ph_extern_pid, file,
+ hdr->ph_line_num, fn, vaf);
+ else if (mask & D_WARNING)
+ pr_warn("%s: %d:%d:(%s:%d:%s()) %pV", prefix,
+ hdr->ph_pid, hdr->ph_extern_pid, file,
+ hdr->ph_line_num, fn, vaf);
+ else if (mask & (D_CONSOLE | libcfs_printk))
+ pr_info("%s: %pV", prefix, vaf);
+ }
+}
+
+static void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
+ const char *file, const char *fn,
+ const char *fmt, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ va_start(args, fmt);
+ vaf.fmt = fmt;
+ vaf.va = &args;
+ cfs_vprint_to_console(hdr, mask, &vaf, file, fn);
+}
+
+int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata,
+ const char *format, ...)
+{
+ struct cfs_trace_cpu_data *tcd = NULL;
+ 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;
+ char *debug_buf;
+ int known_size;
+ int needed = 85; /* seeded with average message length */
+ int max_nob;
+ va_list ap;
+ int retry;
+ int mask = msgdata->msg_mask;
+ char *file = (char *)msgdata->msg_file;
+ struct cfs_debug_limit_state *cdls = msgdata->msg_cdls;
+
+ if (strchr(file, '/'))
+ file = strrchr(file, '/') + 1;
+
+ tcd = cfs_trace_get_tcd();
+
+ /* cfs_trace_get_tcd() grabs a lock, which disables preemption and
+ * pins us to a particular CPU. This avoids an smp_processor_id()
+ * warning on Linux when debugging is enabled.
+ */
+ cfs_set_ptldebug_header(&header, msgdata, CDEBUG_STACK());