diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 01:54:53 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 01:54:53 -0400 |
commit | a23f6ef8ce966abc0f6e24a81ceb6a74ed30693b (patch) | |
tree | fa0d60a742dd47a966c177298268ca956c8bae4b /fs/xfs/xfs_btree.h | |
parent | b524bfeee2152fa64b6210f28ced80489b9d2439 (diff) |
[XFS] refactor btree validation helpers
Move the various btree validation helpers around in xfs_btree.c so that
they are close to each other and in common #ifdef DEBUG sections.
Also add a new xfs_btree_check_ptr helper to check a btree ptr that can be
either long or short form.
Split out from a bigger patch from Dave Chinner with various small changes
applied by me.
SGI-PV: 985583
SGI-Modid: xfs-linux-melb:xfs-kern:32183a
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_btree.h')
-rw-r--r-- | fs/xfs/xfs_btree.h | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 8be838f0154a..a57918276d9f 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -215,81 +215,92 @@ typedef struct xfs_btree_cur | |||
215 | 215 | ||
216 | #ifdef __KERNEL__ | 216 | #ifdef __KERNEL__ |
217 | 217 | ||
218 | #ifdef DEBUG | ||
219 | /* | 218 | /* |
220 | * Debug routine: check that block header is ok. | 219 | * Check that long form block header is ok. |
221 | */ | 220 | */ |
222 | void | 221 | int /* error (0 or EFSCORRUPTED) */ |
223 | xfs_btree_check_block( | 222 | xfs_btree_check_lblock( |
224 | xfs_btree_cur_t *cur, /* btree cursor */ | 223 | struct xfs_btree_cur *cur, /* btree cursor */ |
225 | xfs_btree_block_t *block, /* generic btree block pointer */ | 224 | struct xfs_btree_lblock *block, /* btree long form block pointer */ |
226 | int level, /* level of the btree block */ | 225 | int level, /* level of the btree block */ |
227 | struct xfs_buf *bp); /* buffer containing block, if any */ | 226 | struct xfs_buf *bp); /* buffer containing block, if any */ |
228 | 227 | ||
229 | /* | 228 | /* |
230 | * Debug routine: check that keys are in the right order. | 229 | * Check that short form block header is ok. |
231 | */ | 230 | */ |
232 | void | 231 | int /* error (0 or EFSCORRUPTED) */ |
233 | xfs_btree_check_key( | 232 | xfs_btree_check_sblock( |
234 | xfs_btnum_t btnum, /* btree identifier */ | 233 | struct xfs_btree_cur *cur, /* btree cursor */ |
235 | void *ak1, /* pointer to left (lower) key */ | 234 | struct xfs_btree_sblock *block, /* btree short form block pointer */ |
236 | void *ak2); /* pointer to right (higher) key */ | 235 | int level, /* level of the btree block */ |
237 | 236 | struct xfs_buf *bp); /* buffer containing block */ | |
238 | /* | ||
239 | * Debug routine: check that records are in the right order. | ||
240 | */ | ||
241 | void | ||
242 | xfs_btree_check_rec( | ||
243 | xfs_btnum_t btnum, /* btree identifier */ | ||
244 | void *ar1, /* pointer to left (lower) record */ | ||
245 | void *ar2); /* pointer to right (higher) record */ | ||
246 | #else | ||
247 | #define xfs_btree_check_block(a,b,c,d) | ||
248 | #define xfs_btree_check_key(a,b,c) | ||
249 | #define xfs_btree_check_rec(a,b,c) | ||
250 | #endif /* DEBUG */ | ||
251 | 237 | ||
252 | /* | 238 | /* |
253 | * Checking routine: check that long form block header is ok. | 239 | * Check that block header is ok. |
254 | */ | 240 | */ |
255 | int /* error (0 or EFSCORRUPTED) */ | 241 | int |
256 | xfs_btree_check_lblock( | 242 | xfs_btree_check_block( |
257 | xfs_btree_cur_t *cur, /* btree cursor */ | 243 | struct xfs_btree_cur *cur, /* btree cursor */ |
258 | xfs_btree_lblock_t *block, /* btree long form block pointer */ | 244 | struct xfs_btree_block *block, /* generic btree block pointer */ |
259 | int level, /* level of the btree block */ | 245 | int level, /* level of the btree block */ |
260 | struct xfs_buf *bp); /* buffer containing block, if any */ | 246 | struct xfs_buf *bp); /* buffer containing block, if any */ |
261 | 247 | ||
262 | /* | 248 | /* |
263 | * Checking routine: check that (long) pointer is ok. | 249 | * Check that (long) pointer is ok. |
264 | */ | 250 | */ |
265 | int /* error (0 or EFSCORRUPTED) */ | 251 | int /* error (0 or EFSCORRUPTED) */ |
266 | xfs_btree_check_lptr( | 252 | xfs_btree_check_lptr( |
267 | xfs_btree_cur_t *cur, /* btree cursor */ | 253 | struct xfs_btree_cur *cur, /* btree cursor */ |
268 | xfs_dfsbno_t ptr, /* btree block disk address */ | 254 | xfs_dfsbno_t ptr, /* btree block disk address */ |
269 | int level); /* btree block level */ | 255 | int level); /* btree block level */ |
270 | 256 | ||
271 | #define xfs_btree_check_lptr_disk(cur, ptr, level) \ | 257 | #define xfs_btree_check_lptr_disk(cur, ptr, level) \ |
272 | xfs_btree_check_lptr(cur, be64_to_cpu(ptr), level) | 258 | xfs_btree_check_lptr(cur, be64_to_cpu(ptr), level) |
273 | 259 | ||
260 | |||
274 | /* | 261 | /* |
275 | * Checking routine: check that short form block header is ok. | 262 | * Check that (short) pointer is ok. |
276 | */ | 263 | */ |
277 | int /* error (0 or EFSCORRUPTED) */ | 264 | int /* error (0 or EFSCORRUPTED) */ |
278 | xfs_btree_check_sblock( | 265 | xfs_btree_check_sptr( |
279 | xfs_btree_cur_t *cur, /* btree cursor */ | 266 | struct xfs_btree_cur *cur, /* btree cursor */ |
280 | xfs_btree_sblock_t *block, /* btree short form block pointer */ | 267 | xfs_agblock_t ptr, /* btree block disk address */ |
281 | int level, /* level of the btree block */ | 268 | int level); /* btree block level */ |
282 | struct xfs_buf *bp); /* buffer containing block */ | ||
283 | 269 | ||
284 | /* | 270 | /* |
285 | * Checking routine: check that (short) pointer is ok. | 271 | * Check that (short) pointer is ok. |
286 | */ | 272 | */ |
287 | int /* error (0 or EFSCORRUPTED) */ | 273 | int /* error (0 or EFSCORRUPTED) */ |
288 | xfs_btree_check_sptr( | 274 | xfs_btree_check_ptr( |
289 | xfs_btree_cur_t *cur, /* btree cursor */ | 275 | struct xfs_btree_cur *cur, /* btree cursor */ |
290 | xfs_agblock_t ptr, /* btree block disk address */ | 276 | union xfs_btree_ptr *ptr, /* btree block disk address */ |
277 | int index, /* offset from ptr to check */ | ||
291 | int level); /* btree block level */ | 278 | int level); /* btree block level */ |
292 | 279 | ||
280 | #ifdef DEBUG | ||
281 | |||
282 | /* | ||
283 | * Debug routine: check that keys are in the right order. | ||
284 | */ | ||
285 | void | ||
286 | xfs_btree_check_key( | ||
287 | xfs_btnum_t btnum, /* btree identifier */ | ||
288 | void *ak1, /* pointer to left (lower) key */ | ||
289 | void *ak2); /* pointer to right (higher) key */ | ||
290 | |||
291 | /* | ||
292 | * Debug routine: check that records are in the right order. | ||
293 | */ | ||
294 | void | ||
295 | xfs_btree_check_rec( | ||
296 | xfs_btnum_t btnum, /* btree identifier */ | ||
297 | void *ar1, /* pointer to left (lower) record */ | ||
298 | void *ar2); /* pointer to right (higher) record */ | ||
299 | #else | ||
300 | #define xfs_btree_check_key(a, b, c) | ||
301 | #define xfs_btree_check_rec(a, b, c) | ||
302 | #endif /* DEBUG */ | ||
303 | |||
293 | /* | 304 | /* |
294 | * Delete the btree cursor. | 305 | * Delete the btree cursor. |
295 | */ | 306 | */ |