Lines Matching +full:max +full:- +full:cur
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
30 struct xfs_btree_cur *cur, in xfs_inobt_get_minrecs() argument
33 return M_IGEO(cur->bc_mp)->inobt_mnr[level != 0]; in xfs_inobt_get_minrecs()
38 struct xfs_btree_cur *cur) in xfs_inobt_dup_cursor() argument
40 return xfs_inobt_init_cursor(to_perag(cur->bc_group), cur->bc_tp, in xfs_inobt_dup_cursor()
41 cur->bc_ag.agbp); in xfs_inobt_dup_cursor()
46 struct xfs_btree_cur *cur) in xfs_finobt_dup_cursor() argument
48 return xfs_finobt_init_cursor(to_perag(cur->bc_group), cur->bc_tp, in xfs_finobt_dup_cursor()
49 cur->bc_ag.agbp); in xfs_finobt_dup_cursor()
54 struct xfs_btree_cur *cur, in xfs_inobt_set_root() argument
58 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_inobt_set_root()
59 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_set_root()
61 agi->agi_root = nptr->s; in xfs_inobt_set_root()
62 be32_add_cpu(&agi->agi_level, inc); in xfs_inobt_set_root()
63 xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_ROOT | XFS_AGI_LEVEL); in xfs_inobt_set_root()
68 struct xfs_btree_cur *cur, in xfs_finobt_set_root() argument
72 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_finobt_set_root()
73 struct xfs_agi *agi = agbp->b_addr; in xfs_finobt_set_root()
75 agi->agi_free_root = nptr->s; in xfs_finobt_set_root()
76 be32_add_cpu(&agi->agi_free_level, inc); in xfs_finobt_set_root()
77 xfs_ialloc_log_agi(cur->bc_tp, agbp, in xfs_finobt_set_root()
84 struct xfs_btree_cur *cur, in xfs_inobt_mod_blockcount() argument
87 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_inobt_mod_blockcount()
88 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_mod_blockcount()
90 if (!xfs_has_inobtcounts(cur->bc_mp)) in xfs_inobt_mod_blockcount()
93 if (xfs_btree_is_fino(cur->bc_ops)) in xfs_inobt_mod_blockcount()
94 be32_add_cpu(&agi->agi_fblocks, howmuch); in xfs_inobt_mod_blockcount()
96 be32_add_cpu(&agi->agi_iblocks, howmuch); in xfs_inobt_mod_blockcount()
97 xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_IBLOCKS); in xfs_inobt_mod_blockcount()
102 struct xfs_btree_cur *cur, in __xfs_inobt_alloc_block() argument
110 xfs_agblock_t sbno = be32_to_cpu(start->s); in __xfs_inobt_alloc_block()
113 args.tp = cur->bc_tp; in __xfs_inobt_alloc_block()
114 args.mp = cur->bc_mp; in __xfs_inobt_alloc_block()
115 args.pag = to_perag(cur->bc_group); in __xfs_inobt_alloc_block()
133 new->s = cpu_to_be32(XFS_FSB_TO_AGBNO(args.mp, args.fsbno)); in __xfs_inobt_alloc_block()
135 xfs_inobt_mod_blockcount(cur, 1); in __xfs_inobt_alloc_block()
141 struct xfs_btree_cur *cur, in xfs_inobt_alloc_block() argument
146 return __xfs_inobt_alloc_block(cur, start, new, stat, XFS_AG_RESV_NONE); in xfs_inobt_alloc_block()
151 struct xfs_btree_cur *cur, in xfs_finobt_alloc_block() argument
156 if (cur->bc_mp->m_finobt_nores) in xfs_finobt_alloc_block()
157 return xfs_inobt_alloc_block(cur, start, new, stat); in xfs_finobt_alloc_block()
158 return __xfs_inobt_alloc_block(cur, start, new, stat, in xfs_finobt_alloc_block()
164 struct xfs_btree_cur *cur, in __xfs_inobt_free_block() argument
170 xfs_inobt_mod_blockcount(cur, -1); in __xfs_inobt_free_block()
171 fsbno = XFS_DADDR_TO_FSB(cur->bc_mp, xfs_buf_daddr(bp)); in __xfs_inobt_free_block()
172 return xfs_free_extent_later(cur->bc_tp, fsbno, 1, in __xfs_inobt_free_block()
178 struct xfs_btree_cur *cur, in xfs_inobt_free_block() argument
181 return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_NONE); in xfs_inobt_free_block()
186 struct xfs_btree_cur *cur, in xfs_finobt_free_block() argument
189 if (cur->bc_mp->m_finobt_nores) in xfs_finobt_free_block()
190 return xfs_inobt_free_block(cur, bp); in xfs_finobt_free_block()
191 return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_METADATA); in xfs_finobt_free_block()
196 struct xfs_btree_cur *cur, in xfs_inobt_get_maxrecs() argument
199 return M_IGEO(cur->bc_mp)->inobt_mxr[level != 0]; in xfs_inobt_get_maxrecs()
207 key->inobt.ir_startino = rec->inobt.ir_startino; in xfs_inobt_init_key_from_rec()
217 x = be32_to_cpu(rec->inobt.ir_startino); in xfs_inobt_init_high_key_from_rec()
218 x += XFS_INODES_PER_CHUNK - 1; in xfs_inobt_init_high_key_from_rec()
219 key->inobt.ir_startino = cpu_to_be32(x); in xfs_inobt_init_high_key_from_rec()
224 struct xfs_btree_cur *cur, in xfs_inobt_init_rec_from_cur() argument
227 rec->inobt.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino); in xfs_inobt_init_rec_from_cur()
228 if (xfs_has_sparseinodes(cur->bc_mp)) { in xfs_inobt_init_rec_from_cur()
229 rec->inobt.ir_u.sp.ir_holemask = in xfs_inobt_init_rec_from_cur()
230 cpu_to_be16(cur->bc_rec.i.ir_holemask); in xfs_inobt_init_rec_from_cur()
231 rec->inobt.ir_u.sp.ir_count = cur->bc_rec.i.ir_count; in xfs_inobt_init_rec_from_cur()
232 rec->inobt.ir_u.sp.ir_freecount = cur->bc_rec.i.ir_freecount; in xfs_inobt_init_rec_from_cur()
234 /* ir_holemask/ir_count not supported on-disk */ in xfs_inobt_init_rec_from_cur()
235 rec->inobt.ir_u.f.ir_freecount = in xfs_inobt_init_rec_from_cur()
236 cpu_to_be32(cur->bc_rec.i.ir_freecount); in xfs_inobt_init_rec_from_cur()
238 rec->inobt.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free); in xfs_inobt_init_rec_from_cur()
246 struct xfs_btree_cur *cur, in xfs_inobt_init_ptr_from_cur() argument
249 struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; in xfs_inobt_init_ptr_from_cur()
251 ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agi->agi_seqno)); in xfs_inobt_init_ptr_from_cur()
253 ptr->s = agi->agi_root; in xfs_inobt_init_ptr_from_cur()
258 struct xfs_btree_cur *cur, in xfs_finobt_init_ptr_from_cur() argument
261 struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; in xfs_finobt_init_ptr_from_cur()
263 ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agi->agi_seqno)); in xfs_finobt_init_ptr_from_cur()
265 ptr->s = agi->agi_free_root; in xfs_finobt_init_ptr_from_cur()
270 struct xfs_btree_cur *cur, in xfs_inobt_key_diff() argument
273 return (int64_t)be32_to_cpu(key->inobt.ir_startino) - in xfs_inobt_key_diff()
274 cur->bc_rec.i.ir_startino; in xfs_inobt_key_diff()
279 struct xfs_btree_cur *cur, in xfs_inobt_diff_two_keys() argument
284 ASSERT(!mask || mask->inobt.ir_startino); in xfs_inobt_diff_two_keys()
286 return (int64_t)be32_to_cpu(k1->inobt.ir_startino) - in xfs_inobt_diff_two_keys()
287 be32_to_cpu(k2->inobt.ir_startino); in xfs_inobt_diff_two_keys()
294 struct xfs_mount *mp = bp->b_mount; in xfs_inobt_verify()
299 if (!xfs_verify_magic(bp, block->bb_magic)) in xfs_inobt_verify()
319 level = be16_to_cpu(block->bb_level); in xfs_inobt_verify()
320 if (level >= M_IGEO(mp)->inobt_maxlevels) in xfs_inobt_verify()
324 M_IGEO(mp)->inobt_mxr[level != 0]); in xfs_inobt_verify()
334 xfs_verifier_error(bp, -EFSBADCRC, __this_address); in xfs_inobt_read_verify()
338 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_inobt_read_verify()
341 if (bp->b_error) in xfs_inobt_read_verify()
354 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_inobt_write_verify()
380 struct xfs_btree_cur *cur, in xfs_inobt_keys_inorder() argument
384 return be32_to_cpu(k1->inobt.ir_startino) < in xfs_inobt_keys_inorder()
385 be32_to_cpu(k2->inobt.ir_startino); in xfs_inobt_keys_inorder()
390 struct xfs_btree_cur *cur, in xfs_inobt_recs_inorder() argument
394 return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <= in xfs_inobt_recs_inorder()
395 be32_to_cpu(r2->inobt.ir_startino); in xfs_inobt_recs_inorder()
400 struct xfs_btree_cur *cur, in xfs_inobt_keys_contiguous() argument
405 ASSERT(!mask || mask->inobt.ir_startino); in xfs_inobt_keys_contiguous()
407 return xbtree_key_contig(be32_to_cpu(key1->inobt.ir_startino), in xfs_inobt_keys_contiguous()
408 be32_to_cpu(key2->inobt.ir_startino)); in xfs_inobt_keys_contiguous()
483 struct xfs_btree_cur *cur; in xfs_inobt_init_cursor() local
485 cur = xfs_btree_alloc_cursor(mp, tp, &xfs_inobt_ops, in xfs_inobt_init_cursor()
486 M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache); in xfs_inobt_init_cursor()
487 cur->bc_group = xfs_group_hold(pag_group(pag)); in xfs_inobt_init_cursor()
488 cur->bc_ag.agbp = agbp; in xfs_inobt_init_cursor()
490 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_init_cursor()
492 cur->bc_nlevels = be32_to_cpu(agi->agi_level); in xfs_inobt_init_cursor()
494 return cur; in xfs_inobt_init_cursor()
509 struct xfs_btree_cur *cur; in xfs_finobt_init_cursor() local
511 cur = xfs_btree_alloc_cursor(mp, tp, &xfs_finobt_ops, in xfs_finobt_init_cursor()
512 M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache); in xfs_finobt_init_cursor()
513 cur->bc_group = xfs_group_hold(pag_group(pag)); in xfs_finobt_init_cursor()
514 cur->bc_ag.agbp = agbp; in xfs_finobt_init_cursor()
516 struct xfs_agi *agi = agbp->b_addr; in xfs_finobt_init_cursor()
518 cur->bc_nlevels = be32_to_cpu(agi->agi_free_level); in xfs_finobt_init_cursor()
520 return cur; in xfs_finobt_init_cursor()
529 struct xfs_btree_cur *cur, in xfs_inobt_commit_staged_btree() argument
533 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_commit_staged_btree()
534 struct xbtree_afakeroot *afake = cur->bc_ag.afake; in xfs_inobt_commit_staged_btree()
537 ASSERT(cur->bc_flags & XFS_BTREE_STAGING); in xfs_inobt_commit_staged_btree()
539 if (xfs_btree_is_ino(cur->bc_ops)) { in xfs_inobt_commit_staged_btree()
541 agi->agi_root = cpu_to_be32(afake->af_root); in xfs_inobt_commit_staged_btree()
542 agi->agi_level = cpu_to_be32(afake->af_levels); in xfs_inobt_commit_staged_btree()
543 if (xfs_has_inobtcounts(cur->bc_mp)) { in xfs_inobt_commit_staged_btree()
544 agi->agi_iblocks = cpu_to_be32(afake->af_blocks); in xfs_inobt_commit_staged_btree()
548 xfs_btree_commit_afakeroot(cur, tp, agbp); in xfs_inobt_commit_staged_btree()
551 agi->agi_free_root = cpu_to_be32(afake->af_root); in xfs_inobt_commit_staged_btree()
552 agi->agi_free_level = cpu_to_be32(afake->af_levels); in xfs_inobt_commit_staged_btree()
553 if (xfs_has_inobtcounts(cur->bc_mp)) { in xfs_inobt_commit_staged_btree()
554 agi->agi_fblocks = cpu_to_be32(afake->af_blocks); in xfs_inobt_commit_staged_btree()
558 xfs_btree_commit_afakeroot(cur, tp, agbp); in xfs_inobt_commit_staged_btree()
582 blocklen -= XFS_INOBT_BLOCK_LEN(mp); in xfs_inobt_maxrecs()
591 ((XFS_MAX_AG_BYTES - (4 * BBSIZE)) / XFS_DINODE_MIN_SIZE) / \
594 /* Compute the max possible height for the inode btree. */
601 blocklen = min(XFS_MIN_BLOCKSIZE - XFS_BTREE_SBLOCK_LEN, in xfs_inobt_maxlevels_ondisk()
602 XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN); in xfs_inobt_maxlevels_ondisk()
610 /* Compute the max possible height for the free inode btree. */
617 blocklen = XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN; in xfs_finobt_maxlevels_ondisk()
625 /* Compute the max possible height for either inode btree. */
629 return max(xfs_inobt_maxlevels_ondisk(), in xfs_iallocbt_maxlevels_ondisk()
651 * The holemask has 16-bits for a 64 inode record. Therefore each in xfs_inobt_irec_to_allocmask()
655 inodespbit = (1 << XFS_INODES_PER_HOLEMASK_BIT) - 1; in xfs_inobt_irec_to_allocmask()
663 allocbitmap = ~rec->ir_holemask & ((1 << XFS_INOBT_HOLEMASK_BITS) - 1); in xfs_inobt_irec_to_allocmask()
667 * allocated inodes. To expand from 16-bit holemask granularity to in xfs_inobt_irec_to_allocmask()
668 * 64-bit (e.g., bit-per-inode), set inodespbit bits in the target in xfs_inobt_irec_to_allocmask()
672 while (nextbit != -1) { in xfs_inobt_irec_to_allocmask()
673 ASSERT(nextbit < (sizeof(rec->ir_holemask) * NBBY)); in xfs_inobt_irec_to_allocmask()
686 * Verify that an in-core inode record has a valid inode count.
702 while (nextbit != -1) { in xfs_inobt_rec_check_count()
708 if (inocount != rec->ir_count) in xfs_inobt_rec_check_count()
709 return -EFSCORRUPTED; in xfs_inobt_rec_check_count()
720 xfs_agblock_t agblocks = pag_group(pag)->xg_block_count; in xfs_inobt_max_size()
723 if (M_IGEO(mp)->inobt_mxr[0] == 0) in xfs_inobt_max_size()
732 agblocks -= mp->m_sb.sb_logblocks; in xfs_inobt_max_size()
734 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, in xfs_inobt_max_size()
735 (uint64_t)agblocks * mp->m_sb.sb_inopblock / in xfs_inobt_max_size()
746 struct xfs_btree_cur *cur; in xfs_finobt_count_blocks() local
754 cur = xfs_finobt_init_cursor(pag, tp, agbp); in xfs_finobt_count_blocks()
755 error = xfs_btree_count_blocks(cur, &blocks); in xfs_finobt_count_blocks()
756 xfs_btree_del_cursor(cur, error); in xfs_finobt_count_blocks()
778 agi = agbp->b_addr; in xfs_finobt_read_blocks()
779 *tree_blocks = be32_to_cpu(agi->agi_fblocks); in xfs_finobt_read_blocks()
818 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, len); in xfs_iallocbt_calc_size()
829 return -ENOMEM; in xfs_inobt_init_cur_cache()