Lines Matching +full:ip +full:- +full:block
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
58 int maxrootrecs; /* max records in root block */ in xfs_bmap_compute_maxlevels()
59 int minleafrecs; /* min records in leaf block */ in xfs_bmap_compute_maxlevels()
60 int minnoderecs; /* min records in node block */ in xfs_bmap_compute_maxlevels()
61 int sz; /* root block size */ in xfs_bmap_compute_maxlevels()
65 * leaf entries, is controlled by the size of the on-disk extent count, in xfs_bmap_compute_maxlevels()
66 * either a signed 32-bit number for the data fork, or a signed 16-bit in xfs_bmap_compute_maxlevels()
71 * (xfs_default_attroffset(ip) >> 3) because we could have mounted in xfs_bmap_compute_maxlevels()
85 minleafrecs = mp->m_bmap_dmnr[0]; in xfs_bmap_compute_maxlevels()
86 minnoderecs = mp->m_bmap_dmnr[1]; in xfs_bmap_compute_maxlevels()
87 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; in xfs_bmap_compute_maxlevels()
92 maxblocks = (maxblocks + minnoderecs - 1) / minnoderecs; in xfs_bmap_compute_maxlevels()
94 mp->m_bm_maxlevels[whichfork] = level; in xfs_bmap_compute_maxlevels()
103 cur->bc_rec.b = *irec; in xfs_bmbt_lookup_eq()
112 cur->bc_rec.b.br_startoff = 0; in xfs_bmbt_lookup_first()
113 cur->bc_rec.b.br_startblock = 0; in xfs_bmbt_lookup_first()
114 cur->bc_rec.b.br_blockcount = 0; in xfs_bmbt_lookup_first()
121 static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork) in xfs_bmap_needs_btree() argument
123 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_needs_btree()
126 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_needs_btree()
127 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_needs_btree()
133 static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork) in xfs_bmap_wants_extents() argument
135 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_wants_extents()
138 ifp->if_format == XFS_DINODE_FMT_BTREE && in xfs_bmap_wants_extents()
139 ifp->if_nextents <= XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_wants_extents()
158 * Compute the worst-case number of indirect blocks that will be used
159 * for ip's delayed extent of length "len".
163 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_worst_indlen() argument
171 mp = ip->i_mount; in xfs_bmap_worst_indlen()
172 maxrecs = mp->m_bmap_dmxr[0]; in xfs_bmap_worst_indlen()
176 len += maxrecs - 1; in xfs_bmap_worst_indlen()
180 return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - in xfs_bmap_worst_indlen()
181 level - 1; in xfs_bmap_worst_indlen()
183 maxrecs = mp->m_bmap_dmxr[1]; in xfs_bmap_worst_indlen()
193 struct xfs_inode *ip) in xfs_default_attroffset() argument
195 struct xfs_mount *mp = ip->i_mount; in xfs_default_attroffset()
198 if (mp->m_sb.sb_inodesize == 256) in xfs_default_attroffset()
199 offset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS); in xfs_default_attroffset()
209 * attribute fork from local to extent format - we reset it where
214 xfs_inode_t *ip, in xfs_bmap_forkoff_reset() argument
218 ip->i_df.if_format != XFS_DINODE_FMT_DEV && in xfs_bmap_forkoff_reset()
219 ip->i_df.if_format != XFS_DINODE_FMT_BTREE) { in xfs_bmap_forkoff_reset()
220 uint dfl_forkoff = xfs_default_attroffset(ip) >> 3; in xfs_bmap_forkoff_reset()
222 if (dfl_forkoff > ip->i_d.di_forkoff) in xfs_bmap_forkoff_reset()
223 ip->i_d.di_forkoff = dfl_forkoff; in xfs_bmap_forkoff_reset()
240 if (!cur->bc_bufs[i]) in xfs_bmap_get_bp()
242 if (XFS_BUF_ADDR(cur->bc_bufs[i]) == bno) in xfs_bmap_get_bp()
243 return cur->bc_bufs[i]; in xfs_bmap_get_bp()
247 list_for_each_entry(lip, &cur->bc_tp->t_items, li_trans) { in xfs_bmap_get_bp()
250 if (bip->bli_item.li_type == XFS_LI_BUF && in xfs_bmap_get_bp()
251 XFS_BUF_ADDR(bip->bli_buf) == bno) in xfs_bmap_get_bp()
252 return bip->bli_buf; in xfs_bmap_get_bp()
260 struct xfs_btree_block *block, in xfs_check_block() argument
266 __be64 *pp, *thispa; /* pointer to block address */ in xfs_check_block()
269 ASSERT(be16_to_cpu(block->bb_level) > 0); in xfs_check_block()
272 for( i = 1; i <= xfs_btree_get_numrecs(block); i++) { in xfs_check_block()
273 dmxr = mp->m_bmap_dmxr[0]; in xfs_check_block()
274 keyp = XFS_BMBT_KEY_ADDR(mp, block, i); in xfs_check_block()
277 ASSERT(be64_to_cpu(prevp->br_startoff) < in xfs_check_block()
278 be64_to_cpu(keyp->br_startoff)); in xfs_check_block()
283 * Compare the block numbers to see if there are dups. in xfs_check_block()
286 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, i, sz); in xfs_check_block()
288 pp = XFS_BMBT_PTR_ADDR(mp, block, i, dmxr); in xfs_check_block()
290 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { in xfs_check_block()
292 thispa = XFS_BMAP_BROOT_PTR_ADDR(mp, block, j, sz); in xfs_check_block()
294 thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr); in xfs_check_block()
308 * Check that the extents for the inode ip are in the right order in all
317 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_check_leaf_extents() argument
320 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_check_leaf_extents()
321 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_check_leaf_extents()
322 struct xfs_btree_block *block; /* current btree block */ in xfs_bmap_check_leaf_extents() local
323 xfs_fsblock_t bno; /* block # of "block" */ in xfs_bmap_check_leaf_extents()
324 xfs_buf_t *bp; /* buffer for "block" */ in xfs_bmap_check_leaf_extents()
328 __be64 *pp; /* pointer to block address */ in xfs_bmap_check_leaf_extents()
330 xfs_bmbt_rec_t last = {0, 0}; /* last extent in prev block */ in xfs_bmap_check_leaf_extents()
334 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmap_check_leaf_extents()
338 if (ip->i_df.if_nextents > 10000) in xfs_bmap_check_leaf_extents()
342 block = ifp->if_broot; in xfs_bmap_check_leaf_extents()
346 level = be16_to_cpu(block->bb_level); in xfs_bmap_check_leaf_extents()
348 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
349 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
353 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); in xfs_bmap_check_leaf_extents()
354 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); in xfs_bmap_check_leaf_extents()
360 while (level-- > 0) { in xfs_bmap_check_leaf_extents()
372 block = XFS_BUF_TO_BLOCK(bp); in xfs_bmap_check_leaf_extents()
377 * Check this block for basic sanity (increasing keys and in xfs_bmap_check_leaf_extents()
381 xfs_check_block(block, mp, 0, 0); in xfs_bmap_check_leaf_extents()
382 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); in xfs_bmap_check_leaf_extents()
385 error = -EFSCORRUPTED; in xfs_bmap_check_leaf_extents()
395 * Here with bp and block set to the leftmost leaf node in the tree. in xfs_bmap_check_leaf_extents()
407 num_recs = xfs_btree_get_numrecs(block); in xfs_bmap_check_leaf_extents()
410 * Read-ahead the next leaf block, if any. in xfs_bmap_check_leaf_extents()
413 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); in xfs_bmap_check_leaf_extents()
417 * If we had a previous block, the last entry should in xfs_bmap_check_leaf_extents()
421 ep = XFS_BMBT_REC_ADDR(mp, block, 1); in xfs_bmap_check_leaf_extents()
428 nextp = XFS_BMBT_REC_ADDR(mp, block, j + 1); in xfs_bmap_check_leaf_extents()
458 block = XFS_BUF_TO_BLOCK(bp); in xfs_bmap_check_leaf_extents()
507 mval[i - 1].br_startoff + mval[i - 1].br_blockcount == in xfs_bmap_validate_ret()
517 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0) argument
527 * The list is maintained sorted (by block number).
539 struct xfs_mount *mp = tp->t_mountp; in __xfs_bmap_add_free()
549 ASSERT(agno < mp->m_sb.sb_agcount); in __xfs_bmap_add_free()
550 ASSERT(agbno < mp->m_sb.sb_agblocks); in __xfs_bmap_add_free()
551 ASSERT(len < mp->m_sb.sb_agblocks); in __xfs_bmap_add_free()
552 ASSERT(agbno + len <= mp->m_sb.sb_agblocks); in __xfs_bmap_add_free()
558 new->xefi_startblock = bno; in __xfs_bmap_add_free()
559 new->xefi_blockcount = (xfs_extlen_t)len; in __xfs_bmap_add_free()
561 new->xefi_oinfo = *oinfo; in __xfs_bmap_add_free()
563 new->xefi_oinfo = XFS_RMAP_OINFO_SKIP_UPDATE; in __xfs_bmap_add_free()
564 new->xefi_skip_discard = skip_discard; in __xfs_bmap_add_free()
565 trace_xfs_bmap_free_defer(tp->t_mountp, in __xfs_bmap_add_free()
566 XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0, in __xfs_bmap_add_free()
567 XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len); in __xfs_bmap_add_free()
568 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list); in __xfs_bmap_add_free()
579 * Since the extents are already in-core, all we have to do is give up the space
580 * for the btree root and pitch the leaf block.
585 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_btree_to_extents() argument
590 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_btree_to_extents()
591 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_btree_to_extents()
592 struct xfs_btree_block *rblock = ifp->if_broot; in xfs_bmap_btree_to_extents()
593 struct xfs_btree_block *cblock;/* child btree block */ in xfs_bmap_btree_to_extents()
594 xfs_fsblock_t cbno; /* child block number */ in xfs_bmap_btree_to_extents()
595 xfs_buf_t *cbp; /* child block's buffer */ in xfs_bmap_btree_to_extents()
597 __be64 *pp; /* ptr to block address */ in xfs_bmap_btree_to_extents()
601 if (!xfs_bmap_wants_extents(ip, whichfork)) in xfs_bmap_btree_to_extents()
606 ASSERT(ifp->if_flags & XFS_IFEXTENTS); in xfs_bmap_btree_to_extents()
607 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in xfs_bmap_btree_to_extents()
608 ASSERT(be16_to_cpu(rblock->bb_level) == 1); in xfs_bmap_btree_to_extents()
609 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); in xfs_bmap_btree_to_extents()
610 ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0) == 1); in xfs_bmap_btree_to_extents()
612 pp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, ifp->if_broot_bytes); in xfs_bmap_btree_to_extents()
615 if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_btree_check_lptr(cur, cbno, 1))) in xfs_bmap_btree_to_extents()
616 return -EFSCORRUPTED; in xfs_bmap_btree_to_extents()
625 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); in xfs_bmap_btree_to_extents()
626 xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo); in xfs_bmap_btree_to_extents()
627 ip->i_d.di_nblocks--; in xfs_bmap_btree_to_extents()
628 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_btree_to_extents()
630 if (cur->bc_bufs[0] == cbp) in xfs_bmap_btree_to_extents()
631 cur->bc_bufs[0] = NULL; in xfs_bmap_btree_to_extents()
632 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_btree_to_extents()
633 ASSERT(ifp->if_broot == NULL); in xfs_bmap_btree_to_extents()
634 ASSERT((ifp->if_flags & XFS_IFBROOT) == 0); in xfs_bmap_btree_to_extents()
635 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_btree_to_extents()
641 * Convert an extents-format file into a btree-format file.
642 * The new file will have a root block (in the inode) and a single child block.
647 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_extents_to_btree() argument
653 struct xfs_btree_block *ablock; /* allocated (child) bt block */ in xfs_bmap_extents_to_btree()
657 struct xfs_btree_block *block; /* btree root block */ in xfs_bmap_extents_to_btree() local
661 struct xfs_bmbt_key *kp; /* root block key pointer */ in xfs_bmap_extents_to_btree()
663 xfs_bmbt_ptr_t *pp; /* root block address pointer */ in xfs_bmap_extents_to_btree()
668 mp = ip->i_mount; in xfs_bmap_extents_to_btree()
670 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_extents_to_btree()
671 ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_bmap_extents_to_btree()
677 xfs_iroot_realloc(ip, 1, whichfork); in xfs_bmap_extents_to_btree()
678 ifp->if_flags |= XFS_IFBROOT; in xfs_bmap_extents_to_btree()
683 block = ifp->if_broot; in xfs_bmap_extents_to_btree()
684 xfs_btree_init_block_int(mp, block, XFS_BUF_DADDR_NULL, in xfs_bmap_extents_to_btree()
685 XFS_BTNUM_BMAP, 1, 1, ip->i_ino, in xfs_bmap_extents_to_btree()
690 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_extents_to_btree()
691 cur->bc_ino.flags = wasdel ? XFS_BTCUR_BMBT_WASDEL : 0; in xfs_bmap_extents_to_btree()
695 ifp->if_format = XFS_DINODE_FMT_BTREE; in xfs_bmap_extents_to_btree()
699 xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork); in xfs_bmap_extents_to_btree()
700 if (tp->t_firstblock == NULLFSBLOCK) { in xfs_bmap_extents_to_btree()
702 args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino); in xfs_bmap_extents_to_btree()
703 } else if (tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_extents_to_btree()
705 args.fsbno = tp->t_firstblock; in xfs_bmap_extents_to_btree()
708 args.fsbno = tp->t_firstblock; in xfs_bmap_extents_to_btree()
718 error = -ENOSPC; in xfs_bmap_extents_to_btree()
725 ASSERT(tp->t_firstblock == NULLFSBLOCK || in xfs_bmap_extents_to_btree()
726 args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock)); in xfs_bmap_extents_to_btree()
727 tp->t_firstblock = args.fsbno; in xfs_bmap_extents_to_btree()
728 cur->bc_ino.allocated++; in xfs_bmap_extents_to_btree()
729 ip->i_d.di_nblocks++; in xfs_bmap_extents_to_btree()
730 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); in xfs_bmap_extents_to_btree()
731 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, in xfs_bmap_extents_to_btree()
733 mp->m_bsize, 0, &abp); in xfs_bmap_extents_to_btree()
738 * Fill in the child block. in xfs_bmap_extents_to_btree()
740 abp->b_ops = &xfs_bmbt_buf_ops; in xfs_bmap_extents_to_btree()
742 xfs_btree_init_block_int(mp, ablock, abp->b_bn, in xfs_bmap_extents_to_btree()
743 XFS_BTNUM_BMAP, 0, 0, ip->i_ino, in xfs_bmap_extents_to_btree()
753 ASSERT(cnt == ifp->if_nextents); in xfs_bmap_extents_to_btree()
759 kp = XFS_BMBT_KEY_ADDR(mp, block, 1); in xfs_bmap_extents_to_btree()
761 kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); in xfs_bmap_extents_to_btree()
762 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, xfs_bmbt_get_maxrecs(cur, in xfs_bmap_extents_to_btree()
763 be16_to_cpu(block->bb_level))); in xfs_bmap_extents_to_btree()
771 xfs_btree_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs)); in xfs_bmap_extents_to_btree()
778 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_extents_to_btree()
780 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_extents_to_btree()
781 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_extents_to_btree()
782 ASSERT(ifp->if_broot == NULL); in xfs_bmap_extents_to_btree()
792 * (The bmap-level manipulations are ok, though).
797 struct xfs_inode *ip, in xfs_bmap_local_to_extents_empty() argument
800 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_local_to_extents_empty()
803 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents_empty()
804 ASSERT(ifp->if_bytes == 0); in xfs_bmap_local_to_extents_empty()
805 ASSERT(ifp->if_nextents == 0); in xfs_bmap_local_to_extents_empty()
807 xfs_bmap_forkoff_reset(ip, whichfork); in xfs_bmap_local_to_extents_empty()
808 ifp->if_flags &= ~XFS_IFINLINE; in xfs_bmap_local_to_extents_empty()
809 ifp->if_flags |= XFS_IFEXTENTS; in xfs_bmap_local_to_extents_empty()
810 ifp->if_u1.if_root = NULL; in xfs_bmap_local_to_extents_empty()
811 ifp->if_height = 0; in xfs_bmap_local_to_extents_empty()
812 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_local_to_extents_empty()
813 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmap_local_to_extents_empty()
820 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_local_to_extents() argument
826 struct xfs_inode *ip, in xfs_bmap_local_to_extents() argument
833 xfs_buf_t *bp; /* buffer for extent block */ in xfs_bmap_local_to_extents()
841 ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK)); in xfs_bmap_local_to_extents()
842 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_local_to_extents()
843 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents()
845 if (!ifp->if_bytes) { in xfs_bmap_local_to_extents()
846 xfs_bmap_local_to_extents_empty(tp, ip, whichfork); in xfs_bmap_local_to_extents()
853 ASSERT((ifp->if_flags & (XFS_IFINLINE|XFS_IFEXTENTS)) == XFS_IFINLINE); in xfs_bmap_local_to_extents()
856 args.mp = ip->i_mount; in xfs_bmap_local_to_extents()
857 xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0); in xfs_bmap_local_to_extents()
859 * Allocate a block. We know we need only one, since the in xfs_bmap_local_to_extents()
862 if (tp->t_firstblock == NULLFSBLOCK) { in xfs_bmap_local_to_extents()
863 args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino); in xfs_bmap_local_to_extents()
866 args.fsbno = tp->t_firstblock; in xfs_bmap_local_to_extents()
878 tp->t_firstblock = args.fsbno; in xfs_bmap_local_to_extents()
879 error = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, in xfs_bmap_local_to_extents()
881 args.mp->m_bsize, 0, &bp); in xfs_bmap_local_to_extents()
886 * Initialize the block, copy the data and log the remote buffer. in xfs_bmap_local_to_extents()
893 init_fn(tp, bp, ip, ifp); in xfs_bmap_local_to_extents()
896 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); in xfs_bmap_local_to_extents()
897 xfs_bmap_local_to_extents_empty(tp, ip, whichfork); in xfs_bmap_local_to_extents()
900 ifp->if_u1.if_root = NULL; in xfs_bmap_local_to_extents()
901 ifp->if_height = 0; in xfs_bmap_local_to_extents()
908 xfs_iext_insert(ip, &icur, &rec, 0); in xfs_bmap_local_to_extents()
910 ifp->if_nextents = 1; in xfs_bmap_local_to_extents()
911 ip->i_d.di_nblocks = 1; in xfs_bmap_local_to_extents()
912 xfs_trans_mod_dquot_byino(tp, ip, in xfs_bmap_local_to_extents()
927 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_btree() argument
935 mp = ip->i_mount; in xfs_bmap_add_attrfork_btree()
936 if (ip->i_df.if_broot_bytes <= XFS_IFORK_DSIZE(ip)) in xfs_bmap_add_attrfork_btree()
939 cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK); in xfs_bmap_add_attrfork_btree()
945 error = -EFSCORRUPTED; in xfs_bmap_add_attrfork_btree()
952 return -ENOSPC; in xfs_bmap_add_attrfork_btree()
954 cur->bc_ino.allocated = 0; in xfs_bmap_add_attrfork_btree()
969 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_extents() argument
975 if (ip->i_df.if_nextents * sizeof(struct xfs_bmbt_rec) <= in xfs_bmap_add_attrfork_extents()
976 XFS_IFORK_DSIZE(ip)) in xfs_bmap_add_attrfork_extents()
979 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags, in xfs_bmap_add_attrfork_extents()
982 cur->bc_ino.allocated = 0; in xfs_bmap_add_attrfork_extents()
991 * conversion. Some are basic and only require special block initialisation
996 * formatting callout. It should be possible - it's just a very complex
1002 struct xfs_inode *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork_local() argument
1007 if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip)) in xfs_bmap_add_attrfork_local()
1010 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_bmap_add_attrfork_local()
1012 dargs.geo = ip->i_mount->m_dir_geo; in xfs_bmap_add_attrfork_local()
1013 dargs.dp = ip; in xfs_bmap_add_attrfork_local()
1014 dargs.total = dargs.geo->fsbcount; in xfs_bmap_add_attrfork_local()
1020 if (S_ISLNK(VFS_I(ip)->i_mode)) in xfs_bmap_add_attrfork_local()
1021 return xfs_bmap_local_to_extents(tp, ip, 1, flags, in xfs_bmap_add_attrfork_local()
1027 return -EFSCORRUPTED; in xfs_bmap_add_attrfork_local()
1033 struct xfs_inode *ip, in xfs_bmap_set_attrforkoff() argument
1037 switch (ip->i_df.if_format) { in xfs_bmap_set_attrforkoff()
1039 ip->i_d.di_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3; in xfs_bmap_set_attrforkoff()
1044 ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size); in xfs_bmap_set_attrforkoff()
1045 if (!ip->i_d.di_forkoff) in xfs_bmap_set_attrforkoff()
1046 ip->i_d.di_forkoff = xfs_default_attroffset(ip) >> 3; in xfs_bmap_set_attrforkoff()
1047 else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version) in xfs_bmap_set_attrforkoff()
1052 return -EINVAL; in xfs_bmap_set_attrforkoff()
1059 * Convert inode from non-attributed to attributed.
1060 * Must not be in a transaction, ip must not be locked.
1064 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_attrfork() argument
1075 ASSERT(XFS_IFORK_Q(ip) == 0); in xfs_bmap_add_attrfork()
1077 mp = ip->i_mount; in xfs_bmap_add_attrfork()
1078 ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); in xfs_bmap_add_attrfork()
1082 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_addafork, blks, 0, in xfs_bmap_add_attrfork()
1087 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmap_add_attrfork()
1088 error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? in xfs_bmap_add_attrfork()
1093 if (XFS_IFORK_Q(ip)) in xfs_bmap_add_attrfork()
1096 xfs_trans_ijoin(tp, ip, 0); in xfs_bmap_add_attrfork()
1097 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmap_add_attrfork()
1098 error = xfs_bmap_set_attrforkoff(ip, size, &version); in xfs_bmap_add_attrfork()
1101 ASSERT(ip->i_afp == NULL); in xfs_bmap_add_attrfork()
1103 ip->i_afp = kmem_cache_zalloc(xfs_ifork_zone, in xfs_bmap_add_attrfork()
1106 ip->i_afp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_add_attrfork()
1107 ip->i_afp->if_flags = XFS_IFEXTENTS; in xfs_bmap_add_attrfork()
1109 switch (ip->i_df.if_format) { in xfs_bmap_add_attrfork()
1111 error = xfs_bmap_add_attrfork_local(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1114 error = xfs_bmap_add_attrfork_extents(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1117 error = xfs_bmap_add_attrfork_btree(tp, ip, &logflags); in xfs_bmap_add_attrfork()
1124 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_add_attrfork()
1127 if (!xfs_sb_version_hasattr(&mp->m_sb) || in xfs_bmap_add_attrfork()
1128 (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { in xfs_bmap_add_attrfork()
1131 spin_lock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1132 if (!xfs_sb_version_hasattr(&mp->m_sb)) { in xfs_bmap_add_attrfork()
1133 xfs_sb_version_addattr(&mp->m_sb); in xfs_bmap_add_attrfork()
1136 if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { in xfs_bmap_add_attrfork()
1137 xfs_sb_version_addattr2(&mp->m_sb); in xfs_bmap_add_attrfork()
1140 spin_unlock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1146 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmap_add_attrfork()
1151 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmap_add_attrfork()
1164 /* Stuff every bmbt record from this block into the incore extent map. */
1172 struct xfs_mount *mp = cur->bc_mp; in xfs_iread_bmbt_block()
1173 struct xfs_inode *ip = cur->bc_ino.ip; in xfs_iread_bmbt_block() local
1174 struct xfs_btree_block *block; in xfs_iread_bmbt_block() local
1179 int whichfork = cur->bc_ino.whichfork; in xfs_iread_bmbt_block()
1180 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_iread_bmbt_block()
1182 block = xfs_btree_get_block(cur, level, &bp); in xfs_iread_bmbt_block()
1185 num_recs = xfs_btree_get_numrecs(block); in xfs_iread_bmbt_block()
1186 if (unlikely(ir->loaded + num_recs > ifp->if_nextents)) { in xfs_iread_bmbt_block()
1187 xfs_warn(ip->i_mount, "corrupt dinode %llu, (btree extents).", in xfs_iread_bmbt_block()
1188 (unsigned long long)ip->i_ino); in xfs_iread_bmbt_block()
1189 xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, block, in xfs_iread_bmbt_block()
1190 sizeof(*block), __this_address); in xfs_iread_bmbt_block()
1191 return -EFSCORRUPTED; in xfs_iread_bmbt_block()
1195 frp = XFS_BMBT_REC_ADDR(mp, block, 1); in xfs_iread_bmbt_block()
1196 for (j = 0; j < num_recs; j++, frp++, ir->loaded++) { in xfs_iread_bmbt_block()
1201 fa = xfs_bmap_validate_extent(ip, whichfork, &new); in xfs_iread_bmbt_block()
1203 xfs_inode_verifier_error(ip, -EFSCORRUPTED, in xfs_iread_bmbt_block()
1206 return -EFSCORRUPTED; in xfs_iread_bmbt_block()
1208 xfs_iext_insert(ip, &ir->icur, &new, in xfs_iread_bmbt_block()
1210 trace_xfs_read_extent(ip, &ir->icur, in xfs_iread_bmbt_block()
1212 xfs_iext_next(ifp, &ir->icur); in xfs_iread_bmbt_block()
1219 * Read in extents from a btree-format inode.
1224 struct xfs_inode *ip, in xfs_iread_extents() argument
1228 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_iread_extents()
1229 struct xfs_mount *mp = ip->i_mount; in xfs_iread_extents()
1233 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_iread_extents()
1235 if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) { in xfs_iread_extents()
1236 error = -EFSCORRUPTED; in xfs_iread_extents()
1242 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_iread_extents()
1249 if (XFS_IS_CORRUPT(mp, ir.loaded != ifp->if_nextents)) { in xfs_iread_extents()
1250 error = -EFSCORRUPTED; in xfs_iread_extents()
1255 ifp->if_flags |= XFS_IFEXTENTS; in xfs_iread_extents()
1263 * Returns the relative block number of the first unused block(s) in the given
1265 * lowest-address hole if the fork has holes, else the first block past the end
1266 * of fork. Return 0 if the fork is currently local (in-inode).
1271 struct xfs_inode *ip, /* incore inode */ in xfs_bmap_first_unused() argument
1273 xfs_fileoff_t *first_unused, /* unused block */ in xfs_bmap_first_unused()
1276 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_first_unused()
1283 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) { in xfs_bmap_first_unused()
1290 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_first_unused()
1291 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_first_unused()
1302 got.br_startoff - max >= len) in xfs_bmap_first_unused()
1313 * Returns the file-relative block number of the last block - 1 before
1321 struct xfs_inode *ip, /* incore inode */ in xfs_bmap_last_before() argument
1322 xfs_fileoff_t *last_block, /* last block */ in xfs_bmap_last_before()
1325 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_last_before()
1330 switch (ifp->if_format) { in xfs_bmap_last_before()
1339 return -EFSCORRUPTED; in xfs_bmap_last_before()
1342 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_last_before()
1343 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_last_before()
1348 if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got)) in xfs_bmap_last_before()
1356 struct xfs_inode *ip, in xfs_bmap_last_extent() argument
1361 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_last_extent()
1365 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_last_extent()
1366 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_last_extent()
1382 * blocks at the end of the file which do not start at the previous data block,
1385 * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be
1397 bma->aeof = false; in xfs_bmap_isaeof()
1398 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, in xfs_bmap_isaeof()
1404 bma->aeof = true; in xfs_bmap_isaeof()
1412 bma->aeof = bma->offset >= rec.br_startoff + rec.br_blockcount || in xfs_bmap_isaeof()
1413 (bma->offset >= rec.br_startoff && in xfs_bmap_isaeof()
1419 * Returns the file-relative block number of the first block past eof in
1425 struct xfs_inode *ip, in xfs_bmap_last_offset() argument
1429 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_last_offset()
1436 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) in xfs_bmap_last_offset()
1439 if (XFS_IS_CORRUPT(ip->i_mount, !xfs_ifork_has_extents(ifp))) in xfs_bmap_last_offset()
1440 return -EFSCORRUPTED; in xfs_bmap_last_offset()
1442 error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); in xfs_bmap_last_offset()
1452 * block or not. For the data fork we check this matches di_size,
1453 * implying the file's range is 0..bsize-1.
1455 int /* 1=>1 block, 0=>otherwise */
1457 struct xfs_inode *ip, /* incore inode */ in xfs_bmap_one_block() argument
1460 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_one_block()
1467 return XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize; in xfs_bmap_one_block()
1469 if (ifp->if_nextents != 1) in xfs_bmap_one_block()
1471 if (ifp->if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmap_one_block()
1473 ASSERT(ifp->if_flags & XFS_IFEXTENTS); in xfs_bmap_one_block()
1478 ASSERT(XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize); in xfs_bmap_one_block()
1494 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmap_add_extent_delay_real()
1495 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
1496 struct xfs_bmbt_irec *new = &bma->got; in xfs_bmap_add_extent_delay_real()
1511 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_delay_real()
1512 ASSERT(!bma->cur || in xfs_bmap_add_extent_delay_real()
1513 (bma->cur->bc_ino.flags & XFS_BTCUR_BMBT_WASDEL)); in xfs_bmap_add_extent_delay_real()
1524 xfs_iext_get_extent(ifp, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1525 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1527 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_delay_real()
1537 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_delay_real()
1546 if (xfs_iext_peek_prev_extent(ifp, &bma->icur, &LEFT)) { in xfs_bmap_add_extent_delay_real()
1553 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_delay_real()
1554 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_delay_real()
1555 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_delay_real()
1556 LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) in xfs_bmap_add_extent_delay_real()
1562 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_delay_real()
1564 if (xfs_iext_peek_next_extent(ifp, &bma->icur, &RIGHT)) { in xfs_bmap_add_extent_delay_real()
1572 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_delay_real()
1573 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_delay_real()
1574 new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && in xfs_bmap_add_extent_delay_real()
1579 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_delay_real()
1597 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1598 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1599 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1600 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1601 ifp->if_nextents--; in xfs_bmap_add_extent_delay_real()
1603 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1607 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1611 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1614 error = xfs_btree_delete(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1618 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1621 error = xfs_btree_decrement(bma->cur, 0, &i); in xfs_bmap_add_extent_delay_real()
1625 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1628 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1642 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1643 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1644 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1646 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1650 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1654 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1657 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1667 * with delay -> unwritten extent allocation here because the in xfs_bmap_add_extent_delay_real()
1670 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1672 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1674 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1675 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1676 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1677 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1679 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1683 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1687 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1690 error = xfs_bmbt_update(bma->cur, &PREV); in xfs_bmap_add_extent_delay_real()
1702 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1703 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1704 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1705 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1707 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1711 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1715 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1718 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1722 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1734 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1735 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1738 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1741 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1744 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1745 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1746 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1748 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1752 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1756 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1759 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1770 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1771 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1773 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1777 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1781 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1784 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1788 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1793 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1794 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1795 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1801 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1802 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1803 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1804 (bma->cur ? bma->cur->bc_ino.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1809 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1810 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1811 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1820 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_delay_real()
1821 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1822 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1824 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1828 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1832 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1835 error = xfs_bmbt_update(bma->cur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1840 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1841 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1847 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1848 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1849 xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1857 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1858 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1860 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1864 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1868 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1871 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1875 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1880 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1881 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1882 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1888 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1889 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1890 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1891 (bma->cur ? bma->cur->bc_ino.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1895 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1896 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1929 PREV.br_startoff + PREV.br_blockcount - new_endoff; in xfs_bmap_add_extent_delay_real()
1931 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1935 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_delay_real()
1937 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1939 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1941 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1942 xfs_iext_insert(bma->ip, &bma->icur, &RIGHT, state); in xfs_bmap_add_extent_delay_real()
1943 xfs_iext_insert(bma->ip, &bma->icur, &LEFT, state); in xfs_bmap_add_extent_delay_real()
1944 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1946 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1950 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1954 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1957 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1961 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1966 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1967 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1968 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1992 if (!(bma->flags & XFS_BMAPI_NORMAP)) in xfs_bmap_add_extent_delay_real()
1993 xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new); in xfs_bmap_add_extent_delay_real()
1996 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1999 ASSERT(bma->cur == NULL); in xfs_bmap_add_extent_delay_real()
2000 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
2001 &bma->cur, da_old > 0, &tmp_logflags, in xfs_bmap_add_extent_delay_real()
2003 bma->logflags |= tmp_logflags; in xfs_bmap_add_extent_delay_real()
2009 xfs_mod_delalloc(mp, (int64_t)da_new - da_old); in xfs_bmap_add_extent_delay_real()
2011 if (bma->cur) { in xfs_bmap_add_extent_delay_real()
2012 da_new += bma->cur->bc_ino.allocated; in xfs_bmap_add_extent_delay_real()
2013 bma->cur->bc_ino.allocated = 0; in xfs_bmap_add_extent_delay_real()
2019 error = xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), in xfs_bmap_add_extent_delay_real()
2023 xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
2026 bma->logflags |= rval; in xfs_bmap_add_extent_delay_real()
2039 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_extent_unwritten_real() argument
2055 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_unwritten_real()
2061 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_add_extent_unwritten_real()
2063 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_unwritten_real()
2076 ASSERT(new->br_state != PREV.br_state); in xfs_bmap_add_extent_unwritten_real()
2077 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2078 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_unwritten_real()
2085 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_unwritten_real()
2101 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_unwritten_real()
2102 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_unwritten_real()
2103 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_unwritten_real()
2104 LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) in xfs_bmap_add_extent_unwritten_real()
2110 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_unwritten_real()
2120 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_unwritten_real()
2121 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_unwritten_real()
2122 new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && in xfs_bmap_add_extent_unwritten_real()
2127 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_unwritten_real()
2144 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2145 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2147 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2148 ifp->if_nextents -= 2; in xfs_bmap_add_extent_unwritten_real()
2157 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2163 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2169 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2175 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2181 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2197 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2199 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2200 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2209 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2215 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2221 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2236 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2239 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_unwritten_real()
2241 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2242 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2252 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2258 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2264 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2279 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2280 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2290 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2304 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2307 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2308 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2309 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2311 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2313 xfs_iext_update_extent(ip, state, icur, &LEFT); in xfs_bmap_add_extent_unwritten_real()
2323 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2344 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2345 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2346 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2348 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2349 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_unwritten_real()
2350 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2360 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2366 cur->bc_rec.b = *new; in xfs_bmap_add_extent_unwritten_real()
2370 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2382 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2384 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_unwritten_real()
2385 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_unwritten_real()
2386 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2388 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2390 xfs_iext_update_extent(ip, state, icur, &RIGHT); in xfs_bmap_add_extent_unwritten_real()
2400 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2421 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2423 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2425 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_unwritten_real()
2426 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2436 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2446 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2452 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2465 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_unwritten_real()
2470 old.br_startoff + old.br_blockcount - new_endoff; in xfs_bmap_add_extent_unwritten_real()
2471 r[1].br_startblock = new->br_startblock + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2474 xfs_iext_update_extent(ip, state, icur, &PREV); in xfs_bmap_add_extent_unwritten_real()
2476 xfs_iext_insert(ip, icur, &r[1], state); in xfs_bmap_add_extent_unwritten_real()
2477 xfs_iext_insert(ip, icur, &r[0], state); in xfs_bmap_add_extent_unwritten_real()
2478 ifp->if_nextents += 2; in xfs_bmap_add_extent_unwritten_real()
2488 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2491 /* new right extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2495 /* new left extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2496 cur->bc_rec.b = PREV; in xfs_bmap_add_extent_unwritten_real()
2500 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2512 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2515 /* new middle extent - newext */ in xfs_bmap_add_extent_unwritten_real()
2519 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2539 xfs_rmap_convert_extent(mp, tp, ip, whichfork, new); in xfs_bmap_add_extent_unwritten_real()
2542 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_add_extent_unwritten_real()
2546 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in xfs_bmap_add_extent_unwritten_real()
2555 cur->bc_ino.allocated = 0; in xfs_bmap_add_extent_unwritten_real()
2559 xfs_bmap_check_leaf_extents(*curp, ip, whichfork); in xfs_bmap_add_extent_unwritten_real()
2573 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_add_extent_hole_delay() argument
2586 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_add_extent_hole_delay()
2587 ASSERT(isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_delay()
2600 * If it doesn't exist, we're converting the hole at end-of-file. in xfs_bmap_add_extent_hole_delay()
2613 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_delay()
2614 left.br_blockcount + new->br_blockcount <= MAXEXTLEN) in xfs_bmap_add_extent_hole_delay()
2618 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_delay()
2619 new->br_blockcount + right.br_blockcount <= MAXEXTLEN && in xfs_bmap_add_extent_hole_delay()
2621 (left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2635 temp = left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2639 startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2641 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2646 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_hole_delay()
2648 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_delay()
2657 temp = left.br_blockcount + new->br_blockcount; in xfs_bmap_add_extent_hole_delay()
2660 startblockval(new->br_startblock); in xfs_bmap_add_extent_hole_delay()
2661 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2667 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_delay()
2676 temp = new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_delay()
2677 oldlen = startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2679 newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), in xfs_bmap_add_extent_hole_delay()
2681 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_delay()
2684 xfs_iext_update_extent(ip, state, icur, &right); in xfs_bmap_add_extent_hole_delay()
2694 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_hole_delay()
2699 xfs_mod_fdblocks(ip->i_mount, (int64_t)(oldlen - newlen), in xfs_bmap_add_extent_hole_delay()
2704 xfs_mod_delalloc(ip->i_mount, (int64_t)newlen - oldlen); in xfs_bmap_add_extent_hole_delay()
2714 struct xfs_inode *ip, in xfs_bmap_add_extent_hole_real() argument
2722 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_add_extent_hole_real()
2723 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_hole_real()
2733 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_real()
2734 ASSERT(!cur || !(cur->bc_ino.flags & XFS_BTCUR_BMBT_WASDEL)); in xfs_bmap_add_extent_hole_real()
2762 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_real()
2763 left.br_startblock + left.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_hole_real()
2764 left.br_state == new->br_state && in xfs_bmap_add_extent_hole_real()
2765 left.br_blockcount + new->br_blockcount <= MAXEXTLEN) in xfs_bmap_add_extent_hole_real()
2769 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_real()
2770 new->br_startblock + new->br_blockcount == right.br_startblock && in xfs_bmap_add_extent_hole_real()
2771 new->br_state == right.br_state && in xfs_bmap_add_extent_hole_real()
2772 new->br_blockcount + right.br_blockcount <= MAXEXTLEN && in xfs_bmap_add_extent_hole_real()
2774 left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_real()
2789 left.br_blockcount += new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_real()
2791 xfs_iext_remove(ip, icur, state); in xfs_bmap_add_extent_hole_real()
2793 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_real()
2794 ifp->if_nextents--; in xfs_bmap_add_extent_hole_real()
2804 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2811 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2818 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2834 left.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2837 xfs_iext_update_extent(ip, state, icur, &left); in xfs_bmap_add_extent_hole_real()
2847 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2864 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_real()
2865 right.br_startblock = new->br_startblock; in xfs_bmap_add_extent_hole_real()
2866 right.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2867 xfs_iext_update_extent(ip, state, icur, &right); in xfs_bmap_add_extent_hole_real()
2877 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2892 xfs_iext_insert(ip, icur, new, state); in xfs_bmap_add_extent_hole_real()
2893 ifp->if_nextents++; in xfs_bmap_add_extent_hole_real()
2903 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2910 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2919 xfs_rmap_map_extent(tp, ip, whichfork, new); in xfs_bmap_add_extent_hole_real()
2922 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_add_extent_hole_real()
2926 error = xfs_bmap_extents_to_btree(tp, ip, curp, 0, in xfs_bmap_add_extent_hole_real()
2936 cur->bc_ino.allocated = 0; in xfs_bmap_add_extent_hole_real()
2938 xfs_bmap_check_leaf_extents(cur, ip, whichfork); in xfs_bmap_add_extent_hole_real()
2958 int eof, /* is extent at end-of-file? */ in xfs_bmap_extsize_align()
2985 (orig_off >= gotp->br_startoff) && in xfs_bmap_extsize_align()
2986 (orig_end <= gotp->br_startoff + gotp->br_blockcount)) { in xfs_bmap_extsize_align()
3000 align_off -= temp; in xfs_bmap_extsize_align()
3006 align_alen += extsz - temp; in xfs_bmap_extsize_align()
3017 align_alen -= extsz; in xfs_bmap_extsize_align()
3021 * If the previous block overlaps with this proposed allocation in xfs_bmap_extsize_align()
3024 if (prevp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3025 if (prevp->br_startblock == HOLESTARTBLOCK) in xfs_bmap_extsize_align()
3026 prevo = prevp->br_startoff; in xfs_bmap_extsize_align()
3028 prevo = prevp->br_startoff + prevp->br_blockcount; in xfs_bmap_extsize_align()
3034 * If the next block overlaps with this proposed allocation in xfs_bmap_extsize_align()
3037 * This may of course make the start overlap previous block, in xfs_bmap_extsize_align()
3038 * and if we hit the offset 0 limit then the next block in xfs_bmap_extsize_align()
3041 if (!eof && gotp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3042 if ((delay && gotp->br_startblock == HOLESTARTBLOCK) || in xfs_bmap_extsize_align()
3043 (!delay && gotp->br_startblock == DELAYSTARTBLOCK)) in xfs_bmap_extsize_align()
3044 nexto = gotp->br_startoff + gotp->br_blockcount; in xfs_bmap_extsize_align()
3046 nexto = gotp->br_startoff; in xfs_bmap_extsize_align()
3052 align_off = nexto > align_alen ? nexto - align_alen : 0; in xfs_bmap_extsize_align()
3065 align_alen = nexto - align_off; in xfs_bmap_extsize_align()
3072 if (rt && (temp = (align_alen % mp->m_sb.sb_rextsize))) { in xfs_bmap_extsize_align()
3079 align_alen - temp < orig_alen) in xfs_bmap_extsize_align()
3080 return -EINVAL; in xfs_bmap_extsize_align()
3085 align_alen -= temp; in xfs_bmap_extsize_align()
3091 else if (align_off + align_alen - temp >= orig_end) in xfs_bmap_extsize_align()
3092 align_alen -= temp; in xfs_bmap_extsize_align()
3097 align_alen -= orig_off - align_off; in xfs_bmap_extsize_align()
3099 align_alen -= align_alen % mp->m_sb.sb_rextsize; in xfs_bmap_extsize_align()
3105 return -EINVAL; in xfs_bmap_extsize_align()
3114 if (!eof && gotp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3115 ASSERT(align_off + align_alen <= gotp->br_startoff); in xfs_bmap_extsize_align()
3116 if (prevp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3117 ASSERT(align_off >= prevp->br_startoff + prevp->br_blockcount); in xfs_bmap_extsize_align()
3131 xfs_fsblock_t adjust; /* adjustment to block numbers */ in xfs_bmap_adjacent()
3132 xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */ in xfs_bmap_adjacent()
3134 int nullfb; /* true if ap->firstblock isn't set */ in xfs_bmap_adjacent()
3139 (x) < mp->m_sb.sb_rblocks : \ in xfs_bmap_adjacent()
3141 XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && \ in xfs_bmap_adjacent()
3142 XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks) in xfs_bmap_adjacent()
3144 mp = ap->ip->i_mount; in xfs_bmap_adjacent()
3145 nullfb = ap->tp->t_firstblock == NULLFSBLOCK; in xfs_bmap_adjacent()
3146 rt = XFS_IS_REALTIME_INODE(ap->ip) && in xfs_bmap_adjacent()
3147 (ap->datatype & XFS_ALLOC_USERDATA); in xfs_bmap_adjacent()
3149 ap->tp->t_firstblock); in xfs_bmap_adjacent()
3151 * If allocating at eof, and there's a previous real block, in xfs_bmap_adjacent()
3152 * try to use its last block as our starting point. in xfs_bmap_adjacent()
3154 if (ap->eof && ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3155 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3156 ISVALID(ap->prev.br_startblock + ap->prev.br_blockcount, in xfs_bmap_adjacent()
3157 ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3158 ap->blkno = ap->prev.br_startblock + ap->prev.br_blockcount; in xfs_bmap_adjacent()
3162 adjust = ap->offset - in xfs_bmap_adjacent()
3163 (ap->prev.br_startoff + ap->prev.br_blockcount); in xfs_bmap_adjacent()
3165 ISVALID(ap->blkno + adjust, ap->prev.br_startblock)) in xfs_bmap_adjacent()
3166 ap->blkno += adjust; in xfs_bmap_adjacent()
3173 else if (!ap->eof) { in xfs_bmap_adjacent()
3174 xfs_fsblock_t gotbno; /* right side block number */ in xfs_bmap_adjacent()
3176 xfs_fsblock_t prevbno; /* left side block number */ in xfs_bmap_adjacent()
3180 * If there's a previous (left) block, select a requested in xfs_bmap_adjacent()
3181 * start block based on it. in xfs_bmap_adjacent()
3183 if (ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3184 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3185 (prevbno = ap->prev.br_startblock + in xfs_bmap_adjacent()
3186 ap->prev.br_blockcount) && in xfs_bmap_adjacent()
3187 ISVALID(prevbno, ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3189 * Calculate gap to end of previous block. in xfs_bmap_adjacent()
3191 adjust = prevdiff = ap->offset - in xfs_bmap_adjacent()
3192 (ap->prev.br_startoff + in xfs_bmap_adjacent()
3193 ap->prev.br_blockcount); in xfs_bmap_adjacent()
3195 * Figure the startblock based on the previous block's in xfs_bmap_adjacent()
3199 * allocating, or using it gives us an invalid block in xfs_bmap_adjacent()
3200 * number, then just use the end of the previous block. in xfs_bmap_adjacent()
3202 if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3204 ap->prev.br_startblock)) in xfs_bmap_adjacent()
3217 * No previous block or can't follow it, just default. in xfs_bmap_adjacent()
3222 * If there's a following (right) block, select a requested in xfs_bmap_adjacent()
3223 * start block based on it. in xfs_bmap_adjacent()
3225 if (!isnullstartblock(ap->got.br_startblock)) { in xfs_bmap_adjacent()
3227 * Calculate gap to start of next block. in xfs_bmap_adjacent()
3229 adjust = gotdiff = ap->got.br_startoff - ap->offset; in xfs_bmap_adjacent()
3231 * Figure the startblock based on the next block's in xfs_bmap_adjacent()
3234 gotbno = ap->got.br_startblock; in xfs_bmap_adjacent()
3238 * allocating, or using it gives us an invalid block in xfs_bmap_adjacent()
3239 * number, then just use the start of the next block in xfs_bmap_adjacent()
3242 if (gotdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3243 ISVALID(gotbno - gotdiff, gotbno)) in xfs_bmap_adjacent()
3244 gotbno -= adjust; in xfs_bmap_adjacent()
3245 else if (ISVALID(gotbno - ap->length, gotbno)) { in xfs_bmap_adjacent()
3246 gotbno -= ap->length; in xfs_bmap_adjacent()
3247 gotdiff += adjust - ap->length; in xfs_bmap_adjacent()
3259 * No next block, just default. in xfs_bmap_adjacent()
3265 * one, else ap->blkno is already set (to 0 or the inode block). in xfs_bmap_adjacent()
3268 ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno; in xfs_bmap_adjacent()
3270 ap->blkno = prevbno; in xfs_bmap_adjacent()
3272 ap->blkno = gotbno; in xfs_bmap_adjacent()
3284 struct xfs_mount *mp = tp->t_mountp; in xfs_bmap_longest_free_extent()
3290 if (!pag->pagf_init) { in xfs_bmap_longest_free_extent()
3294 if (error == -EAGAIN) { in xfs_bmap_longest_free_extent()
3320 if (notinit || *blen < ap->minlen) { in xfs_bmap_select_minlen()
3325 args->minlen = ap->minlen; in xfs_bmap_select_minlen()
3326 } else if (*blen < args->maxlen) { in xfs_bmap_select_minlen()
3331 args->minlen = *blen; in xfs_bmap_select_minlen()
3337 args->minlen = args->maxlen; in xfs_bmap_select_minlen()
3347 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_btalloc_nullfb()
3352 args->type = XFS_ALLOCTYPE_START_BNO; in xfs_bmap_btalloc_nullfb()
3353 args->total = ap->total; in xfs_bmap_btalloc_nullfb()
3355 startag = ag = XFS_FSB_TO_AGNO(mp, args->fsbno); in xfs_bmap_btalloc_nullfb()
3359 while (*blen < args->maxlen) { in xfs_bmap_btalloc_nullfb()
3360 error = xfs_bmap_longest_free_extent(args->tp, ag, blen, in xfs_bmap_btalloc_nullfb()
3365 if (++ag == mp->m_sb.sb_agcount) in xfs_bmap_btalloc_nullfb()
3381 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_btalloc_filestreams()
3386 args->type = XFS_ALLOCTYPE_NEAR_BNO; in xfs_bmap_btalloc_filestreams()
3387 args->total = ap->total; in xfs_bmap_btalloc_filestreams()
3389 ag = XFS_FSB_TO_AGNO(mp, args->fsbno); in xfs_bmap_btalloc_filestreams()
3393 error = xfs_bmap_longest_free_extent(args->tp, ag, blen, ¬init); in xfs_bmap_btalloc_filestreams()
3397 if (*blen < args->maxlen) { in xfs_bmap_btalloc_filestreams()
3402 error = xfs_bmap_longest_free_extent(args->tp, ag, blen, in xfs_bmap_btalloc_filestreams()
3415 ap->blkno = args->fsbno = XFS_AGB_TO_FSB(mp, ag, 0); in xfs_bmap_btalloc_filestreams()
3425 if (ap->flags & XFS_BMAPI_COWFORK) { in xfs_bmap_btalloc_accounting()
3427 * COW fork blocks are in-core only and thus are treated as in xfs_bmap_btalloc_accounting()
3428 * in-core quota reservation (like delalloc blocks) even when in xfs_bmap_btalloc_accounting()
3435 if (ap->wasdel) { in xfs_bmap_btalloc_accounting()
3436 xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)args->len); in xfs_bmap_btalloc_accounting()
3442 * has acquired in-core quota reservation for this extent. in xfs_bmap_btalloc_accounting()
3448 ap->ip->i_delayed_blks += args->len; in xfs_bmap_btalloc_accounting()
3449 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, XFS_TRANS_DQ_RES_BLKS, in xfs_bmap_btalloc_accounting()
3450 -(long)args->len); in xfs_bmap_btalloc_accounting()
3455 ap->ip->i_d.di_nblocks += args->len; in xfs_bmap_btalloc_accounting()
3456 xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); in xfs_bmap_btalloc_accounting()
3457 if (ap->wasdel) { in xfs_bmap_btalloc_accounting()
3458 ap->ip->i_delayed_blks -= args->len; in xfs_bmap_btalloc_accounting()
3459 xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)args->len); in xfs_bmap_btalloc_accounting()
3461 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, in xfs_bmap_btalloc_accounting()
3462 ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT, in xfs_bmap_btalloc_accounting()
3463 args->len); in xfs_bmap_btalloc_accounting()
3473 xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */ in xfs_bmap_btalloc()
3480 int nullfb; /* true if ap->firstblock isn't set */ in xfs_bmap_btalloc()
3486 ASSERT(ap->length); in xfs_bmap_btalloc()
3487 orig_offset = ap->offset; in xfs_bmap_btalloc()
3488 orig_length = ap->length; in xfs_bmap_btalloc()
3490 mp = ap->ip->i_mount; in xfs_bmap_btalloc()
3494 if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC)) in xfs_bmap_btalloc()
3495 stripe_align = mp->m_swidth; in xfs_bmap_btalloc()
3496 else if (mp->m_dalign) in xfs_bmap_btalloc()
3497 stripe_align = mp->m_dalign; in xfs_bmap_btalloc()
3499 if (ap->flags & XFS_BMAPI_COWFORK) in xfs_bmap_btalloc()
3500 align = xfs_get_cowextsz_hint(ap->ip); in xfs_bmap_btalloc()
3501 else if (ap->datatype & XFS_ALLOC_USERDATA) in xfs_bmap_btalloc()
3502 align = xfs_get_extsz_hint(ap->ip); in xfs_bmap_btalloc()
3504 error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, in xfs_bmap_btalloc()
3505 align, 0, ap->eof, 0, ap->conv, in xfs_bmap_btalloc()
3506 &ap->offset, &ap->length); in xfs_bmap_btalloc()
3508 ASSERT(ap->length); in xfs_bmap_btalloc()
3512 nullfb = ap->tp->t_firstblock == NULLFSBLOCK; in xfs_bmap_btalloc()
3514 ap->tp->t_firstblock); in xfs_bmap_btalloc()
3516 if ((ap->datatype & XFS_ALLOC_USERDATA) && in xfs_bmap_btalloc()
3517 xfs_inode_is_filestream(ap->ip)) { in xfs_bmap_btalloc()
3518 ag = xfs_filestream_lookup_ag(ap->ip); in xfs_bmap_btalloc()
3520 ap->blkno = XFS_AGB_TO_FSB(mp, ag, 0); in xfs_bmap_btalloc()
3522 ap->blkno = XFS_INO_TO_FSB(mp, ap->ip->i_ino); in xfs_bmap_btalloc()
3525 ap->blkno = ap->tp->t_firstblock; in xfs_bmap_btalloc()
3530 * If allowed, use ap->blkno; otherwise must use firstblock since in xfs_bmap_btalloc()
3533 if (nullfb || XFS_FSB_TO_AGNO(mp, ap->blkno) == fb_agno) in xfs_bmap_btalloc()
3536 ap->blkno = ap->tp->t_firstblock; in xfs_bmap_btalloc()
3542 args.tp = ap->tp; in xfs_bmap_btalloc()
3544 args.fsbno = ap->blkno; in xfs_bmap_btalloc()
3548 args.maxlen = min(ap->length, mp->m_ag_max_usable); in xfs_bmap_btalloc()
3556 if ((ap->datatype & XFS_ALLOC_USERDATA) && in xfs_bmap_btalloc()
3557 xfs_inode_is_filestream(ap->ip)) in xfs_bmap_btalloc()
3563 } else if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_btalloc()
3564 if (xfs_inode_is_filestream(ap->ip)) in xfs_bmap_btalloc()
3568 args.total = args.minlen = ap->minlen; in xfs_bmap_btalloc()
3571 args.total = ap->total; in xfs_bmap_btalloc()
3572 args.minlen = ap->minlen; in xfs_bmap_btalloc()
3577 div_u64_rem(ap->offset, args.prod, &args.mod); in xfs_bmap_btalloc()
3579 args.mod = args.prod - args.mod; in xfs_bmap_btalloc()
3580 } else if (mp->m_sb.sb_blocksize >= PAGE_SIZE) { in xfs_bmap_btalloc()
3584 args.prod = PAGE_SIZE >> mp->m_sb.sb_blocklog; in xfs_bmap_btalloc()
3585 div_u64_rem(ap->offset, args.prod, &args.mod); in xfs_bmap_btalloc()
3587 args.mod = args.prod - args.mod; in xfs_bmap_btalloc()
3592 * try to allocate data blocks on stripe unit boundary. NOTE: ap->aeof in xfs_bmap_btalloc()
3596 if (!(ap->tp->t_flags & XFS_TRANS_LOWMODE) && ap->aeof) { in xfs_bmap_btalloc()
3597 if (!ap->offset) { in xfs_bmap_btalloc()
3607 args.minlen = blen - args.alignment; in xfs_bmap_btalloc()
3626 nextminlen = blen - stripe_align; in xfs_bmap_btalloc()
3631 nextminlen + stripe_align - in xfs_bmap_btalloc()
3632 args.minlen - 1; in xfs_bmap_btalloc()
3640 args.minleft = ap->minleft; in xfs_bmap_btalloc()
3641 args.wasdel = ap->wasdel; in xfs_bmap_btalloc()
3643 args.datatype = ap->datatype; in xfs_bmap_btalloc()
3655 args.fsbno = ap->blkno; in xfs_bmap_btalloc()
3669 args.fsbno = ap->blkno; in xfs_bmap_btalloc()
3675 args.minlen > ap->minlen) { in xfs_bmap_btalloc()
3676 args.minlen = ap->minlen; in xfs_bmap_btalloc()
3678 args.fsbno = ap->blkno; in xfs_bmap_btalloc()
3685 args.total = ap->minlen; in xfs_bmap_btalloc()
3688 ap->tp->t_flags |= XFS_TRANS_LOWMODE; in xfs_bmap_btalloc()
3693 * the first block that was allocated. in xfs_bmap_btalloc()
3695 ASSERT(ap->tp->t_firstblock == NULLFSBLOCK || in xfs_bmap_btalloc()
3696 XFS_FSB_TO_AGNO(mp, ap->tp->t_firstblock) <= in xfs_bmap_btalloc()
3699 ap->blkno = args.fsbno; in xfs_bmap_btalloc()
3700 if (ap->tp->t_firstblock == NULLFSBLOCK) in xfs_bmap_btalloc()
3701 ap->tp->t_firstblock = args.fsbno; in xfs_bmap_btalloc()
3703 ap->length = args.len; in xfs_bmap_btalloc()
3716 if (ap->length <= orig_length) in xfs_bmap_btalloc()
3717 ap->offset = orig_offset; in xfs_bmap_btalloc()
3718 else if (ap->offset + ap->length < orig_offset + orig_length) in xfs_bmap_btalloc()
3719 ap->offset = orig_offset + orig_length - ap->length; in xfs_bmap_btalloc()
3722 ap->blkno = NULLFSBLOCK; in xfs_bmap_btalloc()
3723 ap->length = 0; in xfs_bmap_btalloc()
3728 /* Trim extent to fit a logical block range. */
3738 if (irec->br_startoff + irec->br_blockcount <= bno || in xfs_trim_extent()
3739 irec->br_startoff >= end) { in xfs_trim_extent()
3740 irec->br_blockcount = 0; in xfs_trim_extent()
3744 if (irec->br_startoff < bno) { in xfs_trim_extent()
3745 distance = bno - irec->br_startoff; in xfs_trim_extent()
3746 if (isnullstartblock(irec->br_startblock)) in xfs_trim_extent()
3747 irec->br_startblock = DELAYSTARTBLOCK; in xfs_trim_extent()
3748 if (irec->br_startblock != DELAYSTARTBLOCK && in xfs_trim_extent()
3749 irec->br_startblock != HOLESTARTBLOCK) in xfs_trim_extent()
3750 irec->br_startblock += distance; in xfs_trim_extent()
3751 irec->br_startoff += distance; in xfs_trim_extent()
3752 irec->br_blockcount -= distance; in xfs_trim_extent()
3755 if (end < irec->br_startoff + irec->br_blockcount) { in xfs_trim_extent()
3756 distance = irec->br_startoff + irec->br_blockcount - end; in xfs_trim_extent()
3757 irec->br_blockcount -= distance; in xfs_trim_extent()
3776 got->br_startoff + got->br_blockcount <= obno) { in xfs_bmapi_trim_map()
3778 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3779 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3787 mval->br_startoff = *bno; in xfs_bmapi_trim_map()
3788 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3789 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3791 mval->br_startblock = got->br_startblock + in xfs_bmapi_trim_map()
3792 (*bno - got->br_startoff); in xfs_bmapi_trim_map()
3800 mval->br_blockcount = XFS_FILBLKS_MIN(end - *bno, in xfs_bmapi_trim_map()
3801 got->br_blockcount - (*bno - got->br_startoff)); in xfs_bmapi_trim_map()
3802 mval->br_state = got->br_state; in xfs_bmapi_trim_map()
3803 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_trim_map()
3823 ((mval->br_startoff + mval->br_blockcount) <= end)); in xfs_bmapi_update_map()
3824 ASSERT((flags & XFS_BMAPI_ENTIRE) || (mval->br_blockcount <= *len) || in xfs_bmapi_update_map()
3825 (mval->br_startoff < obno)); in xfs_bmapi_update_map()
3827 *bno = mval->br_startoff + mval->br_blockcount; in xfs_bmapi_update_map()
3828 *len = end - *bno; in xfs_bmapi_update_map()
3829 if (*n > 0 && mval->br_startoff == mval[-1].br_startoff) { in xfs_bmapi_update_map()
3831 ASSERT(mval->br_startblock == mval[-1].br_startblock); in xfs_bmapi_update_map()
3832 ASSERT(mval->br_blockcount > mval[-1].br_blockcount); in xfs_bmapi_update_map()
3833 ASSERT(mval->br_state == mval[-1].br_state); in xfs_bmapi_update_map()
3834 mval[-1].br_blockcount = mval->br_blockcount; in xfs_bmapi_update_map()
3835 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3836 } else if (*n > 0 && mval->br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3837 mval[-1].br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3838 mval[-1].br_startblock != HOLESTARTBLOCK && in xfs_bmapi_update_map()
3839 mval->br_startblock == mval[-1].br_startblock + in xfs_bmapi_update_map()
3840 mval[-1].br_blockcount && in xfs_bmapi_update_map()
3841 mval[-1].br_state == mval->br_state) { in xfs_bmapi_update_map()
3842 ASSERT(mval->br_startoff == in xfs_bmapi_update_map()
3843 mval[-1].br_startoff + mval[-1].br_blockcount); in xfs_bmapi_update_map()
3844 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3846 mval->br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3847 mval[-1].br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3848 mval->br_startoff == in xfs_bmapi_update_map()
3849 mval[-1].br_startoff + mval[-1].br_blockcount) { in xfs_bmapi_update_map()
3850 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3851 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3853 ((mval->br_startoff + mval->br_blockcount) <= in xfs_bmapi_update_map()
3866 struct xfs_inode *ip, in xfs_bmapi_read() argument
3873 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_read()
3875 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmapi_read()
3886 ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)); in xfs_bmapi_read()
3889 return -EFSCORRUPTED; in xfs_bmapi_read()
3893 return -EFSCORRUPTED; in xfs_bmapi_read()
3896 return -EIO; in xfs_bmapi_read()
3900 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmapi_read()
3901 error = xfs_iread_extents(NULL, ip, whichfork); in xfs_bmapi_read()
3906 if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) in xfs_bmapi_read()
3917 mval->br_startoff = bno; in xfs_bmapi_read()
3918 mval->br_startblock = HOLESTARTBLOCK; in xfs_bmapi_read()
3919 mval->br_blockcount = in xfs_bmapi_read()
3920 XFS_FILBLKS_MIN(len, got.br_startoff - bno); in xfs_bmapi_read()
3921 mval->br_state = XFS_EXT_NORM; in xfs_bmapi_read()
3922 bno += mval->br_blockcount; in xfs_bmapi_read()
3923 len -= mval->br_blockcount; in xfs_bmapi_read()
3947 * global pool and the extent inserted into the inode in-core extent tree.
3960 struct xfs_inode *ip, in xfs_bmapi_reserve_delalloc() argument
3969 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_reserve_delalloc()
3970 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmapi_reserve_delalloc()
3982 alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); in xfs_bmapi_reserve_delalloc()
3984 prealloc = alen - len; in xfs_bmapi_reserve_delalloc()
3989 xfs_extlen_t extsz = xfs_get_cowextsz_hint(ip); in xfs_bmapi_reserve_delalloc()
4000 * Make a transaction-less quota reservation for delayed allocation in xfs_bmapi_reserve_delalloc()
4004 error = xfs_trans_reserve_quota_nblks(NULL, ip, (long)alen, 0, in xfs_bmapi_reserve_delalloc()
4013 indlen = (xfs_extlen_t)xfs_bmap_worst_indlen(ip, alen); in xfs_bmapi_reserve_delalloc()
4016 error = xfs_mod_fdblocks(mp, -((int64_t)alen), false); in xfs_bmapi_reserve_delalloc()
4020 error = xfs_mod_fdblocks(mp, -((int64_t)indlen), false); in xfs_bmapi_reserve_delalloc()
4025 ip->i_delayed_blks += alen; in xfs_bmapi_reserve_delalloc()
4026 xfs_mod_delalloc(ip->i_mount, alen + indlen); in xfs_bmapi_reserve_delalloc()
4028 got->br_startoff = aoff; in xfs_bmapi_reserve_delalloc()
4029 got->br_startblock = nullstartblock(indlen); in xfs_bmapi_reserve_delalloc()
4030 got->br_blockcount = alen; in xfs_bmapi_reserve_delalloc()
4031 got->br_state = XFS_EXT_NORM; in xfs_bmapi_reserve_delalloc()
4033 xfs_bmap_add_extent_hole_delay(ip, whichfork, icur, got); in xfs_bmapi_reserve_delalloc()
4041 xfs_inode_set_eofblocks_tag(ip); in xfs_bmapi_reserve_delalloc()
4043 xfs_inode_set_cowblocks_tag(ip); in xfs_bmapi_reserve_delalloc()
4051 xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0, in xfs_bmapi_reserve_delalloc()
4060 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmap_alloc_userdata()
4061 int whichfork = xfs_bmapi_whichfork(bma->flags); in xfs_bmap_alloc_userdata()
4070 bma->datatype = XFS_ALLOC_NOBUSY; in xfs_bmap_alloc_userdata()
4072 bma->datatype |= XFS_ALLOC_USERDATA; in xfs_bmap_alloc_userdata()
4073 if (bma->offset == 0) in xfs_bmap_alloc_userdata()
4074 bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; in xfs_bmap_alloc_userdata()
4076 if (mp->m_dalign && bma->length >= mp->m_dalign) { in xfs_bmap_alloc_userdata()
4082 if (XFS_IS_REALTIME_INODE(bma->ip)) in xfs_bmap_alloc_userdata()
4093 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmapi_allocate()
4094 int whichfork = xfs_bmapi_whichfork(bma->flags); in xfs_bmapi_allocate()
4095 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); in xfs_bmapi_allocate()
4099 ASSERT(bma->length > 0); in xfs_bmapi_allocate()
4105 if (bma->wasdel) { in xfs_bmapi_allocate()
4106 bma->length = (xfs_extlen_t)bma->got.br_blockcount; in xfs_bmapi_allocate()
4107 bma->offset = bma->got.br_startoff; in xfs_bmapi_allocate()
4108 if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev)) in xfs_bmapi_allocate()
4109 bma->prev.br_startoff = NULLFILEOFF; in xfs_bmapi_allocate()
4111 bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN); in xfs_bmapi_allocate()
4112 if (!bma->eof) in xfs_bmapi_allocate()
4113 bma->length = XFS_FILBLKS_MIN(bma->length, in xfs_bmapi_allocate()
4114 bma->got.br_startoff - bma->offset); in xfs_bmapi_allocate()
4117 if (bma->flags & XFS_BMAPI_CONTIG) in xfs_bmapi_allocate()
4118 bma->minlen = bma->length; in xfs_bmapi_allocate()
4120 bma->minlen = 1; in xfs_bmapi_allocate()
4122 if (bma->flags & XFS_BMAPI_METADATA) in xfs_bmapi_allocate()
4126 if (error || bma->blkno == NULLFSBLOCK) in xfs_bmapi_allocate()
4129 if (bma->flags & XFS_BMAPI_ZERO) { in xfs_bmapi_allocate()
4130 error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); in xfs_bmapi_allocate()
4135 if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) in xfs_bmapi_allocate()
4136 bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); in xfs_bmapi_allocate()
4141 bma->nallocs++; in xfs_bmapi_allocate()
4143 if (bma->cur) in xfs_bmapi_allocate()
4144 bma->cur->bc_ino.flags = in xfs_bmapi_allocate()
4145 bma->wasdel ? XFS_BTCUR_BMBT_WASDEL : 0; in xfs_bmapi_allocate()
4147 bma->got.br_startoff = bma->offset; in xfs_bmapi_allocate()
4148 bma->got.br_startblock = bma->blkno; in xfs_bmapi_allocate()
4149 bma->got.br_blockcount = bma->length; in xfs_bmapi_allocate()
4150 bma->got.br_state = XFS_EXT_NORM; in xfs_bmapi_allocate()
4152 if (bma->flags & XFS_BMAPI_PREALLOC) in xfs_bmapi_allocate()
4153 bma->got.br_state = XFS_EXT_UNWRITTEN; in xfs_bmapi_allocate()
4155 if (bma->wasdel) in xfs_bmapi_allocate()
4158 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, in xfs_bmapi_allocate()
4159 whichfork, &bma->icur, &bma->cur, &bma->got, in xfs_bmapi_allocate()
4160 &bma->logflags, bma->flags); in xfs_bmapi_allocate()
4162 bma->logflags |= tmp_logflags; in xfs_bmapi_allocate()
4171 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_allocate()
4173 ASSERT(bma->got.br_startoff <= bma->offset); in xfs_bmapi_allocate()
4174 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= in xfs_bmapi_allocate()
4175 bma->offset + bma->length); in xfs_bmapi_allocate()
4176 ASSERT(bma->got.br_state == XFS_EXT_NORM || in xfs_bmapi_allocate()
4177 bma->got.br_state == XFS_EXT_UNWRITTEN); in xfs_bmapi_allocate()
4189 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4193 /* check if we need to do unwritten->real conversion */ in xfs_bmapi_convert_unwritten()
4194 if (mval->br_state == XFS_EXT_UNWRITTEN && in xfs_bmapi_convert_unwritten()
4198 /* check if we need to do real->unwritten conversion */ in xfs_bmapi_convert_unwritten()
4199 if (mval->br_state == XFS_EXT_NORM && in xfs_bmapi_convert_unwritten()
4207 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_convert_unwritten()
4208 if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) { in xfs_bmapi_convert_unwritten()
4209 bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp, in xfs_bmapi_convert_unwritten()
4210 bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4212 mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) in xfs_bmapi_convert_unwritten()
4220 error = xfs_zero_extent(bma->ip, mval->br_startblock, in xfs_bmapi_convert_unwritten()
4221 mval->br_blockcount); in xfs_bmapi_convert_unwritten()
4226 error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork, in xfs_bmapi_convert_unwritten()
4227 &bma->icur, &bma->cur, mval, &tmp_logflags); in xfs_bmapi_convert_unwritten()
4237 * any on-disk updates to make, so we don't need to log anything. in xfs_bmapi_convert_unwritten()
4240 bma->logflags |= tmp_logflags | XFS_ILOG_CORE; in xfs_bmapi_convert_unwritten()
4249 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_convert_unwritten()
4255 if (mval->br_blockcount < len) in xfs_bmapi_convert_unwritten()
4256 return -EAGAIN; in xfs_bmapi_convert_unwritten()
4263 struct xfs_inode *ip, in xfs_bmapi_minleft() argument
4266 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, fork); in xfs_bmapi_minleft()
4268 if (tp && tp->t_firstblock != NULLFSBLOCK) in xfs_bmapi_minleft()
4270 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_minleft()
4272 return be16_to_cpu(ifp->if_broot->bb_level) + 1; in xfs_bmapi_minleft()
4287 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); in xfs_bmapi_finish()
4289 if ((bma->logflags & xfs_ilog_fext(whichfork)) && in xfs_bmapi_finish()
4290 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_finish()
4291 bma->logflags &= ~xfs_ilog_fext(whichfork); in xfs_bmapi_finish()
4292 else if ((bma->logflags & xfs_ilog_fbroot(whichfork)) && in xfs_bmapi_finish()
4293 ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_finish()
4294 bma->logflags &= ~xfs_ilog_fbroot(whichfork); in xfs_bmapi_finish()
4296 if (bma->logflags) in xfs_bmapi_finish()
4297 xfs_trans_log_inode(bma->tp, bma->ip, bma->logflags); in xfs_bmapi_finish()
4298 if (bma->cur) in xfs_bmapi_finish()
4299 xfs_btree_del_cursor(bma->cur, error); in xfs_bmapi_finish()
4311 struct xfs_inode *ip, /* incore inode */ in xfs_bmapi_write() argument
4321 .ip = ip, in xfs_bmapi_write()
4324 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_write()
4326 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmapi_write()
4331 xfs_fileoff_t obno; /* old block number (offset) */ in xfs_bmapi_write()
4334 xfs_fileoff_t orig_bno; /* original block number value */ in xfs_bmapi_write()
4351 ASSERT(ifp->if_format != XFS_DINODE_FMT_LOCAL); in xfs_bmapi_write()
4352 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_bmapi_write()
4359 * we can allocate unwritten extents or pre-zero allocated blocks, in xfs_bmapi_write()
4369 return -EFSCORRUPTED; in xfs_bmapi_write()
4373 return -EIO; in xfs_bmapi_write()
4377 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmapi_write()
4378 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmapi_write()
4383 if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got)) in xfs_bmapi_write()
4387 bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); in xfs_bmapi_write()
4426 * check for 32-bit overflows and handle them here. in xfs_bmapi_write()
4456 if (error == -EAGAIN) in xfs_bmapi_write()
4479 error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, in xfs_bmapi_write()
4484 ASSERT(ifp->if_format != XFS_DINODE_FMT_BTREE || in xfs_bmapi_write()
4485 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork)); in xfs_bmapi_write()
4503 struct xfs_inode *ip, in xfs_bmapi_convert_delalloc() argument
4509 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmapi_convert_delalloc()
4510 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_convert_delalloc()
4524 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, in xfs_bmapi_convert_delalloc()
4529 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_delalloc()
4530 xfs_trans_ijoin(tp, ip, 0); in xfs_bmapi_convert_delalloc()
4532 if (!xfs_iext_lookup_extent(ip, ifp, offset_fsb, &bma.icur, &bma.got) || in xfs_bmapi_convert_delalloc()
4540 error = -EAGAIN; in xfs_bmapi_convert_delalloc()
4549 xfs_bmbt_to_iomap(ip, iomap, &bma.got, flags); in xfs_bmapi_convert_delalloc()
4550 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_delalloc()
4555 bma.ip = ip; in xfs_bmapi_convert_delalloc()
4559 bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); in xfs_bmapi_convert_delalloc()
4585 error = -ENOSPC; in xfs_bmapi_convert_delalloc()
4588 error = -EFSCORRUPTED; in xfs_bmapi_convert_delalloc()
4589 if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) in xfs_bmapi_convert_delalloc()
4596 xfs_bmbt_to_iomap(ip, iomap, &bma.got, flags); in xfs_bmapi_convert_delalloc()
4597 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_delalloc()
4602 error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, in xfs_bmapi_convert_delalloc()
4609 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_delalloc()
4616 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmapi_convert_delalloc()
4623 struct xfs_inode *ip, in xfs_bmapi_remap() argument
4629 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_remap()
4637 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmapi_remap()
4640 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_bmapi_remap()
4648 return -EFSCORRUPTED; in xfs_bmapi_remap()
4652 return -EIO; in xfs_bmapi_remap()
4654 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmapi_remap()
4655 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmapi_remap()
4660 if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) { in xfs_bmapi_remap()
4663 ASSERT(got.br_startoff - bno >= len); in xfs_bmapi_remap()
4666 ip->i_d.di_nblocks += len; in xfs_bmapi_remap()
4667 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bmapi_remap()
4669 if (ifp->if_flags & XFS_IFBROOT) { in xfs_bmapi_remap()
4670 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmapi_remap()
4671 cur->bc_ino.flags = 0; in xfs_bmapi_remap()
4682 error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur, in xfs_bmapi_remap()
4687 error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags, whichfork); in xfs_bmapi_remap()
4690 if (ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_remap()
4692 else if (ip->i_df.if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_remap()
4696 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmapi_remap()
4732 stolen = XFS_FILBLKS_MIN(nres - ores, avail); in xfs_bmap_split_indlen()
4758 * is zero, we want to make sure that one gets a block first. The loop in xfs_bmap_split_indlen()
4759 * below starts with len1, so hand len2 a block right off the bat if it in xfs_bmap_split_indlen()
4762 ores -= (len1 + len2); in xfs_bmap_split_indlen()
4763 ASSERT((*indlen1 - len1) + (*indlen2 - len2) >= ores); in xfs_bmap_split_indlen()
4766 ores--; in xfs_bmap_split_indlen()
4771 ores--; in xfs_bmap_split_indlen()
4777 ores--; in xfs_bmap_split_indlen()
4789 struct xfs_inode *ip, in xfs_bmap_del_extent_delay() argument
4795 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_delay()
4796 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_del_extent_delay()
4807 isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); in xfs_bmap_del_extent_delay()
4808 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_delay()
4809 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_delay()
4810 da_old = startblockval(got->br_startblock); in xfs_bmap_del_extent_delay()
4813 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_delay()
4814 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_delay()
4818 uint64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount); in xfs_bmap_del_extent_delay()
4820 do_div(rtexts, mp->m_sb.sb_rextsize); in xfs_bmap_del_extent_delay()
4827 * indirect block accounting. in xfs_bmap_del_extent_delay()
4829 error = xfs_trans_reserve_quota_nblks(NULL, ip, in xfs_bmap_del_extent_delay()
4830 -((long)del->br_blockcount), 0, in xfs_bmap_del_extent_delay()
4834 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4836 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_delay()
4846 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_delay()
4853 got->br_startoff = del_endoff; in xfs_bmap_del_extent_delay()
4854 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4855 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, in xfs_bmap_del_extent_delay()
4856 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4857 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4858 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
4864 got->br_blockcount = got->br_blockcount - del->br_blockcount; in xfs_bmap_del_extent_delay()
4865 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, in xfs_bmap_del_extent_delay()
4866 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4867 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4868 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
4880 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_delay()
4881 got_indlen = xfs_bmap_worst_indlen(ip, got->br_blockcount); in xfs_bmap_del_extent_delay()
4883 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_delay()
4884 new_indlen = xfs_bmap_worst_indlen(ip, new.br_blockcount); in xfs_bmap_del_extent_delay()
4888 del->br_blockcount); in xfs_bmap_del_extent_delay()
4890 got->br_startblock = nullstartblock((int)got_indlen); in xfs_bmap_del_extent_delay()
4893 new.br_state = got->br_state; in xfs_bmap_del_extent_delay()
4896 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_delay()
4898 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_delay()
4900 da_new = got_indlen + new_indlen - stolen; in xfs_bmap_del_extent_delay()
4901 del->br_blockcount -= stolen; in xfs_bmap_del_extent_delay()
4906 da_diff = da_old - da_new; in xfs_bmap_del_extent_delay()
4908 da_diff += del->br_blockcount; in xfs_bmap_del_extent_delay()
4911 xfs_mod_delalloc(mp, -da_diff); in xfs_bmap_del_extent_delay()
4918 struct xfs_inode *ip, in xfs_bmap_del_extent_cow() argument
4923 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_cow()
4924 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); in xfs_bmap_del_extent_cow()
4931 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_cow()
4932 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_cow()
4934 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_cow()
4935 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_cow()
4937 ASSERT(!isnullstartblock(got->br_startblock)); in xfs_bmap_del_extent_cow()
4939 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_cow()
4949 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_cow()
4956 got->br_startoff = del_endoff; in xfs_bmap_del_extent_cow()
4957 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
4958 got->br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
4959 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
4965 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
4966 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
4972 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_cow()
4975 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_cow()
4976 new.br_state = got->br_state; in xfs_bmap_del_extent_cow()
4977 new.br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
4979 xfs_iext_update_extent(ip, state, icur, got); in xfs_bmap_del_extent_cow()
4981 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_cow()
4984 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_cow()
4993 xfs_inode_t *ip, /* incore inode pointer */ in xfs_bmap_del_extent_real() argument
5002 xfs_fsblock_t del_endblock=0; /* first block past del */ in xfs_bmap_del_extent_real()
5012 xfs_filblks_t nblks; /* quota/sb block count */ in xfs_bmap_del_extent_real()
5019 mp = ip->i_mount; in xfs_bmap_del_extent_real()
5022 ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_del_extent_real()
5023 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_real()
5025 ASSERT(got.br_startoff <= del->br_startoff); in xfs_bmap_del_extent_real()
5026 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_real()
5034 * If it's the case where the directory code is running with no block in xfs_bmap_del_extent_real()
5035 * reservation, and the deleted block is in the middle of its extent, in xfs_bmap_del_extent_real()
5041 if (tp->t_blk_res == 0 && in xfs_bmap_del_extent_real()
5042 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_del_extent_real()
5043 ifp->if_nextents >= XFS_IFORK_MAXEXT(ip, whichfork) && in xfs_bmap_del_extent_real()
5044 del->br_startoff > got.br_startoff && del_endoff < got_endoff) in xfs_bmap_del_extent_real()
5045 return -ENOSPC; in xfs_bmap_del_extent_real()
5048 if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { in xfs_bmap_del_extent_real()
5052 len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize, in xfs_bmap_del_extent_real()
5059 bno = div_u64_rem(del->br_startblock, in xfs_bmap_del_extent_real()
5060 mp->m_sb.sb_rextsize, &mod); in xfs_bmap_del_extent_real()
5069 nblks = len * mp->m_sb.sb_rextsize; in xfs_bmap_del_extent_real()
5073 nblks = del->br_blockcount; in xfs_bmap_del_extent_real()
5077 del_endblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_real()
5083 error = -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5088 if (got.br_startoff == del->br_startoff) in xfs_bmap_del_extent_real()
5098 xfs_iext_remove(ip, icur, state); in xfs_bmap_del_extent_real()
5100 ifp->if_nextents--; in xfs_bmap_del_extent_real()
5110 error = -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5120 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5121 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5134 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5135 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5150 got.br_blockcount = del->br_startoff - got.br_startoff; in xfs_bmap_del_extent_real()
5151 xfs_iext_update_extent(ip, state, icur, &got); in xfs_bmap_del_extent_real()
5154 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_real()
5166 cur->bc_rec.b = new; in xfs_bmap_del_extent_real()
5168 if (error && error != -ENOSPC) in xfs_bmap_del_extent_real()
5171 * If get no-space back from btree insert, it tried a in xfs_bmap_del_extent_real()
5172 * split, and we have a zero block reservation. Fix up in xfs_bmap_del_extent_real()
5175 if (error == -ENOSPC) { in xfs_bmap_del_extent_real()
5184 error = -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5198 xfs_iext_update_extent(ip, state, icur, &old); in xfs_bmap_del_extent_real()
5200 error = -ENOSPC; in xfs_bmap_del_extent_real()
5204 error = -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5210 ifp->if_nextents++; in xfs_bmap_del_extent_real()
5212 xfs_iext_insert(ip, icur, &new, state); in xfs_bmap_del_extent_real()
5217 xfs_rmap_unmap_extent(tp, ip, whichfork, del); in xfs_bmap_del_extent_real()
5223 if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) { in xfs_bmap_del_extent_real()
5226 __xfs_bmap_add_free(tp, del->br_startblock, in xfs_bmap_del_extent_real()
5227 del->br_blockcount, NULL, in xfs_bmap_del_extent_real()
5229 del->br_state == XFS_EXT_UNWRITTEN); in xfs_bmap_del_extent_real()
5237 ip->i_d.di_nblocks -= nblks; in xfs_bmap_del_extent_real()
5242 xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); in xfs_bmap_del_extent_real()
5252 * that value. If not all extents in the block range can be removed then
5258 struct xfs_inode *ip, /* incore inode */ in __xfs_bunmapi() argument
5273 struct xfs_mount *mp = ip->i_mount; in __xfs_bunmapi()
5285 trace_xfs_bunmap(ip, start, len, flags, _RET_IP_); in __xfs_bunmapi()
5289 ifp = XFS_IFORK_PTR(ip, whichfork); in __xfs_bunmapi()
5291 return -EFSCORRUPTED; in __xfs_bunmapi()
5293 return -EIO; in __xfs_bunmapi()
5295 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in __xfs_bunmapi()
5304 if (tp && xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) in __xfs_bunmapi()
5305 max_len = min(len, xfs_refcount_max_unmap(tp->t_log_res)); in __xfs_bunmapi()
5309 if (!(ifp->if_flags & XFS_IFEXTENTS) && in __xfs_bunmapi()
5310 (error = xfs_iread_extents(tp, ip, whichfork))) in __xfs_bunmapi()
5317 isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); in __xfs_bunmapi()
5320 if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) { in __xfs_bunmapi()
5324 end--; in __xfs_bunmapi()
5327 if (ifp->if_flags & XFS_IFBROOT) { in __xfs_bunmapi()
5328 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in __xfs_bunmapi()
5329 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in __xfs_bunmapi()
5330 cur->bc_ino.flags = 0; in __xfs_bunmapi()
5338 xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL|XFS_ILOCK_RTBITMAP); in __xfs_bunmapi()
5339 xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); in __xfs_bunmapi()
5340 xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL|XFS_ILOCK_RTSUM); in __xfs_bunmapi()
5341 xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL); in __xfs_bunmapi()
5345 while (end != (xfs_fileoff_t)-1 && end >= start && in __xfs_bunmapi()
5357 * Is the last block of this extent before the range in __xfs_bunmapi()
5361 got.br_startoff + got.br_blockcount - 1); in __xfs_bunmapi()
5373 * in a single transaction, as that could cause AB-BA deadlocks. in __xfs_bunmapi()
5383 del.br_blockcount -= start - got.br_startoff; in __xfs_bunmapi()
5385 del.br_startblock += start - got.br_startoff; in __xfs_bunmapi()
5388 del.br_blockcount = end + 1 - del.br_startoff; in __xfs_bunmapi()
5392 del.br_startoff += del.br_blockcount - max_len; in __xfs_bunmapi()
5394 del.br_startblock += del.br_blockcount - max_len; in __xfs_bunmapi()
5402 div_u64_rem(sum, mp->m_sb.sb_rextsize, &mod); in __xfs_bunmapi()
5417 end -= mod > del.br_blockcount ? in __xfs_bunmapi()
5431 ASSERT(tp->t_blk_res > 0); in __xfs_bunmapi()
5437 del.br_startoff += del.br_blockcount - mod; in __xfs_bunmapi()
5438 del.br_startblock += del.br_blockcount - mod; in __xfs_bunmapi()
5442 error = xfs_bmap_add_extent_unwritten_real(tp, ip, in __xfs_bunmapi()
5449 div_u64_rem(del.br_startblock, mp->m_sb.sb_rextsize, &mod); in __xfs_bunmapi()
5451 xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; in __xfs_bunmapi()
5459 del.br_blockcount -= off; in __xfs_bunmapi()
5464 tp->t_blk_res == 0)) { in __xfs_bunmapi()
5470 end -= del.br_blockcount; in __xfs_bunmapi()
5494 del.br_startoff - mod, in __xfs_bunmapi()
5496 mod = unwrite_start - prev.br_startoff; in __xfs_bunmapi()
5499 prev.br_blockcount -= mod; in __xfs_bunmapi()
5502 ip, whichfork, &icur, &cur, in __xfs_bunmapi()
5511 ip, whichfork, &icur, &cur, in __xfs_bunmapi()
5521 error = xfs_bmap_del_extent_delay(ip, whichfork, &icur, in __xfs_bunmapi()
5524 error = xfs_bmap_del_extent_real(ip, tp, &icur, cur, in __xfs_bunmapi()
5533 max_len -= del.br_blockcount; in __xfs_bunmapi()
5534 end = del.br_startoff - 1; in __xfs_bunmapi()
5539 if (end != (xfs_fileoff_t)-1 && end >= start) { in __xfs_bunmapi()
5549 if (done || end == (xfs_fileoff_t)-1 || end < start) in __xfs_bunmapi()
5552 *rlen = end - start + 1; in __xfs_bunmapi()
5557 if (xfs_bmap_needs_btree(ip, whichfork)) { in __xfs_bunmapi()
5559 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in __xfs_bunmapi()
5563 error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags, in __xfs_bunmapi()
5573 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in __xfs_bunmapi()
5576 ifp->if_format != XFS_DINODE_FMT_BTREE) in __xfs_bunmapi()
5583 xfs_trans_log_inode(tp, ip, logflags); in __xfs_bunmapi()
5586 cur->bc_ino.allocated = 0; in __xfs_bunmapi()
5596 struct xfs_inode *ip, in xfs_bunmapi() argument
5605 error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts); in xfs_bunmapi()
5622 startoff = got->br_startoff - shift; in xfs_bmse_can_merge()
5625 * The extent, once shifted, must be adjacent in-file and on-disk with in xfs_bmse_can_merge()
5628 if ((left->br_startoff + left->br_blockcount != startoff) || in xfs_bmse_can_merge()
5629 (left->br_startblock + left->br_blockcount != got->br_startblock) || in xfs_bmse_can_merge()
5630 (left->br_state != got->br_state) || in xfs_bmse_can_merge()
5631 (left->br_blockcount + got->br_blockcount > MAXEXTLEN)) in xfs_bmse_can_merge()
5643 * This function assumes the caller has verified a shift-by-merge is possible
5649 struct xfs_inode *ip, in xfs_bmse_merge() argument
5658 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmse_merge()
5662 struct xfs_mount *mp = ip->i_mount; in xfs_bmse_merge()
5664 blockcount = left->br_blockcount + got->br_blockcount; in xfs_bmse_merge()
5666 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); in xfs_bmse_merge()
5667 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_bmse_merge()
5674 * Update the on-disk extent count, the btree if necessary and log the in xfs_bmse_merge()
5677 ifp->if_nextents--; in xfs_bmse_merge()
5689 return -EFSCORRUPTED; in xfs_bmse_merge()
5695 return -EFSCORRUPTED; in xfs_bmse_merge()
5702 return -EFSCORRUPTED; in xfs_bmse_merge()
5709 error = xfs_bmap_btree_to_extents(tp, ip, cur, logflags, whichfork); in xfs_bmse_merge()
5714 xfs_iext_remove(ip, icur, 0); in xfs_bmse_merge()
5716 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), icur, in xfs_bmse_merge()
5720 xfs_rmap_unmap_extent(tp, ip, whichfork, got); in xfs_bmse_merge()
5722 new.br_startoff = left->br_startoff + left->br_blockcount; in xfs_bmse_merge()
5723 xfs_rmap_map_extent(tp, ip, whichfork, &new); in xfs_bmse_merge()
5730 struct xfs_inode *ip, in xfs_bmap_shift_update_extent() argument
5738 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_shift_update_extent()
5744 got->br_startoff = startoff; in xfs_bmap_shift_update_extent()
5751 return -EFSCORRUPTED; in xfs_bmap_shift_update_extent()
5760 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), icur, in xfs_bmap_shift_update_extent()
5764 xfs_rmap_unmap_extent(tp, ip, whichfork, &prev); in xfs_bmap_shift_update_extent()
5765 xfs_rmap_map_extent(tp, ip, whichfork, got); in xfs_bmap_shift_update_extent()
5772 struct xfs_inode *ip, in xfs_bmap_collapse_extents() argument
5778 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_collapse_extents()
5779 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_collapse_extents()
5789 return -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5793 return -EIO; in xfs_bmap_collapse_extents()
5795 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); in xfs_bmap_collapse_extents()
5797 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_collapse_extents()
5798 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_collapse_extents()
5803 if (ifp->if_flags & XFS_IFBROOT) { in xfs_bmap_collapse_extents()
5804 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_collapse_extents()
5805 cur->bc_ino.flags = 0; in xfs_bmap_collapse_extents()
5808 if (!xfs_iext_lookup_extent(ip, ifp, *next_fsb, &icur, &got)) { in xfs_bmap_collapse_extents()
5813 error = -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5817 new_startoff = got.br_startoff - offset_shift_fsb; in xfs_bmap_collapse_extents()
5820 error = -EINVAL; in xfs_bmap_collapse_extents()
5825 error = xfs_bmse_merge(tp, ip, whichfork, in xfs_bmap_collapse_extents()
5834 error = -EINVAL; in xfs_bmap_collapse_extents()
5839 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got, in xfs_bmap_collapse_extents()
5855 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_collapse_extents()
5859 /* Make sure we won't be right-shifting an extent past the maximum bound. */
5862 struct xfs_inode *ip, in xfs_bmap_can_insert_extents() argument
5870 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); in xfs_bmap_can_insert_extents()
5872 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) in xfs_bmap_can_insert_extents()
5873 return -EIO; in xfs_bmap_can_insert_extents()
5875 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmap_can_insert_extents()
5876 error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &got, &is_empty); in xfs_bmap_can_insert_extents()
5879 error = -EINVAL; in xfs_bmap_can_insert_extents()
5880 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmap_can_insert_extents()
5888 struct xfs_inode *ip, in xfs_bmap_insert_extents() argument
5895 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_insert_extents()
5896 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_insert_extents()
5906 return -EFSCORRUPTED; in xfs_bmap_insert_extents()
5910 return -EIO; in xfs_bmap_insert_extents()
5912 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); in xfs_bmap_insert_extents()
5914 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_insert_extents()
5915 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_insert_extents()
5920 if (ifp->if_flags & XFS_IFBROOT) { in xfs_bmap_insert_extents()
5921 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_insert_extents()
5922 cur->bc_ino.flags = 0; in xfs_bmap_insert_extents()
5933 if (!xfs_iext_lookup_extent(ip, ifp, *next_fsb, &icur, &got)) { in xfs_bmap_insert_extents()
5939 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
5944 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
5951 error = -EINVAL; in xfs_bmap_insert_extents()
5965 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got, in xfs_bmap_insert_extents()
5981 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_insert_extents()
5986 * Splits an extent into two extents at split_fsb block such that it is the
5987 * first block of the current_ext. @ext is a target extent to be split.
5988 * @split_fsb is a block where the extents is split. If split_fsb lies in a
5989 * hole or the first block of extents, just return 0.
5994 struct xfs_inode *ip, in xfs_bmap_split_extent() argument
5998 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); in xfs_bmap_split_extent()
6002 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_split_extent()
6003 xfs_fsblock_t gotblkcnt; /* new block count for got */ in xfs_bmap_split_extent()
6011 return -EFSCORRUPTED; in xfs_bmap_split_extent()
6015 return -EIO; in xfs_bmap_split_extent()
6017 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_bmap_split_extent()
6019 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_split_extent()
6027 if (!xfs_iext_lookup_extent(ip, ifp, split_fsb, &icur, &got) || in xfs_bmap_split_extent()
6031 gotblkcnt = split_fsb - got.br_startoff; in xfs_bmap_split_extent()
6034 new.br_blockcount = got.br_blockcount - gotblkcnt; in xfs_bmap_split_extent()
6037 if (ifp->if_flags & XFS_IFBROOT) { in xfs_bmap_split_extent()
6038 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_split_extent()
6039 cur->bc_ino.flags = 0; in xfs_bmap_split_extent()
6044 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6050 xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), &icur, in xfs_bmap_split_extent()
6063 xfs_iext_insert(ip, &icur, &new, 0); in xfs_bmap_split_extent()
6064 ifp->if_nextents++; in xfs_bmap_split_extent()
6071 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6078 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6086 if (xfs_bmap_needs_btree(ip, whichfork)) { in xfs_bmap_split_extent()
6090 error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, in xfs_bmap_split_extent()
6097 cur->bc_ino.allocated = 0; in xfs_bmap_split_extent()
6102 xfs_trans_log_inode(tp, ip, logflags); in xfs_bmap_split_extent()
6111 return bmap->br_startblock != HOLESTARTBLOCK && in xfs_bmap_is_update_needed()
6112 bmap->br_startblock != DELAYSTARTBLOCK; in xfs_bmap_is_update_needed()
6120 struct xfs_inode *ip, in __xfs_bmap_add() argument
6126 trace_xfs_bmap_defer(tp->t_mountp, in __xfs_bmap_add()
6127 XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock), in __xfs_bmap_add()
6129 XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock), in __xfs_bmap_add()
6130 ip->i_ino, whichfork, in __xfs_bmap_add()
6131 bmap->br_startoff, in __xfs_bmap_add()
6132 bmap->br_blockcount, in __xfs_bmap_add()
6133 bmap->br_state); in __xfs_bmap_add()
6136 INIT_LIST_HEAD(&bi->bi_list); in __xfs_bmap_add()
6137 bi->bi_type = type; in __xfs_bmap_add()
6138 bi->bi_owner = ip; in __xfs_bmap_add()
6139 bi->bi_whichfork = whichfork; in __xfs_bmap_add()
6140 bi->bi_bmap = *bmap; in __xfs_bmap_add()
6142 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list); in __xfs_bmap_add()
6150 struct xfs_inode *ip, in xfs_bmap_map_extent() argument
6156 __xfs_bmap_add(tp, XFS_BMAP_MAP, ip, XFS_DATA_FORK, PREV); in xfs_bmap_map_extent()
6163 struct xfs_inode *ip, in xfs_bmap_unmap_extent() argument
6169 __xfs_bmap_add(tp, XFS_BMAP_UNMAP, ip, XFS_DATA_FORK, PREV); in xfs_bmap_unmap_extent()
6179 struct xfs_inode *ip, in xfs_bmap_finish_one() argument
6189 ASSERT(tp->t_firstblock == NULLFSBLOCK); in xfs_bmap_finish_one()
6191 trace_xfs_bmap_deferred(tp->t_mountp, in xfs_bmap_finish_one()
6192 XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type, in xfs_bmap_finish_one()
6193 XFS_FSB_TO_AGBNO(tp->t_mountp, startblock), in xfs_bmap_finish_one()
6194 ip->i_ino, whichfork, startoff, *blockcount, state); in xfs_bmap_finish_one()
6197 return -EFSCORRUPTED; in xfs_bmap_finish_one()
6199 if (XFS_TEST_ERROR(false, tp->t_mountp, in xfs_bmap_finish_one()
6201 return -EIO; in xfs_bmap_finish_one()
6205 error = xfs_bmapi_remap(tp, ip, startoff, *blockcount, in xfs_bmap_finish_one()
6210 error = __xfs_bunmapi(tp, ip, startoff, blockcount, in xfs_bmap_finish_one()
6215 error = -EFSCORRUPTED; in xfs_bmap_finish_one()
6224 struct xfs_inode *ip, in xfs_bmap_validate_extent() argument
6228 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_validate_extent()
6232 isrt = XFS_IS_REALTIME_INODE(ip); in xfs_bmap_validate_extent()
6233 endfsb = irec->br_startblock + irec->br_blockcount - 1; in xfs_bmap_validate_extent()
6235 if (!xfs_verify_rtbno(mp, irec->br_startblock)) in xfs_bmap_validate_extent()
6240 if (!xfs_verify_fsbno(mp, irec->br_startblock)) in xfs_bmap_validate_extent()
6244 if (XFS_FSB_TO_AGNO(mp, irec->br_startblock) != in xfs_bmap_validate_extent()
6248 if (irec->br_state != XFS_EXT_NORM && whichfork != XFS_DATA_FORK) in xfs_bmap_validate_extent()