aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ialloc_btree.h
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2005-11-01 22:38:42 -0500
committerNathan Scott <nathans@sgi.com>2005-11-01 22:38:42 -0500
commita844f4510dce23c07f3923cb42138f5fdd745017 (patch)
treeffb37e9e60f02d5e92bd69bb53b568e1c991c17f /fs/xfs/xfs_ialloc_btree.h
parent61c1e689fbde7cb50a76262bba190715d86beab6 (diff)
[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
SGI-PV: 943122 SGI-Modid: xfs-linux:xfs-kern:23901a Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_ialloc_btree.h')
-rw-r--r--fs/xfs/xfs_ialloc_btree.h205
1 files changed, 38 insertions, 167 deletions
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 44be188674a6..b8c7e72ed837 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -51,14 +51,12 @@ typedef __uint64_t xfs_inofree_t;
51#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) 51#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3)
52#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) 52#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1)
53 53
54#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASKN)
55xfs_inofree_t xfs_inobt_maskn(int i, int n);
56#define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n) 54#define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n)
57#else 55static inline xfs_inofree_t xfs_inobt_maskn(int i, int n)
58#define XFS_INOBT_MASKN(i,n) \ 56{
59 ((((n) >= XFS_INODES_PER_CHUNK ? \ 57 return (((n) >= XFS_INODES_PER_CHUNK ? \
60 (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i)) 58 (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i);
61#endif 59}
62 60
63/* 61/*
64 * Data record structure 62 * Data record structure
@@ -82,237 +80,110 @@ typedef xfs_agblock_t xfs_inobt_ptr_t; /* btree pointer type */
82 /* btree block header type */ 80 /* btree block header type */
83typedef struct xfs_btree_sblock xfs_inobt_block_t; 81typedef struct xfs_btree_sblock xfs_inobt_block_t;
84 82
85#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_INOBT_BLOCK) 83#define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)XFS_BUF_PTR(bp))
86xfs_inobt_block_t *xfs_buf_to_inobt_block(struct xfs_buf *bp);
87#define XFS_BUF_TO_INOBT_BLOCK(bp) xfs_buf_to_inobt_block(bp)
88#else
89#define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)(XFS_BUF_PTR(bp)))
90#endif
91 84
92/* 85/*
93 * Bit manipulations for ir_free. 86 * Bit manipulations for ir_free.
94 */ 87 */
95#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASK)
96xfs_inofree_t xfs_inobt_mask(int i);
97#define XFS_INOBT_MASK(i) xfs_inobt_mask(i)
98#else
99#define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i)) 88#define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i))
100#endif 89#define XFS_INOBT_IS_FREE(rp,i) \
101#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_FREE) 90 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
102int xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i); 91#define XFS_INOBT_IS_FREE_DISK(rp,i) \
103#define XFS_INOBT_IS_FREE(rp,i) xfs_inobt_is_free(rp,i) 92 ((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
104#define XFS_INOBT_IS_FREE_DISK(rp,i) xfs_inobt_is_free_disk(rp,i)
105#else
106#define XFS_INOBT_IS_FREE(rp,i) \
107 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
108#define XFS_INOBT_IS_FREE_DISK(rp,i) \
109 ((INT_GET((rp)->ir_free, ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
110#endif
111#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_SET_FREE)
112void xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i);
113#define XFS_INOBT_SET_FREE(rp,i) xfs_inobt_set_free(rp,i)
114#else
115#define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) 93#define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i))
116#endif
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_CLR_FREE)
118void xfs_inobt_clr_free(xfs_inobt_rec_t *rp, int i);
119#define XFS_INOBT_CLR_FREE(rp,i) xfs_inobt_clr_free(rp,i)
120#else
121#define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) 94#define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i))
122#endif
123 95
124/* 96/*
125 * Real block structures have a size equal to the disk block size. 97 * Real block structures have a size equal to the disk block size.
126 */ 98 */
127#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_SIZE)
128int xfs_inobt_block_size(int lev, struct xfs_btree_cur *cur);
129#define XFS_INOBT_BLOCK_SIZE(lev,cur) xfs_inobt_block_size(lev,cur)
130#else
131#define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) 99#define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
132#endif 100#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_inobt_mxr[lev != 0])
133 101#define XFS_INOBT_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_inobt_mnr[lev != 0])
134#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MAXRECS)
135int xfs_inobt_block_maxrecs(int lev, struct xfs_btree_cur *cur);
136#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) xfs_inobt_block_maxrecs(lev,cur)
137#else
138#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) \
139 ((cur)->bc_mp->m_inobt_mxr[lev != 0])
140#endif
141#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MINRECS)
142int xfs_inobt_block_minrecs(int lev, struct xfs_btree_cur *cur);
143#define XFS_INOBT_BLOCK_MINRECS(lev,cur) xfs_inobt_block_minrecs(lev,cur)
144#else
145#define XFS_INOBT_BLOCK_MINRECS(lev,cur) \
146 ((cur)->bc_mp->m_inobt_mnr[lev != 0])
147#endif
148
149#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_LAST_REC)
150int xfs_inobt_is_last_rec(struct xfs_btree_cur *cur);
151#define XFS_INOBT_IS_LAST_REC(cur) xfs_inobt_is_last_rec(cur)
152#else
153#define XFS_INOBT_IS_LAST_REC(cur) \ 102#define XFS_INOBT_IS_LAST_REC(cur) \
154 ((cur)->bc_ptrs[0] == \ 103 ((cur)->bc_ptrs[0] == INT_GET(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs, ARCH_CONVERT))
155 INT_GET(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs, ARCH_CONVERT))
156#endif
157 104
158/* 105/*
159 * Maximum number of inode btree levels. 106 * Maximum number of inode btree levels.
160 */ 107 */
161#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IN_MAXLEVELS)
162int xfs_in_maxlevels(struct xfs_mount *mp);
163#define XFS_IN_MAXLEVELS(mp) xfs_in_maxlevels(mp)
164#else
165#define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels) 108#define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels)
166#endif
167 109
168/* 110/*
169 * block numbers in the AG. 111 * block numbers in the AG.
170 */ 112 */
171#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IBT_BLOCK) 113#define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1))
172xfs_agblock_t xfs_ibt_block(struct xfs_mount *mp); 114#define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1))
173#define XFS_IBT_BLOCK(mp) xfs_ibt_block(mp)
174#else
175#define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1))
176#endif
177#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_PREALLOC_BLOCKS)
178xfs_agblock_t xfs_prealloc_blocks(struct xfs_mount *mp);
179#define XFS_PREALLOC_BLOCKS(mp) xfs_prealloc_blocks(mp)
180#else
181#define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1))
182#endif
183 115
184/* 116/*
185 * Record, key, and pointer address macros for btree blocks. 117 * Record, key, and pointer address macros for btree blocks.
186 */ 118 */
187#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_REC_ADDR) 119#define XFS_INOBT_REC_ADDR(bb,i,cur) \
188xfs_inobt_rec_t * 120 (XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, \
189xfs_inobt_rec_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); 121 i, XFS_INOBT_BLOCK_MAXRECS(0, cur)))
190#define XFS_INOBT_REC_ADDR(bb,i,cur) xfs_inobt_rec_addr(bb,i,cur) 122#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
191#else 123 (XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \
192#define XFS_INOBT_REC_ADDR(bb,i,cur) \ 124 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
193 XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, i, \
194 XFS_INOBT_BLOCK_MAXRECS(0, cur))
195#endif
196
197#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_KEY_ADDR)
198xfs_inobt_key_t *
199xfs_inobt_key_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur);
200#define XFS_INOBT_KEY_ADDR(bb,i,cur) xfs_inobt_key_addr(bb,i,cur)
201#else
202#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
203 XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \
204 XFS_INOBT_BLOCK_MAXRECS(1, cur))
205#endif
206 125
207#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_PTR_ADDR) 126#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
208xfs_inobt_ptr_t * 127 (XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \
209xfs_inobt_ptr_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); 128 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
210#define XFS_INOBT_PTR_ADDR(bb,i,cur) xfs_inobt_ptr_addr(bb,i,cur)
211#else
212#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
213 XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \
214 XFS_INOBT_BLOCK_MAXRECS(1, cur))
215#endif
216
217/*
218 * Prototypes for externally visible routines.
219 */
220 129
221/* 130/*
222 * Decrement cursor by one record at the level. 131 * Decrement cursor by one record at the level.
223 * For nonzero levels the leaf-ward information is untouched. 132 * For nonzero levels the leaf-ward information is untouched.
224 */ 133 */
225int /* error */ 134extern int xfs_inobt_decrement(struct xfs_btree_cur *cur, int level, int *stat);
226xfs_inobt_decrement(
227 struct xfs_btree_cur *cur, /* btree cursor */
228 int level, /* level in btree, 0 is leaf */
229 int *stat); /* success/failure */
230 135
231/* 136/*
232 * Delete the record pointed to by cur. 137 * Delete the record pointed to by cur.
233 * The cursor refers to the place where the record was (could be inserted) 138 * The cursor refers to the place where the record was (could be inserted)
234 * when the operation returns. 139 * when the operation returns.
235 */ 140 */
236int /* error */ 141extern int xfs_inobt_delete(struct xfs_btree_cur *cur, int *stat);
237xfs_inobt_delete(
238 struct xfs_btree_cur *cur, /* btree cursor */
239 int *stat); /* success/failure */
240 142
241/* 143/*
242 * Get the data from the pointed-to record. 144 * Get the data from the pointed-to record.
243 */ 145 */
244int /* error */ 146extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino,
245xfs_inobt_get_rec( 147 __int32_t *fcnt, xfs_inofree_t *free, int *stat);
246 struct xfs_btree_cur *cur, /* btree cursor */
247 xfs_agino_t *ino, /* output: starting inode of chunk */
248 __int32_t *fcnt, /* output: number of free inodes */
249 xfs_inofree_t *free, /* output: free inode mask */
250 int *stat); /* output: success/failure */
251 148
252/* 149/*
253 * Increment cursor by one record at the level. 150 * Increment cursor by one record at the level.
254 * For nonzero levels the leaf-ward information is untouched. 151 * For nonzero levels the leaf-ward information is untouched.
255 */ 152 */
256int /* error */ 153extern int xfs_inobt_increment(struct xfs_btree_cur *cur, int level, int *stat);
257xfs_inobt_increment(
258 struct xfs_btree_cur *cur, /* btree cursor */
259 int level, /* level in btree, 0 is leaf */
260 int *stat); /* success/failure */
261 154
262/* 155/*
263 * Insert the current record at the point referenced by cur. 156 * Insert the current record at the point referenced by cur.
264 * The cursor may be inconsistent on return if splits have been done. 157 * The cursor may be inconsistent on return if splits have been done.
265 */ 158 */
266int /* error */ 159extern int xfs_inobt_insert(struct xfs_btree_cur *cur, int *stat);
267xfs_inobt_insert(
268 struct xfs_btree_cur *cur, /* btree cursor */
269 int *stat); /* success/failure */
270 160
271/* 161/*
272 * Lookup the record equal to ino in the btree given by cur. 162 * Lookup the record equal to ino in the btree given by cur.
273 */ 163 */
274int /* error */ 164extern int xfs_inobt_lookup_eq(struct xfs_btree_cur *cur, xfs_agino_t ino,
275xfs_inobt_lookup_eq( 165 __int32_t fcnt, xfs_inofree_t free, int *stat);
276 struct xfs_btree_cur *cur, /* btree cursor */
277 xfs_agino_t ino, /* starting inode of chunk */
278 __int32_t fcnt, /* free inode count */
279 xfs_inofree_t free, /* free inode mask */
280 int *stat); /* success/failure */
281 166
282/* 167/*
283 * Lookup the first record greater than or equal to ino 168 * Lookup the first record greater than or equal to ino
284 * in the btree given by cur. 169 * in the btree given by cur.
285 */ 170 */
286int /* error */ 171extern int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino,
287xfs_inobt_lookup_ge( 172 __int32_t fcnt, xfs_inofree_t free, int *stat);
288 struct xfs_btree_cur *cur, /* btree cursor */
289 xfs_agino_t ino, /* starting inode of chunk */
290 __int32_t fcnt, /* free inode count */
291 xfs_inofree_t free, /* free inode mask */
292 int *stat); /* success/failure */
293 173
294/* 174/*
295 * Lookup the first record less than or equal to ino 175 * Lookup the first record less than or equal to ino
296 * in the btree given by cur. 176 * in the btree given by cur.
297 */ 177 */
298int /* error */ 178extern int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino,
299xfs_inobt_lookup_le( 179 __int32_t fcnt, xfs_inofree_t free, int *stat);
300 struct xfs_btree_cur *cur, /* btree cursor */
301 xfs_agino_t ino, /* starting inode of chunk */
302 __int32_t fcnt, /* free inode count */
303 xfs_inofree_t free, /* free inode mask */
304 int *stat); /* success/failure */
305 180
306/* 181/*
307 * Update the record referred to by cur, to the value given 182 * Update the record referred to by cur, to the value given
308 * by [ino, fcnt, free]. 183 * by [ino, fcnt, free].
309 * This either works (return 0) or gets an EFSCORRUPTED error. 184 * This either works (return 0) or gets an EFSCORRUPTED error.
310 */ 185 */
311int /* error */ 186extern int xfs_inobt_update(struct xfs_btree_cur *cur, xfs_agino_t ino,
312xfs_inobt_update( 187 __int32_t fcnt, xfs_inofree_t free);
313 struct xfs_btree_cur *cur, /* btree cursor */
314 xfs_agino_t ino, /* starting inode of chunk */
315 __int32_t fcnt, /* free inode count */
316 xfs_inofree_t free); /* free inode mask */
317 188
318#endif /* __XFS_IALLOC_BTREE_H__ */ 189#endif /* __XFS_IALLOC_BTREE_H__ */