9b6d6286466e9aac41d8a08f3862b4d3ebea84a5
[linux-2.6-block.git] / fs / xfs / libxfs / xfs_btree.h
1 /*
2  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
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
7  * published by the Free Software Foundation.
8  *
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.
13  *
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
17  */
18 #ifndef __XFS_BTREE_H__
19 #define __XFS_BTREE_H__
20
21 struct xfs_buf;
22 struct xfs_defer_ops;
23 struct xfs_inode;
24 struct xfs_mount;
25 struct xfs_trans;
26
27 extern kmem_zone_t      *xfs_btree_cur_zone;
28
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  */
35 union xfs_btree_ptr {
36         __be32                  s;      /* short form ptr */
37         __be64                  l;      /* long form ptr */
38 };
39
40 union xfs_btree_key {
41         struct xfs_bmbt_key             bmbt;
42         xfs_bmdr_key_t                  bmbr;   /* bmbt root block */
43         xfs_alloc_key_t                 alloc;
44         struct xfs_inobt_key            inobt;
45         struct xfs_rmap_key             rmap;
46 };
47
48 /*
49  * In-core key that holds both low and high keys for overlapped btrees.
50  * The two keys are packed next to each other on disk, so do the same
51  * in memory.  Preserve the existing xfs_btree_key as a single key to
52  * avoid the mental model breakage that would happen if we passed a
53  * bigkey into a function that operates on a single key.
54  */
55 union xfs_btree_bigkey {
56         struct xfs_bmbt_key             bmbt;
57         xfs_bmdr_key_t                  bmbr;   /* bmbt root block */
58         xfs_alloc_key_t                 alloc;
59         struct xfs_inobt_key            inobt;
60         struct {
61                 struct xfs_rmap_key     rmap;
62                 struct xfs_rmap_key     rmap_hi;
63         };
64 };
65
66 union xfs_btree_rec {
67         struct xfs_bmbt_rec             bmbt;
68         xfs_bmdr_rec_t                  bmbr;   /* bmbt root block */
69         struct xfs_alloc_rec            alloc;
70         struct xfs_inobt_rec            inobt;
71         struct xfs_rmap_rec             rmap;
72 };
73
74 /*
75  * This nonsense is to make -wlint happy.
76  */
77 #define XFS_LOOKUP_EQ   ((xfs_lookup_t)XFS_LOOKUP_EQi)
78 #define XFS_LOOKUP_LE   ((xfs_lookup_t)XFS_LOOKUP_LEi)
79 #define XFS_LOOKUP_GE   ((xfs_lookup_t)XFS_LOOKUP_GEi)
80
81 #define XFS_BTNUM_BNO   ((xfs_btnum_t)XFS_BTNUM_BNOi)
82 #define XFS_BTNUM_CNT   ((xfs_btnum_t)XFS_BTNUM_CNTi)
83 #define XFS_BTNUM_BMAP  ((xfs_btnum_t)XFS_BTNUM_BMAPi)
84 #define XFS_BTNUM_INO   ((xfs_btnum_t)XFS_BTNUM_INOi)
85 #define XFS_BTNUM_FINO  ((xfs_btnum_t)XFS_BTNUM_FINOi)
86 #define XFS_BTNUM_RMAP  ((xfs_btnum_t)XFS_BTNUM_RMAPi)
87
88 /*
89  * For logging record fields.
90  */
91 #define XFS_BB_MAGIC            (1 << 0)
92 #define XFS_BB_LEVEL            (1 << 1)
93 #define XFS_BB_NUMRECS          (1 << 2)
94 #define XFS_BB_LEFTSIB          (1 << 3)
95 #define XFS_BB_RIGHTSIB         (1 << 4)
96 #define XFS_BB_BLKNO            (1 << 5)
97 #define XFS_BB_LSN              (1 << 6)
98 #define XFS_BB_UUID             (1 << 7)
99 #define XFS_BB_OWNER            (1 << 8)
100 #define XFS_BB_NUM_BITS         5
101 #define XFS_BB_ALL_BITS         ((1 << XFS_BB_NUM_BITS) - 1)
102 #define XFS_BB_NUM_BITS_CRC     9
103 #define XFS_BB_ALL_BITS_CRC     ((1 << XFS_BB_NUM_BITS_CRC) - 1)
104
105 /*
106  * Generic stats interface
107  */
108 #define __XFS_BTREE_STATS_INC(mp, type, stat) \
109         XFS_STATS_INC(mp, xs_ ## type ## _2_ ## stat)
110 #define XFS_BTREE_STATS_INC(cur, stat)  \
111 do {    \
112         struct xfs_mount *__mp = cur->bc_mp; \
113         switch (cur->bc_btnum) {  \
114         case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(__mp, abtb, stat); break; \
115         case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(__mp, abtc, stat); break; \
116         case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(__mp, bmbt, stat); break; \
117         case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(__mp, ibt, stat); break; \
118         case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(__mp, fibt, stat); break; \
119         case XFS_BTNUM_RMAP: __XFS_BTREE_STATS_INC(__mp, rmap, stat); break; \
120         case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break;       \
121         }       \
122 } while (0)
123
124 #define __XFS_BTREE_STATS_ADD(mp, type, stat, val) \
125         XFS_STATS_ADD(mp, xs_ ## type ## _2_ ## stat, val)
126 #define XFS_BTREE_STATS_ADD(cur, stat, val)  \
127 do {    \
128         struct xfs_mount *__mp = cur->bc_mp; \
129         switch (cur->bc_btnum) {  \
130         case XFS_BTNUM_BNO:     \
131                 __XFS_BTREE_STATS_ADD(__mp, abtb, stat, val); break; \
132         case XFS_BTNUM_CNT:     \
133                 __XFS_BTREE_STATS_ADD(__mp, abtc, stat, val); break; \
134         case XFS_BTNUM_BMAP:    \
135                 __XFS_BTREE_STATS_ADD(__mp, bmbt, stat, val); break; \
136         case XFS_BTNUM_INO:     \
137                 __XFS_BTREE_STATS_ADD(__mp, ibt, stat, val); break; \
138         case XFS_BTNUM_FINO:    \
139                 __XFS_BTREE_STATS_ADD(__mp, fibt, stat, val); break; \
140         case XFS_BTNUM_RMAP:    \
141                 __XFS_BTREE_STATS_ADD(__mp, rmap, stat, val); break; \
142         case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \
143         }       \
144 } while (0)
145
146 #define XFS_BTREE_MAXLEVELS     9       /* max of all btrees */
147
148 struct xfs_btree_ops {
149         /* size of the key and record structures */
150         size_t  key_len;
151         size_t  rec_len;
152
153         /* cursor operations */
154         struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
155         void    (*update_cursor)(struct xfs_btree_cur *src,
156                                  struct xfs_btree_cur *dst);
157
158         /* update btree root pointer */
159         void    (*set_root)(struct xfs_btree_cur *cur,
160                             union xfs_btree_ptr *nptr, int level_change);
161
162         /* block allocation / freeing */
163         int     (*alloc_block)(struct xfs_btree_cur *cur,
164                                union xfs_btree_ptr *start_bno,
165                                union xfs_btree_ptr *new_bno,
166                                int *stat);
167         int     (*free_block)(struct xfs_btree_cur *cur, struct xfs_buf *bp);
168
169         /* update last record information */
170         void    (*update_lastrec)(struct xfs_btree_cur *cur,
171                                   struct xfs_btree_block *block,
172                                   union xfs_btree_rec *rec,
173                                   int ptr, int reason);
174
175         /* records in block/level */
176         int     (*get_minrecs)(struct xfs_btree_cur *cur, int level);
177         int     (*get_maxrecs)(struct xfs_btree_cur *cur, int level);
178
179         /* records on disk.  Matter for the root in inode case. */
180         int     (*get_dmaxrecs)(struct xfs_btree_cur *cur, int level);
181
182         /* init values of btree structures */
183         void    (*init_key_from_rec)(union xfs_btree_key *key,
184                                      union xfs_btree_rec *rec);
185         void    (*init_rec_from_cur)(struct xfs_btree_cur *cur,
186                                      union xfs_btree_rec *rec);
187         void    (*init_ptr_from_cur)(struct xfs_btree_cur *cur,
188                                      union xfs_btree_ptr *ptr);
189         void    (*init_high_key_from_rec)(union xfs_btree_key *key,
190                                           union xfs_btree_rec *rec);
191
192         /* difference between key value and cursor value */
193         __int64_t (*key_diff)(struct xfs_btree_cur *cur,
194                               union xfs_btree_key *key);
195
196         /*
197          * Difference between key2 and key1 -- positive if key1 > key2,
198          * negative if key1 < key2, and zero if equal.
199          */
200         __int64_t (*diff_two_keys)(struct xfs_btree_cur *cur,
201                                    union xfs_btree_key *key1,
202                                    union xfs_btree_key *key2);
203
204         const struct xfs_buf_ops        *buf_ops;
205
206 #if defined(DEBUG) || defined(XFS_WARN)
207         /* check that k1 is lower than k2 */
208         int     (*keys_inorder)(struct xfs_btree_cur *cur,
209                                 union xfs_btree_key *k1,
210                                 union xfs_btree_key *k2);
211
212         /* check that r1 is lower than r2 */
213         int     (*recs_inorder)(struct xfs_btree_cur *cur,
214                                 union xfs_btree_rec *r1,
215                                 union xfs_btree_rec *r2);
216 #endif
217
218         /* derive the low & high keys from the records in a leaf block */
219         void    (*get_leaf_keys)(struct xfs_btree_cur *cur,
220                                  struct xfs_btree_block *block,
221                                  union xfs_btree_key *key);
222
223         /* derive the low & high keys from the keys in a node block */
224         void    (*get_node_keys)(struct xfs_btree_cur *cur,
225                                  struct xfs_btree_block *block,
226                                  union xfs_btree_key *key);
227
228         /* update the parent keys of given btree level */
229         int     (*update_keys)(struct xfs_btree_cur *cur, int level);
230 };
231
232 /*
233  * Reasons for the update_lastrec method to be called.
234  */
235 #define LASTREC_UPDATE  0
236 #define LASTREC_INSREC  1
237 #define LASTREC_DELREC  2
238
239
240 union xfs_btree_irec {
241         struct xfs_alloc_rec_incore     a;
242         struct xfs_bmbt_irec            b;
243         struct xfs_inobt_rec_incore     i;
244         struct xfs_rmap_irec            r;
245 };
246
247 /*
248  * Btree cursor structure.
249  * This collects all information needed by the btree code in one place.
250  */
251 typedef struct xfs_btree_cur
252 {
253         struct xfs_trans        *bc_tp; /* transaction we're in, if any */
254         struct xfs_mount        *bc_mp; /* file system mount struct */
255         const struct xfs_btree_ops *bc_ops;
256         uint                    bc_flags; /* btree features - below */
257         union xfs_btree_irec    bc_rec; /* current insert/search record value */
258         struct xfs_buf  *bc_bufs[XFS_BTREE_MAXLEVELS];  /* buf ptr per level */
259         int             bc_ptrs[XFS_BTREE_MAXLEVELS];   /* key/record # */
260         __uint8_t       bc_ra[XFS_BTREE_MAXLEVELS];     /* readahead bits */
261 #define XFS_BTCUR_LEFTRA        1       /* left sibling has been read-ahead */
262 #define XFS_BTCUR_RIGHTRA       2       /* right sibling has been read-ahead */
263         __uint8_t       bc_nlevels;     /* number of levels in the tree */
264         __uint8_t       bc_blocklog;    /* log2(blocksize) of btree blocks */
265         xfs_btnum_t     bc_btnum;       /* identifies which btree type */
266         union {
267                 struct {                        /* needed for BNO, CNT, INO */
268                         struct xfs_buf  *agbp;  /* agf/agi buffer pointer */
269                         struct xfs_defer_ops *dfops;    /* deferred updates */
270                         xfs_agnumber_t  agno;   /* ag number */
271                 } a;
272                 struct {                        /* needed for BMAP */
273                         struct xfs_inode *ip;   /* pointer to our inode */
274                         struct xfs_defer_ops *dfops;    /* deferred updates */
275                         xfs_fsblock_t   firstblock;     /* 1st blk allocated */
276                         int             allocated;      /* count of alloced */
277                         short           forksize;       /* fork's inode space */
278                         char            whichfork;      /* data or attr fork */
279                         char            flags;          /* flags */
280 #define XFS_BTCUR_BPRV_WASDEL   1                       /* was delayed */
281                 } b;
282         }               bc_private;     /* per-btree type data */
283 } xfs_btree_cur_t;
284
285 /* cursor flags */
286 #define XFS_BTREE_LONG_PTRS             (1<<0)  /* pointers are 64bits long */
287 #define XFS_BTREE_ROOT_IN_INODE         (1<<1)  /* root may be variable size */
288 #define XFS_BTREE_LASTREC_UPDATE        (1<<2)  /* track last rec externally */
289 #define XFS_BTREE_CRC_BLOCKS            (1<<3)  /* uses extended btree blocks */
290 #define XFS_BTREE_OVERLAPPING           (1<<4)  /* overlapping intervals */
291
292
293 #define XFS_BTREE_NOERROR       0
294 #define XFS_BTREE_ERROR         1
295
296 /*
297  * Convert from buffer to btree block header.
298  */
299 #define XFS_BUF_TO_BLOCK(bp)    ((struct xfs_btree_block *)((bp)->b_addr))
300
301
302 /*
303  * Check that block header is ok.
304  */
305 int
306 xfs_btree_check_block(
307         struct xfs_btree_cur    *cur,   /* btree cursor */
308         struct xfs_btree_block  *block, /* generic btree block pointer */
309         int                     level,  /* level of the btree block */
310         struct xfs_buf          *bp);   /* buffer containing block, if any */
311
312 /*
313  * Check that (long) pointer is ok.
314  */
315 int                                     /* error (0 or EFSCORRUPTED) */
316 xfs_btree_check_lptr(
317         struct xfs_btree_cur    *cur,   /* btree cursor */
318         xfs_fsblock_t           ptr,    /* btree block disk address */
319         int                     level); /* btree block level */
320
321 /*
322  * Delete the btree cursor.
323  */
324 void
325 xfs_btree_del_cursor(
326         xfs_btree_cur_t         *cur,   /* btree cursor */
327         int                     error); /* del because of error */
328
329 /*
330  * Duplicate the btree cursor.
331  * Allocate a new one, copy the record, re-get the buffers.
332  */
333 int                                     /* error */
334 xfs_btree_dup_cursor(
335         xfs_btree_cur_t         *cur,   /* input cursor */
336         xfs_btree_cur_t         **ncur);/* output cursor */
337
338 /*
339  * Get a buffer for the block, return it with no data read.
340  * Long-form addressing.
341  */
342 struct xfs_buf *                                /* buffer for fsbno */
343 xfs_btree_get_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 get_buf */
348
349 /*
350  * Get a buffer for the block, return it with no data read.
351  * Short-form addressing.
352  */
353 struct xfs_buf *                                /* buffer for agno/agbno */
354 xfs_btree_get_bufs(
355         struct xfs_mount        *mp,    /* file system mount point */
356         struct xfs_trans        *tp,    /* transaction pointer */
357         xfs_agnumber_t          agno,   /* allocation group number */
358         xfs_agblock_t           agbno,  /* allocation group block number */
359         uint                    lock);  /* lock flags for get_buf */
360
361 /*
362  * Check for the cursor referring to the last block at the given level.
363  */
364 int                                     /* 1=is last block, 0=not last block */
365 xfs_btree_islastblock(
366         xfs_btree_cur_t         *cur,   /* btree cursor */
367         int                     level); /* level to check */
368
369 /*
370  * Compute first and last byte offsets for the fields given.
371  * Interprets the offsets table, which contains struct field offsets.
372  */
373 void
374 xfs_btree_offsets(
375         __int64_t               fields, /* bitmask of fields */
376         const short             *offsets,/* table of field offsets */
377         int                     nbits,  /* number of bits to inspect */
378         int                     *first, /* output: first byte offset */
379         int                     *last); /* output: last byte offset */
380
381 /*
382  * Get a buffer for the block, return it read in.
383  * Long-form addressing.
384  */
385 int                                     /* error */
386 xfs_btree_read_bufl(
387         struct xfs_mount        *mp,    /* file system mount point */
388         struct xfs_trans        *tp,    /* transaction pointer */
389         xfs_fsblock_t           fsbno,  /* file system block number */
390         uint                    lock,   /* lock flags for read_buf */
391         struct xfs_buf          **bpp,  /* buffer for fsbno */
392         int                     refval, /* ref count value for buffer */
393         const struct xfs_buf_ops *ops);
394
395 /*
396  * Read-ahead the block, don't wait for it, don't return a buffer.
397  * Long-form addressing.
398  */
399 void                                    /* error */
400 xfs_btree_reada_bufl(
401         struct xfs_mount        *mp,    /* file system mount point */
402         xfs_fsblock_t           fsbno,  /* file system block number */
403         xfs_extlen_t            count,  /* count of filesystem blocks */
404         const struct xfs_buf_ops *ops);
405
406 /*
407  * Read-ahead the block, don't wait for it, don't return a buffer.
408  * Short-form addressing.
409  */
410 void                                    /* error */
411 xfs_btree_reada_bufs(
412         struct xfs_mount        *mp,    /* file system mount point */
413         xfs_agnumber_t          agno,   /* allocation group number */
414         xfs_agblock_t           agbno,  /* allocation group block number */
415         xfs_extlen_t            count,  /* count of filesystem blocks */
416         const struct xfs_buf_ops *ops);
417
418 /*
419  * Initialise a new btree block header
420  */
421 void
422 xfs_btree_init_block(
423         struct xfs_mount *mp,
424         struct xfs_buf  *bp,
425         __u32           magic,
426         __u16           level,
427         __u16           numrecs,
428         __u64           owner,
429         unsigned int    flags);
430
431 void
432 xfs_btree_init_block_int(
433         struct xfs_mount        *mp,
434         struct xfs_btree_block  *buf,
435         xfs_daddr_t             blkno,
436         __u32                   magic,
437         __u16                   level,
438         __u16                   numrecs,
439         __u64                   owner,
440         unsigned int            flags);
441
442 /*
443  * Common btree core entry points.
444  */
445 int xfs_btree_increment(struct xfs_btree_cur *, int, int *);
446 int xfs_btree_decrement(struct xfs_btree_cur *, int, int *);
447 int xfs_btree_lookup(struct xfs_btree_cur *, xfs_lookup_t, int *);
448 int xfs_btree_update(struct xfs_btree_cur *, union xfs_btree_rec *);
449 int xfs_btree_new_iroot(struct xfs_btree_cur *, int *, int *);
450 int xfs_btree_insert(struct xfs_btree_cur *, int *);
451 int xfs_btree_delete(struct xfs_btree_cur *, int *);
452 int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *);
453 int xfs_btree_change_owner(struct xfs_btree_cur *cur, __uint64_t new_owner,
454                            struct list_head *buffer_list);
455
456 /*
457  * btree block CRC helpers
458  */
459 void xfs_btree_lblock_calc_crc(struct xfs_buf *);
460 bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
461 void xfs_btree_sblock_calc_crc(struct xfs_buf *);
462 bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
463
464 /*
465  * Internal btree helpers also used by xfs_bmap.c.
466  */
467 void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
468 void xfs_btree_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, int);
469
470 /*
471  * Helpers.
472  */
473 static inline int xfs_btree_get_numrecs(struct xfs_btree_block *block)
474 {
475         return be16_to_cpu(block->bb_numrecs);
476 }
477
478 static inline void xfs_btree_set_numrecs(struct xfs_btree_block *block,
479                 __uint16_t numrecs)
480 {
481         block->bb_numrecs = cpu_to_be16(numrecs);
482 }
483
484 static inline int xfs_btree_get_level(struct xfs_btree_block *block)
485 {
486         return be16_to_cpu(block->bb_level);
487 }
488
489
490 /*
491  * Min and max functions for extlen, agblock, fileoff, and filblks types.
492  */
493 #define XFS_EXTLEN_MIN(a,b)     min_t(xfs_extlen_t, (a), (b))
494 #define XFS_EXTLEN_MAX(a,b)     max_t(xfs_extlen_t, (a), (b))
495 #define XFS_AGBLOCK_MIN(a,b)    min_t(xfs_agblock_t, (a), (b))
496 #define XFS_AGBLOCK_MAX(a,b)    max_t(xfs_agblock_t, (a), (b))
497 #define XFS_FILEOFF_MIN(a,b)    min_t(xfs_fileoff_t, (a), (b))
498 #define XFS_FILEOFF_MAX(a,b)    max_t(xfs_fileoff_t, (a), (b))
499 #define XFS_FILBLKS_MIN(a,b)    min_t(xfs_filblks_t, (a), (b))
500 #define XFS_FILBLKS_MAX(a,b)    max_t(xfs_filblks_t, (a), (b))
501
502 #define XFS_FSB_SANITY_CHECK(mp,fsb)    \
503         (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
504                 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
505
506 /*
507  * Trace hooks.  Currently not implemented as they need to be ported
508  * over to the generic tracing functionality, which is some effort.
509  *
510  * i,j = integer (32 bit)
511  * b = btree block buffer (xfs_buf_t)
512  * p = btree ptr
513  * r = btree record
514  * k = btree key
515  */
516 #define XFS_BTREE_TRACE_ARGBI(c, b, i)
517 #define XFS_BTREE_TRACE_ARGBII(c, b, i, j)
518 #define XFS_BTREE_TRACE_ARGI(c, i)
519 #define XFS_BTREE_TRACE_ARGIPK(c, i, p, s)
520 #define XFS_BTREE_TRACE_ARGIPR(c, i, p, r)
521 #define XFS_BTREE_TRACE_ARGIK(c, i, k)
522 #define XFS_BTREE_TRACE_ARGR(c, r)
523 #define XFS_BTREE_TRACE_CURSOR(c, t)
524
525 bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
526 bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
527 uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits,
528                                  unsigned long len);
529
530 void xfs_btree_get_leaf_keys(struct xfs_btree_cur *cur,
531                 struct xfs_btree_block *block, union xfs_btree_key *key);
532 void xfs_btree_get_node_keys(struct xfs_btree_cur *cur,
533                 struct xfs_btree_block *block, union xfs_btree_key *key);
534 int xfs_btree_update_keys(struct xfs_btree_cur *cur, int level);
535 void xfs_btree_get_leaf_keys_overlapped(struct xfs_btree_cur *cur,
536                 struct xfs_btree_block *block, union xfs_btree_key *key);
537 void xfs_btree_get_node_keys_overlapped(struct xfs_btree_cur *cur,
538                 struct xfs_btree_block *block, union xfs_btree_key *key);
539 int xfs_btree_update_keys_overlapped(struct xfs_btree_cur *cur, int level);
540
541 /* return codes */
542 #define XFS_BTREE_QUERY_RANGE_CONTINUE  0       /* keep iterating */
543 #define XFS_BTREE_QUERY_RANGE_ABORT     1       /* stop iterating */
544 typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
545                 union xfs_btree_rec *rec, void *priv);
546
547 int xfs_btree_query_range(struct xfs_btree_cur *cur,
548                 union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec,
549                 xfs_btree_query_range_fn fn, void *priv);
550
551 typedef int (*xfs_btree_visit_blocks_fn)(struct xfs_btree_cur *cur, int level,
552                 void *data);
553 int xfs_btree_visit_blocks(struct xfs_btree_cur *cur,
554                 xfs_btree_visit_blocks_fn fn, void *data);
555
556 #endif  /* __XFS_BTREE_H__ */