Lines Matching +full:ip +full:- +full:block
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
62 int maxrootrecs; /* max records in root block */ in xfs_bmap_compute_maxlevels()
63 int minleafrecs; /* min records in leaf block */ in xfs_bmap_compute_maxlevels()
64 int minnoderecs; /* min records in node block */ in xfs_bmap_compute_maxlevels()
65 int sz; /* root block size */ in xfs_bmap_compute_maxlevels()
69 * leaf entries, is controlled by the size of the on-disk extent count. in xfs_bmap_compute_maxlevels()
73 * (xfs_default_attroffset(ip) >> 3) because we could have mounted with in xfs_bmap_compute_maxlevels()
87 minleafrecs = mp->m_bmap_dmnr[0]; in xfs_bmap_compute_maxlevels()
88 minnoderecs = mp->m_bmap_dmnr[1]; in xfs_bmap_compute_maxlevels()
96 mp->m_bm_maxlevels[whichfork] = level; in xfs_bmap_compute_maxlevels()
97 ASSERT(mp->m_bm_maxlevels[whichfork] <= xfs_bmbt_maxlevels_ondisk()); in xfs_bmap_compute_maxlevels()
104 if (mp->m_sb.sb_inodesize == 256) in xfs_bmap_compute_attr_offset()
105 return XFS_LITINO(mp) - xfs_bmdr_space_calc(MINABTPTRS); in xfs_bmap_compute_attr_offset()
115 cur->bc_rec.b = *irec; in xfs_bmbt_lookup_eq()
124 cur->bc_rec.b.br_startoff = 0; in xfs_bmbt_lookup_first()
125 cur->bc_rec.b.br_startblock = 0; in xfs_bmbt_lookup_first()
126 cur->bc_rec.b.br_blockcount = 0; in xfs_bmbt_lookup_first()
133 static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork) in xfs_bmap_needs_btree() argument
135 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_needs_btree()
138 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_needs_btree()
139 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_needs_btree()
145 static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork) in xfs_bmap_wants_extents() argument
147 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_wants_extents()
150 ifp->if_format == XFS_DINODE_FMT_BTREE && in xfs_bmap_wants_extents()
151 ifp->if_nextents <= XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_wants_extents()
170 * Compute the worst-case number of indirect blocks that will be used
171 * for ip's delayed extent of length "len".
175 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_worst_indlen() argument
183 mp = ip->i_mount; in xfs_bmap_worst_indlen()
184 maxrecs = mp->m_bmap_dmxr[0]; in xfs_bmap_worst_indlen()
188 len += maxrecs - 1; in xfs_bmap_worst_indlen()
192 return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - in xfs_bmap_worst_indlen()
193 level - 1; in xfs_bmap_worst_indlen()
195 maxrecs = mp->m_bmap_dmxr[1]; in xfs_bmap_worst_indlen()
205 struct xfs_inode *ip) in xfs_default_attroffset() argument
207 if (ip->i_df.if_format == XFS_DINODE_FMT_DEV) in xfs_default_attroffset()
209 return M_IGEO(ip->i_mount)->attr_fork_offset; in xfs_default_attroffset()
214 * from local to extent format - we reset it where possible to make space
219 xfs_inode_t *ip, in xfs_bmap_forkoff_reset() argument
223 ip->i_df.if_format != XFS_DINODE_FMT_DEV && in xfs_bmap_forkoff_reset()
224 ip->i_df.if_format != XFS_DINODE_FMT_BTREE) { in xfs_bmap_forkoff_reset()
225 uint dfl_forkoff = xfs_default_attroffset(ip) >> 3; in xfs_bmap_forkoff_reset()
227 if (dfl_forkoff > ip->i_forkoff) in xfs_bmap_forkoff_reset()
228 ip->i_forkoff = dfl_forkoff; in xfs_bmap_forkoff_reset()
236 xfs_fsblock_t fsbno, /* file system block number */ in xfs_bmap_read_buf()
243 return -EFSCORRUPTED; in xfs_bmap_read_buf()
244 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, in xfs_bmap_read_buf()
245 XFS_FSB_TO_DADDR(mp, fsbno), mp->m_bsize, 0, &bp, in xfs_bmap_read_buf()
266 for (i = 0; i < cur->bc_maxlevels; i++) { in xfs_bmap_get_bp()
267 if (!cur->bc_levels[i].bp) in xfs_bmap_get_bp()
269 if (xfs_buf_daddr(cur->bc_levels[i].bp) == bno) in xfs_bmap_get_bp()
270 return cur->bc_levels[i].bp; in xfs_bmap_get_bp()
274 list_for_each_entry(lip, &cur->bc_tp->t_items, li_trans) { in xfs_bmap_get_bp()
277 if (bip->bli_item.li_type == XFS_LI_BUF && in xfs_bmap_get_bp()
278 xfs_buf_daddr(bip->bli_buf) == bno) in xfs_bmap_get_bp()
279 return bip->bli_buf; in xfs_bmap_get_bp()
287 struct xfs_btree_block *block, in xfs_check_block() argument
293 __be64 *pp, *thispa; /* pointer to block address */ in xfs_check_block()
296 ASSERT(be16_to_cpu(block->bb_level) > 0); in xfs_check_block()
299 for( i = 1; i <= xfs_btree_get_numrecs(block); i++) { in xfs_check_block()
300 dmxr = mp->m_bmap_dmxr[0]; in xfs_check_block()
301 keyp = xfs_bmbt_key_addr(mp, block, i); in xfs_check_block()
304 ASSERT(be64_to_cpu(prevp->br_startoff) < in xfs_check_block()
305 be64_to_cpu(keyp->br_startoff)); in xfs_check_block()
310 * Compare the block numbers to see if there are dups. in xfs_check_block()
313 pp = xfs_bmap_broot_ptr_addr(mp, block, i, sz); in xfs_check_block()
315 pp = xfs_bmbt_ptr_addr(mp, block, i, dmxr); in xfs_check_block()
317 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { in xfs_check_block()
319 thispa = xfs_bmap_broot_ptr_addr(mp, block, j, sz); in xfs_check_block()
321 thispa = xfs_bmbt_ptr_addr(mp, block, j, dmxr); in xfs_check_block()
335 * Check that the extents for the inode ip are in the right order in all
344 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_check_leaf_extents() argument
347 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_check_leaf_extents()
348 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_check_leaf_extents()
349 struct xfs_btree_block *block; /* current btree block */ in xfs_bmap_check_leaf_extents() local
350 xfs_fsblock_t bno; /* block # of "block" */ in xfs_bmap_check_leaf_extents()
351 struct xfs_buf *bp; /* buffer for "block" */ in xfs_bmap_check_leaf_extents()
355 __be64 *pp; /* pointer to block address */ in xfs_bmap_check_leaf_extents()
357 xfs_bmbt_rec_t last = {0, 0}; /* last extent in prev block */ in xfs_bmap_check_leaf_extents()
361 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmap_check_leaf_extents()
365 if (ip->i_df.if_nextents > 10000) in xfs_bmap_check_leaf_extents()
369 block = ifp->if_broot; in xfs_bmap_check_leaf_extents()
373 level = be16_to_cpu(block->bb_level); in xfs_bmap_check_leaf_extents()
375 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
376 pp = xfs_bmap_broot_ptr_addr(mp, block, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
380 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); in xfs_bmap_check_leaf_extents()
381 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); in xfs_bmap_check_leaf_extents()
387 while (level-- > 0) { in xfs_bmap_check_leaf_extents()
399 block = XFS_BUF_TO_BLOCK(bp); in xfs_bmap_check_leaf_extents()
404 * Check this block for basic sanity (increasing keys and in xfs_bmap_check_leaf_extents()
408 xfs_check_block(block, mp, 0, 0); in xfs_bmap_check_leaf_extents()
409 pp = xfs_bmbt_ptr_addr(mp, block, 1, mp->m_bmap_dmxr[1]); in xfs_bmap_check_leaf_extents()
413 error = -EFSCORRUPTED; in xfs_bmap_check_leaf_extents()
423 * Here with bp and block set to the leftmost leaf node in the tree. in xfs_bmap_check_leaf_extents()
435 num_recs = xfs_btree_get_numrecs(block); in xfs_bmap_check_leaf_extents()
438 * Read-ahead the next leaf block, if any. in xfs_bmap_check_leaf_extents()
441 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); in xfs_bmap_check_leaf_extents()
445 * If we had a previous block, the last entry should in xfs_bmap_check_leaf_extents()
449 ep = xfs_bmbt_rec_addr(mp, block, 1); in xfs_bmap_check_leaf_extents()
456 nextp = xfs_bmbt_rec_addr(mp, block, j + 1); in xfs_bmap_check_leaf_extents()
486 block = XFS_BUF_TO_BLOCK(bp); in xfs_bmap_check_leaf_extents()
535 mval[i - 1].br_startoff + mval[i - 1].br_blockcount == in xfs_bmap_validate_ret()
545 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0) argument
557 * Since the extents are already in-core, all we have to do is give up the space
558 * for the btree root and pitch the leaf block.
563 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_btree_to_extents() argument
568 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_btree_to_extents()
569 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_btree_to_extents()
570 struct xfs_btree_block *rblock = ifp->if_broot; in xfs_bmap_btree_to_extents()
571 struct xfs_btree_block *cblock;/* child btree block */ in xfs_bmap_btree_to_extents()
572 xfs_fsblock_t cbno; /* child block number */ in xfs_bmap_btree_to_extents()
573 struct xfs_buf *cbp; /* child block's buffer */ in xfs_bmap_btree_to_extents()
575 __be64 *pp; /* ptr to block address */ in xfs_bmap_btree_to_extents()
579 if (!xfs_bmap_wants_extents(ip, whichfork)) in xfs_bmap_btree_to_extents()
584 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in xfs_bmap_btree_to_extents()
585 ASSERT(be16_to_cpu(rblock->bb_level) == 1); in xfs_bmap_btree_to_extents()
586 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); in xfs_bmap_btree_to_extents()
587 ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, false) == 1); in xfs_bmap_btree_to_extents()
589 pp = xfs_bmap_broot_ptr_addr(mp, rblock, 1, ifp->if_broot_bytes); in xfs_bmap_btree_to_extents()
592 if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_verify_fsbno(mp, cbno))) { in xfs_bmap_btree_to_extents()
594 return -EFSCORRUPTED; in xfs_bmap_btree_to_extents()
606 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); in xfs_bmap_btree_to_extents()
607 error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo, in xfs_bmap_btree_to_extents()
612 ip->i_nblocks--; in xfs_bmap_btree_to_extents()
613 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_btree_to_extents()
615 if (cur->bc_levels[0].bp == cbp) in xfs_bmap_btree_to_extents()
616 cur->bc_levels[0].bp = NULL; in xfs_bmap_btree_to_extents()
617 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_btree_to_extents()
618 ASSERT(ifp->if_broot == NULL); in xfs_bmap_btree_to_extents()
619 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_btree_to_extents()
625 * Convert an extents-format file into a btree-format file.
626 * The new file will have a root block (in the inode) and a single child block.
631 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_extents_to_btree() argument
637 struct xfs_btree_block *ablock; /* allocated (child) bt block */ in xfs_bmap_extents_to_btree()
641 struct xfs_btree_block *block; /* btree root block */ in xfs_bmap_extents_to_btree() local
645 struct xfs_bmbt_key *kp; /* root block key pointer */ in xfs_bmap_extents_to_btree()
647 xfs_bmbt_ptr_t *pp; /* root block address pointer */ in xfs_bmap_extents_to_btree()
652 mp = ip->i_mount; in xfs_bmap_extents_to_btree()
654 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_extents_to_btree()
655 ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_bmap_extents_to_btree()
661 xfs_iroot_realloc(ip, 1, whichfork); in xfs_bmap_extents_to_btree()
666 block = ifp->if_broot; in xfs_bmap_extents_to_btree()
667 xfs_bmbt_init_block(ip, block, NULL, 1, 1); in xfs_bmap_extents_to_btree()
671 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_extents_to_btree()
673 cur->bc_flags |= XFS_BTREE_BMBT_WASDEL; in xfs_bmap_extents_to_btree()
677 ifp->if_format = XFS_DINODE_FMT_BTREE; in xfs_bmap_extents_to_btree()
681 xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork); in xfs_bmap_extents_to_btree()
687 XFS_INO_TO_FSB(mp, ip->i_ino)); in xfs_bmap_extents_to_btree()
695 error = -ENOSPC; in xfs_bmap_extents_to_btree()
699 cur->bc_bmap.allocated++; in xfs_bmap_extents_to_btree()
700 ip->i_nblocks++; in xfs_bmap_extents_to_btree()
701 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); in xfs_bmap_extents_to_btree()
702 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, in xfs_bmap_extents_to_btree()
704 mp->m_bsize, 0, &abp); in xfs_bmap_extents_to_btree()
709 * Fill in the child block. in xfs_bmap_extents_to_btree()
712 xfs_bmbt_init_block(ip, ablock, abp, 0, 0); in xfs_bmap_extents_to_btree()
721 ASSERT(cnt == ifp->if_nextents); in xfs_bmap_extents_to_btree()
727 kp = xfs_bmbt_key_addr(mp, block, 1); in xfs_bmap_extents_to_btree()
729 kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); in xfs_bmap_extents_to_btree()
730 pp = xfs_bmbt_ptr_addr(mp, block, 1, xfs_bmbt_get_maxrecs(cur, in xfs_bmap_extents_to_btree()
731 be16_to_cpu(block->bb_level))); in xfs_bmap_extents_to_btree()
739 xfs_btree_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs)); in xfs_bmap_extents_to_btree()
746 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_extents_to_btree()
748 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_extents_to_btree()
749 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_extents_to_btree()
750 ASSERT(ifp->if_broot == NULL); in xfs_bmap_extents_to_btree()
760 * (The bmap-level manipulations are ok, though).
765 struct xfs_inode *ip, in xfs_bmap_local_to_extents_empty() argument
768 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_local_to_extents_empty()
771 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents_empty()
772 ASSERT(ifp->if_bytes == 0); in xfs_bmap_local_to_extents_empty()
773 ASSERT(ifp->if_nextents == 0); in xfs_bmap_local_to_extents_empty()
775 xfs_bmap_forkoff_reset(ip, whichfork); in xfs_bmap_local_to_extents_empty()
776 ifp->if_data = NULL; in xfs_bmap_local_to_extents_empty()
777 ifp->if_height = 0; in xfs_bmap_local_to_extents_empty()
778 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_local_to_extents_empty()
779 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmap_local_to_extents_empty()
786 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_local_to_extents() argument
792 struct xfs_inode *ip, in xfs_bmap_local_to_extents() argument
800 struct xfs_buf *bp; /* buffer for extent block */ in xfs_bmap_local_to_extents()
808 ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK)); in xfs_bmap_local_to_extents()
809 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_local_to_extents()
810 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents()
812 if (!ifp->if_bytes) { in xfs_bmap_local_to_extents()
813 xfs_bmap_local_to_extents_empty(tp, ip, whichfork); in xfs_bmap_local_to_extents()
822 args.mp = ip->i_mount; in xfs_bmap_local_to_extents()
825 xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0); in xfs_bmap_local_to_extents()
828 * Allocate a block. We know we need only one, since the in xfs_bmap_local_to_extents()
834 XFS_INO_TO_FSB(args.mp, ip->i_ino)); in xfs_bmap_local_to_extents()
841 error = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, in xfs_bmap_local_to_extents()
843 args.mp->m_bsize, 0, &bp); in xfs_bmap_local_to_extents()
848 * Initialize the block, copy the data and log the remote buffer. in xfs_bmap_local_to_extents()
855 init_fn(tp, bp, ip, ifp, priv); in xfs_bmap_local_to_extents()
858 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); in xfs_bmap_local_to_extents()
859 xfs_bmap_local_to_extents_empty(tp, ip, whichfork); in xfs_bmap_local_to_extents()
862 ifp->if_data = NULL; in xfs_bmap_local_to_extents()
863 ifp->if_height = 0; in xfs_bmap_local_to_extents()
870 xfs_iext_insert(ip, &icur, &rec, 0); in xfs_bmap_local_to_extents()
872 ifp->if_nextents = 1; in xfs_bmap_local_to_extents()
873 ip->i_nblocks = 1; in xfs_bmap_local_to_extents()
874 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); in xfs_bmap_local_to_extents()
888 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_btree() argument
891 struct xfs_btree_block *block = ip->i_df.if_broot; in xfs_bmap_add_attrfork_btree() local
897 mp = ip->i_mount; in xfs_bmap_add_attrfork_btree()
899 if (xfs_bmap_bmdr_space(block) <= xfs_inode_data_fork_size(ip)) in xfs_bmap_add_attrfork_btree()
902 cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK); in xfs_bmap_add_attrfork_btree()
909 error = -EFSCORRUPTED; in xfs_bmap_add_attrfork_btree()
916 return -ENOSPC; in xfs_bmap_add_attrfork_btree()
918 cur->bc_bmap.allocated = 0; in xfs_bmap_add_attrfork_btree()
933 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_extents() argument
939 if (ip->i_df.if_nextents * sizeof(struct xfs_bmbt_rec) <= in xfs_bmap_add_attrfork_extents()
940 xfs_inode_data_fork_size(ip)) in xfs_bmap_add_attrfork_extents()
943 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags, in xfs_bmap_add_attrfork_extents()
946 cur->bc_bmap.allocated = 0; in xfs_bmap_add_attrfork_extents()
955 * conversion. Some are basic and only require special block initialisation
960 * formatting callout. It should be possible - it's just a very complex
966 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_local() argument
971 if (ip->i_df.if_bytes <= xfs_inode_data_fork_size(ip)) in xfs_bmap_add_attrfork_local()
974 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_bmap_add_attrfork_local()
976 dargs.geo = ip->i_mount->m_dir_geo; in xfs_bmap_add_attrfork_local()
977 dargs.dp = ip; in xfs_bmap_add_attrfork_local()
978 dargs.total = dargs.geo->fsbcount; in xfs_bmap_add_attrfork_local()
981 dargs.owner = ip->i_ino; in xfs_bmap_add_attrfork_local()
985 if (S_ISLNK(VFS_I(ip)->i_mode)) in xfs_bmap_add_attrfork_local()
986 return xfs_bmap_local_to_extents(tp, ip, 1, flags, in xfs_bmap_add_attrfork_local()
992 xfs_bmap_mark_sick(ip, XFS_ATTR_FORK); in xfs_bmap_add_attrfork_local()
993 return -EFSCORRUPTED; in xfs_bmap_add_attrfork_local()
1001 struct xfs_inode *ip, in xfs_bmap_set_attrforkoff() argument
1005 int default_size = xfs_default_attroffset(ip) >> 3; in xfs_bmap_set_attrforkoff()
1007 switch (ip->i_df.if_format) { in xfs_bmap_set_attrforkoff()
1009 ip->i_forkoff = default_size; in xfs_bmap_set_attrforkoff()
1014 ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size); in xfs_bmap_set_attrforkoff()
1015 if (!ip->i_forkoff) in xfs_bmap_set_attrforkoff()
1016 ip->i_forkoff = default_size; in xfs_bmap_set_attrforkoff()
1017 else if (xfs_has_attr2(ip->i_mount) && version) in xfs_bmap_set_attrforkoff()
1022 return -EINVAL; in xfs_bmap_set_attrforkoff()
1029 * Convert inode from non-attributed to attributed. Caller must hold the
1035 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork() argument
1039 struct xfs_mount *mp = tp->t_mountp; in xfs_bmap_add_attrfork()
1044 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_bmap_add_attrfork()
1045 ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); in xfs_bmap_add_attrfork()
1046 ASSERT(!xfs_inode_has_attr_fork(ip)); in xfs_bmap_add_attrfork()
1048 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmap_add_attrfork()
1049 error = xfs_bmap_set_attrforkoff(ip, size, &version); in xfs_bmap_add_attrfork()
1053 xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0); in xfs_bmap_add_attrfork()
1055 switch (ip->i_df.if_format) { in xfs_bmap_add_attrfork()
1057 error = xfs_bmap_add_attrfork_local(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1060 error = xfs_bmap_add_attrfork_extents(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1063 error = xfs_bmap_add_attrfork_btree(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1070 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_add_attrfork()
1077 spin_lock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1086 spin_unlock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1105 struct xfs_inode *ip, in xfs_bmap_complain_bad_rec() argument
1110 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_complain_bad_rec()
1122 ip->i_ino, forkname, fa); in xfs_bmap_complain_bad_rec()
1124 "Offset 0x%llx, start block 0x%llx, block count 0x%llx state 0x%x", in xfs_bmap_complain_bad_rec()
1125 irec->br_startoff, irec->br_startblock, irec->br_blockcount, in xfs_bmap_complain_bad_rec()
1126 irec->br_state); in xfs_bmap_complain_bad_rec()
1128 return -EFSCORRUPTED; in xfs_bmap_complain_bad_rec()
1131 /* Stuff every bmbt record from this block into the incore extent map. */
1139 struct xfs_mount *mp = cur->bc_mp; in xfs_iread_bmbt_block()
1140 struct xfs_inode *ip = cur->bc_ino.ip; in xfs_iread_bmbt_block() local
1141 struct xfs_btree_block *block; in xfs_iread_bmbt_block() local
1146 int whichfork = cur->bc_ino.whichfork; in xfs_iread_bmbt_block()
1147 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_iread_bmbt_block()
1149 block = xfs_btree_get_block(cur, level, &bp); in xfs_iread_bmbt_block()
1152 num_recs = xfs_btree_get_numrecs(block); in xfs_iread_bmbt_block()
1153 if (unlikely(ir->loaded + num_recs > ifp->if_nextents)) { in xfs_iread_bmbt_block()
1154 xfs_warn(ip->i_mount, "corrupt dinode %llu, (btree extents).", in xfs_iread_bmbt_block()
1155 (unsigned long long)ip->i_ino); in xfs_iread_bmbt_block()
1156 xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, block, in xfs_iread_bmbt_block()
1157 sizeof(*block), __this_address); in xfs_iread_bmbt_block()
1158 xfs_bmap_mark_sick(ip, whichfork); in xfs_iread_bmbt_block()
1159 return -EFSCORRUPTED; in xfs_iread_bmbt_block()
1163 frp = xfs_bmbt_rec_addr(mp, block, 1); in xfs_iread_bmbt_block()
1164 for (j = 0; j < num_recs; j++, frp++, ir->loaded++) { in xfs_iread_bmbt_block()
1169 fa = xfs_bmap_validate_extent(ip, whichfork, &new); in xfs_iread_bmbt_block()
1171 xfs_inode_verifier_error(ip, -EFSCORRUPTED, in xfs_iread_bmbt_block()
1174 xfs_bmap_mark_sick(ip, whichfork); in xfs_iread_bmbt_block()
1175 return xfs_bmap_complain_bad_rec(ip, whichfork, fa, in xfs_iread_bmbt_block()
1178 xfs_iext_insert(ip, &ir->icur, &new, in xfs_iread_bmbt_block()
1180 trace_xfs_read_extent(ip, &ir->icur, in xfs_iread_bmbt_block()
1182 xfs_iext_next(ifp, &ir->icur); in xfs_iread_bmbt_block()
1189 * Read in extents from a btree-format inode.
1194 struct xfs_inode *ip, in xfs_iread_extents() argument
1198 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_iread_extents()
1199 struct xfs_mount *mp = ip->i_mount; in xfs_iread_extents()
1206 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_iread_extents()
1210 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_iread_extents()
1217 if (XFS_IS_CORRUPT(mp, ir.loaded != ifp->if_nextents)) { in xfs_iread_extents()
1218 xfs_bmap_mark_sick(ip, whichfork); in xfs_iread_extents()
1219 error = -EFSCORRUPTED; in xfs_iread_extents()
1228 smp_store_release(&ifp->if_needextents, 0); in xfs_iread_extents()
1232 xfs_bmap_mark_sick(ip, whichfork); in xfs_iread_extents()
1238 * Returns the relative block number of the first unused block(s) in the given
1240 * lowest-address hole if the fork has holes, else the first block past the end
1241 * of fork. Return 0 if the fork is currently local (in-inode).
1246 struct xfs_inode *ip, /* incore inode */ in xfs_bmap_first_unused() argument
1248 xfs_fileoff_t *first_unused, /* unused block */ in xfs_bmap_first_unused()
1251 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_first_unused()
1258 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) { in xfs_bmap_first_unused()
1265 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_first_unused()
1275 got.br_startoff - max >= len) in xfs_bmap_first_unused()
1286 * Returns the file-relative block number of the last block - 1 before
1294 struct xfs_inode *ip, /* incore inode */ in xfs_bmap_last_before() argument
1295 xfs_fileoff_t *last_block, /* last block */ in xfs_bmap_last_before()
1298 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_last_before()
1303 switch (ifp->if_format) { in xfs_bmap_last_before()
1312 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_last_before()
1313 return -EFSCORRUPTED; in xfs_bmap_last_before()
1316 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_last_before()
1320 if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got)) in xfs_bmap_last_before()
1328 struct xfs_inode *ip, in xfs_bmap_last_extent() argument
1333 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_last_extent()
1337 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_last_extent()
1352 * blocks at the end of the file which do not start at the previous data block,
1355 * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be
1367 bma->aeof = false; in xfs_bmap_isaeof()
1368 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, in xfs_bmap_isaeof()
1374 bma->aeof = true; in xfs_bmap_isaeof()
1382 bma->aeof = bma->offset >= rec.br_startoff + rec.br_blockcount || in xfs_bmap_isaeof()
1383 (bma->offset >= rec.br_startoff && in xfs_bmap_isaeof()
1389 * Returns the file-relative block number of the first block past eof in
1395 struct xfs_inode *ip, in xfs_bmap_last_offset() argument
1399 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_last_offset()
1406 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) in xfs_bmap_last_offset()
1409 if (XFS_IS_CORRUPT(ip->i_mount, !xfs_ifork_has_extents(ifp))) { in xfs_bmap_last_offset()
1410 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_last_offset()
1411 return -EFSCORRUPTED; in xfs_bmap_last_offset()
1414 error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); in xfs_bmap_last_offset()
1434 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmap_add_extent_delay_real()
1435 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
1436 struct xfs_bmbt_irec *new = &bma->got; in xfs_bmap_add_extent_delay_real()
1451 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_delay_real()
1452 ASSERT(!bma->cur || (bma->cur->bc_flags & XFS_BTREE_BMBT_WASDEL)); in xfs_bmap_add_extent_delay_real()
1463 xfs_iext_get_extent(ifp, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1464 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1466 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_delay_real()
1476 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_delay_real()
1485 if (xfs_iext_peek_prev_extent(ifp, &bma->icur, &LEFT)) { in xfs_bmap_add_extent_delay_real()
1492 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_delay_real()
1493 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_delay_real()
1494 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_delay_real()
1495 LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_delay_real()
1501 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_delay_real()
1503 if (xfs_iext_peek_next_extent(ifp, &bma->icur, &RIGHT)) { in xfs_bmap_add_extent_delay_real()
1511 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_delay_real()
1512 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_delay_real()
1513 new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_delay_real()
1518 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_delay_real()
1536 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1537 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1538 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1539 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1540 ifp->if_nextents--; in xfs_bmap_add_extent_delay_real()
1542 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1546 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1550 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1551 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1554 error = xfs_btree_delete(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1558 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1559 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1562 error = xfs_btree_decrement(bma->cur, 0, &i); in xfs_bmap_add_extent_delay_real()
1566 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1567 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1570 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1585 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1586 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1587 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1589 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1593 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1597 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1598 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1601 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1612 * with delay -> unwritten extent allocation here because the in xfs_bmap_add_extent_delay_real()
1615 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1617 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1619 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1620 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1621 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1622 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1624 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1628 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1632 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1633 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1636 error = xfs_bmbt_update(bma->cur, &PREV); in xfs_bmap_add_extent_delay_real()
1649 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1650 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1651 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1652 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1654 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1658 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1662 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1663 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1666 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1670 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1671 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1684 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1685 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1688 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1691 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1694 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1695 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1696 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1698 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1702 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1706 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1707 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1710 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1722 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1723 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1725 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1729 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1733 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1734 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1737 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1741 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1742 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1747 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1748 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1749 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1755 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1756 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1757 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1758 (bma->cur ? bma->cur->bc_bmap.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1763 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1764 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1765 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1774 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_delay_real()
1775 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1776 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1778 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1782 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1786 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1787 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1790 error = xfs_bmbt_update(bma->cur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1795 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1796 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1802 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1803 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1804 xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1813 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1814 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1816 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1820 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1824 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1825 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1828 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1832 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1833 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1838 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1839 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1840 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1846 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1847 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1848 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1849 (bma->cur ? bma->cur->bc_bmap.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1853 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1854 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1888 PREV.br_startoff + PREV.br_blockcount - new_endoff; in xfs_bmap_add_extent_delay_real()
1890 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1894 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_delay_real()
1896 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1898 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1900 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1901 xfs_iext_insert(bma->ip, &bma->icur, &RIGHT, state); in xfs_bmap_add_extent_delay_real()
1902 xfs_iext_insert(bma->ip, &bma->icur, &LEFT, state); in xfs_bmap_add_extent_delay_real()
1903 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1905 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1909 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1913 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1914 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1917 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1921 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1922 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1927 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1928 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1929 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1953 if (!(bma->flags & XFS_BMAPI_NORMAP)) in xfs_bmap_add_extent_delay_real()
1954 xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new); in xfs_bmap_add_extent_delay_real()
1957 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1960 ASSERT(bma->cur == NULL); in xfs_bmap_add_extent_delay_real()
1961 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1962 &bma->cur, da_old > 0, &tmp_logflags, in xfs_bmap_add_extent_delay_real()
1964 bma->logflags |= tmp_logflags; in xfs_bmap_add_extent_delay_real()
1970 xfs_mod_delalloc(bma->ip, 0, (int64_t)da_new - da_old); in xfs_bmap_add_extent_delay_real()
1972 if (bma->cur) { in xfs_bmap_add_extent_delay_real()
1973 da_new += bma->cur->bc_bmap.allocated; in xfs_bmap_add_extent_delay_real()
1974 bma->cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_delay_real()
1979 xfs_add_fdblocks(mp, da_old - da_new); in xfs_bmap_add_extent_delay_real()
1981 error = xfs_dec_fdblocks(mp, da_new - da_old, true); in xfs_bmap_add_extent_delay_real()
1983 xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
1986 bma->logflags |= rval; in xfs_bmap_add_extent_delay_real()
1999 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_extent_unwritten_real() argument
2015 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_unwritten_real()
2021 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_add_extent_unwritten_real()
2023 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_unwritten_real()
2036 ASSERT(new->br_state != PREV.br_state); in xfs_bmap_add_extent_unwritten_real()
2037 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2038 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_unwritten_real()
2045 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_unwritten_real()
2061 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_unwritten_real()
2062 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_unwritten_real()
2063 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_unwritten_real()
2064 LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_unwritten_real()
2070 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_unwritten_real()
2080 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_unwritten_real()
2081 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_unwritten_real()
2082 new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_unwritten_real()
2087 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_unwritten_real()
2104 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2105 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2107 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2108 ifp->if_nextents -= 2; in xfs_bmap_add_extent_unwritten_real()
2118 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2125 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2132 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2139 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2146 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2162 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2164 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2165 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2175 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2182 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2189 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2204 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2207 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2209 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2210 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2221 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2228 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2235 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2250 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2251 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2262 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2276 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2279 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2280 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2281 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2283 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2285 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2296 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2317 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2318 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2319 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2321 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2322 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_unwritten_real()
2323 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2334 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2340 cur->bc_rec.b = *new; in xfs_bmap_add_extent_unwritten_real()
2345 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2357 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2359 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_unwritten_real()
2360 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_unwritten_real()
2361 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2363 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2365 xfs_iext_update_extent(ip, state, icur, &RIGHT); in xfs_bmap_add_extent_unwritten_real()
2376 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2397 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2399 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2401 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_unwritten_real()
2402 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2413 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2424 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2431 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2444 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_unwritten_real()
2449 old.br_startoff + old.br_blockcount - new_endoff; in xfs_bmap_add_extent_unwritten_real()
2450 r[1].br_startblock = new->br_startblock + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2453 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2455 xfs_iext_insert(ip, icur, &r[1], state); in xfs_bmap_add_extent_unwritten_real()
2456 xfs_iext_insert(ip, icur, &r[0], state); in xfs_bmap_add_extent_unwritten_real()
2457 ifp->if_nextents += 2; in xfs_bmap_add_extent_unwritten_real()
2468 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2471 /* new right extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2475 /* new left extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2476 cur->bc_rec.b = PREV; in xfs_bmap_add_extent_unwritten_real()
2481 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2494 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2497 /* new middle extent - newext */ in xfs_bmap_add_extent_unwritten_real()
2502 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2522 xfs_rmap_convert_extent(mp, tp, ip, whichfork, new); in xfs_bmap_add_extent_unwritten_real()
2525 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_add_extent_unwritten_real()
2529 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in xfs_bmap_add_extent_unwritten_real()
2538 cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_unwritten_real()
2542 xfs_bmap_check_leaf_extents(*curp, ip, whichfork); in xfs_bmap_add_extent_unwritten_real()
2556 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_extent_hole_delay() argument
2569 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_add_extent_hole_delay()
2570 ASSERT(isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_delay()
2583 * If it doesn't exist, we're converting the hole at end-of-file. in xfs_bmap_add_extent_hole_delay()
2596 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_delay()
2597 left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_hole_delay()
2601 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_delay()
2602 new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_hole_delay()
2604 (left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2618 temp = left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2622 startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2624 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2629 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_hole_delay()
2631 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_delay()
2640 temp = left.br_blockcount + new->br_blockcount; in xfs_bmap_add_extent_hole_delay()
2643 startblockval(new->br_startblock); in xfs_bmap_add_extent_hole_delay()
2644 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2650 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_delay()
2659 temp = new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_delay()
2660 oldlen = startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2662 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2664 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_delay()
2667 xfs_iext_update_extent(ip, state, icur, &right); in xfs_bmap_add_extent_hole_delay()
2677 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_hole_delay()
2682 xfs_add_fdblocks(ip->i_mount, oldlen - newlen); in xfs_bmap_add_extent_hole_delay()
2687 xfs_mod_delalloc(ip, 0, (int64_t)newlen - oldlen); in xfs_bmap_add_extent_hole_delay()
2697 struct xfs_inode *ip, in xfs_bmap_add_extent_hole_real() argument
2705 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_add_extent_hole_real()
2706 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_hole_real()
2716 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_real()
2717 ASSERT(!cur || !(cur->bc_flags & XFS_BTREE_BMBT_WASDEL)); in xfs_bmap_add_extent_hole_real()
2745 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_real()
2746 left.br_startblock + left.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_hole_real()
2747 left.br_state == new->br_state && in xfs_bmap_add_extent_hole_real()
2748 left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_hole_real()
2752 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_real()
2753 new->br_startblock + new->br_blockcount == right.br_startblock && in xfs_bmap_add_extent_hole_real()
2754 new->br_state == right.br_state && in xfs_bmap_add_extent_hole_real()
2755 new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_hole_real()
2757 left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_real()
2772 left.br_blockcount += new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_real()
2774 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_hole_real()
2776 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_real()
2777 ifp->if_nextents--; in xfs_bmap_add_extent_hole_real()
2788 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2796 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2804 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2820 left.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2823 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_real()
2834 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2851 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_real()
2852 right.br_startblock = new->br_startblock; in xfs_bmap_add_extent_hole_real()
2853 right.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2854 xfs_iext_update_extent(ip, state, icur, &right); in xfs_bmap_add_extent_hole_real()
2865 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2880 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_hole_real()
2881 ifp->if_nextents++; in xfs_bmap_add_extent_hole_real()
2892 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2900 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2909 xfs_rmap_map_extent(tp, ip, whichfork, new); in xfs_bmap_add_extent_hole_real()
2912 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_add_extent_hole_real()
2916 error = xfs_bmap_extents_to_btree(tp, ip, curp, 0, in xfs_bmap_add_extent_hole_real()
2926 cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_hole_real()
2928 xfs_bmap_check_leaf_extents(cur, ip, whichfork); in xfs_bmap_add_extent_hole_real()
2948 int eof, /* is extent at end-of-file? */ in xfs_bmap_extsize_align()
2975 (orig_off >= gotp->br_startoff) && in xfs_bmap_extsize_align()
2976 (orig_end <= gotp->br_startoff + gotp->br_blockcount)) { in xfs_bmap_extsize_align()
2990 align_off -= temp; in xfs_bmap_extsize_align()
2996 align_alen += extsz - temp; in xfs_bmap_extsize_align()
3007 align_alen -= extsz; in xfs_bmap_extsize_align()
3011 * If the previous block overlaps with this proposed allocation in xfs_bmap_extsize_align()
3014 if (prevp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3015 if (prevp->br_startblock == HOLESTARTBLOCK) in xfs_bmap_extsize_align()
3016 prevo = prevp->br_startoff; in xfs_bmap_extsize_align()
3018 prevo = prevp->br_startoff + prevp->br_blockcount; in xfs_bmap_extsize_align()
3024 * If the next block overlaps with this proposed allocation in xfs_bmap_extsize_align()
3027 * This may of course make the start overlap previous block, in xfs_bmap_extsize_align()
3028 * and if we hit the offset 0 limit then the next block in xfs_bmap_extsize_align()
3031 if (!eof && gotp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3032 if ((delay && gotp->br_startblock == HOLESTARTBLOCK) || in xfs_bmap_extsize_align()
3033 (!delay && gotp->br_startblock == DELAYSTARTBLOCK)) in xfs_bmap_extsize_align()
3034 nexto = gotp->br_startoff + gotp->br_blockcount; in xfs_bmap_extsize_align()
3036 nexto = gotp->br_startoff; in xfs_bmap_extsize_align()
3042 align_off = nexto > align_alen ? nexto - align_alen : 0; in xfs_bmap_extsize_align()
3055 align_alen = nexto - align_off; in xfs_bmap_extsize_align()
3069 align_alen - temp < orig_alen) in xfs_bmap_extsize_align()
3070 return -EINVAL; in xfs_bmap_extsize_align()
3075 align_alen -= temp; in xfs_bmap_extsize_align()
3081 else if (align_off + align_alen - temp >= orig_end) in xfs_bmap_extsize_align()
3082 align_alen -= temp; in xfs_bmap_extsize_align()
3087 align_alen -= orig_off - align_off; in xfs_bmap_extsize_align()
3089 align_alen -= xfs_extlen_to_rtxmod(mp, align_alen); in xfs_bmap_extsize_align()
3095 return -EINVAL; in xfs_bmap_extsize_align()
3104 if (!eof && gotp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3105 ASSERT(align_off + align_alen <= gotp->br_startoff); in xfs_bmap_extsize_align()
3106 if (prevp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3107 ASSERT(align_off >= prevp->br_startoff + prevp->br_blockcount); in xfs_bmap_extsize_align()
3121 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_adjacent_valid()
3123 if (XFS_IS_REALTIME_INODE(ap->ip) && in xfs_bmap_adjacent_valid()
3124 (ap->datatype & XFS_ALLOC_USERDATA)) in xfs_bmap_adjacent_valid()
3125 return x < mp->m_sb.sb_rblocks; in xfs_bmap_adjacent_valid()
3128 XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && in xfs_bmap_adjacent_valid()
3129 XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks; in xfs_bmap_adjacent_valid()
3134 /* returns true if ap->blkno was modified */
3139 xfs_fsblock_t adjust; /* adjustment to block numbers */ in xfs_bmap_adjacent()
3142 * If allocating at eof, and there's a previous real block, in xfs_bmap_adjacent()
3143 * try to use its last block as our starting point. in xfs_bmap_adjacent()
3145 if (ap->eof && ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3146 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3148 ap->prev.br_startblock + ap->prev.br_blockcount, in xfs_bmap_adjacent()
3149 ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3150 ap->blkno = ap->prev.br_startblock + ap->prev.br_blockcount; in xfs_bmap_adjacent()
3154 adjust = ap->offset - in xfs_bmap_adjacent()
3155 (ap->prev.br_startoff + ap->prev.br_blockcount); in xfs_bmap_adjacent()
3156 if (adjust && xfs_bmap_adjacent_valid(ap, ap->blkno + adjust, in xfs_bmap_adjacent()
3157 ap->prev.br_startblock)) in xfs_bmap_adjacent()
3158 ap->blkno += adjust; in xfs_bmap_adjacent()
3166 if (!ap->eof) { in xfs_bmap_adjacent()
3167 xfs_fsblock_t gotbno; /* right side block number */ in xfs_bmap_adjacent()
3169 xfs_fsblock_t prevbno; /* left side block number */ in xfs_bmap_adjacent()
3173 * If there's a previous (left) block, select a requested in xfs_bmap_adjacent()
3174 * start block based on it. in xfs_bmap_adjacent()
3176 if (ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3177 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3178 (prevbno = ap->prev.br_startblock + in xfs_bmap_adjacent()
3179 ap->prev.br_blockcount) && in xfs_bmap_adjacent()
3181 ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3183 * Calculate gap to end of previous block. in xfs_bmap_adjacent()
3185 adjust = prevdiff = ap->offset - in xfs_bmap_adjacent()
3186 (ap->prev.br_startoff + in xfs_bmap_adjacent()
3187 ap->prev.br_blockcount); in xfs_bmap_adjacent()
3189 * Figure the startblock based on the previous block's in xfs_bmap_adjacent()
3193 * allocating, or using it gives us an invalid block in xfs_bmap_adjacent()
3194 * number, then just use the end of the previous block. in xfs_bmap_adjacent()
3196 if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3198 ap->prev.br_startblock)) in xfs_bmap_adjacent()
3204 * No previous block or can't follow it, just default. in xfs_bmap_adjacent()
3209 * If there's a following (right) block, select a requested in xfs_bmap_adjacent()
3210 * start block based on it. in xfs_bmap_adjacent()
3212 if (!isnullstartblock(ap->got.br_startblock)) { in xfs_bmap_adjacent()
3214 * Calculate gap to start of next block. in xfs_bmap_adjacent()
3216 adjust = gotdiff = ap->got.br_startoff - ap->offset; in xfs_bmap_adjacent()
3218 * Figure the startblock based on the next block's in xfs_bmap_adjacent()
3221 gotbno = ap->got.br_startblock; in xfs_bmap_adjacent()
3225 * allocating, or using it gives us an invalid block in xfs_bmap_adjacent()
3226 * number, then just use the start of the next block in xfs_bmap_adjacent()
3229 if (gotdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3230 xfs_bmap_adjacent_valid(ap, gotbno - gotdiff, in xfs_bmap_adjacent()
3232 gotbno -= adjust; in xfs_bmap_adjacent()
3233 else if (xfs_bmap_adjacent_valid(ap, gotbno - ap->length, in xfs_bmap_adjacent()
3235 gotbno -= ap->length; in xfs_bmap_adjacent()
3236 gotdiff += adjust - ap->length; in xfs_bmap_adjacent()
3241 * No next block, just default. in xfs_bmap_adjacent()
3247 * one, else ap->blkno is already set (to 0 or the inode block). in xfs_bmap_adjacent()
3250 ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno; in xfs_bmap_adjacent()
3254 ap->blkno = prevbno; in xfs_bmap_adjacent()
3258 ap->blkno = gotbno; in xfs_bmap_adjacent()
3283 xfs_alloc_min_freelist(pag->pag_mount, pag), in xfs_bmap_longest_free_extent()
3302 if (blen < ap->minlen) in xfs_bmap_select_minlen()
3303 return ap->minlen; in xfs_bmap_select_minlen()
3310 if (blen < args->maxlen) in xfs_bmap_select_minlen()
3312 return args->maxlen; in xfs_bmap_select_minlen()
3321 struct xfs_mount *mp = args->mp; in xfs_bmap_btalloc_select_lengths()
3326 if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_btalloc_select_lengths()
3327 args->total = ap->minlen; in xfs_bmap_btalloc_select_lengths()
3328 args->minlen = ap->minlen; in xfs_bmap_btalloc_select_lengths()
3332 args->total = ap->total; in xfs_bmap_btalloc_select_lengths()
3333 startag = XFS_FSB_TO_AGNO(mp, ap->blkno); in xfs_bmap_btalloc_select_lengths()
3339 error = xfs_bmap_longest_free_extent(pag, args->tp, blen); in xfs_bmap_btalloc_select_lengths()
3340 if (error && error != -EAGAIN) in xfs_bmap_btalloc_select_lengths()
3343 if (*blen >= args->maxlen) in xfs_bmap_btalloc_select_lengths()
3349 args->minlen = xfs_bmap_select_minlen(ap, args, *blen); in xfs_bmap_btalloc_select_lengths()
3358 bool isrt = XFS_IS_REALTIME_INODE(ap->ip) && in xfs_bmap_alloc_account()
3359 !(ap->flags & XFS_BMAPI_ATTRFORK); in xfs_bmap_alloc_account()
3362 if (ap->flags & XFS_BMAPI_COWFORK) { in xfs_bmap_alloc_account()
3364 * COW fork blocks are in-core only and thus are treated as in xfs_bmap_alloc_account()
3365 * in-core quota reservation (like delalloc blocks) even when in xfs_bmap_alloc_account()
3372 if (ap->wasdel) { in xfs_bmap_alloc_account()
3373 xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0); in xfs_bmap_alloc_account()
3379 * has acquired in-core quota reservation for this extent. in xfs_bmap_alloc_account()
3385 ap->ip->i_delayed_blks += ap->length; in xfs_bmap_alloc_account()
3386 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, isrt ? in xfs_bmap_alloc_account()
3388 -(long)ap->length); in xfs_bmap_alloc_account()
3393 ap->ip->i_nblocks += ap->length; in xfs_bmap_alloc_account()
3394 xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); in xfs_bmap_alloc_account()
3395 if (ap->wasdel) { in xfs_bmap_alloc_account()
3396 ap->ip->i_delayed_blks -= ap->length; in xfs_bmap_alloc_account()
3397 xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0); in xfs_bmap_alloc_account()
3403 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length); in xfs_bmap_alloc_account()
3411 struct xfs_mount *mp = args->mp; in xfs_bmap_compute_alignments()
3416 if (mp->m_swidth && xfs_has_swalloc(mp)) in xfs_bmap_compute_alignments()
3417 stripe_align = mp->m_swidth; in xfs_bmap_compute_alignments()
3418 else if (mp->m_dalign) in xfs_bmap_compute_alignments()
3419 stripe_align = mp->m_dalign; in xfs_bmap_compute_alignments()
3421 if (ap->flags & XFS_BMAPI_COWFORK) in xfs_bmap_compute_alignments()
3422 align = xfs_get_cowextsz_hint(ap->ip); in xfs_bmap_compute_alignments()
3423 else if (ap->datatype & XFS_ALLOC_USERDATA) in xfs_bmap_compute_alignments()
3424 align = xfs_get_extsz_hint(ap->ip); in xfs_bmap_compute_alignments()
3426 if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, in xfs_bmap_compute_alignments()
3427 ap->eof, 0, ap->conv, &ap->offset, in xfs_bmap_compute_alignments()
3428 &ap->length)) in xfs_bmap_compute_alignments()
3430 ASSERT(ap->length); in xfs_bmap_compute_alignments()
3435 args->prod = align; in xfs_bmap_compute_alignments()
3436 div_u64_rem(ap->offset, args->prod, &args->mod); in xfs_bmap_compute_alignments()
3437 if (args->mod) in xfs_bmap_compute_alignments()
3438 args->mod = args->prod - args->mod; in xfs_bmap_compute_alignments()
3439 } else if (mp->m_sb.sb_blocksize >= PAGE_SIZE) { in xfs_bmap_compute_alignments()
3440 args->prod = 1; in xfs_bmap_compute_alignments()
3441 args->mod = 0; in xfs_bmap_compute_alignments()
3443 args->prod = PAGE_SIZE >> mp->m_sb.sb_blocklog; in xfs_bmap_compute_alignments()
3444 div_u64_rem(ap->offset, args->prod, &args->mod); in xfs_bmap_compute_alignments()
3445 if (args->mod) in xfs_bmap_compute_alignments()
3446 args->mod = args->prod - args->mod; in xfs_bmap_compute_alignments()
3459 ap->blkno = args->fsbno; in xfs_bmap_process_allocated_extent()
3460 ap->length = args->len; in xfs_bmap_process_allocated_extent()
3473 if (ap->length <= orig_length) in xfs_bmap_process_allocated_extent()
3474 ap->offset = orig_offset; in xfs_bmap_process_allocated_extent()
3475 else if (ap->offset + ap->length < orig_offset + orig_length) in xfs_bmap_process_allocated_extent()
3476 ap->offset = orig_offset + orig_length - ap->length; in xfs_bmap_process_allocated_extent()
3485 if (ap->minlen != 1) { in xfs_bmap_exact_minlen_extent_alloc()
3486 args->fsbno = NULLFSBLOCK; in xfs_bmap_exact_minlen_extent_alloc()
3490 args->alloc_minlen_only = 1; in xfs_bmap_exact_minlen_extent_alloc()
3491 args->minlen = args->maxlen = ap->minlen; in xfs_bmap_exact_minlen_extent_alloc()
3492 args->total = ap->total; in xfs_bmap_exact_minlen_extent_alloc()
3502 ap->blkno = XFS_AGB_TO_FSB(ap->ip->i_mount, 0, 0); in xfs_bmap_exact_minlen_extent_alloc()
3506 * iteration and then drops args->total to args->minlen, which might be in xfs_bmap_exact_minlen_extent_alloc()
3518 * NOTE: ap->aeof is only set if the allocation length is >= the
3529 struct xfs_mount *mp = args->mp; in xfs_bmap_btalloc_at_eof()
3530 struct xfs_perag *caller_pag = args->pag; in xfs_bmap_btalloc_at_eof()
3534 * If there are already extents in the file, try an exact EOF block in xfs_bmap_btalloc_at_eof()
3539 if (ap->offset) { in xfs_bmap_btalloc_at_eof()
3547 args->alignment = 1; in xfs_bmap_btalloc_at_eof()
3548 if (blen > stripe_align && blen <= args->maxlen) in xfs_bmap_btalloc_at_eof()
3549 nextminlen = blen - stripe_align; in xfs_bmap_btalloc_at_eof()
3551 nextminlen = args->minlen; in xfs_bmap_btalloc_at_eof()
3552 if (nextminlen + stripe_align > args->minlen + 1) in xfs_bmap_btalloc_at_eof()
3553 args->minalignslop = nextminlen + stripe_align - in xfs_bmap_btalloc_at_eof()
3554 args->minlen - 1; in xfs_bmap_btalloc_at_eof()
3556 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3559 args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); in xfs_bmap_btalloc_at_eof()
3560 error = xfs_alloc_vextent_exact_bno(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3562 xfs_perag_put(args->pag); in xfs_bmap_btalloc_at_eof()
3563 args->pag = NULL; in xfs_bmap_btalloc_at_eof()
3568 if (args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_at_eof()
3574 args->alignment = stripe_align; in xfs_bmap_btalloc_at_eof()
3575 args->minlen = nextminlen; in xfs_bmap_btalloc_at_eof()
3576 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3582 args->alignment = stripe_align; in xfs_bmap_btalloc_at_eof()
3583 if (blen > args->alignment && in xfs_bmap_btalloc_at_eof()
3584 blen <= args->maxlen + args->alignment) in xfs_bmap_btalloc_at_eof()
3585 args->minlen = blen - args->alignment; in xfs_bmap_btalloc_at_eof()
3586 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3590 error = xfs_alloc_vextent_near_bno(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3592 args->pag = NULL; in xfs_bmap_btalloc_at_eof()
3593 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3594 ASSERT(args->pag == NULL); in xfs_bmap_btalloc_at_eof()
3595 args->pag = caller_pag; in xfs_bmap_btalloc_at_eof()
3600 if (args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_at_eof()
3605 * original non-aligned state so the caller can proceed on allocation in xfs_bmap_btalloc_at_eof()
3608 args->alignment = 1; in xfs_bmap_btalloc_at_eof()
3615 * allocation whilst still maintaining necessary total block reservation
3631 if (args->minlen > ap->minlen) { in xfs_bmap_btalloc_low_space()
3632 args->minlen = ap->minlen; in xfs_bmap_btalloc_low_space()
3633 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_low_space()
3634 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_low_space()
3639 args->total = ap->minlen; in xfs_bmap_btalloc_low_space()
3643 ap->tp->t_flags |= XFS_TRANS_LOWMODE; in xfs_bmap_btalloc_low_space()
3660 ASSERT(args->pag); in xfs_bmap_btalloc_filestreams()
3667 if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_btalloc_filestreams()
3668 args->minlen = ap->minlen; in xfs_bmap_btalloc_filestreams()
3669 ASSERT(args->fsbno == NULLFSBLOCK); in xfs_bmap_btalloc_filestreams()
3673 args->minlen = xfs_bmap_select_minlen(ap, args, blen); in xfs_bmap_btalloc_filestreams()
3674 if (ap->aeof) in xfs_bmap_btalloc_filestreams()
3678 if (!error && args->fsbno == NULLFSBLOCK) in xfs_bmap_btalloc_filestreams()
3679 error = xfs_alloc_vextent_near_bno(args, ap->blkno); in xfs_bmap_btalloc_filestreams()
3689 xfs_perag_rele(args->pag); in xfs_bmap_btalloc_filestreams()
3690 args->pag = NULL; in xfs_bmap_btalloc_filestreams()
3691 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_filestreams()
3706 ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); in xfs_bmap_btalloc_best_length()
3724 if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { in xfs_bmap_btalloc_best_length()
3727 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_best_length()
3731 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_best_length()
3732 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_best_length()
3742 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_btalloc()
3744 .tp = ap->tp, in xfs_bmap_btalloc()
3748 .minleft = ap->minleft, in xfs_bmap_btalloc()
3749 .wasdel = ap->wasdel, in xfs_bmap_btalloc()
3751 .datatype = ap->datatype, in xfs_bmap_btalloc()
3760 ASSERT(ap->length); in xfs_bmap_btalloc()
3761 orig_offset = ap->offset; in xfs_bmap_btalloc()
3762 orig_length = ap->length; in xfs_bmap_btalloc()
3767 args.maxlen = min(ap->length, mp->m_ag_max_usable); in xfs_bmap_btalloc()
3772 else if ((ap->datatype & XFS_ALLOC_USERDATA) && in xfs_bmap_btalloc()
3773 xfs_inode_is_filestream(ap->ip)) in xfs_bmap_btalloc()
3784 ap->blkno = NULLFSBLOCK; in xfs_bmap_btalloc()
3785 ap->length = 0; in xfs_bmap_btalloc()
3790 /* Trim extent to fit a logical block range. */
3800 if (irec->br_startoff + irec->br_blockcount <= bno || in xfs_trim_extent()
3801 irec->br_startoff >= end) { in xfs_trim_extent()
3802 irec->br_blockcount = 0; in xfs_trim_extent()
3806 if (irec->br_startoff < bno) { in xfs_trim_extent()
3807 distance = bno - irec->br_startoff; in xfs_trim_extent()
3808 if (isnullstartblock(irec->br_startblock)) in xfs_trim_extent()
3809 irec->br_startblock = DELAYSTARTBLOCK; in xfs_trim_extent()
3810 if (irec->br_startblock != DELAYSTARTBLOCK && in xfs_trim_extent()
3811 irec->br_startblock != HOLESTARTBLOCK) in xfs_trim_extent()
3812 irec->br_startblock += distance; in xfs_trim_extent()
3813 irec->br_startoff += distance; in xfs_trim_extent()
3814 irec->br_blockcount -= distance; in xfs_trim_extent()
3817 if (end < irec->br_startoff + irec->br_blockcount) { in xfs_trim_extent()
3818 distance = irec->br_startoff + irec->br_blockcount - end; in xfs_trim_extent()
3819 irec->br_blockcount -= distance; in xfs_trim_extent()
3838 got->br_startoff + got->br_blockcount <= obno) { in xfs_bmapi_trim_map()
3840 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3841 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3849 mval->br_startoff = *bno; in xfs_bmapi_trim_map()
3850 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3851 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3853 mval->br_startblock = got->br_startblock + in xfs_bmapi_trim_map()
3854 (*bno - got->br_startoff); in xfs_bmapi_trim_map()
3862 mval->br_blockcount = XFS_FILBLKS_MIN(end - *bno, in xfs_bmapi_trim_map()
3863 got->br_blockcount - (*bno - got->br_startoff)); in xfs_bmapi_trim_map()
3864 mval->br_state = got->br_state; in xfs_bmapi_trim_map()
3865 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_trim_map()
3885 ((mval->br_startoff + mval->br_blockcount) <= end)); in xfs_bmapi_update_map()
3886 ASSERT((flags & XFS_BMAPI_ENTIRE) || (mval->br_blockcount <= *len) || in xfs_bmapi_update_map()
3887 (mval->br_startoff < obno)); in xfs_bmapi_update_map()
3889 *bno = mval->br_startoff + mval->br_blockcount; in xfs_bmapi_update_map()
3890 *len = end - *bno; in xfs_bmapi_update_map()
3891 if (*n > 0 && mval->br_startoff == mval[-1].br_startoff) { in xfs_bmapi_update_map()
3893 ASSERT(mval->br_startblock == mval[-1].br_startblock); in xfs_bmapi_update_map()
3894 ASSERT(mval->br_blockcount > mval[-1].br_blockcount); in xfs_bmapi_update_map()
3895 ASSERT(mval->br_state == mval[-1].br_state); in xfs_bmapi_update_map()
3896 mval[-1].br_blockcount = mval->br_blockcount; in xfs_bmapi_update_map()
3897 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3898 } else if (*n > 0 && mval->br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3899 mval[-1].br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3900 mval[-1].br_startblock != HOLESTARTBLOCK && in xfs_bmapi_update_map()
3901 mval->br_startblock == mval[-1].br_startblock + in xfs_bmapi_update_map()
3902 mval[-1].br_blockcount && in xfs_bmapi_update_map()
3903 mval[-1].br_state == mval->br_state) { in xfs_bmapi_update_map()
3904 ASSERT(mval->br_startoff == in xfs_bmapi_update_map()
3905 mval[-1].br_startoff + mval[-1].br_blockcount); in xfs_bmapi_update_map()
3906 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3908 mval->br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3909 mval[-1].br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3910 mval->br_startoff == in xfs_bmapi_update_map()
3911 mval[-1].br_startoff + mval[-1].br_blockcount) { in xfs_bmapi_update_map()
3912 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3913 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3915 ((mval->br_startoff + mval->br_blockcount) <= in xfs_bmapi_update_map()
3928 struct xfs_inode *ip, in xfs_bmapi_read() argument
3935 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_read()
3937 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmapi_read()
3948 xfs_assert_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL); in xfs_bmapi_read()
3951 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmapi_read()
3952 return -EFSCORRUPTED; in xfs_bmapi_read()
3957 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmapi_read()
3958 return -EFSCORRUPTED; in xfs_bmapi_read()
3962 return -EIO; in xfs_bmapi_read()
3966 error = xfs_iread_extents(NULL, ip, whichfork); in xfs_bmapi_read()
3970 if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) in xfs_bmapi_read()
3981 mval->br_startoff = bno; in xfs_bmapi_read()
3982 mval->br_startblock = HOLESTARTBLOCK; in xfs_bmapi_read()
3983 mval->br_blockcount = in xfs_bmapi_read()
3984 XFS_FILBLKS_MIN(len, got.br_startoff - bno); in xfs_bmapi_read()
3985 mval->br_state = XFS_EXT_NORM; in xfs_bmapi_read()
3986 bno += mval->br_blockcount; in xfs_bmapi_read()
3987 len -= mval->br_blockcount; in xfs_bmapi_read()
4011 * global pool and the extent inserted into the inode in-core extent tree.
4024 struct xfs_inode *ip, in xfs_bmapi_reserve_delalloc() argument
4033 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_reserve_delalloc()
4034 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmapi_reserve_delalloc()
4051 alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); in xfs_bmapi_reserve_delalloc()
4053 prealloc = alen - len; in xfs_bmapi_reserve_delalloc()
4066 xfs_extlen_t extsz = xfs_get_cowextsz_hint(ip); in xfs_bmapi_reserve_delalloc()
4077 * Make a transaction-less quota reservation for delayed allocation in xfs_bmapi_reserve_delalloc()
4081 error = xfs_quota_reserve_blkres(ip, alen); in xfs_bmapi_reserve_delalloc()
4089 indlen = (xfs_extlen_t)xfs_bmap_worst_indlen(ip, alen); in xfs_bmapi_reserve_delalloc()
4093 if (XFS_IS_REALTIME_INODE(ip)) { in xfs_bmapi_reserve_delalloc()
4105 ip->i_delayed_blks += alen; in xfs_bmapi_reserve_delalloc()
4106 xfs_mod_delalloc(ip, alen, indlen); in xfs_bmapi_reserve_delalloc()
4108 got->br_startoff = aoff; in xfs_bmapi_reserve_delalloc()
4109 got->br_startblock = nullstartblock(indlen); in xfs_bmapi_reserve_delalloc()
4110 got->br_blockcount = alen; in xfs_bmapi_reserve_delalloc()
4111 got->br_state = XFS_EXT_NORM; in xfs_bmapi_reserve_delalloc()
4113 xfs_bmap_add_extent_hole_delay(ip, whichfork, icur, got); in xfs_bmapi_reserve_delalloc()
4121 xfs_inode_set_eofblocks_tag(ip); in xfs_bmapi_reserve_delalloc()
4123 xfs_inode_set_cowblocks_tag(ip); in xfs_bmapi_reserve_delalloc()
4128 if (XFS_IS_REALTIME_INODE(ip)) in xfs_bmapi_reserve_delalloc()
4132 xfs_quota_unreserve_blkres(ip, alen); in xfs_bmapi_reserve_delalloc()
4134 if (error == -ENOSPC || error == -EDQUOT) { in xfs_bmapi_reserve_delalloc()
4135 trace_xfs_delalloc_enospc(ip, off, len); in xfs_bmapi_reserve_delalloc()
4151 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmapi_allocate()
4152 int whichfork = xfs_bmapi_whichfork(bma->flags); in xfs_bmapi_allocate()
4153 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_allocate()
4156 ASSERT(bma->length > 0); in xfs_bmapi_allocate()
4157 ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN); in xfs_bmapi_allocate()
4159 if (bma->flags & XFS_BMAPI_CONTIG) in xfs_bmapi_allocate()
4160 bma->minlen = bma->length; in xfs_bmapi_allocate()
4162 bma->minlen = 1; in xfs_bmapi_allocate()
4164 if (!(bma->flags & XFS_BMAPI_METADATA)) { in xfs_bmapi_allocate()
4171 bma->datatype = XFS_ALLOC_NOBUSY; in xfs_bmapi_allocate()
4173 bma->datatype |= XFS_ALLOC_USERDATA; in xfs_bmapi_allocate()
4174 if (bma->offset == 0) in xfs_bmapi_allocate()
4175 bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; in xfs_bmapi_allocate()
4177 if (mp->m_dalign && bma->length >= mp->m_dalign) { in xfs_bmapi_allocate()
4185 if ((bma->datatype & XFS_ALLOC_USERDATA) && in xfs_bmapi_allocate()
4186 XFS_IS_REALTIME_INODE(bma->ip)) in xfs_bmapi_allocate()
4192 if (bma->blkno == NULLFSBLOCK) in xfs_bmapi_allocate()
4193 return -ENOSPC; in xfs_bmapi_allocate()
4195 if (WARN_ON_ONCE(!xfs_valid_startblock(bma->ip, bma->blkno))) { in xfs_bmapi_allocate()
4196 xfs_bmap_mark_sick(bma->ip, whichfork); in xfs_bmapi_allocate()
4197 return -EFSCORRUPTED; in xfs_bmapi_allocate()
4200 if (bma->flags & XFS_BMAPI_ZERO) { in xfs_bmapi_allocate()
4201 error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); in xfs_bmapi_allocate()
4206 if (ifp->if_format == XFS_DINODE_FMT_BTREE && !bma->cur) in xfs_bmapi_allocate()
4207 bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); in xfs_bmapi_allocate()
4212 bma->nallocs++; in xfs_bmapi_allocate()
4214 if (bma->cur && bma->wasdel) in xfs_bmapi_allocate()
4215 bma->cur->bc_flags |= XFS_BTREE_BMBT_WASDEL; in xfs_bmapi_allocate()
4217 bma->got.br_startoff = bma->offset; in xfs_bmapi_allocate()
4218 bma->got.br_startblock = bma->blkno; in xfs_bmapi_allocate()
4219 bma->got.br_blockcount = bma->length; in xfs_bmapi_allocate()
4220 bma->got.br_state = XFS_EXT_NORM; in xfs_bmapi_allocate()
4222 if (bma->flags & XFS_BMAPI_PREALLOC) in xfs_bmapi_allocate()
4223 bma->got.br_state = XFS_EXT_UNWRITTEN; in xfs_bmapi_allocate()
4225 if (bma->wasdel) in xfs_bmapi_allocate()
4228 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, in xfs_bmapi_allocate()
4229 whichfork, &bma->icur, &bma->cur, &bma->got, in xfs_bmapi_allocate()
4230 &bma->logflags, bma->flags); in xfs_bmapi_allocate()
4239 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_allocate()
4241 ASSERT(bma->got.br_startoff <= bma->offset); in xfs_bmapi_allocate()
4242 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= in xfs_bmapi_allocate()
4243 bma->offset + bma->length); in xfs_bmapi_allocate()
4244 ASSERT(bma->got.br_state == XFS_EXT_NORM || in xfs_bmapi_allocate()
4245 bma->got.br_state == XFS_EXT_UNWRITTEN); in xfs_bmapi_allocate()
4257 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4261 /* check if we need to do unwritten->real conversion */ in xfs_bmapi_convert_unwritten()
4262 if (mval->br_state == XFS_EXT_UNWRITTEN && in xfs_bmapi_convert_unwritten()
4266 /* check if we need to do real->unwritten conversion */ in xfs_bmapi_convert_unwritten()
4267 if (mval->br_state == XFS_EXT_NORM && in xfs_bmapi_convert_unwritten()
4275 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_convert_unwritten()
4276 if (ifp->if_format == XFS_DINODE_FMT_BTREE && !bma->cur) { in xfs_bmapi_convert_unwritten()
4277 bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp, in xfs_bmapi_convert_unwritten()
4278 bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4280 mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) in xfs_bmapi_convert_unwritten()
4288 error = xfs_zero_extent(bma->ip, mval->br_startblock, in xfs_bmapi_convert_unwritten()
4289 mval->br_blockcount); in xfs_bmapi_convert_unwritten()
4294 error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork, in xfs_bmapi_convert_unwritten()
4295 &bma->icur, &bma->cur, mval, &tmp_logflags); in xfs_bmapi_convert_unwritten()
4305 * any on-disk updates to make, so we don't need to log anything. in xfs_bmapi_convert_unwritten()
4308 bma->logflags |= tmp_logflags | XFS_ILOG_CORE; in xfs_bmapi_convert_unwritten()
4317 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_convert_unwritten()
4323 if (mval->br_blockcount < len) in xfs_bmapi_convert_unwritten()
4324 return -EAGAIN; in xfs_bmapi_convert_unwritten()
4331 struct xfs_inode *ip, in xfs_bmapi_minleft() argument
4334 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, fork); in xfs_bmapi_minleft()
4336 if (tp && tp->t_highest_agno != NULLAGNUMBER) in xfs_bmapi_minleft()
4338 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_minleft()
4340 return be16_to_cpu(ifp->if_broot->bb_level) + 1; in xfs_bmapi_minleft()
4355 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_finish()
4357 if ((bma->logflags & xfs_ilog_fext(whichfork)) && in xfs_bmapi_finish()
4358 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_finish()
4359 bma->logflags &= ~xfs_ilog_fext(whichfork); in xfs_bmapi_finish()
4360 else if ((bma->logflags & xfs_ilog_fbroot(whichfork)) && in xfs_bmapi_finish()
4361 ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_finish()
4362 bma->logflags &= ~xfs_ilog_fbroot(whichfork); in xfs_bmapi_finish()
4364 if (bma->logflags) in xfs_bmapi_finish()
4365 xfs_trans_log_inode(bma->tp, bma->ip, bma->logflags); in xfs_bmapi_finish()
4366 if (bma->cur) in xfs_bmapi_finish()
4367 xfs_btree_del_cursor(bma->cur, error); in xfs_bmapi_finish()
4381 * Returns a negative error code on failure, including -ENOSPC when it could not
4382 * allocate any blocks and -ENOSR when it did allocate blocks to convert a
4388 struct xfs_inode *ip, /* incore inode */ in xfs_bmapi_write() argument
4398 .ip = ip, in xfs_bmapi_write()
4401 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_write()
4403 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmapi_write()
4408 xfs_fileoff_t obno; /* old block number (offset) */ in xfs_bmapi_write()
4411 xfs_fileoff_t orig_bno; /* original block number value */ in xfs_bmapi_write()
4428 ASSERT(ifp->if_format != XFS_DINODE_FMT_LOCAL); in xfs_bmapi_write()
4429 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_bmapi_write()
4436 * we can allocate unwritten extents or pre-zero allocated blocks, in xfs_bmapi_write()
4446 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmapi_write()
4447 return -EFSCORRUPTED; in xfs_bmapi_write()
4451 return -EIO; in xfs_bmapi_write()
4455 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmapi_write()
4459 if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got)) in xfs_bmapi_write()
4463 bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); in xfs_bmapi_write()
4509 bma.got.br_blockcount - in xfs_bmapi_write()
4510 (bno - bma.got.br_startoff)); in xfs_bmapi_write()
4514 bma.got.br_startoff - bno); in xfs_bmapi_write()
4525 if (error == -ENOSPC && bma.nallocs) in xfs_bmapi_write()
4545 if (error == -EAGAIN) in xfs_bmapi_write()
4567 error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, in xfs_bmapi_write()
4572 ASSERT(ifp->if_format != XFS_DINODE_FMT_BTREE || in xfs_bmapi_write()
4573 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork)); in xfs_bmapi_write()
4584 * -ENOSR error code for this particular case so that the caller can in xfs_bmapi_write()
4589 return -ENOSR; in xfs_bmapi_write()
4606 struct xfs_inode *ip, in xfs_bmapi_convert_one_delalloc() argument
4612 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmapi_convert_one_delalloc()
4613 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_convert_one_delalloc()
4627 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, in xfs_bmapi_convert_one_delalloc()
4632 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_one_delalloc()
4633 xfs_trans_ijoin(tp, ip, 0); in xfs_bmapi_convert_one_delalloc()
4635 error = xfs_iext_count_extend(tp, ip, whichfork, in xfs_bmapi_convert_one_delalloc()
4640 if (!xfs_iext_lookup_extent(ip, ifp, offset_fsb, &bma.icur, &bma.got) || in xfs_bmapi_convert_one_delalloc()
4648 error = -EAGAIN; in xfs_bmapi_convert_one_delalloc()
4657 xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, in xfs_bmapi_convert_one_delalloc()
4658 xfs_iomap_inode_sequence(ip, flags)); in xfs_bmapi_convert_one_delalloc()
4660 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_one_delalloc()
4665 bma.ip = ip; in xfs_bmapi_convert_one_delalloc()
4667 bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); in xfs_bmapi_convert_one_delalloc()
4705 xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, in xfs_bmapi_convert_one_delalloc()
4706 xfs_iomap_inode_sequence(ip, flags)); in xfs_bmapi_convert_one_delalloc()
4708 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_one_delalloc()
4713 error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, in xfs_bmapi_convert_one_delalloc()
4720 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_one_delalloc()
4727 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_one_delalloc()
4737 struct xfs_inode *ip, in xfs_bmapi_convert_delalloc() argument
4752 error = xfs_bmapi_convert_one_delalloc(ip, whichfork, offset, in xfs_bmapi_convert_delalloc()
4756 } while (iomap->offset + iomap->length <= offset); in xfs_bmapi_convert_delalloc()
4764 struct xfs_inode *ip, in xfs_bmapi_remap() argument
4770 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_remap()
4778 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmapi_remap()
4781 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_bmapi_remap()
4789 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmapi_remap()
4790 return -EFSCORRUPTED; in xfs_bmapi_remap()
4794 return -EIO; in xfs_bmapi_remap()
4796 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmapi_remap()
4800 if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) { in xfs_bmapi_remap()
4803 ASSERT(got.br_startoff - bno >= len); in xfs_bmapi_remap()
4806 ip->i_nblocks += len; in xfs_bmapi_remap()
4807 ip->i_delayed_blks -= len; /* see xfs_bmap_defer_add */ in xfs_bmapi_remap()
4808 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmapi_remap()
4810 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmapi_remap()
4811 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmapi_remap()
4821 error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur, in xfs_bmapi_remap()
4826 error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags, whichfork); in xfs_bmapi_remap()
4829 if (ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_remap()
4831 else if (ip->i_df.if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_remap()
4835 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmapi_remap()
4883 * is zero, we want to make sure that one gets a block first. The loop in xfs_bmap_split_indlen()
4884 * below starts with len1, so hand len2 a block right off the bat if it in xfs_bmap_split_indlen()
4887 ores -= (len1 + len2); in xfs_bmap_split_indlen()
4888 ASSERT((*indlen1 - len1) + (*indlen2 - len2) >= ores); in xfs_bmap_split_indlen()
4891 ores--; in xfs_bmap_split_indlen()
4896 ores--; in xfs_bmap_split_indlen()
4902 ores--; in xfs_bmap_split_indlen()
4912 struct xfs_inode *ip, in xfs_bmap_del_extent_delay() argument
4918 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_delay()
4919 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_del_extent_delay()
4930 isrt = xfs_ifork_is_realtime(ip, whichfork); in xfs_bmap_del_extent_delay()
4931 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_delay()
4932 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_delay()
4933 da_old = startblockval(got->br_startblock); in xfs_bmap_del_extent_delay()
4936 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_delay()
4937 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_delay()
4943 * indirect block accounting. in xfs_bmap_del_extent_delay()
4945 xfs_quota_unreserve_blkres(ip, del->br_blockcount); in xfs_bmap_del_extent_delay()
4946 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4948 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_delay()
4958 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_delay()
4965 got->br_startoff = del_endoff; in xfs_bmap_del_extent_delay()
4966 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4967 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, in xfs_bmap_del_extent_delay()
4968 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4969 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4970 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
4976 got->br_blockcount = got->br_blockcount - del->br_blockcount; in xfs_bmap_del_extent_delay()
4977 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, in xfs_bmap_del_extent_delay()
4978 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4979 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4980 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
4992 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_delay()
4993 got_indlen = xfs_bmap_worst_indlen(ip, got->br_blockcount); in xfs_bmap_del_extent_delay()
4995 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_delay()
4996 new_indlen = xfs_bmap_worst_indlen(ip, new.br_blockcount); in xfs_bmap_del_extent_delay()
5006 * under-filled indirect reservation in this case. in xfs_bmap_del_extent_delay()
5010 stolen = XFS_FILBLKS_MIN(da_new - da_old, in xfs_bmap_del_extent_delay()
5011 del->br_blockcount); in xfs_bmap_del_extent_delay()
5018 got->br_startblock = nullstartblock((int)got_indlen); in xfs_bmap_del_extent_delay()
5021 new.br_state = got->br_state; in xfs_bmap_del_extent_delay()
5024 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
5026 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_delay()
5028 del->br_blockcount -= stolen; in xfs_bmap_del_extent_delay()
5033 da_diff = da_old - da_new; in xfs_bmap_del_extent_delay()
5037 xfs_add_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount)); in xfs_bmap_del_extent_delay()
5039 fdblocks += del->br_blockcount; in xfs_bmap_del_extent_delay()
5042 xfs_mod_delalloc(ip, -(int64_t)del->br_blockcount, -da_diff); in xfs_bmap_del_extent_delay()
5047 struct xfs_inode *ip, in xfs_bmap_del_extent_cow() argument
5052 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_cow()
5053 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_COW_FORK); in xfs_bmap_del_extent_cow()
5060 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_cow()
5061 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_cow()
5063 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_cow()
5064 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_cow()
5066 ASSERT(!isnullstartblock(got->br_startblock)); in xfs_bmap_del_extent_cow()
5068 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_cow()
5078 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_cow()
5085 got->br_startoff = del_endoff; in xfs_bmap_del_extent_cow()
5086 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5087 got->br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
5088 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
5094 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5095 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
5101 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_cow()
5104 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_cow()
5105 new.br_state = got->br_state; in xfs_bmap_del_extent_cow()
5106 new.br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
5108 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
5110 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_cow()
5113 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5122 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_del_extent_real() argument
5131 xfs_fsblock_t del_endblock=0; /* first block past del */ in xfs_bmap_del_extent_real()
5139 xfs_filblks_t nblks; /* quota/sb block count */ in xfs_bmap_del_extent_real()
5148 mp = ip->i_mount; in xfs_bmap_del_extent_real()
5151 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_del_extent_real()
5152 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_real()
5154 ASSERT(got.br_startoff <= del->br_startoff); in xfs_bmap_del_extent_real()
5155 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_real()
5162 * If it's the case where the directory code is running with no block in xfs_bmap_del_extent_real()
5163 * reservation, and the deleted block is in the middle of its extent, in xfs_bmap_del_extent_real()
5169 if (tp->t_blk_res == 0 && in xfs_bmap_del_extent_real()
5170 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_del_extent_real()
5171 ifp->if_nextents >= XFS_IFORK_MAXEXT(ip, whichfork) && in xfs_bmap_del_extent_real()
5172 del->br_startoff > got.br_startoff && del_endoff < got_endoff) in xfs_bmap_del_extent_real()
5173 return -ENOSPC; in xfs_bmap_del_extent_real()
5176 if (xfs_ifork_is_realtime(ip, whichfork)) in xfs_bmap_del_extent_real()
5180 nblks = del->br_blockcount; in xfs_bmap_del_extent_real()
5182 del_endblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_real()
5189 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5193 if (got.br_startoff == del->br_startoff) in xfs_bmap_del_extent_real()
5203 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_real()
5205 ifp->if_nextents--; in xfs_bmap_del_extent_real()
5216 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5225 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5226 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5239 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5240 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5256 got.br_blockcount = del->br_startoff - got.br_startoff; in xfs_bmap_del_extent_real()
5257 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5260 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_real()
5272 cur->bc_rec.b = new; in xfs_bmap_del_extent_real()
5274 if (error && error != -ENOSPC) in xfs_bmap_del_extent_real()
5277 * If get no-space back from btree insert, it tried a in xfs_bmap_del_extent_real()
5278 * split, and we have a zero block reservation. Fix up in xfs_bmap_del_extent_real()
5281 if (error == -ENOSPC) { in xfs_bmap_del_extent_real()
5291 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5304 xfs_iext_update_extent(ip, state, icur, &old); in xfs_bmap_del_extent_real()
5306 return -ENOSPC; in xfs_bmap_del_extent_real()
5310 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5315 ifp->if_nextents++; in xfs_bmap_del_extent_real()
5317 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_real()
5322 xfs_rmap_unmap_extent(tp, ip, whichfork, del); in xfs_bmap_del_extent_real()
5328 if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) { in xfs_bmap_del_extent_real()
5330 } else if (xfs_ifork_is_realtime(ip, whichfork)) { in xfs_bmap_del_extent_real()
5335 if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) { in xfs_bmap_del_extent_real()
5336 tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED; in xfs_bmap_del_extent_real()
5340 error = xfs_rtfree_blocks(tp, del->br_startblock, in xfs_bmap_del_extent_real()
5341 del->br_blockcount); in xfs_bmap_del_extent_real()
5346 del->br_state == XFS_EXT_UNWRITTEN) in xfs_bmap_del_extent_real()
5349 error = xfs_free_extent_later(tp, del->br_startblock, in xfs_bmap_del_extent_real()
5350 del->br_blockcount, NULL, in xfs_bmap_del_extent_real()
5361 ip->i_nblocks -= nblks; in xfs_bmap_del_extent_real()
5366 xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); in xfs_bmap_del_extent_real()
5374 * that value. If not all extents in the block range can be removed then
5380 struct xfs_inode *ip, /* incore inode */ in __xfs_bunmapi() argument
5395 struct xfs_mount *mp = ip->i_mount; in __xfs_bunmapi()
5404 trace_xfs_bunmap(ip, start, len, flags, _RET_IP_); in __xfs_bunmapi()
5408 ifp = xfs_ifork_ptr(ip, whichfork); in __xfs_bunmapi()
5410 xfs_bmap_mark_sick(ip, whichfork); in __xfs_bunmapi()
5411 return -EFSCORRUPTED; in __xfs_bunmapi()
5414 return -EIO; in __xfs_bunmapi()
5416 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in __xfs_bunmapi()
5420 error = xfs_iread_extents(tp, ip, whichfork); in __xfs_bunmapi()
5429 isrt = xfs_ifork_is_realtime(ip, whichfork); in __xfs_bunmapi()
5432 if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) { in __xfs_bunmapi()
5436 end--; in __xfs_bunmapi()
5439 if (ifp->if_format == XFS_DINODE_FMT_BTREE) { in __xfs_bunmapi()
5440 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in __xfs_bunmapi()
5441 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in __xfs_bunmapi()
5446 while (end != (xfs_fileoff_t)-1 && end >= start && in __xfs_bunmapi()
5458 * Is the last block of this extent before the range in __xfs_bunmapi()
5462 got.br_startoff + got.br_blockcount - 1); in __xfs_bunmapi()
5474 del.br_blockcount -= start - got.br_startoff; in __xfs_bunmapi()
5476 del.br_startblock += start - got.br_startoff; in __xfs_bunmapi()
5479 del.br_blockcount = end + 1 - del.br_startoff; in __xfs_bunmapi()
5500 end -= mod > del.br_blockcount ? in __xfs_bunmapi()
5514 ASSERT(tp->t_blk_res > 0); in __xfs_bunmapi()
5520 del.br_startoff += del.br_blockcount - mod; in __xfs_bunmapi()
5521 del.br_startblock += del.br_blockcount - mod; in __xfs_bunmapi()
5525 error = xfs_bmap_add_extent_unwritten_real(tp, ip, in __xfs_bunmapi()
5535 xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; in __xfs_bunmapi()
5543 del.br_blockcount -= off; in __xfs_bunmapi()
5548 tp->t_blk_res == 0)) { in __xfs_bunmapi()
5554 end -= del.br_blockcount; in __xfs_bunmapi()
5578 del.br_startoff - mod, in __xfs_bunmapi()
5580 mod = unwrite_start - prev.br_startoff; in __xfs_bunmapi()
5583 prev.br_blockcount -= mod; in __xfs_bunmapi()
5586 ip, whichfork, &icur, &cur, in __xfs_bunmapi()
5595 ip, whichfork, &icur, &cur, in __xfs_bunmapi()
5605 xfs_bmap_del_extent_delay(ip, whichfork, &icur, &got, &del); in __xfs_bunmapi()
5607 error = xfs_bmap_del_extent_real(ip, tp, &icur, cur, in __xfs_bunmapi()
5615 end = del.br_startoff - 1; in __xfs_bunmapi()
5620 if (end != (xfs_fileoff_t)-1 && end >= start) { in __xfs_bunmapi()
5630 if (done || end == (xfs_fileoff_t)-1 || end < start) in __xfs_bunmapi()
5633 *rlen = end - start + 1; in __xfs_bunmapi()
5638 if (xfs_bmap_needs_btree(ip, whichfork)) { in __xfs_bunmapi()
5640 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in __xfs_bunmapi()
5644 error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags, in __xfs_bunmapi()
5654 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in __xfs_bunmapi()
5657 ifp->if_format != XFS_DINODE_FMT_BTREE) in __xfs_bunmapi()
5664 xfs_trans_log_inode(tp, ip, logflags); in __xfs_bunmapi()
5667 cur->bc_bmap.allocated = 0; in __xfs_bunmapi()
5677 struct xfs_inode *ip, in xfs_bunmapi() argument
5686 error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts); in xfs_bunmapi()
5703 startoff = got->br_startoff - shift; in xfs_bmse_can_merge()
5706 * The extent, once shifted, must be adjacent in-file and on-disk with in xfs_bmse_can_merge()
5709 if ((left->br_startoff + left->br_blockcount != startoff) || in xfs_bmse_can_merge()
5710 (left->br_startblock + left->br_blockcount != got->br_startblock) || in xfs_bmse_can_merge()
5711 (left->br_state != got->br_state) || in xfs_bmse_can_merge()
5712 (left->br_blockcount + got->br_blockcount > XFS_MAX_BMBT_EXTLEN)) in xfs_bmse_can_merge()
5724 * This function assumes the caller has verified a shift-by-merge is possible
5730 struct xfs_inode *ip, in xfs_bmse_merge() argument
5739 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmse_merge()
5743 struct xfs_mount *mp = ip->i_mount; in xfs_bmse_merge()
5745 blockcount = left->br_blockcount + got->br_blockcount; in xfs_bmse_merge()
5747 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); in xfs_bmse_merge()
5754 * Update the on-disk extent count, the btree if necessary and log the in xfs_bmse_merge()
5757 ifp->if_nextents--; in xfs_bmse_merge()
5770 return -EFSCORRUPTED; in xfs_bmse_merge()
5778 return -EFSCORRUPTED; in xfs_bmse_merge()
5787 return -EFSCORRUPTED; in xfs_bmse_merge()
5795 error = xfs_bmap_btree_to_extents(tp, ip, cur, logflags, whichfork); in xfs_bmse_merge()
5800 xfs_iext_remove(ip, icur, 0); in xfs_bmse_merge()
5802 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), icur, in xfs_bmse_merge()
5806 xfs_rmap_unmap_extent(tp, ip, whichfork, got); in xfs_bmse_merge()
5808 new.br_startoff = left->br_startoff + left->br_blockcount; in xfs_bmse_merge()
5809 xfs_rmap_map_extent(tp, ip, whichfork, &new); in xfs_bmse_merge()
5816 struct xfs_inode *ip, in xfs_bmap_shift_update_extent() argument
5824 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_shift_update_extent()
5830 got->br_startoff = startoff; in xfs_bmap_shift_update_extent()
5838 return -EFSCORRUPTED; in xfs_bmap_shift_update_extent()
5848 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), icur, in xfs_bmap_shift_update_extent()
5852 xfs_rmap_unmap_extent(tp, ip, whichfork, &prev); in xfs_bmap_shift_update_extent()
5853 xfs_rmap_map_extent(tp, ip, whichfork, got); in xfs_bmap_shift_update_extent()
5860 struct xfs_inode *ip, in xfs_bmap_collapse_extents() argument
5866 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_collapse_extents()
5867 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_collapse_extents()
5877 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_collapse_extents()
5878 return -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5882 return -EIO; in xfs_bmap_collapse_extents()
5884 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); in xfs_bmap_collapse_extents()
5886 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_collapse_extents()
5890 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmap_collapse_extents()
5891 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_collapse_extents()
5893 if (!xfs_iext_lookup_extent(ip, ifp, *next_fsb, &icur, &got)) { in xfs_bmap_collapse_extents()
5898 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_collapse_extents()
5899 error = -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5903 new_startoff = got.br_startoff - offset_shift_fsb; in xfs_bmap_collapse_extents()
5906 error = -EINVAL; in xfs_bmap_collapse_extents()
5911 error = xfs_bmse_merge(tp, ip, whichfork, in xfs_bmap_collapse_extents()
5920 error = -EINVAL; in xfs_bmap_collapse_extents()
5925 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got, in xfs_bmap_collapse_extents()
5941 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_collapse_extents()
5945 /* Make sure we won't be right-shifting an extent past the maximum bound. */
5948 struct xfs_inode *ip, in xfs_bmap_can_insert_extents() argument
5956 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); in xfs_bmap_can_insert_extents()
5958 if (xfs_is_shutdown(ip->i_mount)) in xfs_bmap_can_insert_extents()
5959 return -EIO; in xfs_bmap_can_insert_extents()
5961 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmap_can_insert_extents()
5962 error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &got, &is_empty); in xfs_bmap_can_insert_extents()
5965 error = -EINVAL; in xfs_bmap_can_insert_extents()
5966 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmap_can_insert_extents()
5974 struct xfs_inode *ip, in xfs_bmap_insert_extents() argument
5981 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_insert_extents()
5982 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_insert_extents()
5992 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_insert_extents()
5993 return -EFSCORRUPTED; in xfs_bmap_insert_extents()
5997 return -EIO; in xfs_bmap_insert_extents()
5999 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); in xfs_bmap_insert_extents()
6001 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_insert_extents()
6005 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmap_insert_extents()
6006 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_insert_extents()
6016 if (!xfs_iext_lookup_extent(ip, ifp, *next_fsb, &icur, &got)) { in xfs_bmap_insert_extents()
6022 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_insert_extents()
6023 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
6028 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_insert_extents()
6029 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
6036 error = -EINVAL; in xfs_bmap_insert_extents()
6050 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got, in xfs_bmap_insert_extents()
6066 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_insert_extents()
6071 * Splits an extent into two extents at split_fsb block such that it is the
6072 * first block of the current_ext. @ext is a target extent to be split.
6073 * @split_fsb is a block where the extents is split. If split_fsb lies in a
6074 * hole or the first block of extents, just return 0.
6079 struct xfs_inode *ip, in xfs_bmap_split_extent() argument
6083 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_split_extent()
6087 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_split_extent()
6088 xfs_fsblock_t gotblkcnt; /* new block count for got */ in xfs_bmap_split_extent()
6096 xfs_bmap_mark_sick(ip, whichfork); in xfs_bmap_split_extent()
6097 return -EFSCORRUPTED; in xfs_bmap_split_extent()
6101 return -EIO; in xfs_bmap_split_extent()
6104 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_split_extent()
6111 if (!xfs_iext_lookup_extent(ip, ifp, split_fsb, &icur, &got) || in xfs_bmap_split_extent()
6115 gotblkcnt = split_fsb - got.br_startoff; in xfs_bmap_split_extent()
6118 new.br_blockcount = got.br_blockcount - gotblkcnt; in xfs_bmap_split_extent()
6121 if (ifp->if_format == XFS_DINODE_FMT_BTREE) { in xfs_bmap_split_extent()
6122 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_split_extent()
6128 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6134 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), &icur, in xfs_bmap_split_extent()
6147 xfs_iext_insert(ip, &icur, &new, 0); in xfs_bmap_split_extent()
6148 ifp->if_nextents++; in xfs_bmap_split_extent()
6156 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6164 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6172 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_split_extent()
6176 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in xfs_bmap_split_extent()
6183 cur->bc_bmap.allocated = 0; in xfs_bmap_split_extent()
6188 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_split_extent()
6197 struct xfs_inode *ip, in __xfs_bmap_add() argument
6204 bmap->br_startblock == HOLESTARTBLOCK || in __xfs_bmap_add()
6205 bmap->br_startblock == DELAYSTARTBLOCK) in __xfs_bmap_add()
6209 INIT_LIST_HEAD(&bi->bi_list); in __xfs_bmap_add()
6210 bi->bi_type = type; in __xfs_bmap_add()
6211 bi->bi_owner = ip; in __xfs_bmap_add()
6212 bi->bi_whichfork = whichfork; in __xfs_bmap_add()
6213 bi->bi_bmap = *bmap; in __xfs_bmap_add()
6222 struct xfs_inode *ip, in xfs_bmap_map_extent() argument
6226 __xfs_bmap_add(tp, XFS_BMAP_MAP, ip, whichfork, PREV); in xfs_bmap_map_extent()
6233 struct xfs_inode *ip, in xfs_bmap_unmap_extent() argument
6237 __xfs_bmap_add(tp, XFS_BMAP_UNMAP, ip, whichfork, PREV); in xfs_bmap_unmap_extent()
6249 struct xfs_bmbt_irec *bmap = &bi->bi_bmap; in xfs_bmap_finish_one()
6253 if (bi->bi_whichfork == XFS_ATTR_FORK) in xfs_bmap_finish_one()
6256 ASSERT(tp->t_highest_agno == NULLAGNUMBER); in xfs_bmap_finish_one()
6260 if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE)) in xfs_bmap_finish_one()
6261 return -EIO; in xfs_bmap_finish_one()
6263 switch (bi->bi_type) { in xfs_bmap_finish_one()
6265 if (bi->bi_bmap.br_state == XFS_EXT_UNWRITTEN) in xfs_bmap_finish_one()
6267 error = xfs_bmapi_remap(tp, bi->bi_owner, bmap->br_startoff, in xfs_bmap_finish_one()
6268 bmap->br_blockcount, bmap->br_startblock, in xfs_bmap_finish_one()
6270 bmap->br_blockcount = 0; in xfs_bmap_finish_one()
6273 error = __xfs_bunmapi(tp, bi->bi_owner, bmap->br_startoff, in xfs_bmap_finish_one()
6274 &bmap->br_blockcount, flags | XFS_BMAPI_REMAP, in xfs_bmap_finish_one()
6279 xfs_bmap_mark_sick(bi->bi_owner, bi->bi_whichfork); in xfs_bmap_finish_one()
6280 error = -EFSCORRUPTED; in xfs_bmap_finish_one()
6294 if (!xfs_verify_fileext(mp, irec->br_startoff, irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6298 if (!xfs_verify_rtbext(mp, irec->br_startblock, in xfs_bmap_validate_extent_raw()
6299 irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6302 if (!xfs_verify_fsbext(mp, irec->br_startblock, in xfs_bmap_validate_extent_raw()
6303 irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6306 if (irec->br_state != XFS_EXT_NORM && whichfork != XFS_DATA_FORK) in xfs_bmap_validate_extent_raw()
6318 return xfs_bmap_intent_cache != NULL ? 0 : -ENOMEM; in xfs_bmap_intent_init_cache()
6331 struct xfs_inode *ip, in xfs_bmap_validate_extent() argument
6335 return xfs_bmap_validate_extent_raw(ip->i_mount, in xfs_bmap_validate_extent()
6336 XFS_IS_REALTIME_INODE(ip), whichfork, irec); in xfs_bmap_validate_extent()
6352 struct xfs_inode *ip, in xfs_bunmapi_range() argument
6357 xfs_filblks_t unmap_len = endoff - startoff + 1; in xfs_bunmapi_range()
6360 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_bunmapi_range()
6363 ASSERT((*tpp)->t_highest_agno == NULLAGNUMBER); in xfs_bunmapi_range()
6364 error = __xfs_bunmapi(*tpp, ip, startoff, &unmap_len, flags, in xfs_bunmapi_range()
6395 xfs_bmbt_disk_get_all(&rec->bmbt, &irec); in xfs_bmap_query_range_helper()
6396 fa = xfs_bmap_validate_extent(cur->bc_ino.ip, cur->bc_ino.whichfork, in xfs_bmap_query_range_helper()
6400 return xfs_bmap_complain_bad_rec(cur->bc_ino.ip, in xfs_bmap_query_range_helper()
6401 cur->bc_ino.whichfork, fa, &irec); in xfs_bmap_query_range_helper()
6404 return query->fn(cur, &irec, query->priv); in xfs_bmap_query_range_helper()
6425 struct xfs_inode *ip) in xfs_get_extsz_hint() argument
6431 if (xfs_is_always_cow_inode(ip)) in xfs_get_extsz_hint()
6433 if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize) in xfs_get_extsz_hint()
6434 return ip->i_extsize; in xfs_get_extsz_hint()
6435 if (XFS_IS_REALTIME_INODE(ip) && in xfs_get_extsz_hint()
6436 ip->i_mount->m_sb.sb_rextsize > 1) in xfs_get_extsz_hint()
6437 return ip->i_mount->m_sb.sb_rextsize; in xfs_get_extsz_hint()
6449 struct xfs_inode *ip) in xfs_get_cowextsz_hint() argument
6454 if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_get_cowextsz_hint()
6455 a = ip->i_cowextsize; in xfs_get_cowextsz_hint()
6456 b = xfs_get_extsz_hint(ip); in xfs_get_cowextsz_hint()