[sheepdog] [PATCH stable-0.7 2/2] trace: exclude stuff related to tracing when trace is not enabled

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Jan 27 07:22:15 CET 2014


From: Hitoshi Mitake <mitake.hitoshi at gmail.com>

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 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 655c3ae..517476a 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 7974f68..ae1246b 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -215,4 +215,32 @@ struct object_cache_info {
 	int count;
 };
 
+#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 1d146bd..0872e43 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -36,21 +36,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.7.10.4




More information about the sheepdog mailing list