[sheepdog] [PATCH v2] [PATCH] trace: exclude stuff related to tracing when trace is not enabled

Hitoshi Mitake mitake.hitoshi at gmail.com
Sat Jan 11 12:35:57 CET 2014


Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---

v2: migrate tracing stuff to internal_proto.h and exxclude them with ifdef

 dog/trace.c              |  1 +
 include/internal_proto.h | 28 ++++++++++++++++++++++++++++
 include/sheep.h          | 15 ---------------
 3 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/dog/trace.c b/dog/trace.c
index 806a3dd..e3b6248 100644
--- a/dog/trace.c
+++ b/dog/trace.c
@@ -23,6 +23,7 @@
 #include "dog.h"
 #include "rbtree.h"
 #include "list.h"
+#include "internal_proto.h"
 
 static inline void print_thread_name(struct trace_graph_item *item)
 {
diff --git a/include/internal_proto.h b/include/internal_proto.h
index d32cea7..2a2a785 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -260,4 +260,32 @@ struct sd_stat {
 	} r;
 };
 
+#ifdef HAVE_TRACE
+
+#define TRACE_GRAPH_ENTRY  0x01
+#define TRACE_GRAPH_RETURN 0x02
+
+#define TRACE_FNAME_LEN    36
+#define TRACE_THREAD_LEN   MAX_THREAD_NAME_LEN
+
+struct trace_graph_item {
+	char tname[TRACE_THREAD_LEN];
+	int type;
+	char fname[TRACE_FNAME_LEN];
+	int depth;
+	uint64_t entry_time;
+	uint64_t return_time;
+};
+
+#else
+
+/*
+ * Some functions e.g. trace_buffer_push() can declare a pointer of struct
+ * trace_graph_item in its parameters, so we need the below empty
+ * declaration.
+ */
+struct trace_graph_item;
+
+#endif	/* HAVE_TRACE */
+
 #endif /* __INTERNAL_PROTO_H__ */
diff --git a/include/sheep.h b/include/sheep.h
index d460d54..f7f5c48 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -34,21 +34,6 @@ struct vnode_info {
 	refcnt_t refcnt;
 };
 
-#define TRACE_GRAPH_ENTRY  0x01
-#define TRACE_GRAPH_RETURN 0x02
-
-#define TRACE_FNAME_LEN    36
-#define TRACE_THREAD_LEN   MAX_THREAD_NAME_LEN
-
-struct trace_graph_item {
-	char tname[TRACE_THREAD_LEN];
-	int type;
-	char fname[TRACE_FNAME_LEN];
-	int depth;
-	uint64_t entry_time;
-	uint64_t return_time;
-};
-
 static inline void sd_init_req(struct sd_req *req, uint8_t opcode)
 {
 	memset(req, 0, sizeof(*req));
-- 
1.8.1.2




More information about the sheepdog mailing list