Lines Matching +full:fsync +full:- +full:active +full:- +full:low
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
69 * leaf entries, is controlled by the size of the on-disk extent count. in xfs_bmap_compute_maxlevels()
87 minleafrecs = mp->m_bmap_dmnr[0]; in xfs_bmap_compute_maxlevels()
88 minnoderecs = mp->m_bmap_dmnr[1]; in xfs_bmap_compute_maxlevels()
96 mp->m_bm_maxlevels[whichfork] = level; in xfs_bmap_compute_maxlevels()
97 ASSERT(mp->m_bm_maxlevels[whichfork] <= xfs_bmbt_maxlevels_ondisk()); in xfs_bmap_compute_maxlevels()
104 if (mp->m_sb.sb_inodesize == 256) in xfs_bmap_compute_attr_offset()
105 return XFS_LITINO(mp) - xfs_bmdr_space_calc(MINABTPTRS); in xfs_bmap_compute_attr_offset()
115 cur->bc_rec.b = *irec; in xfs_bmbt_lookup_eq()
124 cur->bc_rec.b.br_startoff = 0; in xfs_bmbt_lookup_first()
125 cur->bc_rec.b.br_startblock = 0; in xfs_bmbt_lookup_first()
126 cur->bc_rec.b.br_blockcount = 0; in xfs_bmbt_lookup_first()
138 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_needs_btree()
139 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_needs_btree()
150 ifp->if_format == XFS_DINODE_FMT_BTREE && in xfs_bmap_wants_extents()
151 ifp->if_nextents <= XFS_IFORK_MAXEXT(ip, whichfork); in xfs_bmap_wants_extents()
170 * Compute the worst-case number of indirect blocks that will be used
183 mp = ip->i_mount; in xfs_bmap_worst_indlen()
184 maxrecs = mp->m_bmap_dmxr[0]; in xfs_bmap_worst_indlen()
188 len += maxrecs - 1; in xfs_bmap_worst_indlen()
192 return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - in xfs_bmap_worst_indlen()
193 level - 1; in xfs_bmap_worst_indlen()
195 maxrecs = mp->m_bmap_dmxr[1]; in xfs_bmap_worst_indlen()
207 if (ip->i_df.if_format == XFS_DINODE_FMT_DEV) in xfs_default_attroffset()
209 return M_IGEO(ip->i_mount)->attr_fork_offset; in xfs_default_attroffset()
214 * from local to extent format - we reset it where possible to make space
223 ip->i_df.if_format != XFS_DINODE_FMT_DEV && in xfs_bmap_forkoff_reset()
224 ip->i_df.if_format != XFS_DINODE_FMT_BTREE) { in xfs_bmap_forkoff_reset()
227 if (dfl_forkoff > ip->i_forkoff) in xfs_bmap_forkoff_reset()
228 ip->i_forkoff = dfl_forkoff; in xfs_bmap_forkoff_reset()
243 return -EFSCORRUPTED; in xfs_bmap_read_buf()
244 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, in xfs_bmap_read_buf()
245 XFS_FSB_TO_DADDR(mp, fsbno), mp->m_bsize, 0, &bp, in xfs_bmap_read_buf()
266 for (i = 0; i < cur->bc_maxlevels; i++) { in xfs_bmap_get_bp()
267 if (!cur->bc_levels[i].bp) in xfs_bmap_get_bp()
269 if (xfs_buf_daddr(cur->bc_levels[i].bp) == bno) in xfs_bmap_get_bp()
270 return cur->bc_levels[i].bp; in xfs_bmap_get_bp()
274 list_for_each_entry(lip, &cur->bc_tp->t_items, li_trans) { in xfs_bmap_get_bp()
277 if (bip->bli_item.li_type == XFS_LI_BUF && in xfs_bmap_get_bp()
278 xfs_buf_daddr(bip->bli_buf) == bno) in xfs_bmap_get_bp()
279 return bip->bli_buf; in xfs_bmap_get_bp()
296 ASSERT(be16_to_cpu(block->bb_level) > 0); in xfs_check_block()
300 dmxr = mp->m_bmap_dmxr[0]; in xfs_check_block()
304 ASSERT(be64_to_cpu(prevp->br_startoff) < in xfs_check_block()
305 be64_to_cpu(keyp->br_startoff)); in xfs_check_block()
317 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { in xfs_check_block()
347 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_check_leaf_extents()
361 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmap_check_leaf_extents()
365 if (ip->i_df.if_nextents > 10000) in xfs_bmap_check_leaf_extents()
369 block = ifp->if_broot; in xfs_bmap_check_leaf_extents()
373 level = be16_to_cpu(block->bb_level); in xfs_bmap_check_leaf_extents()
375 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
376 pp = xfs_bmap_broot_ptr_addr(mp, block, 1, ifp->if_broot_bytes); in xfs_bmap_check_leaf_extents()
380 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); in xfs_bmap_check_leaf_extents()
381 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); in xfs_bmap_check_leaf_extents()
387 while (level-- > 0) { in xfs_bmap_check_leaf_extents()
409 pp = xfs_bmbt_ptr_addr(mp, block, 1, mp->m_bmap_dmxr[1]); in xfs_bmap_check_leaf_extents()
413 error = -EFSCORRUPTED; in xfs_bmap_check_leaf_extents()
438 * Read-ahead the next leaf block, if any. in xfs_bmap_check_leaf_extents()
441 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); in xfs_bmap_check_leaf_extents()
535 mval[i - 1].br_startoff + mval[i - 1].br_blockcount == in xfs_bmap_validate_ret()
557 * Since the extents are already in-core, all we have to do is give up the space
569 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_btree_to_extents()
570 struct xfs_btree_block *rblock = ifp->if_broot; in xfs_bmap_btree_to_extents()
584 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in xfs_bmap_btree_to_extents()
585 ASSERT(be16_to_cpu(rblock->bb_level) == 1); in xfs_bmap_btree_to_extents()
586 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); in xfs_bmap_btree_to_extents()
587 ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, false) == 1); in xfs_bmap_btree_to_extents()
589 pp = xfs_bmap_broot_ptr_addr(mp, rblock, 1, ifp->if_broot_bytes); in xfs_bmap_btree_to_extents()
592 if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_verify_fsbno(mp, cbno))) { in xfs_bmap_btree_to_extents()
594 return -EFSCORRUPTED; in xfs_bmap_btree_to_extents()
606 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); in xfs_bmap_btree_to_extents()
607 error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo, in xfs_bmap_btree_to_extents()
612 ip->i_nblocks--; in xfs_bmap_btree_to_extents()
613 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_btree_to_extents()
615 if (cur->bc_levels[0].bp == cbp) in xfs_bmap_btree_to_extents()
616 cur->bc_levels[0].bp = NULL; in xfs_bmap_btree_to_extents()
617 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_btree_to_extents()
618 ASSERT(ifp->if_broot == NULL); in xfs_bmap_btree_to_extents()
619 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_btree_to_extents()
625 * Convert an extents-format file into a btree-format file.
652 mp = ip->i_mount; in xfs_bmap_extents_to_btree()
655 ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_bmap_extents_to_btree()
666 block = ifp->if_broot; in xfs_bmap_extents_to_btree()
673 cur->bc_flags |= XFS_BTREE_BMBT_WASDEL; in xfs_bmap_extents_to_btree()
677 ifp->if_format = XFS_DINODE_FMT_BTREE; in xfs_bmap_extents_to_btree()
681 xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork); in xfs_bmap_extents_to_btree()
687 XFS_INO_TO_FSB(mp, ip->i_ino)); in xfs_bmap_extents_to_btree()
695 error = -ENOSPC; in xfs_bmap_extents_to_btree()
699 cur->bc_bmap.allocated++; in xfs_bmap_extents_to_btree()
700 ip->i_nblocks++; in xfs_bmap_extents_to_btree()
702 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, in xfs_bmap_extents_to_btree()
704 mp->m_bsize, 0, &abp); in xfs_bmap_extents_to_btree()
721 ASSERT(cnt == ifp->if_nextents); in xfs_bmap_extents_to_btree()
729 kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); in xfs_bmap_extents_to_btree()
731 be16_to_cpu(block->bb_level))); in xfs_bmap_extents_to_btree()
739 xfs_btree_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs)); in xfs_bmap_extents_to_btree()
746 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); in xfs_bmap_extents_to_btree()
748 xfs_iroot_realloc(ip, -1, whichfork); in xfs_bmap_extents_to_btree()
749 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_extents_to_btree()
750 ASSERT(ifp->if_broot == NULL); in xfs_bmap_extents_to_btree()
760 * (The bmap-level manipulations are ok, though).
771 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents_empty()
772 ASSERT(ifp->if_bytes == 0); in xfs_bmap_local_to_extents_empty()
773 ASSERT(ifp->if_nextents == 0); in xfs_bmap_local_to_extents_empty()
776 ifp->if_data = NULL; in xfs_bmap_local_to_extents_empty()
777 ifp->if_height = 0; in xfs_bmap_local_to_extents_empty()
778 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xfs_bmap_local_to_extents_empty()
808 ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK)); in xfs_bmap_local_to_extents()
810 ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL); in xfs_bmap_local_to_extents()
812 if (!ifp->if_bytes) { in xfs_bmap_local_to_extents()
822 args.mp = ip->i_mount; in xfs_bmap_local_to_extents()
825 xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0); in xfs_bmap_local_to_extents()
834 XFS_INO_TO_FSB(args.mp, ip->i_ino)); in xfs_bmap_local_to_extents()
841 error = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, in xfs_bmap_local_to_extents()
843 args.mp->m_bsize, 0, &bp); in xfs_bmap_local_to_extents()
858 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); in xfs_bmap_local_to_extents()
862 ifp->if_data = NULL; in xfs_bmap_local_to_extents()
863 ifp->if_height = 0; in xfs_bmap_local_to_extents()
872 ifp->if_nextents = 1; in xfs_bmap_local_to_extents()
873 ip->i_nblocks = 1; in xfs_bmap_local_to_extents()
891 struct xfs_btree_block *block = ip->i_df.if_broot; in xfs_bmap_add_attrfork_btree()
897 mp = ip->i_mount; in xfs_bmap_add_attrfork_btree()
909 error = -EFSCORRUPTED; in xfs_bmap_add_attrfork_btree()
916 return -ENOSPC; in xfs_bmap_add_attrfork_btree()
918 cur->bc_bmap.allocated = 0; in xfs_bmap_add_attrfork_btree()
939 if (ip->i_df.if_nextents * sizeof(struct xfs_bmbt_rec) <= in xfs_bmap_add_attrfork_extents()
946 cur->bc_bmap.allocated = 0; in xfs_bmap_add_attrfork_extents()
960 * formatting callout. It should be possible - it's just a very complex
971 if (ip->i_df.if_bytes <= xfs_inode_data_fork_size(ip)) in xfs_bmap_add_attrfork_local()
974 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_bmap_add_attrfork_local()
976 dargs.geo = ip->i_mount->m_dir_geo; in xfs_bmap_add_attrfork_local()
978 dargs.total = dargs.geo->fsbcount; in xfs_bmap_add_attrfork_local()
981 dargs.owner = ip->i_ino; in xfs_bmap_add_attrfork_local()
985 if (S_ISLNK(VFS_I(ip)->i_mode)) in xfs_bmap_add_attrfork_local()
993 return -EFSCORRUPTED; in xfs_bmap_add_attrfork_local()
1007 switch (ip->i_df.if_format) { in xfs_bmap_set_attrforkoff()
1009 ip->i_forkoff = default_size; in xfs_bmap_set_attrforkoff()
1014 ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size); in xfs_bmap_set_attrforkoff()
1015 if (!ip->i_forkoff) in xfs_bmap_set_attrforkoff()
1016 ip->i_forkoff = default_size; in xfs_bmap_set_attrforkoff()
1017 else if (xfs_has_attr2(ip->i_mount) && version) in xfs_bmap_set_attrforkoff()
1022 return -EINVAL; in xfs_bmap_set_attrforkoff()
1029 * Convert inode from non-attributed to attributed. Caller must hold the
1039 struct xfs_mount *mp = tp->t_mountp; in xfs_bmap_add_attrfork()
1055 switch (ip->i_df.if_format) { in xfs_bmap_add_attrfork()
1077 spin_lock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1086 spin_unlock(&mp->m_sb_lock); in xfs_bmap_add_attrfork()
1110 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_complain_bad_rec()
1122 ip->i_ino, forkname, fa); in xfs_bmap_complain_bad_rec()
1125 irec->br_startoff, irec->br_startblock, irec->br_blockcount, in xfs_bmap_complain_bad_rec()
1126 irec->br_state); in xfs_bmap_complain_bad_rec()
1128 return -EFSCORRUPTED; in xfs_bmap_complain_bad_rec()
1139 struct xfs_mount *mp = cur->bc_mp; in xfs_iread_bmbt_block()
1140 struct xfs_inode *ip = cur->bc_ino.ip; in xfs_iread_bmbt_block()
1146 int whichfork = cur->bc_ino.whichfork; in xfs_iread_bmbt_block()
1153 if (unlikely(ir->loaded + num_recs > ifp->if_nextents)) { in xfs_iread_bmbt_block()
1154 xfs_warn(ip->i_mount, "corrupt dinode %llu, (btree extents).", in xfs_iread_bmbt_block()
1155 (unsigned long long)ip->i_ino); in xfs_iread_bmbt_block()
1156 xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, block, in xfs_iread_bmbt_block()
1159 return -EFSCORRUPTED; in xfs_iread_bmbt_block()
1164 for (j = 0; j < num_recs; j++, frp++, ir->loaded++) { in xfs_iread_bmbt_block()
1171 xfs_inode_verifier_error(ip, -EFSCORRUPTED, in xfs_iread_bmbt_block()
1178 xfs_iext_insert(ip, &ir->icur, &new, in xfs_iread_bmbt_block()
1180 trace_xfs_read_extent(ip, &ir->icur, in xfs_iread_bmbt_block()
1182 xfs_iext_next(ifp, &ir->icur); in xfs_iread_bmbt_block()
1189 * Read in extents from a btree-format inode.
1199 struct xfs_mount *mp = ip->i_mount; in xfs_iread_extents()
1217 if (XFS_IS_CORRUPT(mp, ir.loaded != ifp->if_nextents)) { in xfs_iread_extents()
1219 error = -EFSCORRUPTED; in xfs_iread_extents()
1228 smp_store_release(&ifp->if_needextents, 0); in xfs_iread_extents()
1240 * lowest-address hole if the fork has holes, else the first block past the end
1241 * of fork. Return 0 if the fork is currently local (in-inode).
1258 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) { in xfs_bmap_first_unused()
1275 got.br_startoff - max >= len) in xfs_bmap_first_unused()
1286 * Returns the file-relative block number of the last block - 1 before
1303 switch (ifp->if_format) { in xfs_bmap_last_before()
1313 return -EFSCORRUPTED; in xfs_bmap_last_before()
1355 * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be
1367 bma->aeof = false; in xfs_bmap_isaeof()
1368 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, in xfs_bmap_isaeof()
1374 bma->aeof = true; in xfs_bmap_isaeof()
1382 bma->aeof = bma->offset >= rec.br_startoff + rec.br_blockcount || in xfs_bmap_isaeof()
1383 (bma->offset >= rec.br_startoff && in xfs_bmap_isaeof()
1389 * Returns the file-relative block number of the first block past eof in
1406 if (ifp->if_format == XFS_DINODE_FMT_LOCAL) in xfs_bmap_last_offset()
1409 if (XFS_IS_CORRUPT(ip->i_mount, !xfs_ifork_has_extents(ifp))) { in xfs_bmap_last_offset()
1411 return -EFSCORRUPTED; in xfs_bmap_last_offset()
1434 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmap_add_extent_delay_real()
1435 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
1436 struct xfs_bmbt_irec *new = &bma->got; in xfs_bmap_add_extent_delay_real()
1451 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_delay_real()
1452 ASSERT(!bma->cur || (bma->cur->bc_flags & XFS_BTREE_BMBT_WASDEL)); in xfs_bmap_add_extent_delay_real()
1463 xfs_iext_get_extent(ifp, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1464 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1466 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_delay_real()
1476 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_delay_real()
1485 if (xfs_iext_peek_prev_extent(ifp, &bma->icur, &LEFT)) { in xfs_bmap_add_extent_delay_real()
1492 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_delay_real()
1493 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_delay_real()
1494 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_delay_real()
1495 LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_delay_real()
1501 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_delay_real()
1503 if (xfs_iext_peek_next_extent(ifp, &bma->icur, &RIGHT)) { in xfs_bmap_add_extent_delay_real()
1511 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_delay_real()
1512 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_delay_real()
1513 new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_delay_real()
1518 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_delay_real()
1536 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1537 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1538 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1539 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1540 ifp->if_nextents--; in xfs_bmap_add_extent_delay_real()
1542 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1546 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1550 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1551 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1554 error = xfs_btree_delete(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1558 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1559 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1562 error = xfs_btree_decrement(bma->cur, 0, &i); in xfs_bmap_add_extent_delay_real()
1566 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1567 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1570 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1585 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1586 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1587 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1589 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1593 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1597 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1598 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1601 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1612 * with delay -> unwritten extent allocation here because the in xfs_bmap_add_extent_delay_real()
1615 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1617 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1619 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1620 xfs_iext_remove(bma->ip, &bma->icur, state); in xfs_bmap_add_extent_delay_real()
1621 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1622 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1624 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1628 error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i); in xfs_bmap_add_extent_delay_real()
1632 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1633 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1636 error = xfs_bmbt_update(bma->cur, &PREV); in xfs_bmap_add_extent_delay_real()
1649 PREV.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1650 PREV.br_state = new->br_state; in xfs_bmap_add_extent_delay_real()
1651 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1652 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1654 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1658 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1662 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1663 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1666 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1670 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1671 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1684 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1685 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1688 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1691 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1694 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1695 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1696 xfs_iext_update_extent(bma->ip, state, &bma->icur, &LEFT); in xfs_bmap_add_extent_delay_real()
1698 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1702 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1706 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1707 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1710 error = xfs_bmbt_update(bma->cur, &LEFT); in xfs_bmap_add_extent_delay_real()
1722 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1723 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1725 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1729 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1733 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1734 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1737 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1741 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1742 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1747 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1748 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1749 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1755 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1756 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1757 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1758 (bma->cur ? bma->cur->bc_bmap.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1763 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1764 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1765 xfs_iext_prev(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1774 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_delay_real()
1775 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_delay_real()
1776 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1778 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1782 error = xfs_bmbt_lookup_eq(bma->cur, &old, &i); in xfs_bmap_add_extent_delay_real()
1786 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1787 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1790 error = xfs_bmbt_update(bma->cur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1795 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1796 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1802 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1803 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1804 xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); in xfs_bmap_add_extent_delay_real()
1813 xfs_iext_update_extent(bma->ip, state, &bma->icur, new); in xfs_bmap_add_extent_delay_real()
1814 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1816 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1820 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1824 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1825 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1828 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1832 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1833 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1838 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1839 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1840 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1846 temp = PREV.br_blockcount - new->br_blockcount; in xfs_bmap_add_extent_delay_real()
1847 da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(bma->ip, temp), in xfs_bmap_add_extent_delay_real()
1848 startblockval(PREV.br_startblock) - in xfs_bmap_add_extent_delay_real()
1849 (bma->cur ? bma->cur->bc_bmap.allocated : 0)); in xfs_bmap_add_extent_delay_real()
1853 xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); in xfs_bmap_add_extent_delay_real()
1854 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1888 PREV.br_startoff + PREV.br_blockcount - new_endoff; in xfs_bmap_add_extent_delay_real()
1890 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1894 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_delay_real()
1896 nullstartblock(xfs_bmap_worst_indlen(bma->ip, in xfs_bmap_add_extent_delay_real()
1898 xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); in xfs_bmap_add_extent_delay_real()
1900 xfs_iext_next(ifp, &bma->icur); in xfs_bmap_add_extent_delay_real()
1901 xfs_iext_insert(bma->ip, &bma->icur, &RIGHT, state); in xfs_bmap_add_extent_delay_real()
1902 xfs_iext_insert(bma->ip, &bma->icur, &LEFT, state); in xfs_bmap_add_extent_delay_real()
1903 ifp->if_nextents++; in xfs_bmap_add_extent_delay_real()
1905 if (bma->cur == NULL) in xfs_bmap_add_extent_delay_real()
1909 error = xfs_bmbt_lookup_eq(bma->cur, new, &i); in xfs_bmap_add_extent_delay_real()
1913 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1914 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1917 error = xfs_btree_insert(bma->cur, &i); in xfs_bmap_add_extent_delay_real()
1921 xfs_btree_mark_sick(bma->cur); in xfs_bmap_add_extent_delay_real()
1922 error = -EFSCORRUPTED; in xfs_bmap_add_extent_delay_real()
1927 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1928 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1929 &bma->cur, 1, &tmp_rval, whichfork); in xfs_bmap_add_extent_delay_real()
1953 if (!(bma->flags & XFS_BMAPI_NORMAP)) in xfs_bmap_add_extent_delay_real()
1954 xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new); in xfs_bmap_add_extent_delay_real()
1957 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { in xfs_bmap_add_extent_delay_real()
1960 ASSERT(bma->cur == NULL); in xfs_bmap_add_extent_delay_real()
1961 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, in xfs_bmap_add_extent_delay_real()
1962 &bma->cur, da_old > 0, &tmp_logflags, in xfs_bmap_add_extent_delay_real()
1964 bma->logflags |= tmp_logflags; in xfs_bmap_add_extent_delay_real()
1970 xfs_mod_delalloc(bma->ip, 0, (int64_t)da_new - da_old); in xfs_bmap_add_extent_delay_real()
1972 if (bma->cur) { in xfs_bmap_add_extent_delay_real()
1973 da_new += bma->cur->bc_bmap.allocated; in xfs_bmap_add_extent_delay_real()
1974 bma->cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_delay_real()
1979 xfs_add_fdblocks(mp, da_old - da_new); in xfs_bmap_add_extent_delay_real()
1981 error = xfs_dec_fdblocks(mp, da_new - da_old, true); in xfs_bmap_add_extent_delay_real()
1983 xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); in xfs_bmap_add_extent_delay_real()
1986 bma->logflags |= rval; in xfs_bmap_add_extent_delay_real()
2015 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_unwritten_real()
2023 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_unwritten_real()
2036 ASSERT(new->br_state != PREV.br_state); in xfs_bmap_add_extent_unwritten_real()
2037 new_endoff = new->br_startoff + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2038 ASSERT(PREV.br_startoff <= new->br_startoff); in xfs_bmap_add_extent_unwritten_real()
2045 if (PREV.br_startoff == new->br_startoff) in xfs_bmap_add_extent_unwritten_real()
2061 LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_unwritten_real()
2062 LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_unwritten_real()
2063 LEFT.br_state == new->br_state && in xfs_bmap_add_extent_unwritten_real()
2064 LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_unwritten_real()
2070 * Also check for all-three-contiguous being too large. in xfs_bmap_add_extent_unwritten_real()
2080 new->br_startblock + new->br_blockcount == RIGHT.br_startblock && in xfs_bmap_add_extent_unwritten_real()
2081 new->br_state == RIGHT.br_state && in xfs_bmap_add_extent_unwritten_real()
2082 new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_unwritten_real()
2087 LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount in xfs_bmap_add_extent_unwritten_real()
2108 ifp->if_nextents -= 2; in xfs_bmap_add_extent_unwritten_real()
2118 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2125 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2132 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2139 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2146 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2165 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2175 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2182 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2189 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2204 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2210 ifp->if_nextents--; in xfs_bmap_add_extent_unwritten_real()
2221 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2228 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2235 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2250 PREV.br_state = new->br_state; in xfs_bmap_add_extent_unwritten_real()
2262 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2276 LEFT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2279 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2280 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2281 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2296 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2317 PREV.br_startoff += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2318 PREV.br_startblock += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2319 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2323 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2334 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2340 cur->bc_rec.b = *new; in xfs_bmap_add_extent_unwritten_real()
2345 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2357 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2359 RIGHT.br_startoff = new->br_startoff; in xfs_bmap_add_extent_unwritten_real()
2360 RIGHT.br_startblock = new->br_startblock; in xfs_bmap_add_extent_unwritten_real()
2361 RIGHT.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2376 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2397 PREV.br_blockcount -= new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2402 ifp->if_nextents++; in xfs_bmap_add_extent_unwritten_real()
2413 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2424 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2431 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2444 PREV.br_blockcount = new->br_startoff - PREV.br_startoff; in xfs_bmap_add_extent_unwritten_real()
2449 old.br_startoff + old.br_blockcount - new_endoff; in xfs_bmap_add_extent_unwritten_real()
2450 r[1].br_startblock = new->br_startblock + new->br_blockcount; in xfs_bmap_add_extent_unwritten_real()
2457 ifp->if_nextents += 2; in xfs_bmap_add_extent_unwritten_real()
2468 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2471 /* new right extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2475 /* new left extent - oldext */ in xfs_bmap_add_extent_unwritten_real()
2476 cur->bc_rec.b = PREV; in xfs_bmap_add_extent_unwritten_real()
2481 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2494 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2497 /* new middle extent - newext */ in xfs_bmap_add_extent_unwritten_real()
2502 error = -EFSCORRUPTED; in xfs_bmap_add_extent_unwritten_real()
2538 cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_unwritten_real()
2570 ASSERT(isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_delay()
2583 * If it doesn't exist, we're converting the hole at end-of-file. in xfs_bmap_add_extent_hole_delay()
2596 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_delay()
2597 left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_hole_delay()
2601 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_delay()
2602 new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_hole_delay()
2604 (left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2618 temp = left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_delay()
2622 startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2640 temp = left.br_blockcount + new->br_blockcount; in xfs_bmap_add_extent_hole_delay()
2643 startblockval(new->br_startblock); in xfs_bmap_add_extent_hole_delay()
2659 temp = new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_delay()
2660 oldlen = startblockval(new->br_startblock) + in xfs_bmap_add_extent_hole_delay()
2664 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_delay()
2682 xfs_add_fdblocks(ip->i_mount, oldlen - newlen); in xfs_bmap_add_extent_hole_delay()
2687 xfs_mod_delalloc(ip, 0, (int64_t)newlen - oldlen); in xfs_bmap_add_extent_hole_delay()
2706 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_add_extent_hole_real()
2716 ASSERT(!isnullstartblock(new->br_startblock)); in xfs_bmap_add_extent_hole_real()
2717 ASSERT(!cur || !(cur->bc_flags & XFS_BTREE_BMBT_WASDEL)); in xfs_bmap_add_extent_hole_real()
2745 left.br_startoff + left.br_blockcount == new->br_startoff && in xfs_bmap_add_extent_hole_real()
2746 left.br_startblock + left.br_blockcount == new->br_startblock && in xfs_bmap_add_extent_hole_real()
2747 left.br_state == new->br_state && in xfs_bmap_add_extent_hole_real()
2748 left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) in xfs_bmap_add_extent_hole_real()
2752 new->br_startoff + new->br_blockcount == right.br_startoff && in xfs_bmap_add_extent_hole_real()
2753 new->br_startblock + new->br_blockcount == right.br_startblock && in xfs_bmap_add_extent_hole_real()
2754 new->br_state == right.br_state && in xfs_bmap_add_extent_hole_real()
2755 new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && in xfs_bmap_add_extent_hole_real()
2757 left.br_blockcount + new->br_blockcount + in xfs_bmap_add_extent_hole_real()
2772 left.br_blockcount += new->br_blockcount + right.br_blockcount; in xfs_bmap_add_extent_hole_real()
2777 ifp->if_nextents--; in xfs_bmap_add_extent_hole_real()
2788 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2796 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2804 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2820 left.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2834 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2851 right.br_startoff = new->br_startoff; in xfs_bmap_add_extent_hole_real()
2852 right.br_startblock = new->br_startblock; in xfs_bmap_add_extent_hole_real()
2853 right.br_blockcount += new->br_blockcount; in xfs_bmap_add_extent_hole_real()
2865 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2881 ifp->if_nextents++; in xfs_bmap_add_extent_hole_real()
2892 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2900 error = -EFSCORRUPTED; in xfs_bmap_add_extent_hole_real()
2926 cur->bc_bmap.allocated = 0; in xfs_bmap_add_extent_hole_real()
2948 int eof, /* is extent at end-of-file? */ in xfs_bmap_extsize_align()
2975 (orig_off >= gotp->br_startoff) && in xfs_bmap_extsize_align()
2976 (orig_end <= gotp->br_startoff + gotp->br_blockcount)) { in xfs_bmap_extsize_align()
2990 align_off -= temp; in xfs_bmap_extsize_align()
2996 align_alen += extsz - temp; in xfs_bmap_extsize_align()
3007 align_alen -= extsz; in xfs_bmap_extsize_align()
3014 if (prevp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3015 if (prevp->br_startblock == HOLESTARTBLOCK) in xfs_bmap_extsize_align()
3016 prevo = prevp->br_startoff; in xfs_bmap_extsize_align()
3018 prevo = prevp->br_startoff + prevp->br_blockcount; in xfs_bmap_extsize_align()
3031 if (!eof && gotp->br_startoff != NULLFILEOFF) { in xfs_bmap_extsize_align()
3032 if ((delay && gotp->br_startblock == HOLESTARTBLOCK) || in xfs_bmap_extsize_align()
3033 (!delay && gotp->br_startblock == DELAYSTARTBLOCK)) in xfs_bmap_extsize_align()
3034 nexto = gotp->br_startoff + gotp->br_blockcount; in xfs_bmap_extsize_align()
3036 nexto = gotp->br_startoff; in xfs_bmap_extsize_align()
3042 align_off = nexto > align_alen ? nexto - align_alen : 0; in xfs_bmap_extsize_align()
3055 align_alen = nexto - align_off; in xfs_bmap_extsize_align()
3069 align_alen - temp < orig_alen) in xfs_bmap_extsize_align()
3070 return -EINVAL; in xfs_bmap_extsize_align()
3075 align_alen -= temp; in xfs_bmap_extsize_align()
3081 else if (align_off + align_alen - temp >= orig_end) in xfs_bmap_extsize_align()
3082 align_alen -= temp; in xfs_bmap_extsize_align()
3087 align_alen -= orig_off - align_off; in xfs_bmap_extsize_align()
3089 align_alen -= xfs_extlen_to_rtxmod(mp, align_alen); in xfs_bmap_extsize_align()
3095 return -EINVAL; in xfs_bmap_extsize_align()
3104 if (!eof && gotp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3105 ASSERT(align_off + align_alen <= gotp->br_startoff); in xfs_bmap_extsize_align()
3106 if (prevp->br_startoff != NULLFILEOFF) in xfs_bmap_extsize_align()
3107 ASSERT(align_off >= prevp->br_startoff + prevp->br_blockcount); in xfs_bmap_extsize_align()
3121 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_adjacent_valid()
3123 if (XFS_IS_REALTIME_INODE(ap->ip) && in xfs_bmap_adjacent_valid()
3124 (ap->datatype & XFS_ALLOC_USERDATA)) in xfs_bmap_adjacent_valid()
3125 return x < mp->m_sb.sb_rblocks; in xfs_bmap_adjacent_valid()
3128 XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && in xfs_bmap_adjacent_valid()
3129 XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks; in xfs_bmap_adjacent_valid()
3134 /* returns true if ap->blkno was modified */
3145 if (ap->eof && ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3146 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3148 ap->prev.br_startblock + ap->prev.br_blockcount, in xfs_bmap_adjacent()
3149 ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3150 ap->blkno = ap->prev.br_startblock + ap->prev.br_blockcount; in xfs_bmap_adjacent()
3154 adjust = ap->offset - in xfs_bmap_adjacent()
3155 (ap->prev.br_startoff + ap->prev.br_blockcount); in xfs_bmap_adjacent()
3156 if (adjust && xfs_bmap_adjacent_valid(ap, ap->blkno + adjust, in xfs_bmap_adjacent()
3157 ap->prev.br_startblock)) in xfs_bmap_adjacent()
3158 ap->blkno += adjust; in xfs_bmap_adjacent()
3166 if (!ap->eof) { in xfs_bmap_adjacent()
3176 if (ap->prev.br_startoff != NULLFILEOFF && in xfs_bmap_adjacent()
3177 !isnullstartblock(ap->prev.br_startblock) && in xfs_bmap_adjacent()
3178 (prevbno = ap->prev.br_startblock + in xfs_bmap_adjacent()
3179 ap->prev.br_blockcount) && in xfs_bmap_adjacent()
3181 ap->prev.br_startblock)) { in xfs_bmap_adjacent()
3185 adjust = prevdiff = ap->offset - in xfs_bmap_adjacent()
3186 (ap->prev.br_startoff + in xfs_bmap_adjacent()
3187 ap->prev.br_blockcount); in xfs_bmap_adjacent()
3196 if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3198 ap->prev.br_startblock)) in xfs_bmap_adjacent()
3212 if (!isnullstartblock(ap->got.br_startblock)) { in xfs_bmap_adjacent()
3216 adjust = gotdiff = ap->got.br_startoff - ap->offset; in xfs_bmap_adjacent()
3221 gotbno = ap->got.br_startblock; in xfs_bmap_adjacent()
3229 if (gotdiff <= XFS_ALLOC_GAP_UNITS * ap->length && in xfs_bmap_adjacent()
3230 xfs_bmap_adjacent_valid(ap, gotbno - gotdiff, in xfs_bmap_adjacent()
3232 gotbno -= adjust; in xfs_bmap_adjacent()
3233 else if (xfs_bmap_adjacent_valid(ap, gotbno - ap->length, in xfs_bmap_adjacent()
3235 gotbno -= ap->length; in xfs_bmap_adjacent()
3236 gotdiff += adjust - ap->length; in xfs_bmap_adjacent()
3247 * one, else ap->blkno is already set (to 0 or the inode block). in xfs_bmap_adjacent()
3250 ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno; in xfs_bmap_adjacent()
3254 ap->blkno = prevbno; in xfs_bmap_adjacent()
3258 ap->blkno = gotbno; in xfs_bmap_adjacent()
3283 xfs_alloc_min_freelist(pag->pag_mount, pag), in xfs_bmap_longest_free_extent()
3302 if (blen < ap->minlen) in xfs_bmap_select_minlen()
3303 return ap->minlen; in xfs_bmap_select_minlen()
3310 if (blen < args->maxlen) in xfs_bmap_select_minlen()
3312 return args->maxlen; in xfs_bmap_select_minlen()
3321 struct xfs_mount *mp = args->mp; in xfs_bmap_btalloc_select_lengths()
3326 if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_btalloc_select_lengths()
3327 args->total = ap->minlen; in xfs_bmap_btalloc_select_lengths()
3328 args->minlen = ap->minlen; in xfs_bmap_btalloc_select_lengths()
3332 args->total = ap->total; in xfs_bmap_btalloc_select_lengths()
3333 startag = XFS_FSB_TO_AGNO(mp, ap->blkno); in xfs_bmap_btalloc_select_lengths()
3339 error = xfs_bmap_longest_free_extent(pag, args->tp, blen); in xfs_bmap_btalloc_select_lengths()
3340 if (error && error != -EAGAIN) in xfs_bmap_btalloc_select_lengths()
3343 if (*blen >= args->maxlen) in xfs_bmap_btalloc_select_lengths()
3349 args->minlen = xfs_bmap_select_minlen(ap, args, *blen); in xfs_bmap_btalloc_select_lengths()
3358 bool isrt = XFS_IS_REALTIME_INODE(ap->ip) && in xfs_bmap_alloc_account()
3359 !(ap->flags & XFS_BMAPI_ATTRFORK); in xfs_bmap_alloc_account()
3362 if (ap->flags & XFS_BMAPI_COWFORK) { in xfs_bmap_alloc_account()
3364 * COW fork blocks are in-core only and thus are treated as in xfs_bmap_alloc_account()
3365 * in-core quota reservation (like delalloc blocks) even when in xfs_bmap_alloc_account()
3372 if (ap->wasdel) { in xfs_bmap_alloc_account()
3373 xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0); in xfs_bmap_alloc_account()
3379 * has acquired in-core quota reservation for this extent. in xfs_bmap_alloc_account()
3385 ap->ip->i_delayed_blks += ap->length; in xfs_bmap_alloc_account()
3386 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, isrt ? in xfs_bmap_alloc_account()
3388 -(long)ap->length); in xfs_bmap_alloc_account()
3393 ap->ip->i_nblocks += ap->length; in xfs_bmap_alloc_account()
3394 xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); in xfs_bmap_alloc_account()
3395 if (ap->wasdel) { in xfs_bmap_alloc_account()
3396 ap->ip->i_delayed_blks -= ap->length; in xfs_bmap_alloc_account()
3397 xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0); in xfs_bmap_alloc_account()
3403 xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length); in xfs_bmap_alloc_account()
3411 struct xfs_mount *mp = args->mp; in xfs_bmap_compute_alignments()
3416 if (mp->m_swidth && xfs_has_swalloc(mp)) in xfs_bmap_compute_alignments()
3417 stripe_align = mp->m_swidth; in xfs_bmap_compute_alignments()
3418 else if (mp->m_dalign) in xfs_bmap_compute_alignments()
3419 stripe_align = mp->m_dalign; in xfs_bmap_compute_alignments()
3421 if (ap->flags & XFS_BMAPI_COWFORK) in xfs_bmap_compute_alignments()
3422 align = xfs_get_cowextsz_hint(ap->ip); in xfs_bmap_compute_alignments()
3423 else if (ap->datatype & XFS_ALLOC_USERDATA) in xfs_bmap_compute_alignments()
3424 align = xfs_get_extsz_hint(ap->ip); in xfs_bmap_compute_alignments()
3426 if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, in xfs_bmap_compute_alignments()
3427 ap->eof, 0, ap->conv, &ap->offset, in xfs_bmap_compute_alignments()
3428 &ap->length)) in xfs_bmap_compute_alignments()
3430 ASSERT(ap->length); in xfs_bmap_compute_alignments()
3435 args->prod = align; in xfs_bmap_compute_alignments()
3436 div_u64_rem(ap->offset, args->prod, &args->mod); in xfs_bmap_compute_alignments()
3437 if (args->mod) in xfs_bmap_compute_alignments()
3438 args->mod = args->prod - args->mod; in xfs_bmap_compute_alignments()
3439 } else if (mp->m_sb.sb_blocksize >= PAGE_SIZE) { in xfs_bmap_compute_alignments()
3440 args->prod = 1; in xfs_bmap_compute_alignments()
3441 args->mod = 0; in xfs_bmap_compute_alignments()
3443 args->prod = PAGE_SIZE >> mp->m_sb.sb_blocklog; in xfs_bmap_compute_alignments()
3444 div_u64_rem(ap->offset, args->prod, &args->mod); in xfs_bmap_compute_alignments()
3445 if (args->mod) in xfs_bmap_compute_alignments()
3446 args->mod = args->prod - args->mod; in xfs_bmap_compute_alignments()
3459 ap->blkno = args->fsbno; in xfs_bmap_process_allocated_extent()
3460 ap->length = args->len; in xfs_bmap_process_allocated_extent()
3462 * If the extent size hint is active, we tried to round the in xfs_bmap_process_allocated_extent()
3473 if (ap->length <= orig_length) in xfs_bmap_process_allocated_extent()
3474 ap->offset = orig_offset; in xfs_bmap_process_allocated_extent()
3475 else if (ap->offset + ap->length < orig_offset + orig_length) in xfs_bmap_process_allocated_extent()
3476 ap->offset = orig_offset + orig_length - ap->length; in xfs_bmap_process_allocated_extent()
3485 if (ap->minlen != 1) { in xfs_bmap_exact_minlen_extent_alloc()
3486 args->fsbno = NULLFSBLOCK; in xfs_bmap_exact_minlen_extent_alloc()
3490 args->alloc_minlen_only = 1; in xfs_bmap_exact_minlen_extent_alloc()
3491 args->minlen = args->maxlen = ap->minlen; in xfs_bmap_exact_minlen_extent_alloc()
3492 args->total = ap->total; in xfs_bmap_exact_minlen_extent_alloc()
3502 ap->blkno = XFS_AGB_TO_FSB(ap->ip->i_mount, 0, 0); in xfs_bmap_exact_minlen_extent_alloc()
3506 * iteration and then drops args->total to args->minlen, which might be in xfs_bmap_exact_minlen_extent_alloc()
3514 * If we are not low on available data blocks and we are allocating at
3518 * NOTE: ap->aeof is only set if the allocation length is >= the
3529 struct xfs_mount *mp = args->mp; in xfs_bmap_btalloc_at_eof()
3530 struct xfs_perag *caller_pag = args->pag; in xfs_bmap_btalloc_at_eof()
3539 if (ap->offset) { in xfs_bmap_btalloc_at_eof()
3547 args->alignment = 1; in xfs_bmap_btalloc_at_eof()
3548 if (blen > stripe_align && blen <= args->maxlen) in xfs_bmap_btalloc_at_eof()
3549 nextminlen = blen - stripe_align; in xfs_bmap_btalloc_at_eof()
3551 nextminlen = args->minlen; in xfs_bmap_btalloc_at_eof()
3552 if (nextminlen + stripe_align > args->minlen + 1) in xfs_bmap_btalloc_at_eof()
3553 args->minalignslop = nextminlen + stripe_align - in xfs_bmap_btalloc_at_eof()
3554 args->minlen - 1; in xfs_bmap_btalloc_at_eof()
3556 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3559 args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); in xfs_bmap_btalloc_at_eof()
3560 error = xfs_alloc_vextent_exact_bno(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3562 xfs_perag_put(args->pag); in xfs_bmap_btalloc_at_eof()
3563 args->pag = NULL; in xfs_bmap_btalloc_at_eof()
3568 if (args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_at_eof()
3574 args->alignment = stripe_align; in xfs_bmap_btalloc_at_eof()
3575 args->minlen = nextminlen; in xfs_bmap_btalloc_at_eof()
3576 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3582 args->alignment = stripe_align; in xfs_bmap_btalloc_at_eof()
3583 if (blen > args->alignment && in xfs_bmap_btalloc_at_eof()
3584 blen <= args->maxlen + args->alignment) in xfs_bmap_btalloc_at_eof()
3585 args->minlen = blen - args->alignment; in xfs_bmap_btalloc_at_eof()
3586 args->minalignslop = 0; in xfs_bmap_btalloc_at_eof()
3590 error = xfs_alloc_vextent_near_bno(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3592 args->pag = NULL; in xfs_bmap_btalloc_at_eof()
3593 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_at_eof()
3594 ASSERT(args->pag == NULL); in xfs_bmap_btalloc_at_eof()
3595 args->pag = caller_pag; in xfs_bmap_btalloc_at_eof()
3600 if (args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_at_eof()
3605 * original non-aligned state so the caller can proceed on allocation in xfs_bmap_btalloc_at_eof()
3608 args->alignment = 1; in xfs_bmap_btalloc_at_eof()
3613 * We have failed multiple allocation attempts so now are in a low space
3618 * If that fails, we are now critically low on space, so perform a last resort
3621 * transaction that we are critically low on space so they don't waste time on
3631 if (args->minlen > ap->minlen) { in xfs_bmap_btalloc_low_space()
3632 args->minlen = ap->minlen; in xfs_bmap_btalloc_low_space()
3633 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_low_space()
3634 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_low_space()
3639 args->total = ap->minlen; in xfs_bmap_btalloc_low_space()
3643 ap->tp->t_flags |= XFS_TRANS_LOWMODE; in xfs_bmap_btalloc_low_space()
3660 ASSERT(args->pag); in xfs_bmap_btalloc_filestreams()
3663 * If we are in low space mode, then optimal allocation will fail so in xfs_bmap_btalloc_filestreams()
3664 * prepare for minimal allocation and jump to the low space algorithm in xfs_bmap_btalloc_filestreams()
3667 if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { in xfs_bmap_btalloc_filestreams()
3668 args->minlen = ap->minlen; in xfs_bmap_btalloc_filestreams()
3669 ASSERT(args->fsbno == NULLFSBLOCK); in xfs_bmap_btalloc_filestreams()
3673 args->minlen = xfs_bmap_select_minlen(ap, args, blen); in xfs_bmap_btalloc_filestreams()
3674 if (ap->aeof) in xfs_bmap_btalloc_filestreams()
3678 if (!error && args->fsbno == NULLFSBLOCK) in xfs_bmap_btalloc_filestreams()
3679 error = xfs_alloc_vextent_near_bno(args, ap->blkno); in xfs_bmap_btalloc_filestreams()
3689 xfs_perag_rele(args->pag); in xfs_bmap_btalloc_filestreams()
3690 args->pag = NULL; in xfs_bmap_btalloc_filestreams()
3691 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_filestreams()
3706 ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); in xfs_bmap_btalloc_best_length()
3724 if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { in xfs_bmap_btalloc_best_length()
3727 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_best_length()
3731 error = xfs_alloc_vextent_start_ag(args, ap->blkno); in xfs_bmap_btalloc_best_length()
3732 if (error || args->fsbno != NULLFSBLOCK) in xfs_bmap_btalloc_best_length()
3742 struct xfs_mount *mp = ap->ip->i_mount; in xfs_bmap_btalloc()
3744 .tp = ap->tp, in xfs_bmap_btalloc()
3748 .minleft = ap->minleft, in xfs_bmap_btalloc()
3749 .wasdel = ap->wasdel, in xfs_bmap_btalloc()
3751 .datatype = ap->datatype, in xfs_bmap_btalloc()
3760 ASSERT(ap->length); in xfs_bmap_btalloc()
3761 orig_offset = ap->offset; in xfs_bmap_btalloc()
3762 orig_length = ap->length; in xfs_bmap_btalloc()
3767 args.maxlen = min(ap->length, mp->m_ag_max_usable); in xfs_bmap_btalloc()
3772 else if ((ap->datatype & XFS_ALLOC_USERDATA) && in xfs_bmap_btalloc()
3773 xfs_inode_is_filestream(ap->ip)) in xfs_bmap_btalloc()
3784 ap->blkno = NULLFSBLOCK; in xfs_bmap_btalloc()
3785 ap->length = 0; in xfs_bmap_btalloc()
3800 if (irec->br_startoff + irec->br_blockcount <= bno || in xfs_trim_extent()
3801 irec->br_startoff >= end) { in xfs_trim_extent()
3802 irec->br_blockcount = 0; in xfs_trim_extent()
3806 if (irec->br_startoff < bno) { in xfs_trim_extent()
3807 distance = bno - irec->br_startoff; in xfs_trim_extent()
3808 if (isnullstartblock(irec->br_startblock)) in xfs_trim_extent()
3809 irec->br_startblock = DELAYSTARTBLOCK; in xfs_trim_extent()
3810 if (irec->br_startblock != DELAYSTARTBLOCK && in xfs_trim_extent()
3811 irec->br_startblock != HOLESTARTBLOCK) in xfs_trim_extent()
3812 irec->br_startblock += distance; in xfs_trim_extent()
3813 irec->br_startoff += distance; in xfs_trim_extent()
3814 irec->br_blockcount -= distance; in xfs_trim_extent()
3817 if (end < irec->br_startoff + irec->br_blockcount) { in xfs_trim_extent()
3818 distance = irec->br_startoff + irec->br_blockcount - end; in xfs_trim_extent()
3819 irec->br_blockcount -= distance; in xfs_trim_extent()
3838 got->br_startoff + got->br_blockcount <= obno) { in xfs_bmapi_trim_map()
3840 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3841 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3849 mval->br_startoff = *bno; in xfs_bmapi_trim_map()
3850 if (isnullstartblock(got->br_startblock)) in xfs_bmapi_trim_map()
3851 mval->br_startblock = DELAYSTARTBLOCK; in xfs_bmapi_trim_map()
3853 mval->br_startblock = got->br_startblock + in xfs_bmapi_trim_map()
3854 (*bno - got->br_startoff); in xfs_bmapi_trim_map()
3862 mval->br_blockcount = XFS_FILBLKS_MIN(end - *bno, in xfs_bmapi_trim_map()
3863 got->br_blockcount - (*bno - got->br_startoff)); in xfs_bmapi_trim_map()
3864 mval->br_state = got->br_state; in xfs_bmapi_trim_map()
3865 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_trim_map()
3885 ((mval->br_startoff + mval->br_blockcount) <= end)); in xfs_bmapi_update_map()
3886 ASSERT((flags & XFS_BMAPI_ENTIRE) || (mval->br_blockcount <= *len) || in xfs_bmapi_update_map()
3887 (mval->br_startoff < obno)); in xfs_bmapi_update_map()
3889 *bno = mval->br_startoff + mval->br_blockcount; in xfs_bmapi_update_map()
3890 *len = end - *bno; in xfs_bmapi_update_map()
3891 if (*n > 0 && mval->br_startoff == mval[-1].br_startoff) { in xfs_bmapi_update_map()
3893 ASSERT(mval->br_startblock == mval[-1].br_startblock); in xfs_bmapi_update_map()
3894 ASSERT(mval->br_blockcount > mval[-1].br_blockcount); in xfs_bmapi_update_map()
3895 ASSERT(mval->br_state == mval[-1].br_state); in xfs_bmapi_update_map()
3896 mval[-1].br_blockcount = mval->br_blockcount; in xfs_bmapi_update_map()
3897 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3898 } else if (*n > 0 && mval->br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3899 mval[-1].br_startblock != DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3900 mval[-1].br_startblock != HOLESTARTBLOCK && in xfs_bmapi_update_map()
3901 mval->br_startblock == mval[-1].br_startblock + in xfs_bmapi_update_map()
3902 mval[-1].br_blockcount && in xfs_bmapi_update_map()
3903 mval[-1].br_state == mval->br_state) { in xfs_bmapi_update_map()
3904 ASSERT(mval->br_startoff == in xfs_bmapi_update_map()
3905 mval[-1].br_startoff + mval[-1].br_blockcount); in xfs_bmapi_update_map()
3906 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3908 mval->br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3909 mval[-1].br_startblock == DELAYSTARTBLOCK && in xfs_bmapi_update_map()
3910 mval->br_startoff == in xfs_bmapi_update_map()
3911 mval[-1].br_startoff + mval[-1].br_blockcount) { in xfs_bmapi_update_map()
3912 mval[-1].br_blockcount += mval->br_blockcount; in xfs_bmapi_update_map()
3913 mval[-1].br_state = mval->br_state; in xfs_bmapi_update_map()
3915 ((mval->br_startoff + mval->br_blockcount) <= in xfs_bmapi_update_map()
3935 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_read()
3952 return -EFSCORRUPTED; in xfs_bmapi_read()
3958 return -EFSCORRUPTED; in xfs_bmapi_read()
3962 return -EIO; in xfs_bmapi_read()
3981 mval->br_startoff = bno; in xfs_bmapi_read()
3982 mval->br_startblock = HOLESTARTBLOCK; in xfs_bmapi_read()
3983 mval->br_blockcount = in xfs_bmapi_read()
3984 XFS_FILBLKS_MIN(len, got.br_startoff - bno); in xfs_bmapi_read()
3985 mval->br_state = XFS_EXT_NORM; in xfs_bmapi_read()
3986 bno += mval->br_blockcount; in xfs_bmapi_read()
3987 len -= mval->br_blockcount; in xfs_bmapi_read()
4011 * global pool and the extent inserted into the inode in-core extent tree.
4033 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_reserve_delalloc()
4051 alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); in xfs_bmapi_reserve_delalloc()
4053 prealloc = alen - len; in xfs_bmapi_reserve_delalloc()
4077 * Make a transaction-less quota reservation for delayed allocation in xfs_bmapi_reserve_delalloc()
4105 ip->i_delayed_blks += alen; in xfs_bmapi_reserve_delalloc()
4108 got->br_startoff = aoff; in xfs_bmapi_reserve_delalloc()
4109 got->br_startblock = nullstartblock(indlen); in xfs_bmapi_reserve_delalloc()
4110 got->br_blockcount = alen; in xfs_bmapi_reserve_delalloc()
4111 got->br_state = XFS_EXT_NORM; in xfs_bmapi_reserve_delalloc()
4134 if (error == -ENOSPC || error == -EDQUOT) { in xfs_bmapi_reserve_delalloc()
4151 struct xfs_mount *mp = bma->ip->i_mount; in xfs_bmapi_allocate()
4152 int whichfork = xfs_bmapi_whichfork(bma->flags); in xfs_bmapi_allocate()
4153 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_allocate()
4156 ASSERT(bma->length > 0); in xfs_bmapi_allocate()
4157 ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN); in xfs_bmapi_allocate()
4159 if (bma->flags & XFS_BMAPI_CONTIG) in xfs_bmapi_allocate()
4160 bma->minlen = bma->length; in xfs_bmapi_allocate()
4162 bma->minlen = 1; in xfs_bmapi_allocate()
4164 if (!(bma->flags & XFS_BMAPI_METADATA)) { in xfs_bmapi_allocate()
4171 bma->datatype = XFS_ALLOC_NOBUSY; in xfs_bmapi_allocate()
4173 bma->datatype |= XFS_ALLOC_USERDATA; in xfs_bmapi_allocate()
4174 if (bma->offset == 0) in xfs_bmapi_allocate()
4175 bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; in xfs_bmapi_allocate()
4177 if (mp->m_dalign && bma->length >= mp->m_dalign) { in xfs_bmapi_allocate()
4185 if ((bma->datatype & XFS_ALLOC_USERDATA) && in xfs_bmapi_allocate()
4186 XFS_IS_REALTIME_INODE(bma->ip)) in xfs_bmapi_allocate()
4192 if (bma->blkno == NULLFSBLOCK) in xfs_bmapi_allocate()
4193 return -ENOSPC; in xfs_bmapi_allocate()
4195 if (WARN_ON_ONCE(!xfs_valid_startblock(bma->ip, bma->blkno))) { in xfs_bmapi_allocate()
4196 xfs_bmap_mark_sick(bma->ip, whichfork); in xfs_bmapi_allocate()
4197 return -EFSCORRUPTED; in xfs_bmapi_allocate()
4200 if (bma->flags & XFS_BMAPI_ZERO) { in xfs_bmapi_allocate()
4201 error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); in xfs_bmapi_allocate()
4206 if (ifp->if_format == XFS_DINODE_FMT_BTREE && !bma->cur) in xfs_bmapi_allocate()
4207 bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); in xfs_bmapi_allocate()
4212 bma->nallocs++; in xfs_bmapi_allocate()
4214 if (bma->cur && bma->wasdel) in xfs_bmapi_allocate()
4215 bma->cur->bc_flags |= XFS_BTREE_BMBT_WASDEL; in xfs_bmapi_allocate()
4217 bma->got.br_startoff = bma->offset; in xfs_bmapi_allocate()
4218 bma->got.br_startblock = bma->blkno; in xfs_bmapi_allocate()
4219 bma->got.br_blockcount = bma->length; in xfs_bmapi_allocate()
4220 bma->got.br_state = XFS_EXT_NORM; in xfs_bmapi_allocate()
4222 if (bma->flags & XFS_BMAPI_PREALLOC) in xfs_bmapi_allocate()
4223 bma->got.br_state = XFS_EXT_UNWRITTEN; in xfs_bmapi_allocate()
4225 if (bma->wasdel) in xfs_bmapi_allocate()
4228 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, in xfs_bmapi_allocate()
4229 whichfork, &bma->icur, &bma->cur, &bma->got, in xfs_bmapi_allocate()
4230 &bma->logflags, bma->flags); in xfs_bmapi_allocate()
4239 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_allocate()
4241 ASSERT(bma->got.br_startoff <= bma->offset); in xfs_bmapi_allocate()
4242 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= in xfs_bmapi_allocate()
4243 bma->offset + bma->length); in xfs_bmapi_allocate()
4244 ASSERT(bma->got.br_state == XFS_EXT_NORM || in xfs_bmapi_allocate()
4245 bma->got.br_state == XFS_EXT_UNWRITTEN); in xfs_bmapi_allocate()
4257 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4261 /* check if we need to do unwritten->real conversion */ in xfs_bmapi_convert_unwritten()
4262 if (mval->br_state == XFS_EXT_UNWRITTEN && in xfs_bmapi_convert_unwritten()
4266 /* check if we need to do real->unwritten conversion */ in xfs_bmapi_convert_unwritten()
4267 if (mval->br_state == XFS_EXT_NORM && in xfs_bmapi_convert_unwritten()
4275 ASSERT(mval->br_blockcount <= len); in xfs_bmapi_convert_unwritten()
4276 if (ifp->if_format == XFS_DINODE_FMT_BTREE && !bma->cur) { in xfs_bmapi_convert_unwritten()
4277 bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp, in xfs_bmapi_convert_unwritten()
4278 bma->ip, whichfork); in xfs_bmapi_convert_unwritten()
4280 mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) in xfs_bmapi_convert_unwritten()
4288 error = xfs_zero_extent(bma->ip, mval->br_startblock, in xfs_bmapi_convert_unwritten()
4289 mval->br_blockcount); in xfs_bmapi_convert_unwritten()
4294 error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork, in xfs_bmapi_convert_unwritten()
4295 &bma->icur, &bma->cur, mval, &tmp_logflags); in xfs_bmapi_convert_unwritten()
4300 * in the transaction for the sake of fsync(), even if nothing has in xfs_bmapi_convert_unwritten()
4301 * changed, because fsync() will not force the log for this transaction in xfs_bmapi_convert_unwritten()
4305 * any on-disk updates to make, so we don't need to log anything. in xfs_bmapi_convert_unwritten()
4308 bma->logflags |= tmp_logflags | XFS_ILOG_CORE; in xfs_bmapi_convert_unwritten()
4317 xfs_iext_get_extent(ifp, &bma->icur, &bma->got); in xfs_bmapi_convert_unwritten()
4323 if (mval->br_blockcount < len) in xfs_bmapi_convert_unwritten()
4324 return -EAGAIN; in xfs_bmapi_convert_unwritten()
4336 if (tp && tp->t_highest_agno != NULLAGNUMBER) in xfs_bmapi_minleft()
4338 if (ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_minleft()
4340 return be16_to_cpu(ifp->if_broot->bb_level) + 1; in xfs_bmapi_minleft()
4355 struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); in xfs_bmapi_finish()
4357 if ((bma->logflags & xfs_ilog_fext(whichfork)) && in xfs_bmapi_finish()
4358 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_finish()
4359 bma->logflags &= ~xfs_ilog_fext(whichfork); in xfs_bmapi_finish()
4360 else if ((bma->logflags & xfs_ilog_fbroot(whichfork)) && in xfs_bmapi_finish()
4361 ifp->if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_finish()
4362 bma->logflags &= ~xfs_ilog_fbroot(whichfork); in xfs_bmapi_finish()
4364 if (bma->logflags) in xfs_bmapi_finish()
4365 xfs_trans_log_inode(bma->tp, bma->ip, bma->logflags); in xfs_bmapi_finish()
4366 if (bma->cur) in xfs_bmapi_finish()
4367 xfs_btree_del_cursor(bma->cur, error); in xfs_bmapi_finish()
4381 * Returns a negative error code on failure, including -ENOSPC when it could not
4382 * allocate any blocks and -ENOSR when it did allocate blocks to convert a
4401 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_write()
4428 ASSERT(ifp->if_format != XFS_DINODE_FMT_LOCAL); in xfs_bmapi_write()
4436 * we can allocate unwritten extents or pre-zero allocated blocks, in xfs_bmapi_write()
4447 return -EFSCORRUPTED; in xfs_bmapi_write()
4451 return -EIO; in xfs_bmapi_write()
4509 bma.got.br_blockcount - in xfs_bmapi_write()
4510 (bno - bma.got.br_startoff)); in xfs_bmapi_write()
4514 bma.got.br_startoff - bno); in xfs_bmapi_write()
4525 if (error == -ENOSPC && bma.nallocs) in xfs_bmapi_write()
4545 if (error == -EAGAIN) in xfs_bmapi_write()
4572 ASSERT(ifp->if_format != XFS_DINODE_FMT_BTREE || in xfs_bmapi_write()
4573 ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork)); in xfs_bmapi_write()
4584 * -ENOSR error code for this particular case so that the caller can in xfs_bmapi_write()
4589 return -ENOSR; in xfs_bmapi_write()
4613 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_convert_one_delalloc()
4627 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, in xfs_bmapi_convert_one_delalloc()
4648 error = -EAGAIN; in xfs_bmapi_convert_one_delalloc()
4660 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_one_delalloc()
4708 *seq = READ_ONCE(ifp->if_seq); in xfs_bmapi_convert_one_delalloc()
4756 } while (iomap->offset + iomap->length <= offset); in xfs_bmapi_convert_delalloc()
4770 struct xfs_mount *mp = ip->i_mount; in xfs_bmapi_remap()
4790 return -EFSCORRUPTED; in xfs_bmapi_remap()
4794 return -EIO; in xfs_bmapi_remap()
4803 ASSERT(got.br_startoff - bno >= len); in xfs_bmapi_remap()
4806 ip->i_nblocks += len; in xfs_bmapi_remap()
4807 ip->i_delayed_blks -= len; /* see xfs_bmap_defer_add */ in xfs_bmapi_remap()
4810 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmapi_remap()
4829 if (ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS) in xfs_bmapi_remap()
4831 else if (ip->i_df.if_format != XFS_DINODE_FMT_BTREE) in xfs_bmapi_remap()
4887 ores -= (len1 + len2); in xfs_bmap_split_indlen()
4888 ASSERT((*indlen1 - len1) + (*indlen2 - len2) >= ores); in xfs_bmap_split_indlen()
4891 ores--; in xfs_bmap_split_indlen()
4896 ores--; in xfs_bmap_split_indlen()
4902 ores--; in xfs_bmap_split_indlen()
4918 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_delay()
4931 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_delay()
4932 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_delay()
4933 da_old = startblockval(got->br_startblock); in xfs_bmap_del_extent_delay()
4936 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_delay()
4937 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_delay()
4945 xfs_quota_unreserve_blkres(ip, del->br_blockcount); in xfs_bmap_del_extent_delay()
4946 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4948 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_delay()
4965 got->br_startoff = del_endoff; in xfs_bmap_del_extent_delay()
4966 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_delay()
4968 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4969 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4976 got->br_blockcount = got->br_blockcount - del->br_blockcount; in xfs_bmap_del_extent_delay()
4978 got->br_blockcount), da_old); in xfs_bmap_del_extent_delay()
4979 got->br_startblock = nullstartblock((int)da_new); in xfs_bmap_del_extent_delay()
4992 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_delay()
4993 got_indlen = xfs_bmap_worst_indlen(ip, got->br_blockcount); in xfs_bmap_del_extent_delay()
4995 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_delay()
5006 * under-filled indirect reservation in this case. in xfs_bmap_del_extent_delay()
5010 stolen = XFS_FILBLKS_MIN(da_new - da_old, in xfs_bmap_del_extent_delay()
5011 del->br_blockcount); in xfs_bmap_del_extent_delay()
5018 got->br_startblock = nullstartblock((int)got_indlen); in xfs_bmap_del_extent_delay()
5021 new.br_state = got->br_state; in xfs_bmap_del_extent_delay()
5028 del->br_blockcount -= stolen; in xfs_bmap_del_extent_delay()
5033 da_diff = da_old - da_new; in xfs_bmap_del_extent_delay()
5037 xfs_add_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount)); in xfs_bmap_del_extent_delay()
5039 fdblocks += del->br_blockcount; in xfs_bmap_del_extent_delay()
5042 xfs_mod_delalloc(ip, -(int64_t)del->br_blockcount, -da_diff); in xfs_bmap_del_extent_delay()
5052 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_del_extent_cow()
5060 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_cow()
5061 got_endoff = got->br_startoff + got->br_blockcount; in xfs_bmap_del_extent_cow()
5063 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_cow()
5064 ASSERT(got->br_startoff <= del->br_startoff); in xfs_bmap_del_extent_cow()
5066 ASSERT(!isnullstartblock(got->br_startblock)); in xfs_bmap_del_extent_cow()
5068 if (got->br_startoff == del->br_startoff) in xfs_bmap_del_extent_cow()
5085 got->br_startoff = del_endoff; in xfs_bmap_del_extent_cow()
5086 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5087 got->br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
5094 got->br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5101 got->br_blockcount = del->br_startoff - got->br_startoff; in xfs_bmap_del_extent_cow()
5104 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_cow()
5105 new.br_state = got->br_state; in xfs_bmap_del_extent_cow()
5106 new.br_startblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_cow()
5113 ip->i_delayed_blks -= del->br_blockcount; in xfs_bmap_del_extent_cow()
5148 mp = ip->i_mount; in xfs_bmap_del_extent_real()
5152 ASSERT(del->br_blockcount > 0); in xfs_bmap_del_extent_real()
5154 ASSERT(got.br_startoff <= del->br_startoff); in xfs_bmap_del_extent_real()
5155 del_endoff = del->br_startoff + del->br_blockcount; in xfs_bmap_del_extent_real()
5169 if (tp->t_blk_res == 0 && in xfs_bmap_del_extent_real()
5170 ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_bmap_del_extent_real()
5171 ifp->if_nextents >= XFS_IFORK_MAXEXT(ip, whichfork) && in xfs_bmap_del_extent_real()
5172 del->br_startoff > got.br_startoff && del_endoff < got_endoff) in xfs_bmap_del_extent_real()
5173 return -ENOSPC; in xfs_bmap_del_extent_real()
5180 nblks = del->br_blockcount; in xfs_bmap_del_extent_real()
5182 del_endblock = del->br_startblock + del->br_blockcount; in xfs_bmap_del_extent_real()
5189 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5193 if (got.br_startoff == del->br_startoff) in xfs_bmap_del_extent_real()
5205 ifp->if_nextents--; in xfs_bmap_del_extent_real()
5216 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5225 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5239 got.br_blockcount -= del->br_blockcount; in xfs_bmap_del_extent_real()
5256 got.br_blockcount = del->br_startoff - got.br_startoff; in xfs_bmap_del_extent_real()
5260 new.br_blockcount = got_endoff - del_endoff; in xfs_bmap_del_extent_real()
5272 cur->bc_rec.b = new; in xfs_bmap_del_extent_real()
5274 if (error && error != -ENOSPC) in xfs_bmap_del_extent_real()
5277 * If get no-space back from btree insert, it tried a in xfs_bmap_del_extent_real()
5281 if (error == -ENOSPC) { in xfs_bmap_del_extent_real()
5291 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5306 return -ENOSPC; in xfs_bmap_del_extent_real()
5310 return -EFSCORRUPTED; in xfs_bmap_del_extent_real()
5315 ifp->if_nextents++; in xfs_bmap_del_extent_real()
5335 if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) { in xfs_bmap_del_extent_real()
5336 tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED; in xfs_bmap_del_extent_real()
5340 error = xfs_rtfree_blocks(tp, del->br_startblock, in xfs_bmap_del_extent_real()
5341 del->br_blockcount); in xfs_bmap_del_extent_real()
5346 del->br_state == XFS_EXT_UNWRITTEN) in xfs_bmap_del_extent_real()
5349 error = xfs_free_extent_later(tp, del->br_startblock, in xfs_bmap_del_extent_real()
5350 del->br_blockcount, NULL, in xfs_bmap_del_extent_real()
5361 ip->i_nblocks -= nblks; in xfs_bmap_del_extent_real()
5366 xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); in xfs_bmap_del_extent_real()
5395 struct xfs_mount *mp = ip->i_mount; in __xfs_bunmapi()
5411 return -EFSCORRUPTED; in __xfs_bunmapi()
5414 return -EIO; in __xfs_bunmapi()
5436 end--; in __xfs_bunmapi()
5439 if (ifp->if_format == XFS_DINODE_FMT_BTREE) { in __xfs_bunmapi()
5440 ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE); in __xfs_bunmapi()
5446 while (end != (xfs_fileoff_t)-1 && end >= start && in __xfs_bunmapi()
5462 got.br_startoff + got.br_blockcount - 1); in __xfs_bunmapi()
5474 del.br_blockcount -= start - got.br_startoff; in __xfs_bunmapi()
5476 del.br_startblock += start - got.br_startoff; in __xfs_bunmapi()
5479 del.br_blockcount = end + 1 - del.br_startoff; in __xfs_bunmapi()
5500 end -= mod > del.br_blockcount ? in __xfs_bunmapi()
5514 ASSERT(tp->t_blk_res > 0); in __xfs_bunmapi()
5520 del.br_startoff += del.br_blockcount - mod; in __xfs_bunmapi()
5521 del.br_startblock += del.br_blockcount - mod; in __xfs_bunmapi()
5535 xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; in __xfs_bunmapi()
5543 del.br_blockcount -= off; in __xfs_bunmapi()
5548 tp->t_blk_res == 0)) { in __xfs_bunmapi()
5554 end -= del.br_blockcount; in __xfs_bunmapi()
5578 del.br_startoff - mod, in __xfs_bunmapi()
5580 mod = unwrite_start - prev.br_startoff; in __xfs_bunmapi()
5583 prev.br_blockcount -= mod; in __xfs_bunmapi()
5615 end = del.br_startoff - 1; in __xfs_bunmapi()
5620 if (end != (xfs_fileoff_t)-1 && end >= start) { in __xfs_bunmapi()
5630 if (done || end == (xfs_fileoff_t)-1 || end < start) in __xfs_bunmapi()
5633 *rlen = end - start + 1; in __xfs_bunmapi()
5654 ifp->if_format != XFS_DINODE_FMT_EXTENTS) in __xfs_bunmapi()
5657 ifp->if_format != XFS_DINODE_FMT_BTREE) in __xfs_bunmapi()
5667 cur->bc_bmap.allocated = 0; in __xfs_bunmapi()
5703 startoff = got->br_startoff - shift; in xfs_bmse_can_merge()
5706 * The extent, once shifted, must be adjacent in-file and on-disk with in xfs_bmse_can_merge()
5709 if ((left->br_startoff + left->br_blockcount != startoff) || in xfs_bmse_can_merge()
5710 (left->br_startblock + left->br_blockcount != got->br_startblock) || in xfs_bmse_can_merge()
5711 (left->br_state != got->br_state) || in xfs_bmse_can_merge()
5712 (left->br_blockcount + got->br_blockcount > XFS_MAX_BMBT_EXTLEN)) in xfs_bmse_can_merge()
5724 * This function assumes the caller has verified a shift-by-merge is possible
5743 struct xfs_mount *mp = ip->i_mount; in xfs_bmse_merge()
5745 blockcount = left->br_blockcount + got->br_blockcount; in xfs_bmse_merge()
5754 * Update the on-disk extent count, the btree if necessary and log the in xfs_bmse_merge()
5757 ifp->if_nextents--; in xfs_bmse_merge()
5770 return -EFSCORRUPTED; in xfs_bmse_merge()
5778 return -EFSCORRUPTED; in xfs_bmse_merge()
5787 return -EFSCORRUPTED; in xfs_bmse_merge()
5808 new.br_startoff = left->br_startoff + left->br_blockcount; in xfs_bmse_merge()
5824 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_shift_update_extent()
5830 got->br_startoff = startoff; in xfs_bmap_shift_update_extent()
5838 return -EFSCORRUPTED; in xfs_bmap_shift_update_extent()
5866 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_collapse_extents()
5878 return -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5882 return -EIO; in xfs_bmap_collapse_extents()
5890 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmap_collapse_extents()
5899 error = -EFSCORRUPTED; in xfs_bmap_collapse_extents()
5903 new_startoff = got.br_startoff - offset_shift_fsb; in xfs_bmap_collapse_extents()
5906 error = -EINVAL; in xfs_bmap_collapse_extents()
5920 error = -EINVAL; in xfs_bmap_collapse_extents()
5945 /* Make sure we won't be right-shifting an extent past the maximum bound. */
5958 if (xfs_is_shutdown(ip->i_mount)) in xfs_bmap_can_insert_extents()
5959 return -EIO; in xfs_bmap_can_insert_extents()
5965 error = -EINVAL; in xfs_bmap_can_insert_extents()
5981 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_insert_extents()
5993 return -EFSCORRUPTED; in xfs_bmap_insert_extents()
5997 return -EIO; in xfs_bmap_insert_extents()
6005 if (ifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_bmap_insert_extents()
6023 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
6029 error = -EFSCORRUPTED; in xfs_bmap_insert_extents()
6036 error = -EINVAL; in xfs_bmap_insert_extents()
6087 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_split_extent()
6097 return -EFSCORRUPTED; in xfs_bmap_split_extent()
6101 return -EIO; in xfs_bmap_split_extent()
6115 gotblkcnt = split_fsb - got.br_startoff; in xfs_bmap_split_extent()
6118 new.br_blockcount = got.br_blockcount - gotblkcnt; in xfs_bmap_split_extent()
6121 if (ifp->if_format == XFS_DINODE_FMT_BTREE) { in xfs_bmap_split_extent()
6128 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6148 ifp->if_nextents++; in xfs_bmap_split_extent()
6156 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6164 error = -EFSCORRUPTED; in xfs_bmap_split_extent()
6183 cur->bc_bmap.allocated = 0; in xfs_bmap_split_extent()
6204 bmap->br_startblock == HOLESTARTBLOCK || in __xfs_bmap_add()
6205 bmap->br_startblock == DELAYSTARTBLOCK) in __xfs_bmap_add()
6209 INIT_LIST_HEAD(&bi->bi_list); in __xfs_bmap_add()
6210 bi->bi_type = type; in __xfs_bmap_add()
6211 bi->bi_owner = ip; in __xfs_bmap_add()
6212 bi->bi_whichfork = whichfork; in __xfs_bmap_add()
6213 bi->bi_bmap = *bmap; in __xfs_bmap_add()
6249 struct xfs_bmbt_irec *bmap = &bi->bi_bmap; in xfs_bmap_finish_one()
6253 if (bi->bi_whichfork == XFS_ATTR_FORK) in xfs_bmap_finish_one()
6256 ASSERT(tp->t_highest_agno == NULLAGNUMBER); in xfs_bmap_finish_one()
6260 if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE)) in xfs_bmap_finish_one()
6261 return -EIO; in xfs_bmap_finish_one()
6263 switch (bi->bi_type) { in xfs_bmap_finish_one()
6265 if (bi->bi_bmap.br_state == XFS_EXT_UNWRITTEN) in xfs_bmap_finish_one()
6267 error = xfs_bmapi_remap(tp, bi->bi_owner, bmap->br_startoff, in xfs_bmap_finish_one()
6268 bmap->br_blockcount, bmap->br_startblock, in xfs_bmap_finish_one()
6270 bmap->br_blockcount = 0; in xfs_bmap_finish_one()
6273 error = __xfs_bunmapi(tp, bi->bi_owner, bmap->br_startoff, in xfs_bmap_finish_one()
6274 &bmap->br_blockcount, flags | XFS_BMAPI_REMAP, in xfs_bmap_finish_one()
6279 xfs_bmap_mark_sick(bi->bi_owner, bi->bi_whichfork); in xfs_bmap_finish_one()
6280 error = -EFSCORRUPTED; in xfs_bmap_finish_one()
6294 if (!xfs_verify_fileext(mp, irec->br_startoff, irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6298 if (!xfs_verify_rtbext(mp, irec->br_startblock, in xfs_bmap_validate_extent_raw()
6299 irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6302 if (!xfs_verify_fsbext(mp, irec->br_startblock, in xfs_bmap_validate_extent_raw()
6303 irec->br_blockcount)) in xfs_bmap_validate_extent_raw()
6306 if (irec->br_state != XFS_EXT_NORM && whichfork != XFS_DATA_FORK) in xfs_bmap_validate_extent_raw()
6318 return xfs_bmap_intent_cache != NULL ? 0 : -ENOMEM; in xfs_bmap_intent_init_cache()
6335 return xfs_bmap_validate_extent_raw(ip->i_mount, in xfs_bmap_validate_extent()
6357 xfs_filblks_t unmap_len = endoff - startoff + 1; in xfs_bunmapi_range()
6363 ASSERT((*tpp)->t_highest_agno == NULLAGNUMBER); in xfs_bunmapi_range()
6395 xfs_bmbt_disk_get_all(&rec->bmbt, &irec); in xfs_bmap_query_range_helper()
6396 fa = xfs_bmap_validate_extent(cur->bc_ino.ip, cur->bc_ino.whichfork, in xfs_bmap_query_range_helper()
6400 return xfs_bmap_complain_bad_rec(cur->bc_ino.ip, in xfs_bmap_query_range_helper()
6401 cur->bc_ino.whichfork, fa, &irec); in xfs_bmap_query_range_helper()
6404 return query->fn(cur, &irec, query->priv); in xfs_bmap_query_range_helper()
6433 if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize) in xfs_get_extsz_hint()
6434 return ip->i_extsize; in xfs_get_extsz_hint()
6436 ip->i_mount->m_sb.sb_rextsize > 1) in xfs_get_extsz_hint()
6437 return ip->i_mount->m_sb.sb_rextsize; in xfs_get_extsz_hint()
6454 if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_get_cowextsz_hint()
6455 a = ip->i_cowextsize; in xfs_get_cowextsz_hint()