aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:55:13 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:55:13 -0400
commit8c4ed633e65d0bd0a25d45aad9b4646e3236cad7 (patch)
tree36877f1d34c0dbd20cfd0315112d62dbf4571b80
parent854929f05831d3a290a802815ee955b96c740c61 (diff)
[XFS] 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. SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32187a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Bill O'Donnell <billodo@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/Makefile3
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c24
-rw-r--r--fs/xfs/xfs.h2
-rw-r--r--fs/xfs/xfs_alloc_btree.c73
-rw-r--r--fs/xfs/xfs_bmap_btree.c356
-rw-r--r--fs/xfs/xfs_bmap_btree.h18
-rw-r--r--fs/xfs/xfs_btree.h19
-rw-r--r--fs/xfs/xfs_ialloc_btree.c73
-rw-r--r--fs/xfs/xfs_inode.c5
-rw-r--r--fs/xfs/xfs_inode.h2
10 files changed, 309 insertions, 266 deletions
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 737c9a425361..75b2be72c39f 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -91,7 +91,8 @@ xfs-y += xfs_alloc.o \
91 xfs_dmops.o \ 91 xfs_dmops.o \
92 xfs_qmops.o 92 xfs_qmops.o
93 93
94xfs-$(CONFIG_XFS_TRACE) += xfs_dir2_trace.o 94xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o \
95 xfs_dir2_trace.o
95 96
96# Objects in linux/ 97# Objects in linux/
97xfs-y += $(addprefix $(XFS_LINUX)/, \ 98xfs-y += $(addprefix $(XFS_LINUX)/, \
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 9bfb26066a84..0c71c2158535 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -36,6 +36,7 @@
36#include "xfs_dinode.h" 36#include "xfs_dinode.h"
37#include "xfs_inode.h" 37#include "xfs_inode.h"
38#include "xfs_btree.h" 38#include "xfs_btree.h"
39#include "xfs_btree_trace.h"
39#include "xfs_ialloc.h" 40#include "xfs_ialloc.h"
40#include "xfs_bmap.h" 41#include "xfs_bmap.h"
41#include "xfs_rtalloc.h" 42#include "xfs_rtalloc.h"
@@ -1916,10 +1917,19 @@ xfs_alloc_trace_bufs(void)
1916 if (!xfs_bmap_trace_buf) 1917 if (!xfs_bmap_trace_buf)
1917 goto out_free_alloc_trace; 1918 goto out_free_alloc_trace;
1918#endif 1919#endif
1919#ifdef XFS_BMBT_TRACE 1920#ifdef XFS_BTREE_TRACE
1921 xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE,
1922 KM_MAYFAIL);
1923 if (!xfs_allocbt_trace_buf)
1924 goto out_free_bmap_trace;
1925
1926 xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL);
1927 if (!xfs_inobt_trace_buf)
1928 goto out_free_allocbt_trace;
1929
1920 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL); 1930 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
1921 if (!xfs_bmbt_trace_buf) 1931 if (!xfs_bmbt_trace_buf)
1922 goto out_free_bmap_trace; 1932 goto out_free_inobt_trace;
1923#endif 1933#endif
1924#ifdef XFS_ATTR_TRACE 1934#ifdef XFS_ATTR_TRACE
1925 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL); 1935 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
@@ -1941,8 +1951,12 @@ xfs_alloc_trace_bufs(void)
1941 ktrace_free(xfs_attr_trace_buf); 1951 ktrace_free(xfs_attr_trace_buf);
1942 out_free_bmbt_trace: 1952 out_free_bmbt_trace:
1943#endif 1953#endif
1944#ifdef XFS_BMBT_TRACE 1954#ifdef XFS_BTREE_TRACE
1945 ktrace_free(xfs_bmbt_trace_buf); 1955 ktrace_free(xfs_bmbt_trace_buf);
1956 out_free_inobt_trace:
1957 ktrace_free(xfs_inobt_trace_buf);
1958 out_free_allocbt_trace:
1959 ktrace_free(xfs_allocbt_trace_buf);
1946 out_free_bmap_trace: 1960 out_free_bmap_trace:
1947#endif 1961#endif
1948#ifdef XFS_BMAP_TRACE 1962#ifdef XFS_BMAP_TRACE
@@ -1965,8 +1979,10 @@ xfs_free_trace_bufs(void)
1965#ifdef XFS_ATTR_TRACE 1979#ifdef XFS_ATTR_TRACE
1966 ktrace_free(xfs_attr_trace_buf); 1980 ktrace_free(xfs_attr_trace_buf);
1967#endif 1981#endif
1968#ifdef XFS_BMBT_TRACE 1982#ifdef XFS_BTREE_TRACE
1969 ktrace_free(xfs_bmbt_trace_buf); 1983 ktrace_free(xfs_bmbt_trace_buf);
1984 ktrace_free(xfs_inobt_trace_buf);
1985 ktrace_free(xfs_allocbt_trace_buf);
1970#endif 1986#endif
1971#ifdef XFS_BMAP_TRACE 1987#ifdef XFS_BMAP_TRACE
1972 ktrace_free(xfs_bmap_trace_buf); 1988 ktrace_free(xfs_bmap_trace_buf);
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h
index 540e4c989825..17254b529c54 100644
--- a/fs/xfs/xfs.h
+++ b/fs/xfs/xfs.h
@@ -30,7 +30,7 @@
30#define XFS_ATTR_TRACE 1 30#define XFS_ATTR_TRACE 1
31#define XFS_BLI_TRACE 1 31#define XFS_BLI_TRACE 1
32#define XFS_BMAP_TRACE 1 32#define XFS_BMAP_TRACE 1
33#define XFS_BMBT_TRACE 1 33#define XFS_BTREE_TRACE 1
34#define XFS_DIR2_TRACE 1 34#define XFS_DIR2_TRACE 1
35#define XFS_DQUOT_TRACE 1 35#define XFS_DQUOT_TRACE 1
36#define XFS_ILOCK_TRACE 1 36#define XFS_ILOCK_TRACE 1
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 60c121f1e81b..9c91dfcb6f29 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -2219,8 +2219,81 @@ xfs_allocbt_dup_cursor(
2219 cur->bc_btnum); 2219 cur->bc_btnum);
2220} 2220}
2221 2221
2222#ifdef XFS_BTREE_TRACE
2223ktrace_t *xfs_allocbt_trace_buf;
2224
2225STATIC void
2226xfs_allocbt_trace_enter(
2227 struct xfs_btree_cur *cur,
2228 const char *func,
2229 char *s,
2230 int type,
2231 int line,
2232 __psunsigned_t a0,
2233 __psunsigned_t a1,
2234 __psunsigned_t a2,
2235 __psunsigned_t a3,
2236 __psunsigned_t a4,
2237 __psunsigned_t a5,
2238 __psunsigned_t a6,
2239 __psunsigned_t a7,
2240 __psunsigned_t a8,
2241 __psunsigned_t a9,
2242 __psunsigned_t a10)
2243{
2244 ktrace_enter(xfs_allocbt_trace_buf, (void *)(__psint_t)type,
2245 (void *)func, (void *)s, NULL, (void *)cur,
2246 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
2247 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
2248 (void *)a8, (void *)a9, (void *)a10);
2249}
2250
2251STATIC void
2252xfs_allocbt_trace_cursor(
2253 struct xfs_btree_cur *cur,
2254 __uint32_t *s0,
2255 __uint64_t *l0,
2256 __uint64_t *l1)
2257{
2258 *s0 = cur->bc_private.a.agno;
2259 *l0 = cur->bc_rec.a.ar_startblock;
2260 *l1 = cur->bc_rec.a.ar_blockcount;
2261}
2262
2263STATIC void
2264xfs_allocbt_trace_key(
2265 struct xfs_btree_cur *cur,
2266 union xfs_btree_key *key,
2267 __uint64_t *l0,
2268 __uint64_t *l1)
2269{
2270 *l0 = be32_to_cpu(key->alloc.ar_startblock);
2271 *l1 = be32_to_cpu(key->alloc.ar_blockcount);
2272}
2273
2274STATIC void
2275xfs_allocbt_trace_record(
2276 struct xfs_btree_cur *cur,
2277 union xfs_btree_rec *rec,
2278 __uint64_t *l0,
2279 __uint64_t *l1,
2280 __uint64_t *l2)
2281{
2282 *l0 = be32_to_cpu(rec->alloc.ar_startblock);
2283 *l1 = be32_to_cpu(rec->alloc.ar_blockcount);
2284 *l2 = 0;
2285}
2286#endif /* XFS_BTREE_TRACE */
2287
2222static const struct xfs_btree_ops xfs_allocbt_ops = { 2288static const struct xfs_btree_ops xfs_allocbt_ops = {
2223 .dup_cursor = xfs_allocbt_dup_cursor, 2289 .dup_cursor = xfs_allocbt_dup_cursor,
2290
2291#ifdef XFS_BTREE_TRACE
2292 .trace_enter = xfs_allocbt_trace_enter,
2293 .trace_cursor = xfs_allocbt_trace_cursor,
2294 .trace_key = xfs_allocbt_trace_key,
2295 .trace_record = xfs_allocbt_trace_record,
2296#endif
2224}; 2297};
2225 2298
2226/* 2299/*
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 519249e20536..16f2fde6433d 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -37,16 +37,13 @@
37#include "xfs_inode_item.h" 37#include "xfs_inode_item.h"
38#include "xfs_alloc.h" 38#include "xfs_alloc.h"
39#include "xfs_btree.h" 39#include "xfs_btree.h"
40#include "xfs_btree_trace.h"
40#include "xfs_ialloc.h" 41#include "xfs_ialloc.h"
41#include "xfs_itable.h" 42#include "xfs_itable.h"
42#include "xfs_bmap.h" 43#include "xfs_bmap.h"
43#include "xfs_error.h" 44#include "xfs_error.h"
44#include "xfs_quota.h" 45#include "xfs_quota.h"
45 46
46#if defined(XFS_BMBT_TRACE)
47ktrace_t *xfs_bmbt_trace_buf;
48#endif
49
50/* 47/*
51 * Prototypes for internal btree functions. 48 * Prototypes for internal btree functions.
52 */ 49 */
@@ -61,245 +58,33 @@ STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *,
61 __uint64_t *, xfs_btree_cur_t **, int *); 58 __uint64_t *, xfs_btree_cur_t **, int *);
62STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); 59STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int);
63 60
64
65#if defined(XFS_BMBT_TRACE)
66
67static char ARGS[] = "args";
68static char ENTRY[] = "entry";
69static char ERROR[] = "error";
70#undef EXIT 61#undef EXIT
71static char EXIT[] = "exit";
72 62
73/* 63#define ENTRY XBT_ENTRY
74 * Add a trace buffer entry for the arguments given to the routine, 64#define ERROR XBT_ERROR
75 * generic form. 65#define EXIT XBT_EXIT
76 */
77STATIC void
78xfs_bmbt_trace_enter(
79 const char *func,
80 xfs_btree_cur_t *cur,
81 char *s,
82 int type,
83 int line,
84 __psunsigned_t a0,
85 __psunsigned_t a1,
86 __psunsigned_t a2,
87 __psunsigned_t a3,
88 __psunsigned_t a4,
89 __psunsigned_t a5,
90 __psunsigned_t a6,
91 __psunsigned_t a7,
92 __psunsigned_t a8,
93 __psunsigned_t a9,
94 __psunsigned_t a10)
95{
96 xfs_inode_t *ip;
97 int whichfork;
98 66
99 ip = cur->bc_private.b.ip;
100 whichfork = cur->bc_private.b.whichfork;
101 ktrace_enter(xfs_bmbt_trace_buf,
102 (void *)((__psint_t)type | (whichfork << 8) | (line << 16)),
103 (void *)func, (void *)s, (void *)ip, (void *)cur,
104 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
105 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
106 (void *)a8, (void *)a9, (void *)a10);
107 ASSERT(ip->i_btrace);
108 ktrace_enter(ip->i_btrace,
109 (void *)((__psint_t)type | (whichfork << 8) | (line << 16)),
110 (void *)func, (void *)s, (void *)ip, (void *)cur,
111 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
112 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
113 (void *)a8, (void *)a9, (void *)a10);
114}
115/* 67/*
116 * Add a trace buffer entry for arguments, for a buffer & 1 integer arg. 68 * Keep the XFS_BMBT_TRACE_ names around for now until all code using them
69 * is converted to be generic and thus switches to the XFS_BTREE_TRACE_ names.
117 */ 70 */
118STATIC void 71#define XFS_BMBT_TRACE_ARGBI(c,b,i) \
119xfs_bmbt_trace_argbi( 72 XFS_BTREE_TRACE_ARGBI(c,b,i)
120 const char *func, 73#define XFS_BMBT_TRACE_ARGBII(c,b,i,j) \
121 xfs_btree_cur_t *cur, 74 XFS_BTREE_TRACE_ARGBII(c,b,i,j)
122 xfs_buf_t *b, 75#define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) \
123 int i, 76 XFS_BTREE_TRACE_ARGFFFI(c,o,b,i,j)
124 int line) 77#define XFS_BMBT_TRACE_ARGI(c,i) \
125{ 78 XFS_BTREE_TRACE_ARGI(c,i)
126 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGBI, line, 79#define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \
127 (__psunsigned_t)b, i, 0, 0, 80 XFS_BTREE_TRACE_ARGIPK(c,i,(union xfs_btree_ptr)f,s)
128 0, 0, 0, 0, 81#define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \
129 0, 0, 0); 82 XFS_BTREE_TRACE_ARGIPR(c,i, \
130} 83 (union xfs_btree_ptr)f, (union xfs_btree_rec *)r)
131 84#define XFS_BMBT_TRACE_ARGIK(c,i,k) \
132/* 85 XFS_BTREE_TRACE_ARGIK(c,i,(union xfs_btree_key *)k)
133 * Add a trace buffer entry for arguments, for a buffer & 2 integer args. 86#define XFS_BMBT_TRACE_CURSOR(c,s) \
134 */ 87 XFS_BTREE_TRACE_CURSOR(c,s)
135STATIC void
136xfs_bmbt_trace_argbii(
137 const char *func,
138 xfs_btree_cur_t *cur,
139 xfs_buf_t *b,
140 int i0,
141 int i1,
142 int line)
143{
144 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGBII, line,
145 (__psunsigned_t)b, i0, i1, 0,
146 0, 0, 0, 0,
147 0, 0, 0);
148}
149
150/*
151 * Add a trace buffer entry for arguments, for 3 block-length args
152 * and an integer arg.
153 */
154STATIC void
155xfs_bmbt_trace_argfffi(
156 const char *func,
157 xfs_btree_cur_t *cur,
158 xfs_dfiloff_t o,
159 xfs_dfsbno_t b,
160 xfs_dfilblks_t i,
161 int j,
162 int line)
163{
164 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGFFFI, line,
165 o >> 32, (int)o, b >> 32, (int)b,
166 i >> 32, (int)i, (int)j, 0,
167 0, 0, 0);
168}
169
170/*
171 * Add a trace buffer entry for arguments, for one integer arg.
172 */
173STATIC void
174xfs_bmbt_trace_argi(
175 const char *func,
176 xfs_btree_cur_t *cur,
177 int i,
178 int line)
179{
180 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGI, line,
181 i, 0, 0, 0,
182 0, 0, 0, 0,
183 0, 0, 0);
184}
185
186/*
187 * Add a trace buffer entry for arguments, for int, fsblock, key.
188 */
189STATIC void
190xfs_bmbt_trace_argifk(
191 const char *func,
192 xfs_btree_cur_t *cur,
193 int i,
194 xfs_fsblock_t f,
195 xfs_dfiloff_t o,
196 int line)
197{
198 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line,
199 i, (xfs_dfsbno_t)f >> 32, (int)f, o >> 32,
200 (int)o, 0, 0, 0,
201 0, 0, 0);
202}
203
204/*
205 * Add a trace buffer entry for arguments, for int, fsblock, rec.
206 */
207STATIC void
208xfs_bmbt_trace_argifr(
209 const char *func,
210 xfs_btree_cur_t *cur,
211 int i,
212 xfs_fsblock_t f,
213 xfs_bmbt_rec_t *r,
214 int line)
215{
216 xfs_dfsbno_t b;
217 xfs_dfilblks_t c;
218 xfs_dfsbno_t d;
219 xfs_dfiloff_t o;
220 xfs_bmbt_irec_t s;
221
222 d = (xfs_dfsbno_t)f;
223 xfs_bmbt_disk_get_all(r, &s);
224 o = (xfs_dfiloff_t)s.br_startoff;
225 b = (xfs_dfsbno_t)s.br_startblock;
226 c = s.br_blockcount;
227 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFR, line,
228 i, d >> 32, (int)d, o >> 32,
229 (int)o, b >> 32, (int)b, c >> 32,
230 (int)c, 0, 0);
231}
232
233/*
234 * Add a trace buffer entry for arguments, for int, key.
235 */
236STATIC void
237xfs_bmbt_trace_argik(
238 const char *func,
239 xfs_btree_cur_t *cur,
240 int i,
241 xfs_bmbt_key_t *k,
242 int line)
243{
244 xfs_dfiloff_t o;
245
246 o = be64_to_cpu(k->br_startoff);
247 xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line,
248 i, o >> 32, (int)o, 0,
249 0, 0, 0, 0,
250 0, 0, 0);
251}
252
253/*
254 * Add a trace buffer entry for the cursor/operation.
255 */
256STATIC void
257xfs_bmbt_trace_cursor(
258 const char *func,
259 xfs_btree_cur_t *cur,
260 char *s,
261 int line)
262{
263 xfs_bmbt_rec_host_t r;
264
265 xfs_bmbt_set_all(&r, &cur->bc_rec.b);
266 xfs_bmbt_trace_enter(func, cur, s, XFS_BMBT_KTRACE_CUR, line,
267 (cur->bc_nlevels << 24) | (cur->bc_private.b.flags << 16) |
268 cur->bc_private.b.allocated,
269 r.l0 >> 32, (int)r.l0,
270 r.l1 >> 32, (int)r.l1,
271 (unsigned long)cur->bc_bufs[0], (unsigned long)cur->bc_bufs[1],
272 (unsigned long)cur->bc_bufs[2], (unsigned long)cur->bc_bufs[3],
273 (cur->bc_ptrs[0] << 16) | cur->bc_ptrs[1],
274 (cur->bc_ptrs[2] << 16) | cur->bc_ptrs[3]);
275}
276
277#define XFS_BMBT_TRACE_ARGBI(c,b,i) \
278 xfs_bmbt_trace_argbi(__func__, c, b, i, __LINE__)
279#define XFS_BMBT_TRACE_ARGBII(c,b,i,j) \
280 xfs_bmbt_trace_argbii(__func__, c, b, i, j, __LINE__)
281#define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) \
282 xfs_bmbt_trace_argfffi(__func__, c, o, b, i, j, __LINE__)
283#define XFS_BMBT_TRACE_ARGI(c,i) \
284 xfs_bmbt_trace_argi(__func__, c, i, __LINE__)
285#define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \
286 xfs_bmbt_trace_argifk(__func__, c, i, f, s, __LINE__)
287#define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \
288 xfs_bmbt_trace_argifr(__func__, c, i, f, r, __LINE__)
289#define XFS_BMBT_TRACE_ARGIK(c,i,k) \
290 xfs_bmbt_trace_argik(__func__, c, i, k, __LINE__)
291#define XFS_BMBT_TRACE_CURSOR(c,s) \
292 xfs_bmbt_trace_cursor(__func__, c, s, __LINE__)
293#else
294#define XFS_BMBT_TRACE_ARGBI(c,b,i)
295#define XFS_BMBT_TRACE_ARGBII(c,b,i,j)
296#define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j)
297#define XFS_BMBT_TRACE_ARGI(c,i)
298#define XFS_BMBT_TRACE_ARGIFK(c,i,f,s)
299#define XFS_BMBT_TRACE_ARGIFR(c,i,f,r)
300#define XFS_BMBT_TRACE_ARGIK(c,i,k)
301#define XFS_BMBT_TRACE_CURSOR(c,s)
302#endif /* XFS_BMBT_TRACE */
303 88
304 89
305/* 90/*
@@ -1485,7 +1270,8 @@ xfs_bmbt_split(
1485 xfs_bmbt_rec_t *rrp; /* right record pointer */ 1270 xfs_bmbt_rec_t *rrp; /* right record pointer */
1486 1271
1487 XFS_BMBT_TRACE_CURSOR(cur, ENTRY); 1272 XFS_BMBT_TRACE_CURSOR(cur, ENTRY);
1488 XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, *startoff); 1273 // disable until merged into common code
1274// XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, *startoff);
1489 args.tp = cur->bc_tp; 1275 args.tp = cur->bc_tp;
1490 args.mp = cur->bc_mp; 1276 args.mp = cur->bc_mp;
1491 lbp = cur->bc_bufs[level]; 1277 lbp = cur->bc_bufs[level];
@@ -2629,8 +2415,100 @@ xfs_bmbt_dup_cursor(
2629 return new; 2415 return new;
2630} 2416}
2631 2417
2418#ifdef XFS_BTREE_TRACE
2419ktrace_t *xfs_bmbt_trace_buf;
2420
2421STATIC void
2422xfs_bmbt_trace_enter(
2423 struct xfs_btree_cur *cur,
2424 const char *func,
2425 char *s,
2426 int type,
2427 int line,
2428 __psunsigned_t a0,
2429 __psunsigned_t a1,
2430 __psunsigned_t a2,
2431 __psunsigned_t a3,
2432 __psunsigned_t a4,
2433 __psunsigned_t a5,
2434 __psunsigned_t a6,
2435 __psunsigned_t a7,
2436 __psunsigned_t a8,
2437 __psunsigned_t a9,
2438 __psunsigned_t a10)
2439{
2440 struct xfs_inode *ip = cur->bc_private.b.ip;
2441 int whichfork = cur->bc_private.b.whichfork;
2442
2443 ktrace_enter(xfs_bmbt_trace_buf,
2444 (void *)((__psint_t)type | (whichfork << 8) | (line << 16)),
2445 (void *)func, (void *)s, (void *)ip, (void *)cur,
2446 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
2447 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
2448 (void *)a8, (void *)a9, (void *)a10);
2449 ktrace_enter(ip->i_btrace,
2450 (void *)((__psint_t)type | (whichfork << 8) | (line << 16)),
2451 (void *)func, (void *)s, (void *)ip, (void *)cur,
2452 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
2453 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
2454 (void *)a8, (void *)a9, (void *)a10);
2455}
2456
2457STATIC void
2458xfs_bmbt_trace_cursor(
2459 struct xfs_btree_cur *cur,
2460 __uint32_t *s0,
2461 __uint64_t *l0,
2462 __uint64_t *l1)
2463{
2464 struct xfs_bmbt_rec_host r;
2465
2466 xfs_bmbt_set_all(&r, &cur->bc_rec.b);
2467
2468 *s0 = (cur->bc_nlevels << 24) |
2469 (cur->bc_private.b.flags << 16) |
2470 cur->bc_private.b.allocated;
2471 *l0 = r.l0;
2472 *l1 = r.l1;
2473}
2474
2475STATIC void
2476xfs_bmbt_trace_key(
2477 struct xfs_btree_cur *cur,
2478 union xfs_btree_key *key,
2479 __uint64_t *l0,
2480 __uint64_t *l1)
2481{
2482 *l0 = be64_to_cpu(key->bmbt.br_startoff);
2483 *l1 = 0;
2484}
2485
2486STATIC void
2487xfs_bmbt_trace_record(
2488 struct xfs_btree_cur *cur,
2489 union xfs_btree_rec *rec,
2490 __uint64_t *l0,
2491 __uint64_t *l1,
2492 __uint64_t *l2)
2493{
2494 struct xfs_bmbt_irec irec;
2495
2496 xfs_bmbt_disk_get_all(&rec->bmbt, &irec);
2497 *l0 = irec.br_startoff;
2498 *l1 = irec.br_startblock;
2499 *l2 = irec.br_blockcount;
2500}
2501#endif /* XFS_BTREE_TRACE */
2502
2632static const struct xfs_btree_ops xfs_bmbt_ops = { 2503static const struct xfs_btree_ops xfs_bmbt_ops = {
2633 .dup_cursor = xfs_bmbt_dup_cursor, 2504 .dup_cursor = xfs_bmbt_dup_cursor,
2505
2506#ifdef XFS_BTREE_TRACE
2507 .trace_enter = xfs_bmbt_trace_enter,
2508 .trace_cursor = xfs_bmbt_trace_cursor,
2509 .trace_key = xfs_bmbt_trace_key,
2510 .trace_record = xfs_bmbt_trace_record,
2511#endif
2634}; 2512};
2635 2513
2636/* 2514/*
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 4f12fff54975..5628d89cea45 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -233,24 +233,6 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
233 233
234#ifdef __KERNEL__ 234#ifdef __KERNEL__
235 235
236#if defined(XFS_BMBT_TRACE)
237/*
238 * Trace buffer entry types.
239 */
240#define XFS_BMBT_KTRACE_ARGBI 1
241#define XFS_BMBT_KTRACE_ARGBII 2
242#define XFS_BMBT_KTRACE_ARGFFFI 3
243#define XFS_BMBT_KTRACE_ARGI 4
244#define XFS_BMBT_KTRACE_ARGIFK 5
245#define XFS_BMBT_KTRACE_ARGIFR 6
246#define XFS_BMBT_KTRACE_ARGIK 7
247#define XFS_BMBT_KTRACE_CUR 8
248
249#define XFS_BMBT_TRACE_SIZE 4096 /* size of global trace buffer */
250#define XFS_BMBT_KTRACE_SIZE 32 /* size of per-inode trace buffer */
251extern ktrace_t *xfs_bmbt_trace_buf;
252#endif
253
254/* 236/*
255 * Prototypes for xfs_bmap.c to call. 237 * Prototypes for xfs_bmap.c to call.
256 */ 238 */
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 57d3bd37526e..0647a0eff0de 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -182,6 +182,25 @@ do { \
182struct xfs_btree_ops { 182struct xfs_btree_ops {
183 /* cursor operations */ 183 /* cursor operations */
184 struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *); 184 struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
185
186 /* btree tracing */
187#ifdef XFS_BTREE_TRACE
188 void (*trace_enter)(struct xfs_btree_cur *, const char *,
189 char *, int, int, __psunsigned_t,
190 __psunsigned_t, __psunsigned_t,
191 __psunsigned_t, __psunsigned_t,
192 __psunsigned_t, __psunsigned_t,
193 __psunsigned_t, __psunsigned_t,
194 __psunsigned_t, __psunsigned_t);
195 void (*trace_cursor)(struct xfs_btree_cur *, __uint32_t *,
196 __uint64_t *, __uint64_t *);
197 void (*trace_key)(struct xfs_btree_cur *,
198 union xfs_btree_key *, __uint64_t *,
199 __uint64_t *);
200 void (*trace_record)(struct xfs_btree_cur *,
201 union xfs_btree_rec *, __uint64_t *,
202 __uint64_t *, __uint64_t *);
203#endif
185}; 204};
186 205
187/* 206/*
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 8c0c4748a8df..fc99524b17af 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -2085,8 +2085,81 @@ xfs_inobt_dup_cursor(
2085 cur->bc_private.a.agbp, cur->bc_private.a.agno); 2085 cur->bc_private.a.agbp, cur->bc_private.a.agno);
2086} 2086}
2087 2087
2088#ifdef XFS_BTREE_TRACE
2089ktrace_t *xfs_inobt_trace_buf;
2090
2091STATIC void
2092xfs_inobt_trace_enter(
2093 struct xfs_btree_cur *cur,
2094 const char *func,
2095 char *s,
2096 int type,
2097 int line,
2098 __psunsigned_t a0,
2099 __psunsigned_t a1,
2100 __psunsigned_t a2,
2101 __psunsigned_t a3,
2102 __psunsigned_t a4,
2103 __psunsigned_t a5,
2104 __psunsigned_t a6,
2105 __psunsigned_t a7,
2106 __psunsigned_t a8,
2107 __psunsigned_t a9,
2108 __psunsigned_t a10)
2109{
2110 ktrace_enter(xfs_inobt_trace_buf, (void *)(__psint_t)type,
2111 (void *)func, (void *)s, NULL, (void *)cur,
2112 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
2113 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
2114 (void *)a8, (void *)a9, (void *)a10);
2115}
2116
2117STATIC void
2118xfs_inobt_trace_cursor(
2119 struct xfs_btree_cur *cur,
2120 __uint32_t *s0,
2121 __uint64_t *l0,
2122 __uint64_t *l1)
2123{
2124 *s0 = cur->bc_private.a.agno;
2125 *l0 = cur->bc_rec.i.ir_startino;
2126 *l1 = cur->bc_rec.i.ir_free;
2127}
2128
2129STATIC void
2130xfs_inobt_trace_key(
2131 struct xfs_btree_cur *cur,
2132 union xfs_btree_key *key,
2133 __uint64_t *l0,
2134 __uint64_t *l1)
2135{
2136 *l0 = be32_to_cpu(key->inobt.ir_startino);
2137 *l1 = 0;
2138}
2139
2140STATIC void
2141xfs_inobt_trace_record(
2142 struct xfs_btree_cur *cur,
2143 union xfs_btree_rec *rec,
2144 __uint64_t *l0,
2145 __uint64_t *l1,
2146 __uint64_t *l2)
2147{
2148 *l0 = be32_to_cpu(rec->inobt.ir_startino);
2149 *l1 = be32_to_cpu(rec->inobt.ir_freecount);
2150 *l2 = be64_to_cpu(rec->inobt.ir_free);
2151}
2152#endif /* XFS_BTREE_TRACE */
2153
2088static const struct xfs_btree_ops xfs_inobt_ops = { 2154static const struct xfs_btree_ops xfs_inobt_ops = {
2089 .dup_cursor = xfs_inobt_dup_cursor, 2155 .dup_cursor = xfs_inobt_dup_cursor,
2156
2157#ifdef XFS_BTREE_TRACE
2158 .trace_enter = xfs_inobt_trace_enter,
2159 .trace_cursor = xfs_inobt_trace_cursor,
2160 .trace_key = xfs_inobt_trace_key,
2161 .trace_record = xfs_inobt_trace_record,
2162#endif
2090}; 2163};
2091 2164
2092/* 2165/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 2a158a26286a..cc0474ddd2d4 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -41,6 +41,7 @@
41#include "xfs_buf_item.h" 41#include "xfs_buf_item.h"
42#include "xfs_inode_item.h" 42#include "xfs_inode_item.h"
43#include "xfs_btree.h" 43#include "xfs_btree.h"
44#include "xfs_btree_trace.h"
44#include "xfs_alloc.h" 45#include "xfs_alloc.h"
45#include "xfs_ialloc.h" 46#include "xfs_ialloc.h"
46#include "xfs_bmap.h" 47#include "xfs_bmap.h"
@@ -835,7 +836,7 @@ xfs_inode_alloc(
835#ifdef XFS_BMAP_TRACE 836#ifdef XFS_BMAP_TRACE
836 ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS); 837 ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS);
837#endif 838#endif
838#ifdef XFS_BMBT_TRACE 839#ifdef XFS_BTREE_TRACE
839 ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS); 840 ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS);
840#endif 841#endif
841#ifdef XFS_RW_TRACE 842#ifdef XFS_RW_TRACE
@@ -2673,7 +2674,7 @@ xfs_idestroy(
2673#ifdef XFS_BMAP_TRACE 2674#ifdef XFS_BMAP_TRACE
2674 ktrace_free(ip->i_xtrace); 2675 ktrace_free(ip->i_xtrace);
2675#endif 2676#endif
2676#ifdef XFS_BMBT_TRACE 2677#ifdef XFS_BTREE_TRACE
2677 ktrace_free(ip->i_btrace); 2678 ktrace_free(ip->i_btrace);
2678#endif 2679#endif
2679#ifdef XFS_RW_TRACE 2680#ifdef XFS_RW_TRACE
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 3af1f6dd1498..2a69a7dee228 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -245,7 +245,7 @@ typedef struct xfs_inode {
245#ifdef XFS_BMAP_TRACE 245#ifdef XFS_BMAP_TRACE
246 struct ktrace *i_xtrace; /* inode extent list trace */ 246 struct ktrace *i_xtrace; /* inode extent list trace */
247#endif 247#endif
248#ifdef XFS_BMBT_TRACE 248#ifdef XFS_BTREE_TRACE
249 struct ktrace *i_btrace; /* inode bmap btree trace */ 249 struct ktrace *i_btrace; /* inode bmap btree trace */
250#endif 250#endif
251#ifdef XFS_RW_TRACE 251#ifdef XFS_RW_TRACE