diff options
Diffstat (limited to 'fs/xfs/xfs_alloc_btree.h')
-rw-r--r-- | fs/xfs/xfs_alloc_btree.h | 107 |
1 files changed, 31 insertions, 76 deletions
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h index 5bd1a2c8bd07..a6caa0022c9b 100644 --- a/fs/xfs/xfs_alloc_btree.h +++ b/fs/xfs/xfs_alloc_btree.h | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | struct xfs_buf; | 25 | struct xfs_buf; |
26 | struct xfs_btree_cur; | 26 | struct xfs_btree_cur; |
27 | struct xfs_btree_sblock; | ||
28 | struct xfs_mount; | 27 | struct xfs_mount; |
29 | 28 | ||
30 | /* | 29 | /* |
@@ -50,16 +49,6 @@ typedef struct xfs_alloc_rec_incore { | |||
50 | 49 | ||
51 | /* btree pointer type */ | 50 | /* btree pointer type */ |
52 | typedef __be32 xfs_alloc_ptr_t; | 51 | typedef __be32 xfs_alloc_ptr_t; |
53 | /* btree block header type */ | ||
54 | typedef struct xfs_btree_sblock xfs_alloc_block_t; | ||
55 | |||
56 | #define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp)) | ||
57 | |||
58 | /* | ||
59 | * Real block structures have a size equal to the disk block size. | ||
60 | */ | ||
61 | #define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0]) | ||
62 | #define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0]) | ||
63 | 52 | ||
64 | /* | 53 | /* |
65 | * Minimum and maximum blocksize and sectorsize. | 54 | * Minimum and maximum blocksize and sectorsize. |
@@ -83,73 +72,39 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t; | |||
83 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) | 72 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) |
84 | 73 | ||
85 | /* | 74 | /* |
86 | * Record, key, and pointer address macros for btree blocks. | 75 | * Btree block header size depends on a superblock flag. |
87 | */ | 76 | * |
88 | #define XFS_ALLOC_REC_ADDR(bb,i,cur) \ | 77 | * (not quite yet, but soon) |
89 | XFS_BTREE_REC_ADDR(xfs_alloc, bb, i) | ||
90 | |||
91 | #define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ | ||
92 | XFS_BTREE_KEY_ADDR(xfs_alloc, bb, i) | ||
93 | |||
94 | #define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ | ||
95 | XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur)) | ||
96 | |||
97 | /* | ||
98 | * Decrement cursor by one record at the level. | ||
99 | * For nonzero levels the leaf-ward information is untouched. | ||
100 | */ | ||
101 | extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat); | ||
102 | |||
103 | /* | ||
104 | * Delete the record pointed to by cur. | ||
105 | * The cursor refers to the place where the record was (could be inserted) | ||
106 | * when the operation returns. | ||
107 | */ | ||
108 | extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat); | ||
109 | |||
110 | /* | ||
111 | * Get the data from the pointed-to record. | ||
112 | */ | ||
113 | extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno, | ||
114 | xfs_extlen_t *len, int *stat); | ||
115 | |||
116 | /* | ||
117 | * Increment cursor by one record at the level. | ||
118 | * For nonzero levels the leaf-ward information is untouched. | ||
119 | */ | ||
120 | extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat); | ||
121 | |||
122 | /* | ||
123 | * Insert the current record at the point referenced by cur. | ||
124 | * The cursor may be inconsistent on return if splits have been done. | ||
125 | */ | ||
126 | extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat); | ||
127 | |||
128 | /* | ||
129 | * Lookup the record equal to [bno, len] in the btree given by cur. | ||
130 | */ | ||
131 | extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno, | ||
132 | xfs_extlen_t len, int *stat); | ||
133 | |||
134 | /* | ||
135 | * Lookup the first record greater than or equal to [bno, len] | ||
136 | * in the btree given by cur. | ||
137 | */ | ||
138 | extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno, | ||
139 | xfs_extlen_t len, int *stat); | ||
140 | |||
141 | /* | ||
142 | * Lookup the first record less than or equal to [bno, len] | ||
143 | * in the btree given by cur. | ||
144 | */ | 78 | */ |
145 | extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno, | 79 | #define XFS_ALLOC_BLOCK_LEN(mp) XFS_BTREE_SBLOCK_LEN |
146 | xfs_extlen_t len, int *stat); | ||
147 | 80 | ||
148 | /* | 81 | /* |
149 | * Update the record referred to by cur, to the value given by [bno, len]. | 82 | * Record, key, and pointer address macros for btree blocks. |
150 | * This either works (return 0) or gets an EFSCORRUPTED error. | 83 | * |
151 | */ | 84 | * (note that some of these may appear unused, but they are used in userspace) |
152 | extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno, | 85 | */ |
153 | xfs_extlen_t len); | 86 | #define XFS_ALLOC_REC_ADDR(mp, block, index) \ |
87 | ((xfs_alloc_rec_t *) \ | ||
88 | ((char *)(block) + \ | ||
89 | XFS_ALLOC_BLOCK_LEN(mp) + \ | ||
90 | (((index) - 1) * sizeof(xfs_alloc_rec_t)))) | ||
91 | |||
92 | #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ | ||
93 | ((xfs_alloc_key_t *) \ | ||
94 | ((char *)(block) + \ | ||
95 | XFS_ALLOC_BLOCK_LEN(mp) + \ | ||
96 | ((index) - 1) * sizeof(xfs_alloc_key_t))) | ||
97 | |||
98 | #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ | ||
99 | ((xfs_alloc_ptr_t *) \ | ||
100 | ((char *)(block) + \ | ||
101 | XFS_ALLOC_BLOCK_LEN(mp) + \ | ||
102 | (maxrecs) * sizeof(xfs_alloc_key_t) + \ | ||
103 | ((index) - 1) * sizeof(xfs_alloc_ptr_t))) | ||
104 | |||
105 | extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, | ||
106 | struct xfs_trans *, struct xfs_buf *, | ||
107 | xfs_agnumber_t, xfs_btnum_t); | ||
108 | extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int); | ||
154 | 109 | ||
155 | #endif /* __XFS_ALLOC_BTREE_H__ */ | 110 | #endif /* __XFS_ALLOC_BTREE_H__ */ |