Whamcloud - gitweb
b=17167 libcfs: ensure all libcfs exported symbols to have cfs_ prefix
[fs/lustre-release.git] / libcfs / libcfs / tracefile.h
index 6bfdaaf..5794d33 100644 (file)
 /* trace file lock routines */
 
 #define TRACEFILE_NAME_SIZE 1024
-extern char      tracefile[TRACEFILE_NAME_SIZE];
-extern long long tracefile_size;
+extern char      cfs_tracefile[TRACEFILE_NAME_SIZE];
+extern long long cfs_tracefile_size;
 
 extern void libcfs_run_debug_log_upcall(char *file);
 
-int  tracefile_init_arch(void);
-void tracefile_fini_arch(void);
-
-void tracefile_read_lock(void);
-void tracefile_read_unlock(void);
-void tracefile_write_lock(void);
-void tracefile_write_unlock(void);
-
-int tracefile_dump_all_pages(char *filename);
-void trace_debug_print(void);
-void trace_flush_pages(void);
-int trace_start_thread(void);
-void trace_stop_thread(void);
-int tracefile_init(int max_pages);
-void tracefile_exit(void);
-
-
-
-int trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
-                        const char *usr_buffer, int usr_buffer_nob);
-int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
-                         const char *knl_str, char *append);
-int trace_allocate_string_buffer(char **str, int nob);
-void trace_free_string_buffer(char *str, int nob);
-int trace_dump_debug_buffer_usrstr(void *usr_str, int usr_str_nob);
-int trace_daemon_command(char *str);
-int trace_daemon_command_usrstr(void *usr_str, int usr_str_nob);
-int trace_set_debug_mb(int mb);
-int trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob);
-int trace_get_debug_mb(void);
+int  cfs_tracefile_init_arch(void);
+void cfs_tracefile_fini_arch(void);
+
+void cfs_tracefile_read_lock(void);
+void cfs_tracefile_read_unlock(void);
+void cfs_tracefile_write_lock(void);
+void cfs_tracefile_write_unlock(void);
+
+int cfs_tracefile_dump_all_pages(char *filename);
+void cfs_trace_debug_print(void);
+void cfs_trace_flush_pages(void);
+int cfs_trace_start_thread(void);
+void cfs_trace_stop_thread(void);
+int cfs_tracefile_init(int max_pages);
+void cfs_tracefile_exit(void);
+
+
+
+int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
+                            const char *usr_buffer, int usr_buffer_nob);
+int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
+                             const char *knl_str, char *append);
+int cfs_trace_allocate_string_buffer(char **str, int nob);
+void cfs_trace_free_string_buffer(char *str, int nob);
+int cfs_trace_dump_debug_buffer_usrstr(void *usr_str, int usr_str_nob);
+int cfs_trace_daemon_command(char *str);
+int cfs_trace_daemon_command_usrstr(void *usr_str, int usr_str_nob);
+int cfs_trace_set_debug_mb(int mb);
+int cfs_trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob);
+int cfs_trace_get_debug_mb(void);
 
 extern void libcfs_debug_dumplog_internal(void *arg);
 extern void libcfs_register_panic_notifier(void);
 extern void libcfs_unregister_panic_notifier(void);
 extern int  libcfs_panic_in_progress;
-extern int  trace_max_debug_mb(void);
+extern int  cfs_trace_max_debug_mb(void);
 
 #define TCD_MAX_PAGES (5 << (20 - CFS_PAGE_SHIFT))
 #define TCD_STOCK_PAGES (TCD_MAX_PAGES)
-#define TRACEFILE_SIZE (500 << 20)
+#define CFS_TRACEFILE_SIZE (500 << 20)
 
 #ifdef LUSTRE_TRACEFILE_PRIVATE
 
@@ -104,14 +104,14 @@ extern int  trace_max_debug_mb(void);
 #define TCD_MAX_PAGES (5 << (20 - CFS_PAGE_SHIFT))
 #define TCD_STOCK_PAGES (TCD_MAX_PAGES)
 
-#define TRACEFILE_SIZE (500 << 20)
+#define CFS_TRACEFILE_SIZE (500 << 20)
 
 /* Size of a buffer for sprinting console messages if we can't get a page
  * from system */
-#define TRACE_CONSOLE_BUFFER_SIZE   1024
+#define CFS_TRACE_CONSOLE_BUFFER_SIZE   1024
 
