xfs_ialloc_btree.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #include "xfs.h"
  7. #include "xfs_fs.h"
  8. #include "xfs_shared.h"
  9. #include "xfs_format.h"
  10. #include "xfs_log_format.h"
  11. #include "xfs_trans_resv.h"
  12. #include "xfs_bit.h"
  13. #include "xfs_mount.h"
  14. #include "xfs_inode.h"
  15. #include "xfs_btree.h"
  16. #include "xfs_ialloc.h"
  17. #include "xfs_ialloc_btree.h"
  18. #include "xfs_alloc.h"
  19. #include "xfs_error.h"
  20. #include "xfs_trace.h"
  21. #include "xfs_cksum.h"
  22. #include "xfs_trans.h"
  23. #include "xfs_rmap.h"
  24. STATIC int
  25. xfs_inobt_get_minrecs(
  26. struct xfs_btree_cur *cur,
  27. int level)
  28. {
  29. return cur->bc_mp->m_inobt_mnr[level != 0];
  30. }
  31. STATIC struct xfs_btree_cur *
  32. xfs_inobt_dup_cursor(
  33. struct xfs_btree_cur *cur)
  34. {
  35. return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp,
  36. cur->bc_private.a.agbp, cur->bc_private.a.agno,
  37. cur->bc_btnum);
  38. }
  39. STATIC void
  40. xfs_inobt_set_root(
  41. struct xfs_btree_cur *cur,
  42. union xfs_btree_ptr *nptr,
  43. int inc) /* level change */
  44. {
  45. struct xfs_buf *agbp = cur->bc_private.a.agbp;
  46. struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp);
  47. agi->agi_root = nptr->s;
  48. be32_add_cpu(&agi->agi_level, inc);
  49. xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_ROOT | XFS_AGI_LEVEL);
  50. }
  51. STATIC void
  52. xfs_finobt_set_root(
  53. struct xfs_btree_cur *cur,
  54. union xfs_btree_ptr *nptr,
  55. int inc) /* level change */
  56. {
  57. struct xfs_buf *agbp = cur->bc_private.a.agbp;
  58. struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp);
  59. agi->agi_free_root = nptr->s;
  60. be32_add_cpu(&agi->agi_free_level, inc);
  61. xfs_ialloc_log_agi(cur->bc_tp, agbp,
  62. XFS_AGI_FREE_ROOT | XFS_AGI_FREE_LEVEL);
  63. }
  64. STATIC int
  65. __xfs_inobt_alloc_block(
  66. struct xfs_btree_cur *cur,
  67. union xfs_btree_ptr *start,
  68. union xfs_btree_ptr *new,
  69. int *stat,
  70. enum xfs_ag_resv_type resv)
  71. {
  72. xfs_alloc_arg_t args; /* block allocation args */
  73. int error; /* error return value */
  74. xfs_agblock_t sbno = be32_to_cpu(start->s);
  75. memset(&args, 0, sizeof(args));
  76. args.tp = cur->bc_tp;
  77. args.mp = cur->bc_mp;
  78. xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_INOBT);
  79. args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, sbno);
  80. args.minlen = 1;
  81. args.maxlen = 1;
  82. args.prod = 1;
  83. args.type = XFS_ALLOCTYPE_NEAR_BNO;
  84. args.resv = resv;
  85. error = xfs_alloc_vextent(&args);
  86. if (error)
  87. return error;
  88. if (args.fsbno == NULLFSBLOCK) {
  89. *stat = 0;
  90. return 0;
  91. }
  92. ASSERT(args.len == 1);
  93. new->s = cpu_to_be32(XFS_FSB_TO_AGBNO(args.mp, args.fsbno));
  94. *stat = 1;
  95. return 0;
  96. }
  97. STATIC int
  98. xfs_inobt_alloc_block(
  99. struct xfs_btree_cur *cur,
  100. union xfs_btree_ptr *start,
  101. union xfs_btree_ptr *new,
  102. int *stat)
  103. {
  104. return __xfs_inobt_alloc_block(cur, start, new, stat, XFS_AG_RESV_NONE);
  105. }
  106. STATIC int
  107. xfs_finobt_alloc_block(
  108. struct xfs_btree_cur *cur,
  109. union xfs_btree_ptr *start,
  110. union xfs_btree_ptr *new,
  111. int *stat)
  112. {
  113. if (cur->bc_mp->m_finobt_nores)
  114. return xfs_inobt_alloc_block(cur, start, new, stat);
  115. return __xfs_inobt_alloc_block(cur, start, new, stat,
  116. XFS_AG_RESV_METADATA);
  117. }
  118. STATIC int
  119. __xfs_inobt_free_block(
  120. struct xfs_btree_cur *cur,
  121. struct xfs_buf *bp,
  122. enum xfs_ag_resv_type resv)
  123. {
  124. struct xfs_owner_info oinfo;
  125. xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT);
  126. return xfs_free_extent(cur->bc_tp,
  127. XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1,
  128. &oinfo, resv);
  129. }
  130. STATIC int
  131. xfs_inobt_free_block(
  132. struct xfs_btree_cur *cur,
  133. struct xfs_buf *bp)
  134. {
  135. return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_NONE);
  136. }
  137. STATIC int
  138. xfs_finobt_free_block(
  139. struct xfs_btree_cur *cur,
  140. struct xfs_buf *bp)
  141. {
  142. if (cur->bc_mp->m_finobt_nores)
  143. return xfs_inobt_free_block(cur, bp);
  144. return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_METADATA);
  145. }
  146. STATIC int
  147. xfs_inobt_get_maxrecs(
  148. struct xfs_btree_cur *cur,
  149. int level)
  150. {
  151. return cur->bc_mp->m_inobt_mxr[level != 0];
  152. }
  153. STATIC void
  154. xfs_inobt_init_key_from_rec(
  155. union xfs_btree_key *key,
  156. union xfs_btree_rec *rec)
  157. {
  158. key->inobt.ir_startino = rec->inobt.ir_startino;
  159. }
  160. STATIC void
  161. xfs_inobt_init_high_key_from_rec(
  162. union xfs_btree_key *key,
  163. union xfs_btree_rec *rec)
  164. {
  165. __u32 x;
  166. x = be32_to_cpu(rec->inobt.ir_startino);
  167. x += XFS_INODES_PER_CHUNK - 1;
  168. key->inobt.ir_startino = cpu_to_be32(x);
  169. }
  170. STATIC void
  171. xfs_inobt_init_rec_from_cur(
  172. struct xfs_btree_cur *cur,
  173. union xfs_btree_rec *rec)
  174. {
  175. rec->inobt.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino);
  176. if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) {
  177. rec->inobt.ir_u.sp.ir_holemask =
  178. cpu_to_be16(cur->bc_rec.i.ir_holemask);
  179. rec->inobt.ir_u.sp.ir_count = cur->bc_rec.i.ir_count;
  180. rec->inobt.ir_u.sp.ir_freecount = cur->bc_rec.i.ir_freecount;
  181. } else {
  182. /* ir_holemask/ir_count not supported on-disk */
  183. rec->inobt.ir_u.f.ir_freecount =
  184. cpu_to_be32(cur->bc_rec.i.ir_freecount);
  185. }
  186. rec->inobt.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free);
  187. }
  188. /*
  189. * initial value of ptr for lookup
  190. */
  191. STATIC void
  192. xfs_inobt_init_ptr_from_cur(
  193. struct xfs_btree_cur *cur,
  194. union xfs_btree_ptr *ptr)
  195. {
  196. struct xfs_agi *agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
  197. ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno));
  198. ptr->s = agi->agi_root;
  199. }
  200. STATIC void
  201. xfs_finobt_init_ptr_from_cur(
  202. struct xfs_btree_cur *cur,
  203. union xfs_btree_ptr *ptr)
  204. {
  205. struct xfs_agi *agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
  206. ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno));
  207. ptr->s = agi->agi_free_root;
  208. }
  209. STATIC int64_t
  210. xfs_inobt_key_diff(
  211. struct xfs_btree_cur *cur,
  212. union xfs_btree_key *key)
  213. {
  214. return (int64_t)be32_to_cpu(key->inobt.ir_startino) -
  215. cur->bc_rec.i.ir_startino;
  216. }
  217. STATIC int64_t
  218. xfs_inobt_diff_two_keys(
  219. struct xfs_btree_cur *cur,
  220. union xfs_btree_key *k1,
  221. union xfs_btree_key *k2)
  222. {
  223. return (int64_t)be32_to_cpu(k1->inobt.ir_startino) -
  224. be32_to_cpu(k2->inobt.ir_startino);
  225. }
  226. static xfs_failaddr_t
  227. xfs_inobt_verify(
  228. struct xfs_buf *bp)
  229. {
  230. struct xfs_mount *mp = bp->b_target->bt_mount;
  231. struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
  232. xfs_failaddr_t fa;
  233. unsigned int level;
  234. /*
  235. * During growfs operations, we can't verify the exact owner as the
  236. * perag is not fully initialised and hence not attached to the buffer.
  237. *
  238. * Similarly, during log recovery we will have a perag structure
  239. * attached, but the agi information will not yet have been initialised
  240. * from the on disk AGI. We don't currently use any of this information,
  241. * but beware of the landmine (i.e. need to check pag->pagi_init) if we
  242. * ever do.
  243. */
  244. switch (block->bb_magic) {
  245. case cpu_to_be32(XFS_IBT_CRC_MAGIC):
  246. case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
  247. fa = xfs_btree_sblock_v5hdr_verify(bp);
  248. if (fa)
  249. return fa;
  250. /* fall through */
  251. case cpu_to_be32(XFS_IBT_MAGIC):
  252. case cpu_to_be32(XFS_FIBT_MAGIC):
  253. break;
  254. default:
  255. return __this_address;
  256. }
  257. /* level verification */
  258. level = be16_to_cpu(block->bb_level);
  259. if (level >= mp->m_in_maxlevels)
  260. return __this_address;
  261. return xfs_btree_sblock_verify(bp, mp->m_inobt_mxr[level != 0]);
  262. }
  263. static void
  264. xfs_inobt_read_verify(
  265. struct xfs_buf *bp)
  266. {
  267. xfs_failaddr_t fa;
  268. if (!xfs_btree_sblock_verify_crc(bp))
  269. xfs_verifier_error(bp, -EFSBADCRC, __this_address);
  270. else {
  271. fa = xfs_inobt_verify(bp);
  272. if (fa)
  273. xfs_verifier_error(bp, -EFSCORRUPTED, fa);
  274. }
  275. if (bp->b_error)
  276. trace_xfs_btree_corrupt(bp, _RET_IP_);
  277. }
  278. static void
  279. xfs_inobt_write_verify(
  280. struct xfs_buf *bp)
  281. {
  282. xfs_failaddr_t fa;
  283. fa = xfs_inobt_verify(bp);
  284. if (fa) {
  285. trace_xfs_btree_corrupt(bp, _RET_IP_);
  286. xfs_verifier_error(bp, -EFSCORRUPTED, fa);
  287. return;
  288. }
  289. xfs_btree_sblock_calc_crc(bp);
  290. }
  291. const struct xfs_buf_ops xfs_inobt_buf_ops = {
  292. .name = "xfs_inobt",
  293. .verify_read = xfs_inobt_read_verify,
  294. .verify_write = xfs_inobt_write_verify,
  295. .verify_struct = xfs_inobt_verify,
  296. };
  297. STATIC int
  298. xfs_inobt_keys_inorder(
  299. struct xfs_btree_cur *cur,
  300. union xfs_btree_key *k1,
  301. union xfs_btree_key *k2)
  302. {
  303. return be32_to_cpu(k1->inobt.ir_startino) <
  304. be32_to_cpu(k2->inobt.ir_startino);
  305. }
  306. STATIC int
  307. xfs_inobt_recs_inorder(
  308. struct xfs_btree_cur *cur,
  309. union xfs_btree_rec *r1,
  310. union xfs_btree_rec *r2)
  311. {
  312. return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <=
  313. be32_to_cpu(r2->inobt.ir_startino);
  314. }
  315. static const struct xfs_btree_ops xfs_inobt_ops = {
  316. .rec_len = sizeof(xfs_inobt_rec_t),
  317. .key_len = sizeof(xfs_inobt_key_t),
  318. .dup_cursor = xfs_inobt_dup_cursor,
  319. .set_root = xfs_inobt_set_root,
  320. .alloc_block = xfs_inobt_alloc_block,
  321. .free_block = xfs_inobt_free_block,
  322. .get_minrecs = xfs_inobt_get_minrecs,
  323. .get_maxrecs = xfs_inobt_get_maxrecs,
  324. .init_key_from_rec = xfs_inobt_init_key_from_rec,
  325. .init_high_key_from_rec = xfs_inobt_init_high_key_from_rec,
  326. .init_rec_from_cur = xfs_inobt_init_rec_from_cur,
  327. .init_ptr_from_cur = xfs_inobt_init_ptr_from_cur,
  328. .key_diff = xfs_inobt_key_diff,
  329. .buf_ops = &xfs_inobt_buf_ops,
  330. .diff_two_keys = xfs_inobt_diff_two_keys,
  331. .keys_inorder = xfs_inobt_keys_inorder,
  332. .recs_inorder = xfs_inobt_recs_inorder,
  333. };
  334. static const struct xfs_btree_ops xfs_finobt_ops = {
  335. .rec_len = sizeof(xfs_inobt_rec_t),
  336. .key_len = sizeof(xfs_inobt_key_t),
  337. .dup_cursor = xfs_inobt_dup_cursor,
  338. .set_root = xfs_finobt_set_root,
  339. .alloc_block = xfs_finobt_alloc_block,
  340. .free_block = xfs_finobt_free_block,
  341. .get_minrecs = xfs_inobt_get_minrecs,
  342. .get_maxrecs = xfs_inobt_get_maxrecs,
  343. .init_key_from_rec = xfs_inobt_init_key_from_rec,
  344. .init_high_key_from_rec = xfs_inobt_init_high_key_from_rec,
  345. .init_rec_from_cur = xfs_inobt_init_rec_from_cur,
  346. .init_ptr_from_cur = xfs_finobt_init_ptr_from_cur,
  347. .key_diff = xfs_inobt_key_diff,
  348. .buf_ops = &xfs_inobt_buf_ops,
  349. .diff_two_keys = xfs_inobt_diff_two_keys,
  350. .keys_inorder = xfs_inobt_keys_inorder,
  351. .recs_inorder = xfs_inobt_recs_inorder,
  352. };
  353. /*
  354. * Allocate a new inode btree cursor.
  355. */
  356. struct xfs_btree_cur * /* new inode btree cursor */
  357. xfs_inobt_init_cursor(
  358. struct xfs_mount *mp, /* file system mount point */
  359. struct xfs_trans *tp, /* transaction pointer */
  360. struct xfs_buf *agbp, /* buffer for agi structure */
  361. xfs_agnumber_t agno, /* allocation group number */
  362. xfs_btnum_t btnum) /* ialloc or free ino btree */
  363. {
  364. struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp);
  365. struct xfs_btree_cur *cur;
  366. cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
  367. cur->bc_tp = tp;
  368. cur->bc_mp = mp;
  369. cur->bc_btnum = btnum;
  370. if (btnum == XFS_BTNUM_INO) {
  371. cur->bc_nlevels = be32_to_cpu(agi->agi_level);
  372. cur->bc_ops = &xfs_inobt_ops;
  373. cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_ibt_2);
  374. } else {
  375. cur->bc_nlevels = be32_to_cpu(agi->agi_free_level);
  376. cur->bc_ops = &xfs_finobt_ops;
  377. cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_fibt_2);
  378. }
  379. cur->bc_blocklog = mp->m_sb.sb_blocklog;
  380. if (xfs_sb_version_hascrc(&mp->m_sb))
  381. cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
  382. cur->bc_private.a.agbp = agbp;
  383. cur->bc_private.a.agno = agno;
  384. return cur;
  385. }
  386. /*
  387. * Calculate number of records in an inobt btree block.
  388. */
  389. int
  390. xfs_inobt_maxrecs(
  391. struct xfs_mount *mp,
  392. int blocklen,
  393. int leaf)
  394. {
  395. blocklen -= XFS_INOBT_BLOCK_LEN(mp);
  396. if (leaf)
  397. return blocklen / sizeof(xfs_inobt_rec_t);
  398. return blocklen / (sizeof(xfs_inobt_key_t) + sizeof(xfs_inobt_ptr_t));
  399. }
  400. /*
  401. * Convert the inode record holemask to an inode allocation bitmap. The inode
  402. * allocation bitmap is inode granularity and specifies whether an inode is
  403. * physically allocated on disk (not whether the inode is considered allocated
  404. * or free by the fs).
  405. *
  406. * A bit value of 1 means the inode is allocated, a value of 0 means it is free.
  407. */
  408. uint64_t
  409. xfs_inobt_irec_to_allocmask(
  410. struct xfs_inobt_rec_incore *rec)
  411. {
  412. uint64_t bitmap = 0;
  413. uint64_t inodespbit;
  414. int nextbit;
  415. uint allocbitmap;
  416. /*
  417. * The holemask has 16-bits for a 64 inode record. Therefore each
  418. * holemask bit represents multiple inodes. Create a mask of bits to set
  419. * in the allocmask for each holemask bit.
  420. */
  421. inodespbit = (1 << XFS_INODES_PER_HOLEMASK_BIT) - 1;
  422. /*
  423. * Allocated inodes are represented by 0 bits in holemask. Invert the 0
  424. * bits to 1 and convert to a uint so we can use xfs_next_bit(). Mask
  425. * anything beyond the 16 holemask bits since this casts to a larger
  426. * type.
  427. */
  428. allocbitmap = ~rec->ir_holemask & ((1 << XFS_INOBT_HOLEMASK_BITS) - 1);
  429. /*
  430. * allocbitmap is the inverted holemask so every set bit represents
  431. * allocated inodes. To expand from 16-bit holemask granularity to
  432. * 64-bit (e.g., bit-per-inode), set inodespbit bits in the target
  433. * bitmap for every holemask bit.
  434. */
  435. nextbit = xfs_next_bit(&allocbitmap, 1, 0);
  436. while (nextbit != -1) {
  437. ASSERT(nextbit < (sizeof(rec->ir_holemask) * NBBY));
  438. bitmap |= (inodespbit <<
  439. (nextbit * XFS_INODES_PER_HOLEMASK_BIT));
  440. nextbit = xfs_next_bit(&allocbitmap, 1, nextbit + 1);
  441. }
  442. return bitmap;
  443. }
  444. #if defined(DEBUG) || defined(XFS_WARN)
  445. /*
  446. * Verify that an in-core inode record has a valid inode count.
  447. */
  448. int
  449. xfs_inobt_rec_check_count(
  450. struct xfs_mount *mp,
  451. struct xfs_inobt_rec_incore *rec)
  452. {
  453. int inocount = 0;
  454. int nextbit = 0;
  455. uint64_t allocbmap;
  456. int wordsz;
  457. wordsz = sizeof(allocbmap) / sizeof(unsigned int);
  458. allocbmap = xfs_inobt_irec_to_allocmask(rec);
  459. nextbit = xfs_next_bit((uint *) &allocbmap, wordsz, nextbit);
  460. while (nextbit != -1) {
  461. inocount++;
  462. nextbit = xfs_next_bit((uint *) &allocbmap, wordsz,
  463. nextbit + 1);
  464. }
  465. if (inocount != rec->ir_count)
  466. return -EFSCORRUPTED;
  467. return 0;
  468. }
  469. #endif /* DEBUG */
  470. static xfs_extlen_t
  471. xfs_inobt_max_size(
  472. struct xfs_mount *mp)
  473. {
  474. /* Bail out if we're uninitialized, which can happen in mkfs. */
  475. if (mp->m_inobt_mxr[0] == 0)
  476. return 0;
  477. return xfs_btree_calc_size(mp->m_inobt_mnr,
  478. (uint64_t)mp->m_sb.sb_agblocks * mp->m_sb.sb_inopblock /
  479. XFS_INODES_PER_CHUNK);
  480. }
  481. static int
  482. xfs_inobt_count_blocks(
  483. struct xfs_mount *mp,
  484. struct xfs_trans *tp,
  485. xfs_agnumber_t agno,
  486. xfs_btnum_t btnum,
  487. xfs_extlen_t *tree_blocks)
  488. {
  489. struct xfs_buf *agbp;
  490. struct xfs_btree_cur *cur;
  491. int error;
  492. error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
  493. if (error)
  494. return error;
  495. cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum);
  496. error = xfs_btree_count_blocks(cur, tree_blocks);
  497. xfs_btree_del_cursor(cur, error);
  498. xfs_trans_brelse(tp, agbp);
  499. return error;
  500. }
  501. /*
  502. * Figure out how many blocks to reserve and how many are used by this btree.
  503. */
  504. int
  505. xfs_finobt_calc_reserves(
  506. struct xfs_mount *mp,
  507. struct xfs_trans *tp,
  508. xfs_agnumber_t agno,
  509. xfs_extlen_t *ask,
  510. xfs_extlen_t *used)
  511. {
  512. xfs_extlen_t tree_len = 0;
  513. int error;
  514. if (!xfs_sb_version_hasfinobt(&mp->m_sb))
  515. return 0;
  516. error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO, &tree_len);
  517. if (error)
  518. return error;
  519. *ask += xfs_inobt_max_size(mp);
  520. *used += tree_len;
  521. return 0;
  522. }
  523. /* Calculate the inobt btree size for some records. */
  524. xfs_extlen_t
  525. xfs_iallocbt_calc_size(
  526. struct xfs_mount *mp,
  527. unsigned long long len)
  528. {
  529. return xfs_btree_calc_size(mp->m_inobt_mnr, len);
  530. }