Skip to contentSkip to conversation

make btree tracing generic

PATCH In review Christoph Hellwig 2 participants 3 messages Jul 29, 2008 – Aug 1, 2008 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 8/21 make btree tracing generic

make the existing bmap btree tracing generic so that it applies to all btree types.

Some fragments lifted from a patch by Dave Chinner.

fs/xfs/xfs_btree.h +19 -0
Index: linux-2.6-xfs/fs/xfs/xfs_btree.h
===================================================================
@@ -190,6 +190,25 @@ struct xfs_btree_ops {
 
 	/* get inode rooted btree root */
 	struct xfs_btree_block *(*get_root_from_inode)(struct xfs_btree_cur *);
+
+	/* btree tracing */
+#ifdef XFS_BTREE_TRACE
+	void		(*trace_enter)(struct xfs_btree_cur *, const char *,
+				       char *, int, int, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t);
+	void		(*trace_cursor)(struct xfs_btree_cur *, __uint32_t *,
+					__uint64_t *, __uint64_t *);
+	void		(*trace_key)(struct xfs_btree_cur *,
+				     union xfs_btree_key *, __uint64_t *,
+				     __uint64_t *);
+	void		(*trace_record)(struct xfs_btree_cur *,
+					union xfs_btree_rec *, __uint64_t *,
+					__uint64_t *, __uint64_t *);
+#endif
 };
 
 /*
fs/xfs/xfs_btree_trace.c new file +247 -0

247 lines not on this page · raw message

fs/xfs/Makefile +2 -1
Index: linux-2.6-xfs/fs/xfs/Makefile
===================================================================
@@ -81,7 +81,8 @@ xfs-y				+= xfs_alloc.o \
 				   xfs_dmops.o \
 				   xfs_qmops.o
 
-xfs-$(CONFIG_XFS_TRACE)		+= xfs_dir2_trace.o
+xfs-$(CONFIG_XFS_TRACE)		+= xfs_btree_trace.o \
+				   xfs_dir2_trace.o
 
 # Objects in linux/
 xfs-y				+= $(addprefix $(XFS_LINUX)/, \
fs/xfs/xfs.h +1 -1
Index: linux-2.6-xfs/fs/xfs/xfs.h
===================================================================
@@ -30,7 +30,7 @@
 #define XFS_ATTR_TRACE 1
 #define XFS_BLI_TRACE 1
 #define XFS_BMAP_TRACE 1
-#define XFS_BMBT_TRACE 1
+#define XFS_BTREE_TRACE 1
 #define XFS_DIR2_TRACE 1
 #define XFS_DQUOT_TRACE 1
 #define XFS_ILOCK_TRACE 1
fs/xfs/xfs_bmap_btree.c +121 -242

398 lines not on this page · raw message

fs/xfs/linux-2.6/xfs_ksyms.c +4 -1
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================
@@ -39,6 +39,7 @@
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_btree.h"
+#include "xfs_btree_trace.h"
 #include "xfs_ialloc.h"
 #include "xfs_bmap.h"
 #include "xfs_rtalloc.h"
@@ -97,7 +98,9 @@ EXPORT_SYMBOL(xfs_alloc_trace_buf);
 #ifdef XFS_BMAP_TRACE
 EXPORT_SYMBOL(xfs_bmap_trace_buf);
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
+EXPORT_SYMBOL(xfs_allocbt_trace_buf);
+EXPORT_SYMBOL(xfs_inobt_trace_buf);
 EXPORT_SYMBOL(xfs_bmbt_trace_buf);
 #endif
 #ifdef XFS_ATTR_TRACE
fs/xfs/linux-2.6/xfs_super.c +19 -4
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
@@ -35,6 +35,7 @@
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_btree.h"
+#include "xfs_btree_trace.h"
 #include "xfs_ialloc.h"
 #include "xfs_bmap.h"
 #include "xfs_rtalloc.h"
@@ -1744,10 +1745,18 @@ xfs_alloc_trace_bufs(void)
 	if (!xfs_bmap_trace_buf)
 		goto out_free_alloc_trace;
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
+	xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE, KM_MAYFAIL);
+	if (!xfs_allocbt_trace_buf)
+		goto out_free_bmap_trace;
+
+	xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL);
+	if (!xfs_inobt_trace_buf)
+		goto out_free_allocbt_trace;
+
 	xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
 	if (!xfs_bmbt_trace_buf)
-		goto out_free_bmap_trace;
+		goto out_free_inobt_trace;
 #endif
 #ifdef XFS_ATTR_TRACE
 	xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
@@ -1769,8 +1778,12 @@ xfs_alloc_trace_bufs(void)
 	ktrace_free(xfs_attr_trace_buf);
  out_free_bmbt_trace:
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
 	ktrace_free(xfs_bmbt_trace_buf);
+ out_free_inobt_trace:
+	ktrace_free(xfs_inobt_trace_buf);
+ out_free_allocbt_trace:
+	ktrace_free(xfs_allocbt_trace_buf);
  out_free_bmap_trace:
 #endif
 #ifdef XFS_BMAP_TRACE
@@ -1793,8 +1806,10 @@ xfs_free_trace_bufs(void)
 #ifdef XFS_ATTR_TRACE
 	ktrace_free(xfs_attr_trace_buf);
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
 	ktrace_free(xfs_bmbt_trace_buf);
+	ktrace_free(xfs_inobt_trace_buf);
+	ktrace_free(xfs_allocbt_trace_buf);
 #endif
 #ifdef XFS_BMAP_TRACE
 	ktrace_free(xfs_bmap_trace_buf);
fs/xfs/xfs_bmap_btree.h +0 -18
Index: linux-2.6-xfs/fs/xfs/xfs_bmap_btree.h
===================================================================
@@ -233,24 +233,6 @@ typedef struct xfs_btree_lblock xfs_bmbt
 
 #ifdef __KERNEL__
 
-#if defined(XFS_BMBT_TRACE)
-/*
- * Trace buffer entry types.
- */
-#define XFS_BMBT_KTRACE_ARGBI	1
-#define XFS_BMBT_KTRACE_ARGBII	2
-#define XFS_BMBT_KTRACE_ARGFFFI 3
-#define XFS_BMBT_KTRACE_ARGI	4
-#define XFS_BMBT_KTRACE_ARGIFK	5
-#define XFS_BMBT_KTRACE_ARGIFR	6
-#define XFS_BMBT_KTRACE_ARGIK	7
-#define XFS_BMBT_KTRACE_CUR	8
-
-#define XFS_BMBT_TRACE_SIZE	4096	/* size of global trace buffer */
-#define XFS_BMBT_KTRACE_SIZE	32	/* size of per-inode trace buffer */
-extern ktrace_t	*xfs_bmbt_trace_buf;
-#endif
-
 /*
  * Prototypes for xfs_bmap.c to call.
  */
