--- initial
+++ final
@@ -1,85 +1,84 @@
 STATIC int xfs_reflink_remap_extent(struct xfs_inode *ip, struct xfs_bmbt_irec *irec, xfs_fileoff_t destoff, xfs_off_t new_isize) {
   struct xfs_mount *mp = ip->i_mount;
   bool real_extent = xfs_bmap_is_real_extent(irec);
   struct xfs_trans *tp;
   xfs_fsblock_t firstfsb;
   unsigned int resblks;
   struct xfs_defer_ops dfops;
   struct xfs_bmbt_irec uirec;
   xfs_filblks_t rlen;
   xfs_filblks_t unmap_len;
   xfs_off_t newlen;
   int error;
   unmap_len = irec->br_startoff + irec->br_blockcount - destoff;
   trace_xfs_reflink_punch_range(ip, destoff, unmap_len);
   /* No reflinking if we're low on space */
   if (real_extent) {
     error = xfs_reflink_ag_has_free_space(mp, XFS_FSB_TO_AGNO(mp, irec->br_startblock));
     if (error) goto out;
   }
   /* Start a rolling transaction to switch the mappings */
   resblks = XFS_EXTENTADD_SPACE_RES(ip->i_mount, XFS_DATA_FORK);
   error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
   if (error) goto out;
   xfs_ilock(ip, XFS_ILOCK_EXCL);
   xfs_trans_ijoin(tp, ip, 0);
   /* If we're not just clearing space, then do we have enough quota? */
   if (real_extent) {
     error = xfs_trans_reserve_quota_nblks(tp, ip, irec->br_blockcount, 0, XFS_QMOPT_RES_REGBLKS);
     if (error) goto out_cancel;
   }
   trace_xfs_reflink_remap(ip, irec->br_startoff, irec->br_blockcount, irec->br_startblock);
   /* Unmap the old blocks in the data fork. */
   rlen = unmap_len;
   while (rlen) {
-    xfs_defer_init(&dfops, &firstfsb);
-    tp->t_dfops = &dfops;
+    xfs_defer_init(tp, &dfops, &firstfsb);
     error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, &firstfsb);
     if (error) goto out_defer;
     /*
      * Trim the extent to whatever got unmapped.
      * Remember, bunmapi works backwards.
      */
     uirec.br_startblock = irec->br_startblock + rlen;
     uirec.br_startoff = irec->br_startoff + rlen;
     uirec.br_blockcount = unmap_len - rlen;
     unmap_len = rlen;
     /* If this isn't a real mapping, we're done. */
     if (!real_extent || uirec.br_blockcount == 0) goto next_extent;
     trace_xfs_reflink_remap(ip, uirec.br_startoff, uirec.br_blockcount, uirec.br_startblock);
     /* Update the refcount tree */
     error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec);
     if (error) goto out_defer;
     /* Map the new blocks into the data fork. */
     error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec);
     if (error) goto out_defer;
     /* Update quota accounting. */
     xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, uirec.br_blockcount);
     /* Update dest isize if needed. */
     newlen = XFS_FSB_TO_B(mp, uirec.br_startoff + uirec.br_blockcount);
     newlen = min_t(xfs_off_t, newlen, new_isize);
     if (newlen > i_size_read(VFS_I(ip))) {
       trace_xfs_reflink_update_inode_size(ip, newlen);
       i_size_write(VFS_I(ip), newlen);
       ip->i_d.di_size = newlen;
       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
     }
   next_extent:
     /* Process all the deferred stuff. */
     xfs_defer_ijoin(tp->t_dfops, ip);
     error = xfs_defer_finish(&tp, tp->t_dfops);
     if (error) goto out_defer;
   }
   error = xfs_trans_commit(tp);
   xfs_iunlock(ip, XFS_ILOCK_EXCL);
   if (error) goto out;
   return 0;
 out_defer:
   xfs_defer_cancel(tp->t_dfops);
 out_cancel:
   xfs_trans_cancel(tp);
   xfs_iunlock(ip, XFS_ILOCK_EXCL);
 out:
   trace_xfs_reflink_remap_extent_error(ip, error, _RET_IP_);
   return error;
 }<sep>@@
expression e1,e2,tp;
@@

-		xfs_defer_init(e1, e2);
-		(tp)->t_dfops = e1;
+		xfs_defer_init(tp, e1, e2);