diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 01:55:13 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 01:55:13 -0400 |
commit | 8c4ed633e65d0bd0a25d45aad9b4646e3236cad7 (patch) | |
tree | 36877f1d34c0dbd20cfd0315112d62dbf4571b80 /fs/xfs/xfs_bmap_btree.c | |
parent | 854929f05831d3a290a802815ee955b96c740c61 (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>
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 356 |
1 files changed, 117 insertions, 239 deletions
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) | ||
47 | ktrace_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 *); |
62 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); | 59 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); |
63 | 60 | ||
64 | |||
65 | #if defined(XFS_BMBT_TRACE) | ||
66 | |||
67 | static char ARGS[] = "args"; | ||
68 | static char ENTRY[] = "entry"; | ||
69 | static char ERROR[] = "error"; | ||
70 | #undef EXIT | 61 | #undef EXIT |
71 | static 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 | */ | ||
77 | STATIC void | ||
78 | xfs_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 | */ |
118 | STATIC void | 71 | #define XFS_BMBT_TRACE_ARGBI(c,b,i) \ |
119 | xfs_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) |
135 | STATIC void | ||
136 | xfs_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 | */ | ||
154 | STATIC void | ||
155 | xfs_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 | */ | ||
173 | STATIC void | ||
174 | xfs_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 | */ | ||
189 | STATIC void | ||
190 | xfs_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 | */ | ||
207 | STATIC void | ||
208 | xfs_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 | */ | ||
236 | STATIC void | ||
237 | xfs_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 | */ | ||
256 | STATIC void | ||
257 | xfs_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 | ||
2419 | ktrace_t *xfs_bmbt_trace_buf; | ||
2420 | |||
2421 | STATIC void | ||
2422 | xfs_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 | |||
2457 | STATIC void | ||
2458 | xfs_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 | |||
2475 | STATIC void | ||
2476 | xfs_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 | |||
2486 | STATIC void | ||
2487 | xfs_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 | |||
2632 | static const struct xfs_btree_ops xfs_bmbt_ops = { | 2503 | static 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 | /* |