fs/xfs/xfs_inode.c +3 -2
Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================
@@ -41,6 +41,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_inode_item.h"
 #include "xfs_btree.h"
+#include "xfs_btree_trace.h"
 #include "xfs_alloc.h"
 #include "xfs_ialloc.h"
 #include "xfs_bmap.h"
@@ -841,7 +842,7 @@ xfs_iread(
 #ifdef XFS_BMAP_TRACE
 	ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_SLEEP);
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
 	ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_SLEEP);
 #endif
 #ifdef XFS_RW_TRACE
@@ -2600,7 +2601,7 @@ xfs_idestroy(
 #ifdef XFS_BMAP_TRACE
 	ktrace_free(ip->i_xtrace);
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
 	ktrace_free(ip->i_btrace);
 #endif
 #ifdef XFS_RW_TRACE
fs/xfs/xfs_inode.h +1 -1
Index: linux-2.6-xfs/fs/xfs/xfs_inode.h
===================================================================
@@ -251,7 +251,7 @@ typedef struct xfs_inode {
 #ifdef XFS_BMAP_TRACE
 	struct ktrace		*i_xtrace;	/* inode extent list trace */
 #endif
-#ifdef XFS_BMBT_TRACE
+#ifdef XFS_BTREE_TRACE
 	struct ktrace		*i_btrace;	/* inode bmap btree trace */
 #endif
 #ifdef XFS_RW_TRACE
fs/xfs/xfsidbg.c +205 -56

413 lines not on this page · raw message

fs/xfs/xfs_btree_trace.h new file +116 -0

116 lines not on this page · raw message

fs/xfs/xfs_alloc_btree.c +74 -0

82 lines not on this page · raw message

fs/xfs/xfs_ialloc_btree.c +74 -0

82 lines not on this page · raw message

#1 lore raw
Quoted 16 lines · Christoph Hellwig

make the existing bmap btree tracing generic so that it applies to all btree types.

Some fragments lifted from a patch by Dave Chinner.

Index: linux-2.6-xfs/fs/xfs/xfs_btree.h
===================================================================

fs/xfs/xfs_btree.h +0 -0
@@ -190,6 +190,25 @@ struct xfs_btree_ops {
 
 	/* get inode rooted btree root */
 	struct xfs_btree_block *(*get_root_from_inode)(struct xfs_btree_cur *);

fs/xfs/xfs_btree.h struct xfs_btree_ops { · line 202

Quoted 10 lines
fs/xfs/xfs_btree.h +10 -0
+
+	/* btree tracing */
+#ifdef XFS_BTREE_TRACE
+	void		(*trace_enter)(struct xfs_btree_cur *, const char *,
+				       char *, int, int, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t);

Would it be better to use a 'trace args' structure here rather than passing a heap of parameters? memset(args, 0,...) rather than passing a whole heap of zeros in most cases seems like a better approach to me, esp. as they all get cast to (void *) anyway....

fs/xfs/xfs_btree.h struct xfs_btree_ops { · line 204

Quoted 2 lines
fs/xfs/xfs_btree.h +2 -0
+static void
+xfsidb_btree_trace_record(

shouldn't these all use "xfsidbg" prefixes?

Otherwise looks ok.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 4 lines · Dave Chinner
Quoted 4 lines
fs/xfs/xfs_btree.h +4 -0
+	void		(*trace_enter)(struct xfs_btree_cur *, const char *,
+				       char *, int, int, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
Quoted 8 lines

fs/xfs/xfs_btree.h struct xfs_btree_ops { · line 202

Quoted 3 lines
fs/xfs/xfs_btree.h +3 -0
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t,
+				       __psunsigned_t, __psunsigned_t);

Would it be better to use a 'trace args' structure here rather than passing a heap of parameters? memset(args, 0,...) rather than passing a whole heap of zeros in most cases seems like a better approach to me, esp. as they all get cast to (void *) anyway....

Well, we need to case to void * somewhere, and going from struct to arguments list isn't helpful either.

Changing the whole ktrace thing to an args strucutr and/or varags would be nice, but is not in scope for this patchset..

Quoted 4 lines

fs/xfs/xfsidbg.c xfs_bmap_trace_entry(ktrace_entry_t *kte · line 2754

Quoted 2 lines
fs/xfs/xfsidbg.c +2 -0
+static void
+xfsidb_btree_trace_record(

shouldn't these all use "xfsidbg" prefixes?

Probably.