aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 02:14:34 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:14:34 -0400
commit7cc95a821df8f09a5d37a923cf8c3a7c3ee00c29 (patch)
tree8fde02d4c9a52b7da7b3e961f8a23cf4b493a4a4 /fs/xfs/xfs_btree.h
parent136341b41ad4883bd668120f727a52c42331fe8a (diff)
[XFS] Always use struct xfs_btree_block instead of short / longform
structures. Always use the generic xfs_btree_block type instead of the short / long structures. Add XFS_BTREE_SBLOCK_LEN / XFS_BTREE_LBLOCK_LEN defines for the length of a short / long form block. The rationale for this is that we will grow more btree block header variants to support CRCs and other RAS information, and always accessing them through the same datatype with unions for the short / long form pointers makes implementing this much easier. SGI-PV: 988146 SGI-Modid: xfs-linux-melb:xfs-kern:32300a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Donald Douwsma <donaldd@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_btree.h')
-rw-r--r--fs/xfs/xfs_btree.h53
1 files changed, 15 insertions, 38 deletions
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index d6120a749060..789fffdf8b2f 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -39,31 +39,16 @@ extern kmem_zone_t *xfs_btree_cur_zone;
39#define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi) 39#define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi)
40 40
41/* 41/*
42 * Short form header: space allocation btrees. 42 * Generic btree header.
43 */ 43 *
44typedef struct xfs_btree_sblock { 44 * This is a comination of the actual format used on disk for short and long
45 __be32 bb_magic; /* magic number for block type */ 45 * format btrees. The first three fields are shared by both format, but
46 __be16 bb_level; /* 0 is a leaf */ 46 * the pointers are different and should be used with care.
47 __be16 bb_numrecs; /* current # of data records */ 47 *
48 __be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */ 48 * To get the size of the actual short or long form headers please use
49 __be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */ 49 * the size macros below. Never use sizeof(xfs_btree_block).
50} xfs_btree_sblock_t;
51
52/*
53 * Long form header: bmap btrees.
54 */
55typedef struct xfs_btree_lblock {
56 __be32 bb_magic; /* magic number for block type */
57 __be16 bb_level; /* 0 is a leaf */
58 __be16 bb_numrecs; /* current # of data records */
59 __be64 bb_leftsib; /* left sibling block or NULLDFSBNO */
60 __be64 bb_rightsib; /* right sibling block or NULLDFSBNO */
61} xfs_btree_lblock_t;
62
63/*
64 * Combined header and structure, used by common code.
65 */ 50 */
66typedef struct xfs_btree_block { 51struct xfs_btree_block {
67 __be32 bb_magic; /* magic number for block type */ 52 __be32 bb_magic; /* magic number for block type */
68 __be16 bb_level; /* 0 is a leaf */ 53 __be16 bb_level; /* 0 is a leaf */
69 __be16 bb_numrecs; /* current # of data records */ 54 __be16 bb_numrecs; /* current # of data records */
@@ -77,7 +62,11 @@ typedef struct xfs_btree_block {
77 __be64 bb_rightsib; 62 __be64 bb_rightsib;
78 } l; /* long form pointers */ 63 } l; /* long form pointers */
79 } bb_u; /* rest */ 64 } bb_u; /* rest */
80} xfs_btree_block_t; 65};
66
67#define XFS_BTREE_SBLOCK_LEN 16 /* size of a short form block */
68#define XFS_BTREE_LBLOCK_LEN 24 /* size of a long form block */
69
81 70
82/* 71/*
83 * Generic key, ptr and record wrapper structures. 72 * Generic key, ptr and record wrapper structures.
@@ -294,20 +283,8 @@ typedef struct xfs_btree_cur
294/* 283/*
295 * Convert from buffer to btree block header. 284 * Convert from buffer to btree block header.
296 */ 285 */
297#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp)) 286#define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)XFS_BUF_PTR(bp))
298#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp))
299#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
300
301 287
302/*
303 * Check that long form block header is ok.
304 */
305int /* error (0 or EFSCORRUPTED) */
306xfs_btree_check_lblock(
307 struct xfs_btree_cur *cur, /* btree cursor */
308 struct xfs_btree_lblock *block, /* btree long form block pointer */
309 int level, /* level of the btree block */
310 struct xfs_buf *bp); /* buffer containing block, if any */
311 288
312/* 289/*
313 * Check that block header is ok. 290 * Check that block header is ok.