* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
/* 0 indicates no messages to console, 1 is errors, > 1 is all debug messages */
static int toconsole = 1;
unsigned int libcfs_console_ratelimit = 1;
-cfs_duration_t libcfs_console_max_delay;
-cfs_duration_t libcfs_console_min_delay;
+unsigned int libcfs_console_max_delay;
+unsigned int libcfs_console_min_delay;
unsigned int libcfs_console_backoff = CDEBUG_DEFAULT_BACKOFF;
#else /* !HAVE_CATAMOUNT_DATA_H */
#ifdef HAVE_NETDB_H
#endif /* HAVE_CATAMOUNT_DATA_H */
static int source_pid;
-int smp_processor_id = 1;
-char debug_file_path[1024];
+int cfs_smp_processor_id = 1;
+char libcfs_debug_file_path[1024];
FILE *debug_file_fd;
int portals_do_debug_dumplog(void *arg)
debug_filename = getenv("LIBLUSTRE_DEBUG_BASE");
if (debug_filename)
- strncpy(debug_file_path,debug_filename,sizeof(debug_file_path));
+ strncpy(libcfs_debug_file_path, debug_filename,
+ sizeof(libcfs_debug_file_path));
debug_filename = getenv("LIBLUSTRE_DEBUG_FILE");
if (debug_filename)
strncpy(debug_file_name,debug_filename,sizeof(debug_file_name));
- if (debug_file_name[0] == '\0' && debug_file_path[0] != '\0')
+ if (debug_file_name[0] == '\0' && libcfs_debug_file_path[0] != '\0')
snprintf(debug_file_name, sizeof(debug_file_name) - 1,
- "%s-%s-"CFS_TIME_T".log", debug_file_path, source_nid, time(0));
+ "%s-%s-"CFS_TIME_T".log", libcfs_debug_file_path,
+ source_nid, time(0));
if (strcmp(debug_file_name, "stdout") == 0 ||
strcmp(debug_file_name, "-") == 0) {
return 0;
}
-int libcfs_debug_mark_buffer(char *text)
+int libcfs_debug_mark_buffer(const char *text)
{
fprintf(debug_file_fd, "*******************************************************************************\n");
}
#endif
+int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata,
+ const char *format, ...)
+{
+ va_list args;
+ int rc;
+
+ va_start(args, format);
+ rc = libcfs_debug_vmsg2(msgdata, format, args, NULL);
+ va_end(args);
+
+ return rc;
+}
+
int
-libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
- int subsys, int mask,
- const char *file, const char *fn, const int line,
+libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
const char *format1, va_list args,
const char *format2, ...)
{
/* toconsole == 0 - all messages to debug_file_fd
* toconsole == 1 - warnings to console, all to debug_file_fd
* toconsole > 1 - all debug to console */
- if (((mask & libcfs_printk) && toconsole == 1) || toconsole > 1)
+ if (((msgdata->msg_mask & libcfs_printk) && toconsole == 1) || toconsole > 1)
console = 1;
#endif
return 0;
}
- if (mask & (D_EMERG | D_ERROR))
+ if (msgdata->msg_mask & (D_EMERG | D_ERROR))
prefix = "LustreError";
nob = snprintf(buf, sizeof(buf), "%s: %u-%s:(%s:%d:%s()): ", prefix,
- source_pid, source_nid, file, line, fn);
+ source_pid, source_nid, msgdata->msg_file,
+ msgdata->msg_line, msgdata->msg_fn);
remain = sizeof(buf) - nob;
if (format1) {
#ifdef HAVE_CATAMOUNT_DATA_H
if (console) {
+ cfs_debug_limit_state_t *cdls = msgdata->msg_cdls;
+
/* check rate limit for console */
if (cdls != NULL) {
if (libcfs_console_ratelimit &&
fprintf(debug_file_fd, CFS_TIME_T".%06lu:%u:%s:(%s:%d:%s()): %s",
tv.tv_sec, tv.tv_usec, source_pid, source_nid,
- file, line, fn, buf);
+ msgdata->msg_file, msgdata->msg_line, msgdata->msg_fn, buf);
return 0;
}
void
-libcfs_assertion_failed(const char *expr, const char *file, const char *func,
- const int line)
+libcfs_assertion_failed(const char *expr, struct libcfs_debug_msg_data *msgdata)
{
- libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line,
- "ASSERTION(%s) failed\n", expr);
+ libcfs_debug_msg(msgdata, "ASSERTION(%s) failed\n", expr);
abort();
}
+
+/*
+ * a helper function for RETURN(): the sole purpose is to save 8-16 bytes
+ * on the stack - function calling RETURN() doesn't need to allocate two
+ * additional 'rc' on the stack
+ */
+long libcfs_log_return(struct libcfs_debug_msg_data *msgdata, long rc)
+{
+ libcfs_debug_msg(msgdata, "Process leaving (rc=%lu : %ld : %lx)\n",
+ rc, rc, rc);
+ return rc;
+}
+
+/*
+ * a helper function for GOTO(): the sole purpose is to save 8-16 bytes
+ * on the stack - function calling GOTO() doesn't need to allocate two
+ * additional 'rc' on the stack
+ */
+void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *l,
+ long_ptr_t rc)
+{
+ libcfs_debug_msg(msgdata, "Process leaving via %s (rc=" LPLU " : "
+ LPLD " : " LPLX ")\n", l, (ulong_ptr_t) rc, rc, rc);
+}