xfs_rmap_btree.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2014 Red Hat, 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_sb.h"
  14. #include "xfs_mount.h"
  15. #include "xfs_defer.h"
  16. #include "xfs_inode.h"
  17. #include "xfs_trans.h"
  18. #include "xfs_alloc.h"
  19. #include "xfs_btree.h"
  20. #include "xfs_rmap.h"
  21. #include "xfs_rmap_btree.h"
  22. #include "xfs_trace.h"
  23. #include "xfs_cksum.h"
  24. #include "xfs_error.h"
  25. #include "xfs_extent_busy.h"
  26. #include "xfs_ag_resv.h"
  27. /*
  28. * Reverse map btree.
  29. *
  30. * This is a per-ag tree used to track the owner(s) of a given extent. With
  31. * reflink it is possible for there to be multiple owners, which is a departure
  32. * from classic XFS. Owner records for data extents are inserted when the
  33. * extent is mapped and removed when an extent is unmapped. Owner records for
  34. * all other block types (i.e. metadata) are inserted when an extent is
  35. * allocated and removed when an extent is freed. There can only be one owner
  36. * of a metadata extent, usually an inode or some other metadata structure like
  37. * an AG btree.
  38. *
  39. * The rmap btree is part of the free space management, so blocks for the tree
  40. * are sourced from the agfl. Hence we need transaction reservation support for
  41. * this tree so that the freelist is always large enough. This also impacts on
  42. * the minimum space we need to leave free in the AG.
  43. *
  44. * The tree is ordered by [ag block, owner, offset]. This is a large key size,
  45. * but it is the only way to enforce unique keys when a block can be owned by
  46. * multiple files at any offset. There's no need to order/search by extent
  47. * size for online updating/management of the tree. It is intended that most
  48. * reverse lookups will be to find the owner(s) of a particular block, or to
  49. * try to recover tree and file data from corrupt primary metadata.
  50. */
  51. static struct xfs_btree_cur *
  52. xfs_rmapbt_dup_cursor(
  53. struct xfs_btree_cur *cur)
  54. {
  55. return xfs_rmapbt_init_cursor(cur->bc_mp, cur->bc_tp,
  56. cur->bc_private.a.agbp, cur->bc_private.a.agno);
  57. }
  58. STATIC void
  59. xfs_rmapbt_set_root(
  60. struct xfs_btree_cur *cur,
  61. union xfs_btree_ptr *ptr,
  62. int inc)
  63. {
  64. struct xfs_buf *agbp = cur->bc_private.a.agbp;
  65. struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
  66. xfs_agnumber_t seqno = be32_to_cpu(agf->agf_seqno);
  67. int btnum = cur->bc_btnum;
  68. struct xfs_perag *pag = xfs_perag_get(cur->bc_mp, seqno);
  69. ASSERT(ptr->s != 0);
  70. agf->agf_roots[btnum] = ptr->s;
  71. be32_add_cpu(&agf->agf_levels[btnum], inc);
  72. pag->pagf_levels[btnum] += inc;
  73. xfs_perag_put(pag);
  74. xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_ROOTS | XFS_AGF_LEVELS);
  75. }
  76. STATIC int
  77. xfs_rmapbt_alloc_block(
  78. struct xfs_btree_cur *cur,
  79. union xfs_btree_ptr *start,
  80. union xfs_btree_ptr *new,
  81. int *stat)
  82. {
  83. struct xfs_buf *agbp = cur->bc_private.a.agbp;
  84. struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
  85. int error;
  86. xfs_agblock_t bno;
  87. /* Allocate the new block from the freelist. If we can't, give up. */
  88. error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
  89. &bno, 1);
  90. if (error)
  91. return error;
  92. trace_xfs_rmapbt_alloc_block(cur->bc_mp, cur->bc_private.a.agno,
  93. bno, 1);
  94. if (bno == NULLAGBLOCK) {
  95. *stat = 0;
  96. return 0;
  97. }
  98. xfs_extent_busy_reuse(cur->bc_mp, cur->bc_private.a.agno, bno, 1,
  99. false);
  100. xfs_trans_agbtree_delta(cur->bc_tp, 1);
  101. new->s = cpu_to_be32(bno);
  102. be32_add_cpu(&agf->agf_rmap_blocks, 1);
  103. xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS);
  104. xfs_ag_resv_rmapbt_alloc(cur->bc_mp, cur->bc_private.a.agno);
  105. *stat = 1;
  106. return 0;
  107. }
  108. STATIC int
  109. xfs_rmapbt_free_block(
  110. struct xfs_btree_cur *cur,
  111. struct xfs_buf *bp)
  112. {
  113. struct xfs_buf *agbp = cur->bc_private.a.agbp;
  114. struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
  115. xfs_agblock_t bno;
  116. int error;
  117. bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp));
  118. trace_xfs_rmapbt_free_block(cur->bc_mp, cur->bc_private.a.agno,
  119. bno, 1);
  120. be32_add_cpu(&agf->agf_rmap_blocks, -1);
  121. xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS);
  122. error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1);
  123. if (error)
  124. return error;
  125. xfs_extent_busy_insert(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1,
  126. XFS_EXTENT_BUSY_SKIP_DISCARD);
  127. xfs_trans_agbtree_delta(cur->bc_tp, -1);
  128. xfs_ag_resv_rmapbt_free(cur->bc_mp, cur->bc_private.a.agno);
  129. return 0;
  130. }
  131. STATIC int
  132. xfs_rmapbt_get_minrecs(
  133. struct xfs_btree_cur *cur,
  134. int level)
  135. {
  136. return cur->bc_mp->m_rmap_mnr[level != 0];
  137. }
  138. STATIC int
  139. xfs_rmapbt_get_maxrecs(
  140. struct xfs_btree_cur *cur,
  141. int level)
  142. {
  143. return cur->bc_mp->m_rmap_mxr[level != 0];
  144. }
  145. STATIC void
  146. xfs_rmapbt_init_key_from_rec(
  147. union xfs_btree_key *key,
  148. union xfs_btree_rec *rec)
  149. {
  150. key->rmap.rm_startblock = rec->rmap.rm_startblock;
  151. key->rmap.rm_owner = rec->rmap.rm_owner;
  152. key->rmap.rm_offset = rec->rmap.rm_offset;
  153. }
  154. /*
  155. * The high key for a reverse mapping record can be computed by shifting
  156. * the startblock and offset to the highest value that would still map
  157. * to that record. In practice this means that we add blockcount-1 to
  158. * the startblock for all records, and if the record is for a data/attr
  159. * fork mapping, we add blockcount-1 to the offset too.
  160. */
  161. STATIC void
  162. xfs_rmapbt_init_high_key_from_rec(
  163. union xfs_btree_key *key,
  164. union xfs_btree_rec *rec)
  165. {
  166. uint64_t off;
  167. int adj;
  168. adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1;
  169. key->rmap.rm_startblock = rec->rmap.rm_startblock;
  170. be32_add_cpu(&key->rmap.rm_startblock, adj);
  171. key->rmap.rm_owner = rec->rmap.rm_owner;
  172. key->rmap.rm_offset = rec->rmap.rm_offset;
  173. if (XFS_RMAP_NON_INODE_OWNER(be64_to_cpu(rec->rmap.rm_owner)) ||
  174. XFS_RMAP_IS_BMBT_BLOCK(be64_to_cpu(rec->rmap.rm_offset)))
  175. return;
  176. off = be64_to_cpu(key->rmap.rm_offset);
  177. off = (XFS_RMAP_OFF(off) + adj) | (off & ~XFS_RMAP_OFF_MASK);
  178. key->rmap.rm_offset = cpu_to_be64(off);
  179. }
  180. STATIC void
  181. xfs_rmapbt_init_rec_from_cur(
  182. struct xfs_btree_cur *cur,
  183. union xfs_btree_rec *rec)
  184. {
  185. rec->rmap.rm_startblock = cpu_to_be32(cur->bc_rec.r.rm_startblock);
  186. rec->rmap.rm_blockcount = cpu_to_be32(cur->bc_rec.r.rm_blockcount);
  187. rec->rmap.rm_owner = cpu_to_be64(cur->bc_rec.r.rm_owner);
  188. rec->rmap.rm_offset = cpu_to_be64(
  189. xfs_rmap_irec_offset_pack(&cur->bc_rec.r));
  190. }
  191. STATIC void
  192. xfs_rmapbt_init_ptr_from_cur(
  193. struct xfs_btree_cur *cur,
  194. union xfs_btree_ptr *ptr)
  195. {
  196. struct xfs_agf *agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
  197. ASSERT(cur->bc_private.a.agno == be32_to_cpu(agf->agf_seqno));
  198. ptr->s = agf->agf_roots[cur->bc_btnum];
  199. }
  200. STATIC int64_t
  201. xfs_rmapbt_key_diff(
  202. struct xfs_btree_cur *cur,
  203. union xfs_btree_key *key)
  204. {
  205. struct xfs_rmap_irec *rec = &cur->bc_rec.r;
  206. struct xfs_rmap_key *kp = &key->rmap;
  207. __u64 x, y;
  208. int64_t d;
  209. d = (int64_t)be32_to_cpu(kp->rm_startblock) - rec->rm_startblock;
  210. if (d)
  211. return d;
  212. x = be64_to_cpu(kp->rm_owner);
  213. y = rec->rm_owner;
  214. if (x > y)
  215. return 1;
  216. else if (y > x)
  217. return -1;
  218. x = XFS_RMAP_OFF(be64_to_cpu(kp->rm_offset));
  219. y = rec->rm_offset;
  220. if (x > y)
  221. return 1;
  222. else if (y > x)
  223. return -1;
  224. return 0;
  225. }
  226. STATIC int64_t
  227. xfs_rmapbt_diff_two_keys(
  228. struct xfs_btree_cur *cur,
  229. union xfs_btree_key *k1,
  230. union xfs_btree_key *k2)
  231. {
  232. struct xfs_rmap_key *kp1 = &k1->rmap;
  233. struct xfs_rmap_key *kp2 = &k2->rmap;
  234. int64_t d;
  235. __u64 x, y;
  236. d = (int64_t)be32_to_cpu(kp1->rm_startblock) -
  237. be32_to_cpu(kp2->rm_startblock);
  238. if (d)
  239. return d;
  240. x = be64_to_cpu(kp1->rm_owner);
  241. y = be64_to_cpu(kp2->rm_owner);
  242. if (x > y)
  243. return 1;
  244. else if (y > x)
  245. return -1;
  246. x = XFS_RMAP_OFF(be64_to_cpu(kp1->rm_offset));
  247. y = XFS_RMAP_OFF(be64_to_cpu(kp2->rm_offset));
  248. if (x > y)
  249. return 1;
  250. else if (y > x)
  251. return -1;
  252. return 0;
  253. }
  254. static xfs_failaddr_t
  255. xfs_rmapbt_verify(
  256. struct xfs_buf *bp)
  257. {
  258. struct xfs_mount *mp = bp->b_target->bt_mount;
  259. struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
  260. struct xfs_perag *pag = bp->b_pag;
  261. xfs_failaddr_t fa;
  262. unsigned int level;
  263. /*
  264. * magic number and level verification
  265. *
  266. * During growfs operations, we can't verify the exact level or owner as
  267. * the perag is not fully initialised and hence not attached to the
  268. * buffer. In this case, check against the maximum tree depth.
  269. *
  270. * Similarly, during log recovery we will have a perag structure
  271. * attached, but the agf information will not yet have been initialised
  272. * from the on disk AGF. Again, we can only check against maximum limits
  273. * in this case.
  274. */
  275. if (block->bb_magic != cpu_to_be32(XFS_RMAP_CRC_MAGIC))
  276. return __this_address;
  277. if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
  278. return __this_address;
  279. fa = xfs_btree_sblock_v5hdr_verify(bp);
  280. if (fa)
  281. return fa;
  282. level = be16_to_cpu(block->bb_level);
  283. if (pag && pag->pagf_init) {
  284. if (level >= pag->pagf_levels[XFS_BTNUM_RMAPi])
  285. return __this_address;
  286. } else if (level >= mp->m_rmap_maxlevels)
  287. return __this_address;
  288. return xfs_btree_sblock_verify(bp, mp->m_rmap_mxr[level != 0]);
  289. }
  290. static void
  291. xfs_rmapbt_read_verify(
  292. struct xfs_buf *bp)
  293. {
  294. xfs_failaddr_t fa;
  295. if (!xfs_btree_sblock_verify_crc(bp))
  296. xfs_verifier_error(bp, -EFSBADCRC, __this_address);
  297. else {
  298. fa = xfs_rmapbt_verify(bp);
  299. if (fa)
  300. xfs_verifier_error(bp, -EFSCORRUPTED, fa);
  301. }
  302. if (bp->b_error)
  303. trace_xfs_btree_corrupt(bp, _RET_IP_);
  304. }
  305. static void
  306. xfs_rmapbt_write_verify(
  307. struct xfs_buf *bp)
  308. {
  309. xfs_failaddr_t fa;
  310. fa = xfs_rmapbt_verify(bp);
  311. if (fa) {
  312. trace_xfs_btree_corrupt(bp, _RET_IP_);
  313. xfs_verifier_error(bp, -EFSCORRUPTED, fa);
  314. return;
  315. }
  316. xfs_btree_sblock_calc_crc(bp);
  317. }
  318. const struct xfs_buf_ops xfs_rmapbt_buf_ops = {
  319. .name = "xfs_rmapbt",
  320. .verify_read = xfs_rmapbt_read_verify,
  321. .verify_write = xfs_rmapbt_write_verify,
  322. .verify_struct = xfs_rmapbt_verify,
  323. };
  324. STATIC int
  325. xfs_rmapbt_keys_inorder(
  326. struct xfs_btree_cur *cur,
  327. union xfs_btree_key *k1,
  328. union xfs_btree_key *k2)
  329. {
  330. uint32_t x;
  331. uint32_t y;
  332. uint64_t a;
  333. uint64_t b;
  334. x = be32_to_cpu(k1->rmap.rm_startblock);
  335. y = be32_to_cpu(k2->rmap.rm_startblock);
  336. if (x < y)
  337. return 1;
  338. else if (x > y)
  339. return 0;
  340. a = be64_to_cpu(k1->rmap.rm_owner);
  341. b = be64_to_cpu(k2->rmap.rm_owner);
  342. if (a < b)
  343. return 1;
  344. else if (a > b)
  345. return 0;
  346. a = XFS_RMAP_OFF(be64_to_cpu(k1->rmap.rm_offset));
  347. b = XFS_RMAP_OFF(be64_to_cpu(k2->rmap.rm_offset));
  348. if (a <= b)
  349. return 1;
  350. return 0;
  351. }
  352. STATIC int
  353. xfs_rmapbt_recs_inorder(
  354. struct xfs_btree_cur *cur,
  355. union xfs_btree_rec *r1,
  356. union xfs_btree_rec *r2)
  357. {
  358. uint32_t x;
  359. uint32_t y;
  360. uint64_t a;
  361. uint64_t b;
  362. x = be32_to_cpu(r1->rmap.rm_startblock);
  363. y = be32_to_cpu(r2->rmap.rm_startblock);
  364. if (x < y)
  365. return 1;
  366. else if (x > y)
  367. return 0;
  368. a = be64_to_cpu(r1->rmap.rm_owner);
  369. b = be64_to_cpu(r2->rmap.rm_owner);
  370. if (a < b)
  371. return 1;
  372. else if (a > b)
  373. return 0;
  374. a = XFS_RMAP_OFF(be64_to_cpu(r1->rmap.rm_offset));
  375. b = XFS_RMAP_OFF(be64_to_cpu(r2->rmap.rm_offset));
  376. if (a <= b)
  377. return 1;
  378. return 0;
  379. }
  380. static const struct xfs_btree_ops xfs_rmapbt_ops = {
  381. .rec_len = sizeof(struct xfs_rmap_rec),
  382. .key_len = 2 * sizeof(struct xfs_rmap_key),
  383. .dup_cursor = xfs_rmapbt_dup_cursor,
  384. .set_root = xfs_rmapbt_set_root,
  385. .alloc_block = xfs_rmapbt_alloc_block,
  386. .free_block = xfs_rmapbt_free_block,
  387. .get_minrecs = xfs_rmapbt_get_minrecs,
  388. .get_maxrecs = xfs_rmapbt_get_maxrecs,
  389. .init_key_from_rec = xfs_rmapbt_init_key_from_rec,
  390. .init_high_key_from_rec = xfs_rmapbt_init_high_key_from_rec,
  391. .init_rec_from_cur = xfs_rmapbt_init_rec_from_cur,
  392. .init_ptr_from_cur = xfs_rmapbt_init_ptr_from_cur,
  393. .key_diff = xfs_rmapbt_key_diff,
  394. .buf_ops = &xfs_rmapbt_buf_ops,
  395. .diff_two_keys = xfs_rmapbt_diff_two_keys,
  396. .keys_inorder = xfs_rmapbt_keys_inorder,
  397. .recs_inorder = xfs_rmapbt_recs_inorder,
  398. };
  399. /*
  400. * Allocate a new allocation btree cursor.
  401. */
  402. struct xfs_btree_cur *
  403. xfs_rmapbt_init_cursor(
  404. struct xfs_mount *mp,
  405. struct xfs_trans *tp,
  406. struct xfs_buf *agbp,
  407. xfs_agnumber_t agno)
  408. {
  409. struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
  410. struct xfs_btree_cur *cur;
  411. cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
  412. cur->bc_tp = tp;
  413. cur->bc_mp = mp;
  414. /* Overlapping btree; 2 keys per pointer. */
  415. cur->bc_btnum = XFS_BTNUM_RMAP;
  416. cur->bc_flags = XFS_BTREE_CRC_BLOCKS | XFS_BTREE_OVERLAPPING;
  417. cur->bc_blocklog = mp->m_sb.sb_blocklog;
  418. cur->bc_ops = &xfs_rmapbt_ops;
  419. cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]);
  420. cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_rmap_2);
  421. cur->bc_private.a.agbp = agbp;
  422. cur->bc_private.a.agno = agno;
  423. return cur;
  424. }
  425. /*
  426. * Calculate number of records in an rmap btree block.
  427. */
  428. int
  429. xfs_rmapbt_maxrecs(
  430. int blocklen,
  431. int leaf)
  432. {
  433. blocklen -= XFS_RMAP_BLOCK_LEN;
  434. if (leaf)
  435. return blocklen / sizeof(struct xfs_rmap_rec);
  436. return blocklen /
  437. (2 * sizeof(struct xfs_rmap_key) + sizeof(xfs_rmap_ptr_t));
  438. }
  439. /* Compute the maximum height of an rmap btree. */
  440. void
  441. xfs_rmapbt_compute_maxlevels(
  442. struct xfs_mount *mp)
  443. {
  444. /*
  445. * On a non-reflink filesystem, the maximum number of rmap
  446. * records is the number of blocks in the AG, hence the max
  447. * rmapbt height is log_$maxrecs($agblocks). However, with
  448. * reflink each AG block can have up to 2^32 (per the refcount
  449. * record format) owners, which means that theoretically we
  450. * could face up to 2^64 rmap records.
  451. *
  452. * That effectively means that the max rmapbt height must be
  453. * XFS_BTREE_MAXLEVELS. "Fortunately" we'll run out of AG
  454. * blocks to feed the rmapbt long before the rmapbt reaches
  455. * maximum height. The reflink code uses ag_resv_critical to
  456. * disallow reflinking when less than 10% of the per-AG metadata
  457. * block reservation since the fallback is a regular file copy.
  458. */
  459. if (xfs_sb_version_hasreflink(&mp->m_sb))
  460. mp->m_rmap_maxlevels = XFS_BTREE_MAXLEVELS;
  461. else
  462. mp->m_rmap_maxlevels = xfs_btree_compute_maxlevels(
  463. mp->m_rmap_mnr, mp->m_sb.sb_agblocks);
  464. }
  465. /* Calculate the refcount btree size for some records. */
  466. xfs_extlen_t
  467. xfs_rmapbt_calc_size(
  468. struct xfs_mount *mp,
  469. unsigned long long len)
  470. {
  471. return xfs_btree_calc_size(mp->m_rmap_mnr, len);
  472. }
  473. /*
  474. * Calculate the maximum refcount btree size.
  475. */
  476. xfs_extlen_t
  477. xfs_rmapbt_max_size(
  478. struct xfs_mount *mp,
  479. xfs_agblock_t agblocks)
  480. {
  481. /* Bail out if we're uninitialized, which can happen in mkfs. */
  482. if (mp->m_rmap_mxr[0] == 0)
  483. return 0;
  484. return xfs_rmapbt_calc_size(mp, agblocks);
  485. }
  486. /*
  487. * Figure out how many blocks to reserve and how many are used by this btree.
  488. */
  489. int
  490. xfs_rmapbt_calc_reserves(
  491. struct xfs_mount *mp,
  492. struct xfs_trans *tp,
  493. xfs_agnumber_t agno,
  494. xfs_extlen_t *ask,
  495. xfs_extlen_t *used)
  496. {
  497. struct xfs_buf *agbp;
  498. struct xfs_agf *agf;
  499. xfs_agblock_t agblocks;
  500. xfs_extlen_t tree_len;
  501. int error;
  502. if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
  503. return 0;
  504. error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
  505. if (error)
  506. return error;
  507. agf = XFS_BUF_TO_AGF(agbp);
  508. agblocks = be32_to_cpu(agf->agf_length);
  509. tree_len = be32_to_cpu(agf->agf_rmap_blocks);
  510. xfs_trans_brelse(tp, agbp);
  511. /* Reserve 1% of the AG or enough for 1 block per record. */
  512. *ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
  513. *used += tree_len;
  514. return error;
  515. }