xfs_btree.h 17 KB

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