xfs_btree.h 17 KB

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