aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_bmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/libxfs/xfs_bmap.c')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 2760314fdf7f..a47670332326 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -673,7 +673,8 @@ xfs_bmap_extents_to_btree(
673 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS); 673 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS);
674 674
675 /* 675 /*
676 * Make space in the inode incore. 676 * Make space in the inode incore. This needs to be undone if we fail
677 * to expand the root.
677 */ 678 */
678 xfs_iroot_realloc(ip, 1, whichfork); 679 xfs_iroot_realloc(ip, 1, whichfork);
679 ifp->if_flags |= XFS_IFBROOT; 680 ifp->if_flags |= XFS_IFBROOT;
@@ -711,16 +712,15 @@ xfs_bmap_extents_to_btree(
711 args.minlen = args.maxlen = args.prod = 1; 712 args.minlen = args.maxlen = args.prod = 1;
712 args.wasdel = wasdel; 713 args.wasdel = wasdel;
713 *logflagsp = 0; 714 *logflagsp = 0;
714 if ((error = xfs_alloc_vextent(&args))) { 715 error = xfs_alloc_vextent(&args);
715 ASSERT(ifp->if_broot == NULL); 716 if (error)
716 goto err1; 717 goto out_root_realloc;
717 }
718 718
719 if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) { 719 if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
720 ASSERT(ifp->if_broot == NULL);
721 error = -ENOSPC; 720 error = -ENOSPC;
722 goto err1; 721 goto out_root_realloc;
723 } 722 }
723
724 /* 724 /*
725 * Allocation can't fail, the space was reserved. 725 * Allocation can't fail, the space was reserved.
726 */ 726 */
@@ -732,9 +732,10 @@ xfs_bmap_extents_to_btree(
732 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); 732 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
733 abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); 733 abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0);
734 if (!abp) { 734 if (!abp) {
735 error = -ENOSPC; 735 error = -EFSCORRUPTED;
736 goto err2; 736 goto out_unreserve_dquot;
737 } 737 }
738
738 /* 739 /*
739 * Fill in the child block. 740 * Fill in the child block.
740 */ 741 */
@@ -775,11 +776,12 @@ xfs_bmap_extents_to_btree(
775 *logflagsp = XFS_ILOG_CORE | xfs_ilog_fbroot(whichfork); 776 *logflagsp = XFS_ILOG_CORE | xfs_ilog_fbroot(whichfork);
776 return 0; 777 return 0;
777 778
778err2: 779out_unreserve_dquot:
779 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 780 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
780err1: 781out_root_realloc:
781 xfs_iroot_realloc(ip, -1, whichfork); 782 xfs_iroot_realloc(ip, -1, whichfork);
782 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); 783 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
784 ASSERT(ifp->if_broot == NULL);
783 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 785 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
784 786
785 return error; 787 return error;