-union trace_data_union {
-       struct trace_cpu_data {
+union cfs_trace_data_union {
+       struct cfs_trace_cpu_data {
                /*
                 * Even though this structure is meant to be per-CPU, locking
                 * is needed because in some places the data may be accessed
@@ -119,13 +119,13 @@ union trace_data_union {
                 * and trace_put_tcd, which are called in libcfs_debug_vmsg2 and
                 * tcd_for_each_type_lock
                 */
-               spinlock_t              tcd_lock;
+               cfs_spinlock_t          tcd_lock;
                unsigned long           tcd_lock_flags;
 
                /*
                 * pages with trace records not yet processed by tracefiled.
                 */
-               struct list_head        tcd_pages;
+               cfs_list_t              tcd_pages;
                /* number of pages on ->tcd_pages */
                unsigned long           tcd_cur_pages;
 
@@ -139,7 +139,7 @@ union trace_data_union {
                 * (put_pages_on_daemon_list()). LRU pages from this list are
                 * discarded when list grows too large.
                 */
-               struct list_head        tcd_daemon_pages;
+               cfs_list_t              tcd_daemon_pages;
                /* number of pages on ->tcd_daemon_pages */
                unsigned long           tcd_cur_daemon_pages;
 
@@ -173,7 +173,7 @@ union trace_data_union {
                 * TCD_STOCK_PAGES pagesful are consumed by trace records all
                 * emitted in non-blocking contexts. Which is quite unlikely.
                 */
-               struct list_head        tcd_stock_pages;
+               cfs_list_t              tcd_stock_pages;
                /* number of pages on ->tcd_stock_pages */
                unsigned long           tcd_cur_stock_pages;
 
@@ -183,26 +183,27 @@ union trace_data_union {
                /* The factors to share debug memory. */
                unsigned short          tcd_pages_factor;
        } tcd;
-       char __pad[L1_CACHE_ALIGN(sizeof(struct trace_cpu_data))];
+       char __pad[CFS_L1_CACHE_ALIGN(sizeof(struct cfs_trace_cpu_data))];
 };
 
 #define TCD_MAX_TYPES      8
-extern union trace_data_union (*trace_data[TCD_MAX_TYPES])[NR_CPUS];
+extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[CFS_NR_CPUS];
 
-#define tcd_for_each(tcd, i, j)                                       \
-    for (i = 0; trace_data[i] != NULL; i++)                           \
-        for (j = 0, ((tcd) = &(*trace_data[i])[j].tcd);               \
-             j < num_possible_cpus(); j++, (tcd) = &(*trace_data[i])[j].tcd)
+#define cfs_tcd_for_each(tcd, i, j)                                       \
+    for (i = 0; cfs_trace_data[i] != NULL; i++)                           \
+        for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd);               \
+             j < cfs_num_possible_cpus();                                 \
+             j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)
 
-#define tcd_for_each_type_lock(tcd, i, cpu)                           \
-    for (i = 0; trace_data[i] &&                                      \
-         (tcd = &(*trace_data[i])[cpu].tcd) &&                        \
-         trace_lock_tcd(tcd); trace_unlock_tcd(tcd), i++)
+#define cfs_tcd_for_each_type_lock(tcd, i, cpu)                           \
+    for (i = 0; cfs_trace_data[i] &&                                      \
+         (tcd = &(*cfs_trace_data[i])[cpu].tcd) &&                        \
+         cfs_trace_lock_tcd(tcd); cfs_trace_unlock_tcd(tcd), i++)
 
 /* XXX nikita: this declaration is internal to tracefile.c and should probably
  * be moved there */
 struct page_collection {
-       struct list_head        pc_pages;
+       cfs_list_t              pc_pages;
        /*
         * spin-lock protecting ->pc_pages. It is taken by smp_call_function()
         * call-back functions. XXX nikita: Which is horrible: all processors
@@ -210,7 +211,7 @@ struct page_collection {
         * lock. Probably ->pc_pages should be replaced with an array of
         * NR_CPUS elements accessed locklessly.
         */
-       spinlock_t              pc_lock;
+       cfs_spinlock_t          pc_lock;
        /*
         * if this flag is set, collect_pages() will spill both
         * ->tcd_daemon_pages and ->tcd_pages to the ->pc_pages. Otherwise,
@@ -222,11 +223,11 @@ struct page_collection {
 /* XXX nikita: this declaration is internal to tracefile.c and should probably
  * be moved there */
 struct tracefiled_ctl {
-       struct completion       tctl_start;
-       struct completion       tctl_stop;
-       cfs_waitq_t             tctl_waitq;
-       pid_t                   tctl_pid;
-       atomic_t                tctl_shutdown;
+       cfs_completion_t       tctl_start;
+       cfs_completion_t       tctl_stop;
+       cfs_waitq_t            tctl_waitq;
+       pid_t                  tctl_pid;
+       cfs_atomic_t           tctl_shutdown;
 };
 
 /*
@@ -234,38 +235,39 @@ struct tracefiled_ctl {
  */
 /* XXX nikita: this declaration is internal to tracefile.c and should probably
  * be moved there */
-struct trace_page {
+struct cfs_trace_page {
        /*
         * page itself
         */
-       cfs_page_t      *page;
+       cfs_page_t          *page;
        /*
         * linkage into one of the lists in trace_data_union or
         * page_collection
         */
-       struct list_head linkage;
+       cfs_list_t           linkage;
        /*
         * number of bytes used within this page
         */
-       unsigned int     used;
+       unsigned int         used;
        /*
         * cpu that owns this page
         */
-       unsigned short   cpu;
+       unsigned short       cpu;
        /*
         * type(context) of this page
         */
-       unsigned short   type;
+       unsigned short       type;
 };
 
-extern void set_ptldebug_header(struct ptldebug_header *header,
-                          int subsys, int mask, const int line,
-                          unsigned long stack);
-extern void print_to_console(struct ptldebug_header *hdr, int mask, const char *buf,
-                            int len, const char *file, const char *fn);
+extern void cfs_set_ptldebug_header(struct ptldebug_header *header,
+                                    int subsys, int mask, const int line,
+                                    unsigned long stack);
+extern void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
+                                 const char *buf, int len, const char *file,
+                                 const char *fn);
 
-extern int trace_lock_tcd(struct trace_cpu_data *tcd);
-extern void trace_unlock_tcd(struct trace_cpu_data *tcd);
+extern int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd);
+extern void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd);
 
 /**
  * trace_buf_type_t, trace_buf_idx_get() and trace_console_buffers[][]
@@ -274,56 +276,58 @@ extern void trace_unlock_tcd(struct trace_cpu_data *tcd);
  * (see, for example, linux-tracefile.h).
  */
 
-extern char *trace_console_buffers[NR_CPUS][TCD_TYPE_MAX];
-extern trace_buf_type_t trace_buf_idx_get(void);
+extern char *cfs_trace_console_buffers[CFS_NR_CPUS][CFS_TCD_TYPE_MAX];
+extern cfs_trace_buf_type_t cfs_trace_buf_idx_get(void);
 
 static inline char *
-trace_get_console_buffer(void)
+cfs_trace_get_console_buffer(void)
 {
-        return trace_console_buffers[cfs_get_cpu()][trace_buf_idx_get()];
+        unsigned int i = cfs_get_cpu();
+        unsigned int j = cfs_trace_buf_idx_get();
+
+        return cfs_trace_console_buffers[i][j];
 }
 
 static inline void
-trace_put_console_buffer(char *buffer)
+cfs_trace_put_console_buffer(char *buffer)
 {
         cfs_put_cpu();
 }
 
-extern union trace_data_union (*trace_data[TCD_MAX_TYPES])[NR_CPUS];
-
-static inline struct trace_cpu_data *
-trace_get_tcd(void)
+static inline struct cfs_trace_cpu_data *
+cfs_trace_get_tcd(void)
 {
-       struct trace_cpu_data *tcd =
-                &(*trace_data[trace_buf_idx_get()])[cfs_get_cpu()].tcd;
+       struct cfs_trace_cpu_data *tcd =
+                &(*cfs_trace_data[cfs_trace_buf_idx_get()])[cfs_get_cpu()].tcd;
 
-       trace_lock_tcd(tcd);
+       cfs_trace_lock_tcd(tcd);
 
        return tcd;
 }
 
 static inline void
-trace_put_tcd (struct trace_cpu_data *tcd)
+cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd)
 {
-       trace_unlock_tcd(tcd);
+       cfs_trace_unlock_tcd(tcd);
 
        cfs_put_cpu();
 }
 
-int trace_refill_stock(struct trace_cpu_data *tcd, int gfp,
-                      struct list_head *stock);
+int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, int gfp,
+                           cfs_list_t *stock);
 
 
-int tcd_owns_tage(struct trace_cpu_data *tcd, struct trace_page *tage);
+int cfs_tcd_owns_tage(struct cfs_trace_cpu_data *tcd,
+                      struct cfs_trace_page *tage);
 
-extern void trace_assertion_failed(const char *str, const char *fn,
-                                  const char *file, int line);
+extern void cfs_trace_assertion_failed(const char *str, const char *fn,
+                                       const char *file, int line);
 
 /* ASSERTION that is safe to use within the debug system */
 #define __LASSERT(cond)                                                 \
     do {                                                                \
         if (unlikely(!(cond))) {                                        \
-                trace_assertion_failed("ASSERTION("#cond") failed",     \
+                cfs_trace_assertion_failed("ASSERTION("#cond") failed", \
                                  __FUNCTION__, __FILE__, __LINE__);     \
         }                                                               \
     } while (0)