]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/xfs/libxfs/xfs_btree.h
xfs: skip bmbt block ino validation during owner change
[mirror_ubuntu-artful-kernel.git] / fs / xfs / libxfs / xfs_btree.h
CommitLineData
1da177e4 1/*
7b718769
NS
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
7b718769
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
7b718769
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
1da177e4 13 *
7b718769
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1da177e4
LT
17 */
18#ifndef __XFS_BTREE_H__
19#define __XFS_BTREE_H__
20
21struct xfs_buf;
310a75a3 22struct xfs_defer_ops;
1da177e4
LT
23struct xfs_inode;
24struct xfs_mount;
25struct xfs_trans;
26
a8272ce0
DC
27extern kmem_zone_t *xfs_btree_cur_zone;
28
de227dd9
CH
29/*
30 * Generic key, ptr and record wrapper structures.
31 *
32 * These are disk format structures, and are converted where necessary
33 * by the btree specific code that needs to interpret them.
34 */
35union xfs_btree_ptr {
36 __be32 s; /* short form ptr */
37 __be64 l; /* long form ptr */
38};
39
2c813ad6 40/*
a1d46cff
DW
41 * The in-core btree key. Overlapping btrees actually store two keys
42 * per pointer, so we reserve enough memory to hold both. The __*bigkey
43 * items should never be accessed directly.
2c813ad6 44 */
a1d46cff 45union xfs_btree_key {
2c813ad6
DW
46 struct xfs_bmbt_key bmbt;
47 xfs_bmdr_key_t bmbr; /* bmbt root block */
48 xfs_alloc_key_t alloc;
49 struct xfs_inobt_key inobt;
a1d46cff
DW
50 struct xfs_rmap_key rmap;
51 struct xfs_rmap_key __rmap_bigkey[2];
1946b91c 52 struct xfs_refcount_key refc;
2c813ad6
DW
53};
54
de227dd9 55union xfs_btree_rec {
035e00ac
DW
56 struct xfs_bmbt_rec bmbt;
57 xfs_bmdr_rec_t bmbr; /* bmbt root block */
58 struct xfs_alloc_rec alloc;
59 struct xfs_inobt_rec inobt;
60 struct xfs_rmap_rec rmap;
1946b91c 61 struct xfs_refcount_rec refc;
de227dd9
CH
62};
63
a4fbe6ab
DC
64/*
65 * This nonsense is to make -wlint happy.
66 */
67#define XFS_LOOKUP_EQ ((xfs_lookup_t)XFS_LOOKUP_EQi)
68#define XFS_LOOKUP_LE ((xfs_lookup_t)XFS_LOOKUP_LEi)
69#define XFS_LOOKUP_GE ((xfs_lookup_t)XFS_LOOKUP_GEi)
70
71#define XFS_BTNUM_BNO ((xfs_btnum_t)XFS_BTNUM_BNOi)
72#define XFS_BTNUM_CNT ((xfs_btnum_t)XFS_BTNUM_CNTi)
73#define XFS_BTNUM_BMAP ((xfs_btnum_t)XFS_BTNUM_BMAPi)
74#define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi)
aafc3c24 75#define XFS_BTNUM_FINO ((xfs_btnum_t)XFS_BTNUM_FINOi)
b8704944 76#define XFS_BTNUM_RMAP ((xfs_btnum_t)XFS_BTNUM_RMAPi)
46eeb521 77#define XFS_BTNUM_REFC ((xfs_btnum_t)XFS_BTNUM_REFCi)
a4fbe6ab 78
c8ce540d 79uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum);
af7d20fd 80
1da177e4
LT
81/*
82 * For logging record fields.
83 */
21b5c978
DC
84#define XFS_BB_MAGIC (1 << 0)
85#define XFS_BB_LEVEL (1 << 1)
86#define XFS_BB_NUMRECS (1 << 2)
87#define XFS_BB_LEFTSIB (1 << 3)
88#define XFS_BB_RIGHTSIB (1 << 4)
89#define XFS_BB_BLKNO (1 << 5)
90#define XFS_BB_LSN (1 << 6)
91#define XFS_BB_UUID (1 << 7)
92#define XFS_BB_OWNER (1 << 8)
1da177e4
LT
93#define XFS_BB_NUM_BITS 5
94#define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1)
21b5c978 95#define XFS_BB_NUM_BITS_CRC 9
ee1a47ab 96#define XFS_BB_ALL_BITS_CRC ((1 << XFS_BB_NUM_BITS_CRC) - 1)
1da177e4 97
854929f0
DC
98/*
99 * Generic stats interface
100 */
ff6d6af2 101#define XFS_BTREE_STATS_INC(cur, stat) \
11ef38af
DC
102 XFS_STATS_INC_OFF((cur)->bc_mp, (cur)->bc_statoff + __XBTS_ ## stat)
103#define XFS_BTREE_STATS_ADD(cur, stat, val) \
104 XFS_STATS_ADD_OFF((cur)->bc_mp, (cur)->bc_statoff + __XBTS_ ## stat, val)
1da177e4 105
df3954ff 106#define XFS_BTREE_MAXLEVELS 9 /* max of all btrees */
1da177e4 107
561f7d17 108struct xfs_btree_ops {
65f1eaea
CH
109 /* size of the key and record structures */
110 size_t key_len;
111 size_t rec_len;
112
561f7d17
CH
113 /* cursor operations */
114 struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
4b22a571
CH
115 void (*update_cursor)(struct xfs_btree_cur *src,
116 struct xfs_btree_cur *dst);
8c4ed633 117
344207ce
CH
118 /* update btree root pointer */
119 void (*set_root)(struct xfs_btree_cur *cur,
c0e59e1a 120 union xfs_btree_ptr *nptr, int level_change);
344207ce 121
f5eb8e7c
CH
122 /* block allocation / freeing */
123 int (*alloc_block)(struct xfs_btree_cur *cur,
124 union xfs_btree_ptr *start_bno,
125 union xfs_btree_ptr *new_bno,
6f8950cd 126 int *stat);
d4b3a4b7 127 int (*free_block)(struct xfs_btree_cur *cur, struct xfs_buf *bp);
f5eb8e7c 128
278d0ca1
CH
129 /* update last record information */
130 void (*update_lastrec)(struct xfs_btree_cur *cur,
131 struct xfs_btree_block *block,
132 union xfs_btree_rec *rec,
133 int ptr, int reason);
134
ce5e42db 135 /* records in block/level */
91cca5df 136 int (*get_minrecs)(struct xfs_btree_cur *cur, int level);
ce5e42db
CH
137 int (*get_maxrecs)(struct xfs_btree_cur *cur, int level);
138
4b22a571
CH
139 /* records on disk. Matter for the root in inode case. */
140 int (*get_dmaxrecs)(struct xfs_btree_cur *cur, int level);
141
fe033cc8
CH
142 /* init values of btree structures */
143 void (*init_key_from_rec)(union xfs_btree_key *key,
144 union xfs_btree_rec *rec);
4b22a571
CH
145 void (*init_rec_from_cur)(struct xfs_btree_cur *cur,
146 union xfs_btree_rec *rec);
fe033cc8
CH
147 void (*init_ptr_from_cur)(struct xfs_btree_cur *cur,
148 union xfs_btree_ptr *ptr);
2c813ad6
DW
149 void (*init_high_key_from_rec)(union xfs_btree_key *key,
150 union xfs_btree_rec *rec);
fe033cc8
CH
151
152 /* difference between key value and cursor value */
c8ce540d 153 int64_t (*key_diff)(struct xfs_btree_cur *cur,
fe033cc8
CH
154 union xfs_btree_key *key);
155
2c813ad6
DW
156 /*
157 * Difference between key2 and key1 -- positive if key1 > key2,
158 * negative if key1 < key2, and zero if equal.
159 */
c8ce540d 160 int64_t (*diff_two_keys)(struct xfs_btree_cur *cur,
2c813ad6
DW
161 union xfs_btree_key *key1,
162 union xfs_btree_key *key2);
163
1813dd64 164 const struct xfs_buf_ops *buf_ops;
b0f539de 165
4a26e66e
CH
166 /* check that k1 is lower than k2 */
167 int (*keys_inorder)(struct xfs_btree_cur *cur,
168 union xfs_btree_key *k1,
169 union xfs_btree_key *k2);
170
171 /* check that r1 is lower than r2 */
172 int (*recs_inorder)(struct xfs_btree_cur *cur,
173 union xfs_btree_rec *r1,
174 union xfs_btree_rec *r2);
561f7d17
CH
175};
176
278d0ca1
CH
177/*
178 * Reasons for the update_lastrec method to be called.
179 */
180#define LASTREC_UPDATE 0
4b22a571 181#define LASTREC_INSREC 1
91cca5df 182#define LASTREC_DELREC 2
278d0ca1
CH
183
184
105f7d83
DW
185union xfs_btree_irec {
186 struct xfs_alloc_rec_incore a;
187 struct xfs_bmbt_irec b;
188 struct xfs_inobt_rec_incore i;
4b8ed677 189 struct xfs_rmap_irec r;
1946b91c
DW
190 struct xfs_refcount_irec rc;
191};
192
193/* Per-AG btree private information. */
194union xfs_btree_cur_private {
195 struct {
196 unsigned long nr_ops; /* # record updates */
197 int shape_changes; /* # of extent splits */
198 } refc;
105f7d83
DW
199};
200
1da177e4
LT
201/*
202 * Btree cursor structure.
203 * This collects all information needed by the btree code in one place.
204 */
205typedef struct xfs_btree_cur
206{
207 struct xfs_trans *bc_tp; /* transaction we're in, if any */
208 struct xfs_mount *bc_mp; /* file system mount struct */
561f7d17 209 const struct xfs_btree_ops *bc_ops;
8186e517 210 uint bc_flags; /* btree features - below */
105f7d83 211 union xfs_btree_irec bc_rec; /* current insert/search record value */
1da177e4
LT
212 struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */
213 int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */
c8ce540d 214 uint8_t bc_ra[XFS_BTREE_MAXLEVELS]; /* readahead bits */
1da177e4
LT
215#define XFS_BTCUR_LEFTRA 1 /* left sibling has been read-ahead */
216#define XFS_BTCUR_RIGHTRA 2 /* right sibling has been read-ahead */
c8ce540d
DW
217 uint8_t bc_nlevels; /* number of levels in the tree */
218 uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */
1da177e4 219 xfs_btnum_t bc_btnum; /* identifies which btree type */
11ef38af 220 int bc_statoff; /* offset of btre stats array */
1da177e4 221 union {
169d6227
CH
222 struct { /* needed for BNO, CNT, INO */
223 struct xfs_buf *agbp; /* agf/agi buffer pointer */
2c3234d1 224 struct xfs_defer_ops *dfops; /* deferred updates */
1da177e4 225 xfs_agnumber_t agno; /* ag number */
1946b91c 226 union xfs_btree_cur_private priv;
1da177e4
LT
227 } a;
228 struct { /* needed for BMAP */
229 struct xfs_inode *ip; /* pointer to our inode */
2c3234d1 230 struct xfs_defer_ops *dfops; /* deferred updates */
1da177e4
LT
231 xfs_fsblock_t firstblock; /* 1st blk allocated */
232 int allocated; /* count of alloced */
233 short forksize; /* fork's inode space */
234 char whichfork; /* data or attr fork */
235 char flags; /* flags */
f4050285
BF
236#define XFS_BTCUR_BPRV_WASDEL (1<<0) /* was delayed */
237#define XFS_BTCUR_BPRV_INVALID_OWNER (1<<1) /* for ext swap */
1da177e4 238 } b;
1da177e4
LT
239 } bc_private; /* per-btree type data */
240} xfs_btree_cur_t;
241
8186e517 242/* cursor flags */
e99ab90d 243#define XFS_BTREE_LONG_PTRS (1<<0) /* pointers are 64bits long */
8186e517 244#define XFS_BTREE_ROOT_IN_INODE (1<<1) /* root may be variable size */
278d0ca1 245#define XFS_BTREE_LASTREC_UPDATE (1<<2) /* track last rec externally */
ee1a47ab 246#define XFS_BTREE_CRC_BLOCKS (1<<3) /* uses extended btree blocks */
2c813ad6 247#define XFS_BTREE_OVERLAPPING (1<<4) /* overlapping intervals */
8186e517
CH
248
249
1da177e4
LT
250#define XFS_BTREE_NOERROR 0
251#define XFS_BTREE_ERROR 1
252
253/*
254 * Convert from buffer to btree block header.
255 */
62926044 256#define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)((bp)->b_addr))
1da177e4 257
1da177e4 258
1da177e4 259/*
a23f6ef8 260 * Check that block header is ok.
1da177e4 261 */
a23f6ef8
CH
262int
263xfs_btree_check_block(
264 struct xfs_btree_cur *cur, /* btree cursor */
265 struct xfs_btree_block *block, /* generic btree block pointer */
1da177e4
LT
266 int level, /* level of the btree block */
267 struct xfs_buf *bp); /* buffer containing block, if any */
268
269/*
a23f6ef8 270 * Check that (long) pointer is ok.
1da177e4
LT
271 */
272int /* error (0 or EFSCORRUPTED) */
273xfs_btree_check_lptr(
a23f6ef8 274 struct xfs_btree_cur *cur, /* btree cursor */
d5cf09ba 275 xfs_fsblock_t ptr, /* btree block disk address */
1da177e4
LT
276 int level); /* btree block level */
277
1da177e4
LT
278/*
279 * Delete the btree cursor.
280 */
281void
282xfs_btree_del_cursor(
283 xfs_btree_cur_t *cur, /* btree cursor */
284 int error); /* del because of error */
285
286/*
287 * Duplicate the btree cursor.
288 * Allocate a new one, copy the record, re-get the buffers.
289 */
290int /* error */
291xfs_btree_dup_cursor(
292 xfs_btree_cur_t *cur, /* input cursor */
293 xfs_btree_cur_t **ncur);/* output cursor */
294
1da177e4
LT
295/*
296 * Get a buffer for the block, return it with no data read.
297 * Long-form addressing.
298 */
299struct xfs_buf * /* buffer for fsbno */
300xfs_btree_get_bufl(
301 struct xfs_mount *mp, /* file system mount point */
302 struct xfs_trans *tp, /* transaction pointer */
303 xfs_fsblock_t fsbno, /* file system block number */
304 uint lock); /* lock flags for get_buf */
305
306/*
307 * Get a buffer for the block, return it with no data read.
308 * Short-form addressing.
309 */
310struct xfs_buf * /* buffer for agno/agbno */
311xfs_btree_get_bufs(
312 struct xfs_mount *mp, /* file system mount point */
313 struct xfs_trans *tp, /* transaction pointer */
314 xfs_agnumber_t agno, /* allocation group number */
315 xfs_agblock_t agbno, /* allocation group block number */
316 uint lock); /* lock flags for get_buf */
317
1da177e4
LT
318/*
319 * Check for the cursor referring to the last block at the given level.
320 */
321int /* 1=is last block, 0=not last block */
322xfs_btree_islastblock(
323 xfs_btree_cur_t *cur, /* btree cursor */
324 int level); /* level to check */
325
1da177e4
LT
326/*
327 * Compute first and last byte offsets for the fields given.
328 * Interprets the offsets table, which contains struct field offsets.
329 */
330void
331xfs_btree_offsets(
c8ce540d 332 int64_t fields, /* bitmask of fields */
1da177e4
LT
333 const short *offsets,/* table of field offsets */
334 int nbits, /* number of bits to inspect */
335 int *first, /* output: first byte offset */
336 int *last); /* output: last byte offset */
337
338/*
339 * Get a buffer for the block, return it read in.
340 * Long-form addressing.
341 */
342int /* error */
343xfs_btree_read_bufl(
344 struct xfs_mount *mp, /* file system mount point */
345 struct xfs_trans *tp, /* transaction pointer */
346 xfs_fsblock_t fsbno, /* file system block number */
347 uint lock, /* lock flags for read_buf */
348 struct xfs_buf **bpp, /* buffer for fsbno */
3d3e6f64 349 int refval, /* ref count value for buffer */
1813dd64 350 const struct xfs_buf_ops *ops);
1da177e4 351
1da177e4
LT
352/*
353 * Read-ahead the block, don't wait for it, don't return a buffer.
354 * Long-form addressing.
355 */
356void /* error */
357xfs_btree_reada_bufl(
358 struct xfs_mount *mp, /* file system mount point */
359 xfs_fsblock_t fsbno, /* file system block number */
3d3e6f64 360 xfs_extlen_t count, /* count of filesystem blocks */
1813dd64 361 const struct xfs_buf_ops *ops);
1da177e4
LT
362
363/*
364 * Read-ahead the block, don't wait for it, don't return a buffer.
365 * Short-form addressing.
366 */
367void /* error */
368xfs_btree_reada_bufs(
369 struct xfs_mount *mp, /* file system mount point */
370 xfs_agnumber_t agno, /* allocation group number */
371 xfs_agblock_t agbno, /* allocation group block number */
3d3e6f64 372 xfs_extlen_t count, /* count of filesystem blocks */
1813dd64 373 const struct xfs_buf_ops *ops);
1da177e4 374
b64f3a39
DC
375/*
376 * Initialise a new btree block header
377 */
378void
379xfs_btree_init_block(
380 struct xfs_mount *mp,
381 struct xfs_buf *bp,
b6f41e44 382 xfs_btnum_t btnum,
b64f3a39
DC
383 __u16 level,
384 __u16 numrecs,
ee1a47ab 385 __u64 owner,
b64f3a39 386 unsigned int flags);
65f1eaea 387
ee1a47ab
CH
388void
389xfs_btree_init_block_int(
390 struct xfs_mount *mp,
391 struct xfs_btree_block *buf,
392 xfs_daddr_t blkno,
b6f41e44 393 xfs_btnum_t btnum,
ee1a47ab
CH
394 __u16 level,
395 __u16 numrecs,
396 __u64 owner,
397 unsigned int flags);
398
637aa50f
CH
399/*
400 * Common btree core entry points.
401 */
402int xfs_btree_increment(struct xfs_btree_cur *, int, int *);
8df4da4a 403int xfs_btree_decrement(struct xfs_btree_cur *, int, int *);
fe033cc8 404int xfs_btree_lookup(struct xfs_btree_cur *, xfs_lookup_t, int *);
278d0ca1 405int xfs_btree_update(struct xfs_btree_cur *, union xfs_btree_rec *);
ea77b0a6 406int xfs_btree_new_iroot(struct xfs_btree_cur *, int *, int *);
4b22a571 407int xfs_btree_insert(struct xfs_btree_cur *, int *);
91cca5df 408int xfs_btree_delete(struct xfs_btree_cur *, int *);
8cc938fe 409int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *);
c8ce540d 410int xfs_btree_change_owner(struct xfs_btree_cur *cur, uint64_t new_owner,
638f4416 411 struct list_head *buffer_list);
637aa50f 412
ee1a47ab
CH
413/*
414 * btree block CRC helpers
415 */
416void xfs_btree_lblock_calc_crc(struct xfs_buf *);
417bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
418void xfs_btree_sblock_calc_crc(struct xfs_buf *);
419bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
420
fd6bcc5b
CH
421/*
422 * Internal btree helpers also used by xfs_bmap.c.
423 */
424void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
425void xfs_btree_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, int);
426
65f1eaea
CH
427/*
428 * Helpers.
429 */
637aa50f
CH
430static inline int xfs_btree_get_numrecs(struct xfs_btree_block *block)
431{
432 return be16_to_cpu(block->bb_numrecs);
433}
434
9eaead51 435static inline void xfs_btree_set_numrecs(struct xfs_btree_block *block,
c8ce540d 436 uint16_t numrecs)
9eaead51
CH
437{
438 block->bb_numrecs = cpu_to_be16(numrecs);
439}
440
65f1eaea
CH
441static inline int xfs_btree_get_level(struct xfs_btree_block *block)
442{
443 return be16_to_cpu(block->bb_level);
444}
445
1da177e4
LT
446
447/*
448 * Min and max functions for extlen, agblock, fileoff, and filblks types.
449 */
54aa8e26
DC
450#define XFS_EXTLEN_MIN(a,b) min_t(xfs_extlen_t, (a), (b))
451#define XFS_EXTLEN_MAX(a,b) max_t(xfs_extlen_t, (a), (b))
452#define XFS_AGBLOCK_MIN(a,b) min_t(xfs_agblock_t, (a), (b))
453#define XFS_AGBLOCK_MAX(a,b) max_t(xfs_agblock_t, (a), (b))
454#define XFS_FILEOFF_MIN(a,b) min_t(xfs_fileoff_t, (a), (b))
455#define XFS_FILEOFF_MAX(a,b) max_t(xfs_fileoff_t, (a), (b))
456#define XFS_FILBLKS_MIN(a,b) min_t(xfs_filblks_t, (a), (b))
457#define XFS_FILBLKS_MAX(a,b) max_t(xfs_filblks_t, (a), (b))
a844f451 458
1da177e4 459#define XFS_FSB_SANITY_CHECK(mp,fsb) \
d5a91bae 460 (fsb && XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
a844f451 461 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
1da177e4 462
c84470dd
CH
463/*
464 * Trace hooks. Currently not implemented as they need to be ported
465 * over to the generic tracing functionality, which is some effort.
466 *
467 * i,j = integer (32 bit)
468 * b = btree block buffer (xfs_buf_t)
469 * p = btree ptr
470 * r = btree record
471 * k = btree key
472 */
473#define XFS_BTREE_TRACE_ARGBI(c, b, i)
474#define XFS_BTREE_TRACE_ARGBII(c, b, i, j)
475#define XFS_BTREE_TRACE_ARGI(c, i)
476#define XFS_BTREE_TRACE_ARGIPK(c, i, p, s)
477#define XFS_BTREE_TRACE_ARGIPR(c, i, p, r)
478#define XFS_BTREE_TRACE_ARGIK(c, i, k)
479#define XFS_BTREE_TRACE_ARGR(c, r)
480#define XFS_BTREE_TRACE_CURSOR(c, t)
481
c5ab131b
DW
482bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
483bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
19b54ee6
DW
484uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits,
485 unsigned long len);
4ed3f687
DW
486xfs_extlen_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits,
487 unsigned long long len);
c5ab131b 488
105f7d83
DW
489/* return codes */
490#define XFS_BTREE_QUERY_RANGE_CONTINUE 0 /* keep iterating */
491#define XFS_BTREE_QUERY_RANGE_ABORT 1 /* stop iterating */
492typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
493 union xfs_btree_rec *rec, void *priv);
494
495int xfs_btree_query_range(struct xfs_btree_cur *cur,
496 union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec,
497 xfs_btree_query_range_fn fn, void *priv);
e9a2599a
DW
498int xfs_btree_query_all(struct xfs_btree_cur *cur, xfs_btree_query_range_fn fn,
499 void *priv);
105f7d83 500
28a89567
DW
501typedef int (*xfs_btree_visit_blocks_fn)(struct xfs_btree_cur *cur, int level,
502 void *data);
503int xfs_btree_visit_blocks(struct xfs_btree_cur *cur,
504 xfs_btree_visit_blocks_fn fn, void *data);
505
c611cc03
DW
506int xfs_btree_count_blocks(struct xfs_btree_cur *cur, xfs_extlen_t *blocks);
507
26788097
DW
508union xfs_btree_rec *xfs_btree_rec_addr(struct xfs_btree_cur *cur, int n,
509 struct xfs_btree_block *block);
510union xfs_btree_key *xfs_btree_key_addr(struct xfs_btree_cur *cur, int n,
511 struct xfs_btree_block *block);
512union xfs_btree_key *xfs_btree_high_key_addr(struct xfs_btree_cur *cur, int n,
513 struct xfs_btree_block *block);
514union xfs_btree_ptr *xfs_btree_ptr_addr(struct xfs_btree_cur *cur, int n,
515 struct xfs_btree_block *block);
516int xfs_btree_lookup_get_block(struct xfs_btree_cur *cur, int level,
517 union xfs_btree_ptr *pp, struct xfs_btree_block **blkp);
518struct xfs_btree_block *xfs_btree_get_block(struct xfs_btree_cur *cur,
519 int level, struct xfs_buf **bpp);
520
1da177e4 521#endif /* __XFS_BTREE_H__ */