aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc_btree.h
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 09:36:37 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 09:36:37 -0500
commit2fc2991175bf77395e6b15fe6b2304d3bf72da40 (patch)
treeb0ff38c09240e7c00e1577d447ebe89143d752dc /fs/xfs/xfs_alloc_btree.h
parent8b491d750885ebe8e7d385ce4186c85957d67123 (diff)
parent7015faa7df829876a0f931cd18aa6d7c24a1b581 (diff)
Merge branch 'master' of /home/tglx/work/mtd/git/linux-2.6.git/
Diffstat (limited to 'fs/xfs/xfs_alloc_btree.h')
-rw-r--r--fs/xfs/xfs_alloc_btree.h186
1 files changed, 44 insertions, 142 deletions
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index ed5161a572ef..bce81c7a4fdc 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ALLOC_BTREE_H__ 18#ifndef __XFS_ALLOC_BTREE_H__
33#define __XFS_ALLOC_BTREE_H__ 19#define __XFS_ALLOC_BTREE_H__
@@ -52,48 +38,29 @@ struct xfs_mount;
52/* 38/*
53 * Data record/key structure 39 * Data record/key structure
54 */ 40 */
55typedef struct xfs_alloc_rec 41typedef struct xfs_alloc_rec {
56{ 42 __be32 ar_startblock; /* starting block number */
43 __be32 ar_blockcount; /* count of free blocks */
44} xfs_alloc_rec_t, xfs_alloc_key_t;
45
46typedef struct xfs_alloc_rec_incore {
57 xfs_agblock_t ar_startblock; /* starting block number */ 47 xfs_agblock_t ar_startblock; /* starting block number */
58 xfs_extlen_t ar_blockcount; /* count of free blocks */ 48 xfs_extlen_t ar_blockcount; /* count of free blocks */
59} xfs_alloc_rec_t, xfs_alloc_key_t; 49} xfs_alloc_rec_incore_t;
60 50
61typedef xfs_agblock_t xfs_alloc_ptr_t; /* btree pointer type */ 51/* btree pointer type */
62 /* btree block header type */ 52typedef __be32 xfs_alloc_ptr_t;
53/* btree block header type */
63typedef struct xfs_btree_sblock xfs_alloc_block_t; 54typedef struct xfs_btree_sblock xfs_alloc_block_t;
64 55
65#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) 56#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp))
66xfs_alloc_block_t *xfs_buf_to_alloc_block(struct xfs_buf *bp);
67#define XFS_BUF_TO_ALLOC_BLOCK(bp) xfs_buf_to_alloc_block(bp)
68#else
69#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)(XFS_BUF_PTR(bp)))
70#endif
71 57
72/* 58/*
73 * Real block structures have a size equal to the disk block size. 59 * Real block structures have a size equal to the disk block size.
74 */ 60 */
75
76#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_SIZE)
77int xfs_alloc_block_size(int lev, struct xfs_btree_cur *cur);
78#define XFS_ALLOC_BLOCK_SIZE(lev,cur) xfs_alloc_block_size(lev,cur)
79#else
80#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) 61#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
81#endif 62#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0])
82 63#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0])
83#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MAXRECS)
84int xfs_alloc_block_maxrecs(int lev, struct xfs_btree_cur *cur);
85#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) xfs_alloc_block_maxrecs(lev,cur)
86#else
87#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) \
88 ((cur)->bc_mp->m_alloc_mxr[lev != 0])
89#endif
90#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MINRECS)
91int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
92#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) xfs_alloc_block_minrecs(lev,cur)
93#else
94#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) \
95 ((cur)->bc_mp->m_alloc_mnr[lev != 0])
96#endif
97 64
98/* 65/*
99 * Minimum and maximum blocksize and sectorsize. 66 * Minimum and maximum blocksize and sectorsize.
@@ -113,145 +80,80 @@ int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
113 * Block numbers in the AG: 80 * Block numbers in the AG:
114 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. 81 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3.
115 */ 82 */
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BNO_BLOCK)
117xfs_agblock_t xfs_bno_block(struct xfs_mount *mp);
118#define XFS_BNO_BLOCK(mp) xfs_bno_block(mp)
119#else
120#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) 83#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1))
121#endif
122#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CNT_BLOCK)
123xfs_agblock_t xfs_cnt_block(struct xfs_mount *mp);
124#define XFS_CNT_BLOCK(mp) xfs_cnt_block(mp)
125#else
126#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) 84#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1))
127#endif
128 85
129/* 86/*
130 * Record, key, and pointer address macros for btree blocks. 87 * Record, key, and pointer address macros for btree blocks.
131 */ 88 */
132#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_REC_ADDR)
133xfs_alloc_rec_t *xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i,
134 struct xfs_btree_cur *cur);
135#define XFS_ALLOC_REC_ADDR(bb,i,cur) xfs_alloc_rec_addr(bb,i,cur)
136#else
137#define XFS_ALLOC_REC_ADDR(bb,i,cur) \ 89#define XFS_ALLOC_REC_ADDR(bb,i,cur) \
138 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, bb, i, \ 90 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \
139 XFS_ALLOC_BLOCK_MAXRECS(0, cur)) 91 bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur))
140#endif
141 92
142#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_KEY_ADDR)
143xfs_alloc_key_t *xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i,
144 struct xfs_btree_cur *cur);
145#define XFS_ALLOC_KEY_ADDR(bb,i,cur) xfs_alloc_key_addr(bb,i,cur)
146#else
147#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ 93#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
148 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 94 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
149 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 95 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
150#endif
151 96
152#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_PTR_ADDR)
153xfs_alloc_ptr_t *xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i,
154 struct xfs_btree_cur *cur);
155#define XFS_ALLOC_PTR_ADDR(bb,i,cur) xfs_alloc_ptr_addr(bb,i,cur)
156#else
157#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ 97#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
158 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 98 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
159 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 99 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
160#endif
161
162/*
163 * Prototypes for externally visible routines.
164 */
165 100
166/* 101/*
167 * Decrement cursor by one record at the level. 102 * Decrement cursor by one record at the level.
168 * For nonzero levels the leaf-ward information is untouched. 103 * For nonzero levels the leaf-ward information is untouched.
169 */ 104 */
170int /* error */ 105extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat);
171xfs_alloc_decrement(
172 struct xfs_btree_cur *cur, /* btree cursor */
173 int level, /* level in btree, 0 is leaf */
174 int *stat); /* success/failure */
175 106
176/* 107/*
177 * Delete the record pointed to by cur. 108 * Delete the record pointed to by cur.
178 * The cursor refers to the place where the record was (could be inserted) 109 * The cursor refers to the place where the record was (could be inserted)
179 * when the operation returns. 110 * when the operation returns.
180 */ 111 */
181int /* error */ 112extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat);
182xfs_alloc_delete(
183 struct xfs_btree_cur *cur, /* btree cursor */
184 int *stat); /* success/failure */
185 113
186/* 114/*
187 * Get the data from the pointed-to record. 115 * Get the data from the pointed-to record.
188 */ 116 */
189int /* error */ 117extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno,
190xfs_alloc_get_rec( 118 xfs_extlen_t *len, int *stat);
191 struct xfs_btree_cur *cur, /* btree cursor */
192 xfs_agblock_t *bno, /* output: starting block of extent */
193 xfs_extlen_t *len, /* output: length of extent */
194 int *stat); /* output: success/failure */
195 119
196/* 120/*
197 * Increment cursor by one record at the level. 121 * Increment cursor by one record at the level.
198 * For nonzero levels the leaf-ward information is untouched. 122 * For nonzero levels the leaf-ward information is untouched.
199 */ 123 */
200int /* error */ 124extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat);
201xfs_alloc_increment(
202 struct xfs_btree_cur *cur, /* btree cursor */
203 int level, /* level in btree, 0 is leaf */
204 int *stat); /* success/failure */
205 125
206/* 126/*
207 * Insert the current record at the point referenced by cur. 127 * Insert the current record at the point referenced by cur.
208 * The cursor may be inconsistent on return if splits have been done. 128 * The cursor may be inconsistent on return if splits have been done.
209 */ 129 */
210int /* error */ 130extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat);
211xfs_alloc_insert(
212 struct xfs_btree_cur *cur, /* btree cursor */
213 int *stat); /* success/failure */
214 131
215/* 132/*
216 * Lookup the record equal to [bno, len] in the btree given by cur. 133 * Lookup the record equal to [bno, len] in the btree given by cur.
217 */ 134 */
218int /* error */ 135extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
219xfs_alloc_lookup_eq( 136 xfs_extlen_t len, int *stat);
220 struct xfs_btree_cur *cur, /* btree cursor */
221 xfs_agblock_t bno, /* starting block of extent */
222 xfs_extlen_t len, /* length of extent */
223 int *stat); /* success/failure */
224 137
225/* 138/*
226 * Lookup the first record greater than or equal to [bno, len] 139 * Lookup the first record greater than or equal to [bno, len]
227 * in the btree given by cur. 140 * in the btree given by cur.
228 */ 141 */
229int /* error */ 142extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno,
230xfs_alloc_lookup_ge( 143 xfs_extlen_t len, int *stat);
231 struct xfs_btree_cur *cur, /* btree cursor */
232 xfs_agblock_t bno, /* starting block of extent */
233 xfs_extlen_t len, /* length of extent */
234 int *stat); /* success/failure */
235 144
236/* 145/*
237 * Lookup the first record less than or equal to [bno, len] 146 * Lookup the first record less than or equal to [bno, len]
238 * in the btree given by cur. 147 * in the btree given by cur.
239 */ 148 */
240int /* error */ 149extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
241xfs_alloc_lookup_le( 150 xfs_extlen_t len, int *stat);
242 struct xfs_btree_cur *cur, /* btree cursor */
243 xfs_agblock_t bno, /* starting block of extent */
244 xfs_extlen_t len, /* length of extent */
245 int *stat); /* success/failure */
246 151
247/* 152/*
248 * Update the record referred to by cur, to the value given by [bno, len]. 153 * Update the record referred to by cur, to the value given by [bno, len].
249 * This either works (return 0) or gets an EFSCORRUPTED error. 154 * This either works (return 0) or gets an EFSCORRUPTED error.
250 */ 155 */
251int /* error */ 156extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno,
252xfs_alloc_update( 157 xfs_extlen_t len);
253 struct xfs_btree_cur *cur, /* btree cursor */
254 xfs_agblock_t bno, /* starting block of extent */
255 xfs_extlen_t len); /* length of extent */
256 158
257#endif /* __XFS_ALLOC_BTREE_H__ */ 159#endif /* __XFS_ALLOC_BTREE_H__ */