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

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Fri Jan 10 06:18:28 CET 2014


Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 dog/trace.c              |    1 +
 include/Makefile.am      |    4 ++++
 include/sheep.h          |   15 ---------------
 include/sheepdog_trace.h |   19 +++++++++++++++++++
 sheep/trace/trace.h      |    1 +
 5 files changed, 25 insertions(+), 15 deletions(-)
 create mode 100644 include/sheepdog_trace.h

diff --git a/dog/trace.c b/dog/trace.c
index 806a3dd..51e061b 100644
--- a/dog/trace.c
+++ b/dog/trace.c
@@ -23,6 +23,7 @@
 #include "dog.h"
 #include "rbtree.h"
 #include "list.h"
+#include "sheepdog_trace.h"
 
 static inline void print_thread_name(struct trace_graph_item *item)
 {
diff --git a/include/Makefile.am b/include/Makefile.am
index 2c86984..13990bc 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -4,3 +4,7 @@ noinst_HEADERS          = bitops.h event.h logger.h sheepdog_proto.h util.h \
 			  list.h net.h sheep.h exits.h strbuf.h rbtree.h \
 			  sha1.h option.h internal_proto.h shepherd.h work.h \
 			  sockfd_cache.h compiler.h fec.h
+
+if BUILD_TRACE
+noinst_HEADERS		+= sheepdog_trace.h
+endif
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));
diff --git a/include/sheepdog_trace.h b/include/sheepdog_trace.h
new file mode 100644
index 0000000..905c1d7
--- /dev/null
+++ b/include/sheepdog_trace.h
@@ -0,0 +1,19 @@
+#ifndef SHEEPDOG_TRACE_H
+#define SHEEPDOG_TRACE_H
+
+#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;
+};
+
+#endif	/* SHEEPDOG_TRACE_H */
diff --git a/sheep/trace/trace.h b/sheep/trace/trace.h
index ea72733..889453a 100644
--- a/sheep/trace/trace.h
+++ b/sheep/trace/trace.h
@@ -6,6 +6,7 @@
 #ifndef __ASSEMBLY__
 
 #include "sheep_priv.h"
+#include "sheepdog_trace.h"
 
 struct caller {
 	unsigned long addr;
-- 
1.7.10.4




More information about the sheepdog mailing list