aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-08-01 10:20:34 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-08-03 02:05:14 -0400
commit0f37d1780c3d864599fb377dcb47ad1aa0686b4e (patch)
tree4b54695109c61c7a5141636a89ba0ede57312585 /fs/xfs
parent1ae093cbea3d1ef04e1344b9e3996a9e1763a91b (diff)
xfs: pass transaction to xfs_defer_add()
The majority of remaining references to struct xfs_defer_ops in XFS are associated with xfs_defer_add(). At this point, there are no more external xfs_defer_ops users left. All instances of xfs_defer_ops are embedded in the transaction, which means we can safely pass the transaction down to the dfops add interface. Update xfs_defer_add() to receive the transaction as a parameter. Various subsystems implement wrappers to allocate and construct the context specific data structures for the associated deferred operation type. Update these to also carry the transaction down as needed and clean up unused dfops parameters along the way. This removes most of the remaining references to struct xfs_defer_ops throughout the code and facilitates removal of the structure. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> [darrick: fix unused variable warnings with ftrace disabled] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c9
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c89
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h19
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c2
-rw-r--r--fs/xfs/libxfs/xfs_defer.c5
-rw-r--r--fs/xfs/libxfs/xfs_defer.h2
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c25
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c80
-rw-r--r--fs/xfs/libxfs/xfs_refcount.h18
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c57
-rw-r--r--fs/xfs/libxfs/xfs_rmap.h22
-rw-r--r--fs/xfs/xfs_bmap_item.c3
-rw-r--r--fs/xfs/xfs_bmap_util.c13
-rw-r--r--fs/xfs/xfs_refcount_item.c14
-rw-r--r--fs/xfs/xfs_reflink.c21
15 files changed, 169 insertions, 210 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 9847c1632712..5580b6e23bb3 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -2198,12 +2198,12 @@ xfs_agfl_reset(
2198 */ 2198 */
2199STATIC void 2199STATIC void
2200xfs_defer_agfl_block( 2200xfs_defer_agfl_block(
2201 struct xfs_mount *mp, 2201 struct xfs_trans *tp,
2202 struct xfs_defer_ops *dfops,
2203 xfs_agnumber_t agno, 2202 xfs_agnumber_t agno,
2204 xfs_fsblock_t agbno, 2203 xfs_fsblock_t agbno,
2205 struct xfs_owner_info *oinfo) 2204 struct xfs_owner_info *oinfo)
2206{ 2205{
2206 struct xfs_mount *mp = tp->t_mountp;
2207 struct xfs_extent_free_item *new; /* new element */ 2207 struct xfs_extent_free_item *new; /* new element */
2208 2208
2209 ASSERT(xfs_bmap_free_item_zone != NULL); 2209 ASSERT(xfs_bmap_free_item_zone != NULL);
@@ -2216,7 +2216,7 @@ xfs_defer_agfl_block(
2216 2216
2217 trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1); 2217 trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
2218 2218
2219 xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_AGFL_FREE, &new->xefi_list); 2219 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &new->xefi_list);
2220} 2220}
2221 2221
2222/* 2222/*
@@ -2325,8 +2325,7 @@ xfs_alloc_fix_freelist(
2325 2325
2326 /* defer agfl frees if dfops is provided */ 2326 /* defer agfl frees if dfops is provided */
2327 if (tp->t_dfops) { 2327 if (tp->t_dfops) {
2328 xfs_defer_agfl_block(mp, tp->t_dfops, args->agno, 2328 xfs_defer_agfl_block(tp, args->agno, bno, &targs.oinfo);
2329 bno, &targs.oinfo);
2330 } else { 2329 } else {
2331 error = xfs_free_agfl_block(tp, args->agno, bno, agbp, 2330 error = xfs_free_agfl_block(tp, args->agno, bno, agbp,
2332 &targs.oinfo); 2331 &targs.oinfo);
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index d20f541b7061..c9fec0443f38 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -533,8 +533,7 @@ xfs_bmap_validate_ret(
533 */ 533 */
534void 534void
535__xfs_bmap_add_free( 535__xfs_bmap_add_free(
536 struct xfs_mount *mp, 536 struct xfs_trans *tp,
537 struct xfs_defer_ops *dfops,
538 xfs_fsblock_t bno, 537 xfs_fsblock_t bno,
539 xfs_filblks_t len, 538 xfs_filblks_t len,
540 struct xfs_owner_info *oinfo, 539 struct xfs_owner_info *oinfo,
@@ -542,8 +541,9 @@ __xfs_bmap_add_free(
542{ 541{
543 struct xfs_extent_free_item *new; /* new element */ 542 struct xfs_extent_free_item *new; /* new element */
544#ifdef DEBUG 543#ifdef DEBUG
545 xfs_agnumber_t agno; 544 struct xfs_mount *mp = tp->t_mountp;
546 xfs_agblock_t agbno; 545 xfs_agnumber_t agno;
546 xfs_agblock_t agbno;
547 547
548 ASSERT(bno != NULLFSBLOCK); 548 ASSERT(bno != NULLFSBLOCK);
549 ASSERT(len > 0); 549 ASSERT(len > 0);
@@ -566,9 +566,10 @@ __xfs_bmap_add_free(
566 else 566 else
567 xfs_rmap_skip_owner_update(&new->xefi_oinfo); 567 xfs_rmap_skip_owner_update(&new->xefi_oinfo);
568 new->xefi_skip_discard = skip_discard; 568 new->xefi_skip_discard = skip_discard;
569 trace_xfs_bmap_free_defer(mp, XFS_FSB_TO_AGNO(mp, bno), 0, 569 trace_xfs_bmap_free_defer(tp->t_mountp,
570 XFS_FSB_TO_AGBNO(mp, bno), len); 570 XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
571 xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list); 571 XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len);
572 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list);
572} 573}
573 574
574/* 575/*
@@ -624,7 +625,7 @@ xfs_bmap_btree_to_extents(
624 if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) 625 if ((error = xfs_btree_check_block(cur, cblock, 0, cbp)))
625 return error; 626 return error;
626 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); 627 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
627 xfs_bmap_add_free(mp, cur->bc_tp->t_dfops, cbno, 1, &oinfo); 628 xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
628 ip->i_d.di_nblocks--; 629 ip->i_d.di_nblocks--;
629 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 630 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
630 xfs_trans_binval(tp, cbp); 631 xfs_trans_binval(tp, cbp);
@@ -1961,8 +1962,7 @@ xfs_bmap_add_extent_delay_real(
1961 1962
1962 /* add reverse mapping unless caller opted out */ 1963 /* add reverse mapping unless caller opted out */
1963 if (!(bma->flags & XFS_BMAPI_NORMAP)) { 1964 if (!(bma->flags & XFS_BMAPI_NORMAP)) {
1964 error = xfs_rmap_map_extent(mp, bma->tp->t_dfops, bma->ip, 1965 error = xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new);
1965 whichfork, new);
1966 if (error) 1966 if (error)
1967 goto done; 1967 goto done;
1968 } 1968 }
@@ -2026,7 +2026,6 @@ xfs_bmap_add_extent_unwritten_real(
2026 int state = xfs_bmap_fork_to_state(whichfork); 2026 int state = xfs_bmap_fork_to_state(whichfork);
2027 struct xfs_mount *mp = ip->i_mount; 2027 struct xfs_mount *mp = ip->i_mount;
2028 struct xfs_bmbt_irec old; 2028 struct xfs_bmbt_irec old;
2029 struct xfs_defer_ops *dfops = tp ? tp->t_dfops : NULL;
2030 2029
2031 *logflagsp = 0; 2030 *logflagsp = 0;
2032 2031
@@ -2445,7 +2444,7 @@ xfs_bmap_add_extent_unwritten_real(
2445 } 2444 }
2446 2445
2447 /* update reverse mappings */ 2446 /* update reverse mappings */
2448 error = xfs_rmap_convert_extent(mp, dfops, ip, whichfork, new); 2447 error = xfs_rmap_convert_extent(mp, tp, ip, whichfork, new);
2449 if (error) 2448 if (error)
2450 goto done; 2449 goto done;
2451 2450
@@ -2806,8 +2805,7 @@ xfs_bmap_add_extent_hole_real(
2806 2805
2807 /* add reverse mapping unless caller opted out */ 2806 /* add reverse mapping unless caller opted out */
2808 if (!(flags & XFS_BMAPI_NORMAP)) { 2807 if (!(flags & XFS_BMAPI_NORMAP)) {
2809 error = xfs_rmap_map_extent(mp, tp->t_dfops, ip, whichfork, 2808 error = xfs_rmap_map_extent(tp, ip, whichfork, new);
2810 new);
2811 if (error) 2809 if (error)
2812 goto done; 2810 goto done;
2813 } 2811 }
@@ -4364,9 +4362,8 @@ xfs_bmapi_write(
4364 * the refcount btree for orphan recovery. 4362 * the refcount btree for orphan recovery.
4365 */ 4363 */
4366 if (whichfork == XFS_COW_FORK) { 4364 if (whichfork == XFS_COW_FORK) {
4367 error = xfs_refcount_alloc_cow_extent(mp, 4365 error = xfs_refcount_alloc_cow_extent(tp,
4368 tp->t_dfops, bma.blkno, 4366 bma.blkno, bma.length);
4369 bma.length);
4370 if (error) 4367 if (error)
4371 goto error0; 4368 goto error0;
4372 } 4369 }
@@ -4852,7 +4849,6 @@ xfs_bmap_del_extent_real(
4852 uint qfield; /* quota field to update */ 4849 uint qfield; /* quota field to update */
4853 int state = xfs_bmap_fork_to_state(whichfork); 4850 int state = xfs_bmap_fork_to_state(whichfork);
4854 struct xfs_bmbt_irec old; 4851 struct xfs_bmbt_irec old;
4855 struct xfs_defer_ops *dfops = tp ? tp->t_dfops : NULL;
4856 4852
4857 mp = ip->i_mount; 4853 mp = ip->i_mount;
4858 XFS_STATS_INC(mp, xs_del_exlist); 4854 XFS_STATS_INC(mp, xs_del_exlist);
@@ -5036,7 +5032,7 @@ xfs_bmap_del_extent_real(
5036 } 5032 }
5037 5033
5038 /* remove reverse mapping */ 5034 /* remove reverse mapping */
5039 error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, del); 5035 error = xfs_rmap_unmap_extent(tp, ip, whichfork, del);
5040 if (error) 5036 if (error)
5041 goto done; 5037 goto done;
5042 5038
@@ -5045,11 +5041,11 @@ xfs_bmap_del_extent_real(
5045 */ 5041 */
5046 if (do_fx && !(bflags & XFS_BMAPI_REMAP)) { 5042 if (do_fx && !(bflags & XFS_BMAPI_REMAP)) {
5047 if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) { 5043 if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
5048 error = xfs_refcount_decrease_extent(mp, dfops, del); 5044 error = xfs_refcount_decrease_extent(tp, del);
5049 if (error) 5045 if (error)
5050 goto done; 5046 goto done;
5051 } else { 5047 } else {
5052 __xfs_bmap_add_free(mp, dfops, del->br_startblock, 5048 __xfs_bmap_add_free(tp, del->br_startblock,
5053 del->br_blockcount, NULL, 5049 del->br_blockcount, NULL,
5054 (bflags & XFS_BMAPI_NODISCARD) || 5050 (bflags & XFS_BMAPI_NODISCARD) ||
5055 del->br_state == XFS_EXT_UNWRITTEN); 5051 del->br_state == XFS_EXT_UNWRITTEN);
@@ -5489,6 +5485,7 @@ xfs_bmse_can_merge(
5489 */ 5485 */
5490STATIC int 5486STATIC int
5491xfs_bmse_merge( 5487xfs_bmse_merge(
5488 struct xfs_trans *tp,
5492 struct xfs_inode *ip, 5489 struct xfs_inode *ip,
5493 int whichfork, 5490 int whichfork,
5494 xfs_fileoff_t shift, /* shift fsb */ 5491 xfs_fileoff_t shift, /* shift fsb */
@@ -5496,8 +5493,7 @@ xfs_bmse_merge(
5496 struct xfs_bmbt_irec *got, /* extent to shift */ 5493 struct xfs_bmbt_irec *got, /* extent to shift */
5497 struct xfs_bmbt_irec *left, /* preceding extent */ 5494 struct xfs_bmbt_irec *left, /* preceding extent */
5498 struct xfs_btree_cur *cur, 5495 struct xfs_btree_cur *cur,
5499 int *logflags, /* output */ 5496 int *logflags) /* output */
5500 struct xfs_defer_ops *dfops)
5501{ 5497{
5502 struct xfs_bmbt_irec new; 5498 struct xfs_bmbt_irec new;
5503 xfs_filblks_t blockcount; 5499 xfs_filblks_t blockcount;
@@ -5553,23 +5549,23 @@ done:
5553 &new); 5549 &new);
5554 5550
5555 /* update reverse mapping. rmap functions merge the rmaps for us */ 5551 /* update reverse mapping. rmap functions merge the rmaps for us */
5556 error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got); 5552 error = xfs_rmap_unmap_extent(tp, ip, whichfork, got);
5557 if (error) 5553 if (error)
5558 return error; 5554 return error;
5559 memcpy(&new, got, sizeof(new)); 5555 memcpy(&new, got, sizeof(new));
5560 new.br_startoff = left->br_startoff + left->br_blockcount; 5556 new.br_startoff = left->br_startoff + left->br_blockcount;
5561 return xfs_rmap_map_extent(mp, dfops, ip, whichfork, &new); 5557 return xfs_rmap_map_extent(tp, ip, whichfork, &new);
5562} 5558}
5563 5559
5564static int 5560static int
5565xfs_bmap_shift_update_extent( 5561xfs_bmap_shift_update_extent(
5562 struct xfs_trans *tp,
5566 struct xfs_inode *ip, 5563 struct xfs_inode *ip,
5567 int whichfork, 5564 int whichfork,
5568 struct xfs_iext_cursor *icur, 5565 struct xfs_iext_cursor *icur,
5569 struct xfs_bmbt_irec *got, 5566 struct xfs_bmbt_irec *got,
5570 struct xfs_btree_cur *cur, 5567 struct xfs_btree_cur *cur,
5571 int *logflags, 5568 int *logflags,
5572 struct xfs_defer_ops *dfops,
5573 xfs_fileoff_t startoff) 5569 xfs_fileoff_t startoff)
5574{ 5570{
5575 struct xfs_mount *mp = ip->i_mount; 5571 struct xfs_mount *mp = ip->i_mount;
@@ -5597,10 +5593,10 @@ xfs_bmap_shift_update_extent(
5597 got); 5593 got);
5598 5594
5599 /* update reverse mapping */ 5595 /* update reverse mapping */
5600 error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, &prev); 5596 error = xfs_rmap_unmap_extent(tp, ip, whichfork, &prev);
5601 if (error) 5597 if (error)
5602 return error; 5598 return error;
5603 return xfs_rmap_map_extent(mp, dfops, ip, whichfork, got); 5599 return xfs_rmap_map_extent(tp, ip, whichfork, got);
5604} 5600}
5605 5601
5606int 5602int
@@ -5660,9 +5656,9 @@ xfs_bmap_collapse_extents(
5660 } 5656 }
5661 5657
5662 if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) { 5658 if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) {
5663 error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb, 5659 error = xfs_bmse_merge(tp, ip, whichfork,
5664 &icur, &got, &prev, cur, &logflags, 5660 offset_shift_fsb, &icur, &got, &prev,
5665 tp->t_dfops); 5661 cur, &logflags);
5666 if (error) 5662 if (error)
5667 goto del_cursor; 5663 goto del_cursor;
5668 goto done; 5664 goto done;
@@ -5674,8 +5670,8 @@ xfs_bmap_collapse_extents(
5674 } 5670 }
5675 } 5671 }
5676 5672
5677 error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur, 5673 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
5678 &logflags, tp->t_dfops, new_startoff); 5674 cur, &logflags, new_startoff);
5679 if (error) 5675 if (error)
5680 goto del_cursor; 5676 goto del_cursor;
5681 5677
@@ -5801,8 +5797,8 @@ xfs_bmap_insert_extents(
5801 WARN_ON_ONCE(1); 5797 WARN_ON_ONCE(1);
5802 } 5798 }
5803 5799
5804 error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur, 5800 error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
5805 &logflags, tp->t_dfops, new_startoff); 5801 cur, &logflags, new_startoff);
5806 if (error) 5802 if (error)
5807 goto del_cursor; 5803 goto del_cursor;
5808 5804
@@ -5979,8 +5975,7 @@ xfs_bmap_is_update_needed(
5979/* Record a bmap intent. */ 5975/* Record a bmap intent. */
5980static int 5976static int
5981__xfs_bmap_add( 5977__xfs_bmap_add(
5982 struct xfs_mount *mp, 5978 struct xfs_trans *tp,
5983 struct xfs_defer_ops *dfops,
5984 enum xfs_bmap_intent_type type, 5979 enum xfs_bmap_intent_type type,
5985 struct xfs_inode *ip, 5980 struct xfs_inode *ip,
5986 int whichfork, 5981 int whichfork,
@@ -5988,10 +5983,10 @@ __xfs_bmap_add(
5988{ 5983{
5989 struct xfs_bmap_intent *bi; 5984 struct xfs_bmap_intent *bi;
5990 5985
5991 trace_xfs_bmap_defer(mp, 5986 trace_xfs_bmap_defer(tp->t_mountp,
5992 XFS_FSB_TO_AGNO(mp, bmap->br_startblock), 5987 XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
5993 type, 5988 type,
5994 XFS_FSB_TO_AGBNO(mp, bmap->br_startblock), 5989 XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
5995 ip->i_ino, whichfork, 5990 ip->i_ino, whichfork,
5996 bmap->br_startoff, 5991 bmap->br_startoff,
5997 bmap->br_blockcount, 5992 bmap->br_blockcount,
@@ -6004,38 +5999,34 @@ __xfs_bmap_add(
6004 bi->bi_whichfork = whichfork; 5999 bi->bi_whichfork = whichfork;
6005 bi->bi_bmap = *bmap; 6000 bi->bi_bmap = *bmap;
6006 6001
6007 xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list); 6002 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list);
6008 return 0; 6003 return 0;
6009} 6004}
6010 6005
6011/* Map an extent into a file. */ 6006/* Map an extent into a file. */
6012int 6007int
6013xfs_bmap_map_extent( 6008xfs_bmap_map_extent(
6014 struct xfs_mount *mp, 6009 struct xfs_trans *tp,
6015 struct xfs_defer_ops *dfops,
6016 struct xfs_inode *ip, 6010 struct xfs_inode *ip,
6017 struct xfs_bmbt_irec *PREV) 6011 struct xfs_bmbt_irec *PREV)
6018{ 6012{
6019 if (!xfs_bmap_is_update_needed(PREV)) 6013 if (!xfs_bmap_is_update_needed(PREV))
6020 return 0; 6014 return 0;
6021 6015
6022 return __xfs_bmap_add(mp, dfops, XFS_BMAP_MAP, ip, 6016 return __xfs_bmap_add(tp, XFS_BMAP_MAP, ip, XFS_DATA_FORK, PREV);
6023 XFS_DATA_FORK, PREV);
6024} 6017}
6025 6018
6026/* Unmap an extent out of a file. */ 6019/* Unmap an extent out of a file. */
6027int 6020int
6028xfs_bmap_unmap_extent( 6021xfs_bmap_unmap_extent(
6029 struct xfs_mount *mp, 6022 struct xfs_trans *tp,
6030 struct xfs_defer_ops *dfops,
6031 struct xfs_inode *ip, 6023 struct xfs_inode *ip,
6032 struct xfs_bmbt_irec *PREV) 6024 struct xfs_bmbt_irec *PREV)
6033{ 6025{
6034 if (!xfs_bmap_is_update_needed(PREV)) 6026 if (!xfs_bmap_is_update_needed(PREV))
6035 return 0; 6027 return 0;
6036 6028
6037 return __xfs_bmap_add(mp, dfops, XFS_BMAP_UNMAP, ip, 6029 return __xfs_bmap_add(tp, XFS_BMAP_UNMAP, ip, XFS_DATA_FORK, PREV);
6038 XFS_DATA_FORK, PREV);
6039} 6030}
6040 6031
6041/* 6032/*
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 9165a878edcd..b6e9b639e731 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -184,9 +184,9 @@ void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
184void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *); 184void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *);
185int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); 185int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
186void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); 186void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
187void __xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 187void __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
188 xfs_fsblock_t bno, xfs_filblks_t len, 188 xfs_filblks_t len, struct xfs_owner_info *oinfo,
189 struct xfs_owner_info *oinfo, bool skip_discard); 189 bool skip_discard);
190void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); 190void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
191int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, 191int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
192 xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); 192 xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork);
@@ -230,13 +230,12 @@ int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
230 230
231static inline void 231static inline void
232xfs_bmap_add_free( 232xfs_bmap_add_free(
233 struct xfs_mount *mp, 233 struct xfs_trans *tp,
234 struct xfs_defer_ops *dfops,
235 xfs_fsblock_t bno, 234 xfs_fsblock_t bno,
236 xfs_filblks_t len, 235 xfs_filblks_t len,
237 struct xfs_owner_info *oinfo) 236 struct xfs_owner_info *oinfo)
238{ 237{
239 __xfs_bmap_add_free(mp, dfops, bno, len, oinfo, false); 238 __xfs_bmap_add_free(tp, bno, len, oinfo, false);
240} 239}
241 240
242enum xfs_bmap_intent_type { 241enum xfs_bmap_intent_type {
@@ -256,10 +255,10 @@ int xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip,
256 enum xfs_bmap_intent_type type, int whichfork, 255 enum xfs_bmap_intent_type type, int whichfork,
257 xfs_fileoff_t startoff, xfs_fsblock_t startblock, 256 xfs_fileoff_t startoff, xfs_fsblock_t startblock,
258 xfs_filblks_t *blockcount, xfs_exntst_t state); 257 xfs_filblks_t *blockcount, xfs_exntst_t state);
259int xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 258int xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
260 struct xfs_inode *ip, struct xfs_bmbt_irec *imap); 259 struct xfs_bmbt_irec *imap);
261int xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 260int xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
262 struct xfs_inode *ip, struct xfs_bmbt_irec *imap); 261 struct xfs_bmbt_irec *imap);
263 262
264static inline int xfs_bmap_fork_to_state(int whichfork) 263static inline int xfs_bmap_fork_to_state(int whichfork)
265{ 264{
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 955e29de8cae..cdb74d2e2a43 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -289,7 +289,7 @@ xfs_bmbt_free_block(
289 struct xfs_owner_info oinfo; 289 struct xfs_owner_info oinfo;
290 290
291 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_private.b.whichfork); 291 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_private.b.whichfork);
292 xfs_bmap_add_free(mp, cur->bc_tp->t_dfops, fsbno, 1, &oinfo); 292 xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
293 ip->i_d.di_nblocks--; 293 ip->i_d.di_nblocks--;
294 294
295 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 295 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 1cbddcf539da..ce2286763531 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -487,12 +487,15 @@ xfs_defer_cancel(
487/* Add an item for later deferred processing. */ 487/* Add an item for later deferred processing. */
488void 488void
489xfs_defer_add( 489xfs_defer_add(
490 struct xfs_defer_ops *dop, 490 struct xfs_trans *tp,
491 enum xfs_defer_ops_type type, 491 enum xfs_defer_ops_type type,
492 struct list_head *li) 492 struct list_head *li)
493{ 493{
494 struct xfs_defer_ops *dop = tp->t_dfops;
494 struct xfs_defer_pending *dfp = NULL; 495 struct xfs_defer_pending *dfp = NULL;
495 496
497 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
498
496 /* 499 /*
497 * Add the item to a pending item at the end of the intake list. 500 * Add the item to a pending item at the end of the intake list.
498 * If the last pending item has the same type, reuse it. Else, 501 * If the last pending item has the same type, reuse it. Else,
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index f091bf3abeaf..b2675f1ca909 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -35,7 +35,7 @@ enum xfs_defer_ops_type {
35 XFS_DEFER_OPS_TYPE_MAX, 35 XFS_DEFER_OPS_TYPE_MAX,
36}; 36};
37 37
38void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type, 38void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
39 struct list_head *h); 39 struct list_head *h);
40int xfs_defer_finish_noroll(struct xfs_trans **tp); 40int xfs_defer_finish_noroll(struct xfs_trans **tp);
41int xfs_defer_finish(struct xfs_trans **tp); 41int xfs_defer_finish(struct xfs_trans **tp);
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 295304ad1bc1..a8f6db735d5d 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1838,23 +1838,24 @@ out_error:
1838 */ 1838 */
1839STATIC void 1839STATIC void
1840xfs_difree_inode_chunk( 1840xfs_difree_inode_chunk(
1841 struct xfs_mount *mp, 1841 struct xfs_trans *tp,
1842 xfs_agnumber_t agno, 1842 xfs_agnumber_t agno,
1843 struct xfs_inobt_rec_incore *rec, 1843 struct xfs_inobt_rec_incore *rec)
1844 struct xfs_defer_ops *dfops)
1845{ 1844{
1846 xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp, rec->ir_startino); 1845 struct xfs_mount *mp = tp->t_mountp;
1847 int startidx, endidx; 1846 xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp,
1848 int nextbit; 1847 rec->ir_startino);
1849 xfs_agblock_t agbno; 1848 int startidx, endidx;
1850 int contigblk; 1849 int nextbit;
1851 struct xfs_owner_info oinfo; 1850 xfs_agblock_t agbno;
1851 int contigblk;
1852 struct xfs_owner_info oinfo;
1852 DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS); 1853 DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS);
1853 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES); 1854 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES);
1854 1855
1855 if (!xfs_inobt_issparse(rec->ir_holemask)) { 1856 if (!xfs_inobt_issparse(rec->ir_holemask)) {
1856 /* not sparse, calculate extent info directly */ 1857 /* not sparse, calculate extent info directly */
1857 xfs_bmap_add_free(mp, dfops, XFS_AGB_TO_FSB(mp, agno, sagbno), 1858 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno),
1858 mp->m_ialloc_blks, &oinfo); 1859 mp->m_ialloc_blks, &oinfo);
1859 return; 1860 return;
1860 } 1861 }
@@ -1898,7 +1899,7 @@ xfs_difree_inode_chunk(
1898 1899
1899 ASSERT(agbno % mp->m_sb.sb_spino_align == 0); 1900 ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
1900 ASSERT(contigblk % mp->m_sb.sb_spino_align == 0); 1901 ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
1901 xfs_bmap_add_free(mp, dfops, XFS_AGB_TO_FSB(mp, agno, agbno), 1902 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, agbno),
1902 contigblk, &oinfo); 1903 contigblk, &oinfo);
1903 1904
1904 /* reset range to current bit and carry on... */ 1905 /* reset range to current bit and carry on... */
@@ -2002,7 +2003,7 @@ xfs_difree_inobt(
2002 goto error0; 2003 goto error0;
2003 } 2004 }
2004 2005
2005 xfs_difree_inode_chunk(mp, agno, &rec, tp->t_dfops); 2006 xfs_difree_inode_chunk(tp, agno, &rec);
2006 } else { 2007 } else {
2007 xic->deleted = false; 2008 xic->deleted = false;
2008 2009
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 86f297ca90cd..542aa1475b5f 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -34,11 +34,9 @@ enum xfs_refc_adjust_op {
34}; 34};
35 35
36STATIC int __xfs_refcount_cow_alloc(struct xfs_btree_cur *rcur, 36STATIC int __xfs_refcount_cow_alloc(struct xfs_btree_cur *rcur,
37 xfs_agblock_t agbno, xfs_extlen_t aglen, 37 xfs_agblock_t agbno, xfs_extlen_t aglen);
38 struct xfs_defer_ops *dfops);
39STATIC int __xfs_refcount_cow_free(struct xfs_btree_cur *rcur, 38STATIC int __xfs_refcount_cow_free(struct xfs_btree_cur *rcur,
40 xfs_agblock_t agbno, xfs_extlen_t aglen, 39 xfs_agblock_t agbno, xfs_extlen_t aglen);
41 struct xfs_defer_ops *dfops);
42 40
43/* 41/*
44 * Look up the first record less than or equal to [bno, len] in the btree 42 * Look up the first record less than or equal to [bno, len] in the btree
@@ -870,7 +868,6 @@ xfs_refcount_adjust_extents(
870 xfs_agblock_t *agbno, 868 xfs_agblock_t *agbno,
871 xfs_extlen_t *aglen, 869 xfs_extlen_t *aglen,
872 enum xfs_refc_adjust_op adj, 870 enum xfs_refc_adjust_op adj,
873 struct xfs_defer_ops *dfops,
874 struct xfs_owner_info *oinfo) 871 struct xfs_owner_info *oinfo)
875{ 872{
876 struct xfs_refcount_irec ext, tmp; 873 struct xfs_refcount_irec ext, tmp;
@@ -925,8 +922,8 @@ xfs_refcount_adjust_extents(
925 fsbno = XFS_AGB_TO_FSB(cur->bc_mp, 922 fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
926 cur->bc_private.a.agno, 923 cur->bc_private.a.agno,
927 tmp.rc_startblock); 924 tmp.rc_startblock);
928 xfs_bmap_add_free(cur->bc_mp, dfops, fsbno, 925 xfs_bmap_add_free(cur->bc_tp, fsbno,
929 tmp.rc_blockcount, oinfo); 926 tmp.rc_blockcount, oinfo);
930 } 927 }
931 928
932 (*agbno) += tmp.rc_blockcount; 929 (*agbno) += tmp.rc_blockcount;
@@ -968,8 +965,8 @@ xfs_refcount_adjust_extents(
968 fsbno = XFS_AGB_TO_FSB(cur->bc_mp, 965 fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
969 cur->bc_private.a.agno, 966 cur->bc_private.a.agno,
970 ext.rc_startblock); 967 ext.rc_startblock);
971 xfs_bmap_add_free(cur->bc_mp, dfops, fsbno, 968 xfs_bmap_add_free(cur->bc_tp, fsbno, ext.rc_blockcount,
972 ext.rc_blockcount, oinfo); 969 oinfo);
973 } 970 }
974 971
975skip: 972skip:
@@ -998,7 +995,6 @@ xfs_refcount_adjust(
998 xfs_agblock_t *new_agbno, 995 xfs_agblock_t *new_agbno,
999 xfs_extlen_t *new_aglen, 996 xfs_extlen_t *new_aglen,
1000 enum xfs_refc_adjust_op adj, 997 enum xfs_refc_adjust_op adj,
1001 struct xfs_defer_ops *dfops,
1002 struct xfs_owner_info *oinfo) 998 struct xfs_owner_info *oinfo)
1003{ 999{
1004 bool shape_changed; 1000 bool shape_changed;
@@ -1043,7 +1039,7 @@ xfs_refcount_adjust(
1043 1039
1044 /* Now that we've taken care of the ends, adjust the middle extents */ 1040 /* Now that we've taken care of the ends, adjust the middle extents */
1045 error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, 1041 error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen,
1046 adj, dfops, oinfo); 1042 adj, oinfo);
1047 if (error) 1043 if (error)
1048 goto out_error; 1044 goto out_error;
1049 1045
@@ -1090,7 +1086,6 @@ xfs_refcount_finish_one(
1090 struct xfs_btree_cur **pcur) 1086 struct xfs_btree_cur **pcur)
1091{ 1087{
1092 struct xfs_mount *mp = tp->t_mountp; 1088 struct xfs_mount *mp = tp->t_mountp;
1093 struct xfs_defer_ops *dfops = tp->t_dfops;
1094 struct xfs_btree_cur *rcur; 1089 struct xfs_btree_cur *rcur;
1095 struct xfs_buf *agbp = NULL; 1090 struct xfs_buf *agbp = NULL;
1096 int error = 0; 1091 int error = 0;
@@ -1145,23 +1140,23 @@ xfs_refcount_finish_one(
1145 switch (type) { 1140 switch (type) {
1146 case XFS_REFCOUNT_INCREASE: 1141 case XFS_REFCOUNT_INCREASE:
1147 error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, 1142 error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
1148 new_len, XFS_REFCOUNT_ADJUST_INCREASE, dfops, NULL); 1143 new_len, XFS_REFCOUNT_ADJUST_INCREASE, NULL);
1149 *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno); 1144 *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
1150 break; 1145 break;
1151 case XFS_REFCOUNT_DECREASE: 1146 case XFS_REFCOUNT_DECREASE:
1152 error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, 1147 error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
1153 new_len, XFS_REFCOUNT_ADJUST_DECREASE, dfops, NULL); 1148 new_len, XFS_REFCOUNT_ADJUST_DECREASE, NULL);
1154 *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno); 1149 *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
1155 break; 1150 break;
1156 case XFS_REFCOUNT_ALLOC_COW: 1151 case XFS_REFCOUNT_ALLOC_COW:
1157 *new_fsb = startblock + blockcount; 1152 *new_fsb = startblock + blockcount;
1158 *new_len = 0; 1153 *new_len = 0;
1159 error = __xfs_refcount_cow_alloc(rcur, bno, blockcount, dfops); 1154 error = __xfs_refcount_cow_alloc(rcur, bno, blockcount);
1160 break; 1155 break;
1161 case XFS_REFCOUNT_FREE_COW: 1156 case XFS_REFCOUNT_FREE_COW:
1162 *new_fsb = startblock + blockcount; 1157 *new_fsb = startblock + blockcount;
1163 *new_len = 0; 1158 *new_len = 0;
1164 error = __xfs_refcount_cow_free(rcur, bno, blockcount, dfops); 1159 error = __xfs_refcount_cow_free(rcur, bno, blockcount);
1165 break; 1160 break;
1166 default: 1161 default:
1167 ASSERT(0); 1162 ASSERT(0);
@@ -1183,16 +1178,16 @@ out_cur:
1183 */ 1178 */
1184static int 1179static int
1185__xfs_refcount_add( 1180__xfs_refcount_add(
1186 struct xfs_mount *mp, 1181 struct xfs_trans *tp,
1187 struct xfs_defer_ops *dfops,
1188 enum xfs_refcount_intent_type type, 1182 enum xfs_refcount_intent_type type,
1189 xfs_fsblock_t startblock, 1183 xfs_fsblock_t startblock,
1190 xfs_extlen_t blockcount) 1184 xfs_extlen_t blockcount)
1191{ 1185{
1192 struct xfs_refcount_intent *ri; 1186 struct xfs_refcount_intent *ri;
1193 1187
1194 trace_xfs_refcount_defer(mp, XFS_FSB_TO_AGNO(mp, startblock), 1188 trace_xfs_refcount_defer(tp->t_mountp,
1195 type, XFS_FSB_TO_AGBNO(mp, startblock), 1189 XFS_FSB_TO_AGNO(tp->t_mountp, startblock),
1190 type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
1196 blockcount); 1191 blockcount);
1197 1192
1198 ri = kmem_alloc(sizeof(struct xfs_refcount_intent), 1193 ri = kmem_alloc(sizeof(struct xfs_refcount_intent),
@@ -1202,7 +1197,7 @@ __xfs_refcount_add(
1202 ri->ri_startblock = startblock; 1197 ri->ri_startblock = startblock;
1203 ri->ri_blockcount = blockcount; 1198 ri->ri_blockcount = blockcount;
1204 1199
1205 xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_REFCOUNT, &ri->ri_list); 1200 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_REFCOUNT, &ri->ri_list);
1206 return 0; 1201 return 0;
1207} 1202}
1208 1203
@@ -1211,14 +1206,13 @@ __xfs_refcount_add(
1211 */ 1206 */
1212int 1207int
1213xfs_refcount_increase_extent( 1208xfs_refcount_increase_extent(
1214 struct xfs_mount *mp, 1209 struct xfs_trans *tp,
1215 struct xfs_defer_ops *dfops,
1216 struct xfs_bmbt_irec *PREV) 1210 struct xfs_bmbt_irec *PREV)
1217{ 1211{
1218 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1212 if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb))
1219 return 0; 1213 return 0;
1220 1214
1221 return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_INCREASE, 1215 return __xfs_refcount_add(tp, XFS_REFCOUNT_INCREASE,
1222 PREV->br_startblock, PREV->br_blockcount); 1216 PREV->br_startblock, PREV->br_blockcount);
1223} 1217}
1224 1218
@@ -1227,14 +1221,13 @@ xfs_refcount_increase_extent(
1227 */ 1221 */
1228int 1222int
1229xfs_refcount_decrease_extent( 1223xfs_refcount_decrease_extent(
1230 struct xfs_mount *mp, 1224 struct xfs_trans *tp,
1231 struct xfs_defer_ops *dfops,
1232 struct xfs_bmbt_irec *PREV) 1225 struct xfs_bmbt_irec *PREV)
1233{ 1226{
1234 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1227 if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb))
1235 return 0; 1228 return 0;
1236 1229
1237 return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_DECREASE, 1230 return __xfs_refcount_add(tp, XFS_REFCOUNT_DECREASE,
1238 PREV->br_startblock, PREV->br_blockcount); 1231 PREV->br_startblock, PREV->br_blockcount);
1239} 1232}
1240 1233
@@ -1522,8 +1515,7 @@ STATIC int
1522__xfs_refcount_cow_alloc( 1515__xfs_refcount_cow_alloc(
1523 struct xfs_btree_cur *rcur, 1516 struct xfs_btree_cur *rcur,
1524 xfs_agblock_t agbno, 1517 xfs_agblock_t agbno,
1525 xfs_extlen_t aglen, 1518 xfs_extlen_t aglen)
1526 struct xfs_defer_ops *dfops)
1527{ 1519{
1528 trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_private.a.agno, 1520 trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_private.a.agno,
1529 agbno, aglen); 1521 agbno, aglen);
@@ -1540,8 +1532,7 @@ STATIC int
1540__xfs_refcount_cow_free( 1532__xfs_refcount_cow_free(
1541 struct xfs_btree_cur *rcur, 1533 struct xfs_btree_cur *rcur,
1542 xfs_agblock_t agbno, 1534 xfs_agblock_t agbno,
1543 xfs_extlen_t aglen, 1535 xfs_extlen_t aglen)
1544 struct xfs_defer_ops *dfops)
1545{ 1536{
1546 trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_private.a.agno, 1537 trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_private.a.agno,
1547 agbno, aglen); 1538 agbno, aglen);
@@ -1554,47 +1545,45 @@ __xfs_refcount_cow_free(
1554/* Record a CoW staging extent in the refcount btree. */ 1545/* Record a CoW staging extent in the refcount btree. */
1555int 1546int
1556xfs_refcount_alloc_cow_extent( 1547xfs_refcount_alloc_cow_extent(
1557 struct xfs_mount *mp, 1548 struct xfs_trans *tp,
1558 struct xfs_defer_ops *dfops,
1559 xfs_fsblock_t fsb, 1549 xfs_fsblock_t fsb,
1560 xfs_extlen_t len) 1550 xfs_extlen_t len)
1561{ 1551{
1552 struct xfs_mount *mp = tp->t_mountp;
1562 int error; 1553 int error;
1563 1554
1564 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1555 if (!xfs_sb_version_hasreflink(&mp->m_sb))
1565 return 0; 1556 return 0;
1566 1557
1567 error = __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_ALLOC_COW, 1558 error = __xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len);
1568 fsb, len);
1569 if (error) 1559 if (error)
1570 return error; 1560 return error;
1571 1561
1572 /* Add rmap entry */ 1562 /* Add rmap entry */
1573 return xfs_rmap_alloc_extent(mp, dfops, XFS_FSB_TO_AGNO(mp, fsb), 1563 return xfs_rmap_alloc_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
1574 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW); 1564 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
1575} 1565}
1576 1566
1577/* Forget a CoW staging event in the refcount btree. */ 1567/* Forget a CoW staging event in the refcount btree. */
1578int 1568int
1579xfs_refcount_free_cow_extent( 1569xfs_refcount_free_cow_extent(
1580 struct xfs_mount *mp, 1570 struct xfs_trans *tp,
1581 struct xfs_defer_ops *dfops,
1582 xfs_fsblock_t fsb, 1571 xfs_fsblock_t fsb,
1583 xfs_extlen_t len) 1572 xfs_extlen_t len)
1584{ 1573{
1574 struct xfs_mount *mp = tp->t_mountp;
1585 int error; 1575 int error;
1586 1576
1587 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1577 if (!xfs_sb_version_hasreflink(&mp->m_sb))
1588 return 0; 1578 return 0;
1589 1579
1590 /* Remove rmap entry */ 1580 /* Remove rmap entry */
1591 error = xfs_rmap_free_extent(mp, dfops, XFS_FSB_TO_AGNO(mp, fsb), 1581 error = xfs_rmap_free_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
1592 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW); 1582 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
1593 if (error) 1583 if (error)
1594 return error; 1584 return error;
1595 1585
1596 return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_FREE_COW, 1586 return __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
1597 fsb, len);
1598} 1587}
1599 1588
1600struct xfs_refcount_recovery { 1589struct xfs_refcount_recovery {
@@ -1692,14 +1681,13 @@ xfs_refcount_recover_cow_leftovers(
1692 /* Free the orphan record */ 1681 /* Free the orphan record */
1693 agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START; 1682 agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
1694 fsb = XFS_AGB_TO_FSB(mp, agno, agbno); 1683 fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
1695 error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb, 1684 error = xfs_refcount_free_cow_extent(tp, fsb,
1696 rr->rr_rrec.rc_blockcount); 1685 rr->rr_rrec.rc_blockcount);
1697 if (error) 1686 if (error)
1698 goto out_trans; 1687 goto out_trans;
1699 1688
1700 /* Free the block. */ 1689 /* Free the block. */
1701 xfs_bmap_add_free(mp, tp->t_dfops, fsb, 1690 xfs_bmap_add_free(tp, fsb, rr->rr_rrec.rc_blockcount, NULL);
1702 rr->rr_rrec.rc_blockcount, NULL);
1703 1691
1704 error = xfs_trans_commit(tp); 1692 error = xfs_trans_commit(tp);
1705 if (error) 1693 if (error)
diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h
index 3b72c6dbf6ad..1d9c518575e7 100644
--- a/fs/xfs/libxfs/xfs_refcount.h
+++ b/fs/xfs/libxfs/xfs_refcount.h
@@ -29,10 +29,10 @@ struct xfs_refcount_intent {
29 xfs_extlen_t ri_blockcount; 29 xfs_extlen_t ri_blockcount;
30}; 30};
31 31
32extern int xfs_refcount_increase_extent(struct xfs_mount *mp, 32extern int xfs_refcount_increase_extent(struct xfs_trans *tp,
33 struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec); 33 struct xfs_bmbt_irec *irec);
34extern int xfs_refcount_decrease_extent(struct xfs_mount *mp, 34extern int xfs_refcount_decrease_extent(struct xfs_trans *tp,
35 struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec); 35 struct xfs_bmbt_irec *irec);
36 36
37extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp, 37extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
38 struct xfs_btree_cur *rcur, int error); 38 struct xfs_btree_cur *rcur, int error);
@@ -45,12 +45,10 @@ extern int xfs_refcount_find_shared(struct xfs_btree_cur *cur,
45 xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno, 45 xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,
46 xfs_extlen_t *flen, bool find_end_of_shared); 46 xfs_extlen_t *flen, bool find_end_of_shared);
47 47
48extern int xfs_refcount_alloc_cow_extent(struct xfs_mount *mp, 48extern int xfs_refcount_alloc_cow_extent(struct xfs_trans *tp,
49 struct xfs_defer_ops *dfops, xfs_fsblock_t fsb, 49 xfs_fsblock_t fsb, xfs_extlen_t len);
50 xfs_extlen_t len); 50extern int xfs_refcount_free_cow_extent(struct xfs_trans *tp,
51extern int xfs_refcount_free_cow_extent(struct xfs_mount *mp, 51 xfs_fsblock_t fsb, xfs_extlen_t len);
52 struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
53 xfs_extlen_t len);
54extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp, 52extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
55 xfs_agnumber_t agno); 53 xfs_agnumber_t agno);
56 54
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index fb266fa2cc45..245af452840e 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2277,18 +2277,18 @@ xfs_rmap_update_is_needed(
2277 */ 2277 */
2278static int 2278static int
2279__xfs_rmap_add( 2279__xfs_rmap_add(
2280 struct xfs_mount *mp, 2280 struct xfs_trans *tp,
2281 struct xfs_defer_ops *dfops,
2282 enum xfs_rmap_intent_type type, 2281 enum xfs_rmap_intent_type type,
2283 uint64_t owner, 2282 uint64_t owner,
2284 int whichfork, 2283 int whichfork,
2285 struct xfs_bmbt_irec *bmap) 2284 struct xfs_bmbt_irec *bmap)
2286{ 2285{
2287 struct xfs_rmap_intent *ri; 2286 struct xfs_rmap_intent *ri;
2288 2287
2289 trace_xfs_rmap_defer(mp, XFS_FSB_TO_AGNO(mp, bmap->br_startblock), 2288 trace_xfs_rmap_defer(tp->t_mountp,
2289 XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
2290 type, 2290 type,
2291 XFS_FSB_TO_AGBNO(mp, bmap->br_startblock), 2291 XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
2292 owner, whichfork, 2292 owner, whichfork,
2293 bmap->br_startoff, 2293 bmap->br_startoff,
2294 bmap->br_blockcount, 2294 bmap->br_blockcount,
@@ -2301,23 +2301,22 @@ __xfs_rmap_add(
2301 ri->ri_whichfork = whichfork; 2301 ri->ri_whichfork = whichfork;
2302 ri->ri_bmap = *bmap; 2302 ri->ri_bmap = *bmap;
2303 2303
2304 xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list); 2304 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list);
2305 return 0; 2305 return 0;
2306} 2306}
2307 2307
2308/* Map an extent into a file. */ 2308/* Map an extent into a file. */
2309int 2309int
2310xfs_rmap_map_extent( 2310xfs_rmap_map_extent(
2311 struct xfs_mount *mp, 2311 struct xfs_trans *tp,
2312 struct xfs_defer_ops *dfops,
2313 struct xfs_inode *ip, 2312 struct xfs_inode *ip,
2314 int whichfork, 2313 int whichfork,
2315 struct xfs_bmbt_irec *PREV) 2314 struct xfs_bmbt_irec *PREV)
2316{ 2315{
2317 if (!xfs_rmap_update_is_needed(mp, whichfork)) 2316 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
2318 return 0; 2317 return 0;
2319 2318
2320 return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ? 2319 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2321 XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino, 2320 XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino,
2322 whichfork, PREV); 2321 whichfork, PREV);
2323} 2322}
@@ -2325,25 +2324,29 @@ xfs_rmap_map_extent(
2325/* Unmap an extent out of a file. */ 2324/* Unmap an extent out of a file. */
2326int 2325int
2327xfs_rmap_unmap_extent( 2326xfs_rmap_unmap_extent(
2328 struct xfs_mount *mp, 2327 struct xfs_trans *tp,
2329 struct xfs_defer_ops *dfops,
2330 struct xfs_inode *ip, 2328 struct xfs_inode *ip,
2331 int whichfork, 2329 int whichfork,
2332 struct xfs_bmbt_irec *PREV) 2330 struct xfs_bmbt_irec *PREV)
2333{ 2331{
2334 if (!xfs_rmap_update_is_needed(mp, whichfork)) 2332 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
2335 return 0; 2333 return 0;
2336 2334
2337 return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ? 2335 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2338 XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino, 2336 XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino,
2339 whichfork, PREV); 2337 whichfork, PREV);
2340} 2338}
2341 2339
2342/* Convert a data fork extent from unwritten to real or vice versa. */ 2340/*
2341 * Convert a data fork extent from unwritten to real or vice versa.
2342 *
2343 * Note that tp can be NULL here as no transaction is used for COW fork
2344 * unwritten conversion.
2345 */
2343int 2346int
2344xfs_rmap_convert_extent( 2347xfs_rmap_convert_extent(
2345 struct xfs_mount *mp, 2348 struct xfs_mount *mp,
2346 struct xfs_defer_ops *dfops, 2349 struct xfs_trans *tp,
2347 struct xfs_inode *ip, 2350 struct xfs_inode *ip,
2348 int whichfork, 2351 int whichfork,
2349 struct xfs_bmbt_irec *PREV) 2352 struct xfs_bmbt_irec *PREV)
@@ -2351,7 +2354,7 @@ xfs_rmap_convert_extent(
2351 if (!xfs_rmap_update_is_needed(mp, whichfork)) 2354 if (!xfs_rmap_update_is_needed(mp, whichfork))
2352 return 0; 2355 return 0;
2353 2356
2354 return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ? 2357 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2355 XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino, 2358 XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino,
2356 whichfork, PREV); 2359 whichfork, PREV);
2357} 2360}
@@ -2359,8 +2362,7 @@ xfs_rmap_convert_extent(
2359/* Schedule the creation of an rmap for non-file data. */ 2362/* Schedule the creation of an rmap for non-file data. */
2360int 2363int
2361xfs_rmap_alloc_extent( 2364xfs_rmap_alloc_extent(
2362 struct xfs_mount *mp, 2365 struct xfs_trans *tp,
2363 struct xfs_defer_ops *dfops,
2364 xfs_agnumber_t agno, 2366 xfs_agnumber_t agno,
2365 xfs_agblock_t bno, 2367 xfs_agblock_t bno,
2366 xfs_extlen_t len, 2368 xfs_extlen_t len,
@@ -2368,23 +2370,21 @@ xfs_rmap_alloc_extent(
2368{ 2370{
2369 struct xfs_bmbt_irec bmap; 2371 struct xfs_bmbt_irec bmap;
2370 2372
2371 if (!xfs_rmap_update_is_needed(mp, XFS_DATA_FORK)) 2373 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
2372 return 0; 2374 return 0;
2373 2375
2374 bmap.br_startblock = XFS_AGB_TO_FSB(mp, agno, bno); 2376 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
2375 bmap.br_blockcount = len; 2377 bmap.br_blockcount = len;
2376 bmap.br_startoff = 0; 2378 bmap.br_startoff = 0;
2377 bmap.br_state = XFS_EXT_NORM; 2379 bmap.br_state = XFS_EXT_NORM;
2378 2380
2379 return __xfs_rmap_add(mp, dfops, XFS_RMAP_ALLOC, owner, 2381 return __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap);
2380 XFS_DATA_FORK, &bmap);
2381} 2382}
2382 2383
2383/* Schedule the deletion of an rmap for non-file data. */ 2384/* Schedule the deletion of an rmap for non-file data. */
2384int 2385int
2385xfs_rmap_free_extent( 2386xfs_rmap_free_extent(
2386 struct xfs_mount *mp, 2387 struct xfs_trans *tp,
2387 struct xfs_defer_ops *dfops,
2388 xfs_agnumber_t agno, 2388 xfs_agnumber_t agno,
2389 xfs_agblock_t bno, 2389 xfs_agblock_t bno,
2390 xfs_extlen_t len, 2390 xfs_extlen_t len,
@@ -2392,16 +2392,15 @@ xfs_rmap_free_extent(
2392{ 2392{
2393 struct xfs_bmbt_irec bmap; 2393 struct xfs_bmbt_irec bmap;
2394 2394
2395 if (!xfs_rmap_update_is_needed(mp, XFS_DATA_FORK)) 2395 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
2396 return 0; 2396 return 0;
2397 2397
2398 bmap.br_startblock = XFS_AGB_TO_FSB(mp, agno, bno); 2398 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
2399 bmap.br_blockcount = len; 2399 bmap.br_blockcount = len;
2400 bmap.br_startoff = 0; 2400 bmap.br_startoff = 0;
2401 bmap.br_state = XFS_EXT_NORM; 2401 bmap.br_state = XFS_EXT_NORM;
2402 2402
2403 return __xfs_rmap_add(mp, dfops, XFS_RMAP_FREE, owner, 2403 return __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap);
2404 XFS_DATA_FORK, &bmap);
2405} 2404}
2406 2405
2407/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */ 2406/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */
diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
index 9f19454768b2..157dc722ad35 100644
--- a/fs/xfs/libxfs/xfs_rmap.h
+++ b/fs/xfs/libxfs/xfs_rmap.h
@@ -185,21 +185,17 @@ struct xfs_rmap_intent {
185}; 185};
186 186
187/* functions for updating the rmapbt based on bmbt map/unmap operations */ 187/* functions for updating the rmapbt based on bmbt map/unmap operations */
188int xfs_rmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 188int xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
189 int whichfork, struct xfs_bmbt_irec *imap);
190int xfs_rmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
191 int whichfork, struct xfs_bmbt_irec *imap);
192int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp,
189 struct xfs_inode *ip, int whichfork, 193 struct xfs_inode *ip, int whichfork,
190 struct xfs_bmbt_irec *imap); 194 struct xfs_bmbt_irec *imap);
191int xfs_rmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 195int xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
192 struct xfs_inode *ip, int whichfork, 196 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
193 struct xfs_bmbt_irec *imap); 197int xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
194int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 198 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
195 struct xfs_inode *ip, int whichfork,
196 struct xfs_bmbt_irec *imap);
197int xfs_rmap_alloc_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
198 xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
199 uint64_t owner);
200int xfs_rmap_free_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
201 xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
202 uint64_t owner);
203 199
204void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp, 200void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,
205 struct xfs_btree_cur *rcur, int error); 201 struct xfs_btree_cur *rcur, int error);
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index e828e0b51814..ce45f066995e 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -486,8 +486,7 @@ xfs_bui_recover(
486 irec.br_blockcount = count; 486 irec.br_blockcount = count;
487 irec.br_startoff = bmap->me_startoff; 487 irec.br_startoff = bmap->me_startoff;
488 irec.br_state = state; 488 irec.br_state = state;
489 error = xfs_bmap_unmap_extent(tp->t_mountp, tp->t_dfops, ip, 489 error = xfs_bmap_unmap_extent(tp, ip, &irec);
490 &irec);
491 if (error) 490 if (error)
492 goto err_inode; 491 goto err_inode;
493 } 492 }
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index d9dad399440a..addbd74ecd8e 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1534,7 +1534,6 @@ xfs_swap_extent_rmap(
1534 struct xfs_inode *tip) 1534 struct xfs_inode *tip)
1535{ 1535{
1536 struct xfs_trans *tp = *tpp; 1536 struct xfs_trans *tp = *tpp;
1537 struct xfs_mount *mp = tp->t_mountp;
1538 struct xfs_bmbt_irec irec; 1537 struct xfs_bmbt_irec irec;
1539 struct xfs_bmbt_irec uirec; 1538 struct xfs_bmbt_irec uirec;
1540 struct xfs_bmbt_irec tirec; 1539 struct xfs_bmbt_irec tirec;
@@ -1598,26 +1597,22 @@ xfs_swap_extent_rmap(
1598 trace_xfs_swap_extent_rmap_remap_piece(tip, &uirec); 1597 trace_xfs_swap_extent_rmap_remap_piece(tip, &uirec);
1599 1598
1600 /* Remove the mapping from the donor file. */ 1599 /* Remove the mapping from the donor file. */
1601 error = xfs_bmap_unmap_extent(mp, tp->t_dfops, tip, 1600 error = xfs_bmap_unmap_extent(tp, tip, &uirec);
1602 &uirec);
1603 if (error) 1601 if (error)
1604 goto out_defer; 1602 goto out_defer;
1605 1603
1606 /* Remove the mapping from the source file. */ 1604 /* Remove the mapping from the source file. */
1607 error = xfs_bmap_unmap_extent(mp, tp->t_dfops, ip, 1605 error = xfs_bmap_unmap_extent(tp, ip, &irec);
1608 &irec);
1609 if (error) 1606 if (error)
1610 goto out_defer; 1607 goto out_defer;
1611 1608
1612 /* Map the donor file's blocks into the source file. */ 1609 /* Map the donor file's blocks into the source file. */
1613 error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, 1610 error = xfs_bmap_map_extent(tp, ip, &uirec);
1614 &uirec);
1615 if (error) 1611 if (error)
1616 goto out_defer; 1612 goto out_defer;
1617 1613
1618 /* Map the source file's blocks into the donor file. */ 1614 /* Map the source file's blocks into the donor file. */
1619 error = xfs_bmap_map_extent(mp, tp->t_dfops, tip, 1615 error = xfs_bmap_map_extent(tp, tip, &irec);
1620 &irec);
1621 if (error) 1616 if (error)
1622 goto out_defer; 1617 goto out_defer;
1623 1618
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 43c4ac374cba..fce38b56b962 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -490,24 +490,18 @@ xfs_cui_recover(
490 irec.br_blockcount = new_len; 490 irec.br_blockcount = new_len;
491 switch (type) { 491 switch (type) {
492 case XFS_REFCOUNT_INCREASE: 492 case XFS_REFCOUNT_INCREASE:
493 error = xfs_refcount_increase_extent( 493 error = xfs_refcount_increase_extent(tp, &irec);
494 tp->t_mountp, tp->t_dfops,
495 &irec);
496 break; 494 break;
497 case XFS_REFCOUNT_DECREASE: 495 case XFS_REFCOUNT_DECREASE:
498 error = xfs_refcount_decrease_extent( 496 error = xfs_refcount_decrease_extent(tp, &irec);
499 tp->t_mountp, tp->t_dfops,
500 &irec);
501 break; 497 break;
502 case XFS_REFCOUNT_ALLOC_COW: 498 case XFS_REFCOUNT_ALLOC_COW:
503 error = xfs_refcount_alloc_cow_extent( 499 error = xfs_refcount_alloc_cow_extent(tp,
504 tp->t_mountp, tp->t_dfops,
505 irec.br_startblock, 500 irec.br_startblock,
506 irec.br_blockcount); 501 irec.br_blockcount);
507 break; 502 break;
508 case XFS_REFCOUNT_FREE_COW: 503 case XFS_REFCOUNT_FREE_COW:
509 error = xfs_refcount_free_cow_extent( 504 error = xfs_refcount_free_cow_extent(tp,
510 tp->t_mountp, tp->t_dfops,
511 irec.br_startblock, 505 irec.br_startblock,
512 irec.br_blockcount); 506 irec.br_blockcount);
513 break; 507 break;
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 2ec562d75494..cbceb320a2e7 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -506,15 +506,13 @@ xfs_reflink_cancel_cow_blocks(
506 ASSERT((*tpp)->t_firstblock == NULLFSBLOCK); 506 ASSERT((*tpp)->t_firstblock == NULLFSBLOCK);
507 507
508 /* Free the CoW orphan record. */ 508 /* Free the CoW orphan record. */
509 error = xfs_refcount_free_cow_extent(ip->i_mount, 509 error = xfs_refcount_free_cow_extent(*tpp,
510 (*tpp)->t_dfops, del.br_startblock, 510 del.br_startblock, del.br_blockcount);
511 del.br_blockcount);
512 if (error) 511 if (error)
513 break; 512 break;
514 513
515 xfs_bmap_add_free(ip->i_mount, (*tpp)->t_dfops, 514 xfs_bmap_add_free(*tpp, del.br_startblock,
516 del.br_startblock, del.br_blockcount, 515 del.br_blockcount, NULL);
517 NULL);
518 516
519 /* Roll the transaction */ 517 /* Roll the transaction */
520 error = xfs_defer_finish(tpp); 518 error = xfs_defer_finish(tpp);
@@ -694,14 +692,13 @@ xfs_reflink_end_cow(
694 trace_xfs_reflink_cow_remap(ip, &del); 692 trace_xfs_reflink_cow_remap(ip, &del);
695 693
696 /* Free the CoW orphan record. */ 694 /* Free the CoW orphan record. */
697 error = xfs_refcount_free_cow_extent(tp->t_mountp, tp->t_dfops, 695 error = xfs_refcount_free_cow_extent(tp, del.br_startblock,
698 del.br_startblock, del.br_blockcount); 696 del.br_blockcount);
699 if (error) 697 if (error)
700 goto out_cancel; 698 goto out_cancel;
701 699
702 /* Map the new blocks into the data fork. */ 700 /* Map the new blocks into the data fork. */
703 error = xfs_bmap_map_extent(tp->t_mountp, tp->t_dfops, ip, 701 error = xfs_bmap_map_extent(tp, ip, &del);
704 &del);
705 if (error) 702 if (error)
706 goto out_cancel; 703 goto out_cancel;
707 704
@@ -1046,12 +1043,12 @@ xfs_reflink_remap_extent(
1046 uirec.br_blockcount, uirec.br_startblock); 1043 uirec.br_blockcount, uirec.br_startblock);
1047 1044
1048 /* Update the refcount tree */ 1045 /* Update the refcount tree */
1049 error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec); 1046 error = xfs_refcount_increase_extent(tp, &uirec);
1050 if (error) 1047 if (error)
1051 goto out_cancel; 1048 goto out_cancel;
1052 1049
1053 /* Map the new blocks into the data fork. */ 1050 /* Map the new blocks into the data fork. */
1054 error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec); 1051 error = xfs_bmap_map_extent(tp, ip, &uirec);
1055 if (error) 1052 if (error)
1056 goto out_cancel; 1053 goto out_cancel;
1057 1054