Lines Matching +full:max +full:- +full:cur
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
29 struct xfs_btree_cur *cur, in xfs_inobt_get_minrecs() argument
32 return M_IGEO(cur->bc_mp)->inobt_mnr[level != 0]; in xfs_inobt_get_minrecs()
37 struct xfs_btree_cur *cur) in xfs_inobt_dup_cursor() argument
39 return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp, in xfs_inobt_dup_cursor()
40 cur->bc_ag.agbp, cur->bc_ag.pag, cur->bc_btnum); in xfs_inobt_dup_cursor()
45 struct xfs_btree_cur *cur, in xfs_inobt_set_root() argument
49 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_inobt_set_root()
50 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_set_root()
52 agi->agi_root = nptr->s; in xfs_inobt_set_root()
53 be32_add_cpu(&agi->agi_level, inc); in xfs_inobt_set_root()
54 xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_ROOT | XFS_AGI_LEVEL); in xfs_inobt_set_root()
59 struct xfs_btree_cur *cur, in xfs_finobt_set_root() argument
63 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_finobt_set_root()
64 struct xfs_agi *agi = agbp->b_addr; in xfs_finobt_set_root()
66 agi->agi_free_root = nptr->s; in xfs_finobt_set_root()
67 be32_add_cpu(&agi->agi_free_level, inc); in xfs_finobt_set_root()
68 xfs_ialloc_log_agi(cur->bc_tp, agbp, in xfs_finobt_set_root()
75 struct xfs_btree_cur *cur, in xfs_inobt_mod_blockcount() argument
78 struct xfs_buf *agbp = cur->bc_ag.agbp; in xfs_inobt_mod_blockcount()
79 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_mod_blockcount()
81 if (!xfs_has_inobtcounts(cur->bc_mp)) in xfs_inobt_mod_blockcount()
84 if (cur->bc_btnum == XFS_BTNUM_FINO) in xfs_inobt_mod_blockcount()
85 be32_add_cpu(&agi->agi_fblocks, howmuch); in xfs_inobt_mod_blockcount()
86 else if (cur->bc_btnum == XFS_BTNUM_INO) in xfs_inobt_mod_blockcount()
87 be32_add_cpu(&agi->agi_iblocks, howmuch); in xfs_inobt_mod_blockcount()
88 xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_IBLOCKS); in xfs_inobt_mod_blockcount()
93 struct xfs_btree_cur *cur, in __xfs_inobt_alloc_block() argument
101 xfs_agblock_t sbno = be32_to_cpu(start->s); in __xfs_inobt_alloc_block()
104 args.tp = cur->bc_tp; in __xfs_inobt_alloc_block()
105 args.mp = cur->bc_mp; in __xfs_inobt_alloc_block()
107 args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_ag.pag->pag_agno, sbno); in __xfs_inobt_alloc_block()
124 new->s = cpu_to_be32(XFS_FSB_TO_AGBNO(args.mp, args.fsbno)); in __xfs_inobt_alloc_block()
126 xfs_inobt_mod_blockcount(cur, 1); in __xfs_inobt_alloc_block()
132 struct xfs_btree_cur *cur, in xfs_inobt_alloc_block() argument
137 return __xfs_inobt_alloc_block(cur, start, new, stat, XFS_AG_RESV_NONE); in xfs_inobt_alloc_block()
142 struct xfs_btree_cur *cur, in xfs_finobt_alloc_block() argument
147 if (cur->bc_mp->m_finobt_nores) in xfs_finobt_alloc_block()
148 return xfs_inobt_alloc_block(cur, start, new, stat); in xfs_finobt_alloc_block()
149 return __xfs_inobt_alloc_block(cur, start, new, stat, in xfs_finobt_alloc_block()
155 struct xfs_btree_cur *cur, in __xfs_inobt_free_block() argument
159 xfs_inobt_mod_blockcount(cur, -1); in __xfs_inobt_free_block()
160 return xfs_free_extent(cur->bc_tp, in __xfs_inobt_free_block()
161 XFS_DADDR_TO_FSB(cur->bc_mp, xfs_buf_daddr(bp)), 1, in __xfs_inobt_free_block()
167 struct xfs_btree_cur *cur, in xfs_inobt_free_block() argument
170 return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_NONE); in xfs_inobt_free_block()
175 struct xfs_btree_cur *cur, in xfs_finobt_free_block() argument
178 if (cur->bc_mp->m_finobt_nores) in xfs_finobt_free_block()
179 return xfs_inobt_free_block(cur, bp); in xfs_finobt_free_block()
180 return __xfs_inobt_free_block(cur, bp, XFS_AG_RESV_METADATA); in xfs_finobt_free_block()
185 struct xfs_btree_cur *cur, in xfs_inobt_get_maxrecs() argument
188 return M_IGEO(cur->bc_mp)->inobt_mxr[level != 0]; in xfs_inobt_get_maxrecs()
196 key->inobt.ir_startino = rec->inobt.ir_startino; in xfs_inobt_init_key_from_rec()
206 x = be32_to_cpu(rec->inobt.ir_startino); in xfs_inobt_init_high_key_from_rec()
207 x += XFS_INODES_PER_CHUNK - 1; in xfs_inobt_init_high_key_from_rec()
208 key->inobt.ir_startino = cpu_to_be32(x); in xfs_inobt_init_high_key_from_rec()
213 struct xfs_btree_cur *cur, in xfs_inobt_init_rec_from_cur() argument
216 rec->inobt.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino); in xfs_inobt_init_rec_from_cur()
217 if (xfs_has_sparseinodes(cur->bc_mp)) { in xfs_inobt_init_rec_from_cur()
218 rec->inobt.ir_u.sp.ir_holemask = in xfs_inobt_init_rec_from_cur()
219 cpu_to_be16(cur->bc_rec.i.ir_holemask); in xfs_inobt_init_rec_from_cur()
220 rec->inobt.ir_u.sp.ir_count = cur->bc_rec.i.ir_count; in xfs_inobt_init_rec_from_cur()
221 rec->inobt.ir_u.sp.ir_freecount = cur->bc_rec.i.ir_freecount; in xfs_inobt_init_rec_from_cur()
223 /* ir_holemask/ir_count not supported on-disk */ in xfs_inobt_init_rec_from_cur()
224 rec->inobt.ir_u.f.ir_freecount = in xfs_inobt_init_rec_from_cur()
225 cpu_to_be32(cur->bc_rec.i.ir_freecount); in xfs_inobt_init_rec_from_cur()
227 rec->inobt.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free); in xfs_inobt_init_rec_from_cur()
235 struct xfs_btree_cur *cur, in xfs_inobt_init_ptr_from_cur() argument
238 struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; in xfs_inobt_init_ptr_from_cur()
240 ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno)); in xfs_inobt_init_ptr_from_cur()
242 ptr->s = agi->agi_root; in xfs_inobt_init_ptr_from_cur()
247 struct xfs_btree_cur *cur, in xfs_finobt_init_ptr_from_cur() argument
250 struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; in xfs_finobt_init_ptr_from_cur()
252 ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno)); in xfs_finobt_init_ptr_from_cur()
253 ptr->s = agi->agi_free_root; in xfs_finobt_init_ptr_from_cur()
258 struct xfs_btree_cur *cur, in xfs_inobt_key_diff() argument
261 return (int64_t)be32_to_cpu(key->inobt.ir_startino) - in xfs_inobt_key_diff()
262 cur->bc_rec.i.ir_startino; in xfs_inobt_key_diff()
267 struct xfs_btree_cur *cur, in xfs_inobt_diff_two_keys() argument
271 return (int64_t)be32_to_cpu(k1->inobt.ir_startino) - in xfs_inobt_diff_two_keys()
272 be32_to_cpu(k2->inobt.ir_startino); in xfs_inobt_diff_two_keys()
279 struct xfs_mount *mp = bp->b_mount; in xfs_inobt_verify()
284 if (!xfs_verify_magic(bp, block->bb_magic)) in xfs_inobt_verify()
294 * but beware of the landmine (i.e. need to check pag->pagi_init) if we in xfs_inobt_verify()
304 level = be16_to_cpu(block->bb_level); in xfs_inobt_verify()
305 if (level >= M_IGEO(mp)->inobt_maxlevels) in xfs_inobt_verify()
309 M_IGEO(mp)->inobt_mxr[level != 0]); in xfs_inobt_verify()
319 xfs_verifier_error(bp, -EFSBADCRC, __this_address); in xfs_inobt_read_verify()
323 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_inobt_read_verify()
326 if (bp->b_error) in xfs_inobt_read_verify()
339 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_inobt_write_verify()
365 struct xfs_btree_cur *cur, in xfs_inobt_keys_inorder() argument
369 return be32_to_cpu(k1->inobt.ir_startino) < in xfs_inobt_keys_inorder()
370 be32_to_cpu(k2->inobt.ir_startino); in xfs_inobt_keys_inorder()
375 struct xfs_btree_cur *cur, in xfs_inobt_recs_inorder() argument
379 return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <= in xfs_inobt_recs_inorder()
380 be32_to_cpu(r2->inobt.ir_startino); in xfs_inobt_recs_inorder()
435 struct xfs_btree_cur *cur; in xfs_inobt_init_common() local
437 cur = xfs_btree_alloc_cursor(mp, tp, btnum, in xfs_inobt_init_common()
438 M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache); in xfs_inobt_init_common()
440 cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_ibt_2); in xfs_inobt_init_common()
441 cur->bc_ops = &xfs_inobt_ops; in xfs_inobt_init_common()
443 cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_fibt_2); in xfs_inobt_init_common()
444 cur->bc_ops = &xfs_finobt_ops; in xfs_inobt_init_common()
448 cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; in xfs_inobt_init_common()
451 atomic_inc(&pag->pag_ref); in xfs_inobt_init_common()
452 cur->bc_ag.pag = pag; in xfs_inobt_init_common()
453 return cur; in xfs_inobt_init_common()
465 struct xfs_btree_cur *cur; in xfs_inobt_init_cursor() local
466 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_init_cursor()
468 cur = xfs_inobt_init_common(mp, tp, pag, btnum); in xfs_inobt_init_cursor()
470 cur->bc_nlevels = be32_to_cpu(agi->agi_level); in xfs_inobt_init_cursor()
472 cur->bc_nlevels = be32_to_cpu(agi->agi_free_level); in xfs_inobt_init_cursor()
473 cur->bc_ag.agbp = agbp; in xfs_inobt_init_cursor()
474 return cur; in xfs_inobt_init_cursor()
485 struct xfs_btree_cur *cur; in xfs_inobt_stage_cursor() local
487 cur = xfs_inobt_init_common(mp, NULL, pag, btnum); in xfs_inobt_stage_cursor()
488 xfs_btree_stage_afakeroot(cur, afake); in xfs_inobt_stage_cursor()
489 return cur; in xfs_inobt_stage_cursor()
498 struct xfs_btree_cur *cur, in xfs_inobt_commit_staged_btree() argument
502 struct xfs_agi *agi = agbp->b_addr; in xfs_inobt_commit_staged_btree()
503 struct xbtree_afakeroot *afake = cur->bc_ag.afake; in xfs_inobt_commit_staged_btree()
506 ASSERT(cur->bc_flags & XFS_BTREE_STAGING); in xfs_inobt_commit_staged_btree()
508 if (cur->bc_btnum == XFS_BTNUM_INO) { in xfs_inobt_commit_staged_btree()
510 agi->agi_root = cpu_to_be32(afake->af_root); in xfs_inobt_commit_staged_btree()
511 agi->agi_level = cpu_to_be32(afake->af_levels); in xfs_inobt_commit_staged_btree()
512 if (xfs_has_inobtcounts(cur->bc_mp)) { in xfs_inobt_commit_staged_btree()
513 agi->agi_iblocks = cpu_to_be32(afake->af_blocks); in xfs_inobt_commit_staged_btree()
517 xfs_btree_commit_afakeroot(cur, tp, agbp, &xfs_inobt_ops); in xfs_inobt_commit_staged_btree()
520 agi->agi_free_root = cpu_to_be32(afake->af_root); in xfs_inobt_commit_staged_btree()
521 agi->agi_free_level = cpu_to_be32(afake->af_levels); in xfs_inobt_commit_staged_btree()
522 if (xfs_has_inobtcounts(cur->bc_mp)) { in xfs_inobt_commit_staged_btree()
523 agi->agi_fblocks = cpu_to_be32(afake->af_blocks); in xfs_inobt_commit_staged_btree()
527 xfs_btree_commit_afakeroot(cur, tp, agbp, &xfs_finobt_ops); in xfs_inobt_commit_staged_btree()
551 blocklen -= XFS_INOBT_BLOCK_LEN(mp); in xfs_inobt_maxrecs()
560 ((XFS_MAX_AG_BYTES - (4 * BBSIZE)) / XFS_DINODE_MIN_SIZE) / \
563 /* Compute the max possible height for the inode btree. */
570 blocklen = min(XFS_MIN_BLOCKSIZE - XFS_BTREE_SBLOCK_LEN, in xfs_inobt_maxlevels_ondisk()
571 XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN); in xfs_inobt_maxlevels_ondisk()
579 /* Compute the max possible height for the free inode btree. */
586 blocklen = XFS_MIN_CRC_BLOCKSIZE - XFS_BTREE_SBLOCK_CRC_LEN; in xfs_finobt_maxlevels_ondisk()
594 /* Compute the max possible height for either inode btree. */
598 return max(xfs_inobt_maxlevels_ondisk(), in xfs_iallocbt_maxlevels_ondisk()
620 * The holemask has 16-bits for a 64 inode record. Therefore each in xfs_inobt_irec_to_allocmask()
624 inodespbit = (1 << XFS_INODES_PER_HOLEMASK_BIT) - 1; in xfs_inobt_irec_to_allocmask()
632 allocbitmap = ~rec->ir_holemask & ((1 << XFS_INOBT_HOLEMASK_BITS) - 1); in xfs_inobt_irec_to_allocmask()
636 * allocated inodes. To expand from 16-bit holemask granularity to in xfs_inobt_irec_to_allocmask()
637 * 64-bit (e.g., bit-per-inode), set inodespbit bits in the target in xfs_inobt_irec_to_allocmask()
641 while (nextbit != -1) { in xfs_inobt_irec_to_allocmask()
642 ASSERT(nextbit < (sizeof(rec->ir_holemask) * NBBY)); in xfs_inobt_irec_to_allocmask()
655 * Verify that an in-core inode record has a valid inode count.
671 while (nextbit != -1) { in xfs_inobt_rec_check_count()
677 if (inocount != rec->ir_count) in xfs_inobt_rec_check_count()
678 return -EFSCORRUPTED; in xfs_inobt_rec_check_count()
688 struct xfs_mount *mp = pag->pag_mount; in xfs_inobt_max_size()
689 xfs_agblock_t agblocks = pag->block_count; in xfs_inobt_max_size()
692 if (M_IGEO(mp)->inobt_mxr[0] == 0) in xfs_inobt_max_size()
700 if (xfs_ag_contains_log(mp, pag->pag_agno)) in xfs_inobt_max_size()
701 agblocks -= mp->m_sb.sb_logblocks; in xfs_inobt_max_size()
703 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, in xfs_inobt_max_size()
704 (uint64_t)agblocks * mp->m_sb.sb_inopblock / in xfs_inobt_max_size()
718 struct xfs_btree_cur *cur; in xfs_inobt_cur() local
728 cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, pag, which); in xfs_inobt_cur()
729 *curpp = cur; in xfs_inobt_cur()
742 struct xfs_btree_cur *cur = NULL; in xfs_inobt_count_blocks() local
745 error = xfs_inobt_cur(mp, tp, pag, btnum, &cur, &agbp); in xfs_inobt_count_blocks()
749 error = xfs_btree_count_blocks(cur, tree_blocks); in xfs_inobt_count_blocks()
750 xfs_btree_del_cursor(cur, error); in xfs_inobt_count_blocks()
771 agi = agbp->b_addr; in xfs_finobt_read_blocks()
772 *tree_blocks = be32_to_cpu(agi->agi_fblocks); in xfs_finobt_read_blocks()
813 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, len); in xfs_iallocbt_calc_size()
824 return -ENOMEM; in xfs_inobt_init_cur_cache()