--- initial
+++ final
@@ -1,124 +1,123 @@
 int xfs_iomap_write_allocate(xfs_inode_t *ip, int whichfork, xfs_off_t offset, xfs_bmbt_irec_t *imap) {
   xfs_mount_t *mp = ip->i_mount;
   xfs_fileoff_t offset_fsb, last_block;
   xfs_fileoff_t end_fsb, map_start_fsb;
   xfs_fsblock_t first_block;
   struct xfs_defer_ops dfops;
   xfs_filblks_t count_fsb;
   xfs_trans_t *tp;
   int nimaps;
   int error = 0;
   int flags = XFS_BMAPI_DELALLOC;
   int nres;
   if (whichfork == XFS_COW_FORK) flags |= XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC;
   /*
    * Make sure that the dquots are there.
    */
   error = xfs_qm_dqattach(ip);
   if (error) return error;
   offset_fsb = XFS_B_TO_FSBT(mp, offset);
   count_fsb = imap->br_blockcount;
   map_start_fsb = imap->br_startoff;
   XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb));
   while (count_fsb != 0) {
     /*
      * Set up a transaction with which to allocate the
      * backing store for the file.  Do allocations in a
      * loop until we get some space in the range we are
      * interested in.  The other space that might be allocated
      * is in the delayed allocation extent on which we sit
      * but before our buffer starts.
      */
     nimaps = 0;
     while (nimaps == 0) {
       nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
       /*
        * We have already reserved space for the extent and any
        * indirect blocks when creating the delalloc extent,
        * there is no need to reserve space in this transaction
        * again.
        */
       error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, XFS_TRANS_RESERVE, &tp);
       if (error) return error;
       xfs_ilock(ip, XFS_ILOCK_EXCL);
       xfs_trans_ijoin(tp, ip, 0);
-      xfs_defer_init(&dfops, &first_block);
-      tp->t_dfops = &dfops;
+      xfs_defer_init(tp, &dfops, &first_block);
       /*
        * it is possible that the extents have changed since
        * we did the read call as we dropped the ilock for a
        * while. We have to be careful about truncates or hole
        * punchs here - we are not allowed to allocate
        * non-delalloc blocks here.
        *
        * The only protection against truncation is the pages
        * for the range we are being asked to convert are
        * locked and hence a truncate will block on them
        * first.
        *
        * As a result, if we go beyond the range we really
        * need and hit an delalloc extent boundary followed by
        * a hole while we have excess blocks in the map, we
        * will fill the hole incorrectly and overrun the
        * transaction reservation.
        *
        * Using a single map prevents this as we are forced to
        * check each map we look for overlap with the desired
        * range and abort as soon as we find it. Also, given
        * that we only return a single map, having one beyond
        * what we can return is probably a bit silly.
        *
        * We also need to check that we don't go beyond EOF;
        * this is a truncate optimisation as a truncate sets
        * the new file size before block on the pages we
        * currently have locked under writeback. Because they
        * are about to be tossed, we don't need to write them
        * back....
        */
       nimaps = 1;
       end_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
       error = xfs_bmap_last_offset(ip, &last_block, XFS_DATA_FORK);
       if (error) goto trans_cancel;
       last_block = XFS_FILEOFF_MAX(last_block, end_fsb);
       if ((map_start_fsb + count_fsb) > last_block) {
         count_fsb = last_block - map_start_fsb;
         if (count_fsb == 0) {
           error = -EAGAIN;
           goto trans_cancel;
         }
       }
       /*
        * From this point onwards we overwrite the imap
        * pointer that the caller gave to us.
        */
       error = xfs_bmapi_write(tp, ip, map_start_fsb, count_fsb, flags, &first_block, nres, imap, &nimaps);
       if (error) goto trans_cancel;
       error = xfs_defer_finish(&tp, tp->t_dfops);
       if (error) goto trans_cancel;
       error = xfs_trans_commit(tp);
       if (error) goto error0;
       xfs_iunlock(ip, XFS_ILOCK_EXCL);
     }
     /*
      * See if we were able to allocate an extent that
      * covers at least part of the callers request
      */
     if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) return xfs_alert_fsblock_zero(ip, imap);
     if ((offset_fsb >= imap->br_startoff) && (offset_fsb < (imap->br_startoff + imap->br_blockcount))) {
       XFS_STATS_INC(mp, xs_xstrat_quick);
       return 0;
     }
     /*
      * So far we have not mapped the requested part of the
      * file, just surrounding data, try again.
      */
     count_fsb -= imap->br_blockcount;
     map_start_fsb = imap->br_startoff + imap->br_blockcount;
   }
 trans_cancel:
   xfs_defer_cancel(tp->t_dfops);
   xfs_trans_cancel(tp);
 error0:
   xfs_iunlock(ip, XFS_ILOCK_EXCL);
   return error;
 }<sep>@@
expression e1,e2,tp;
@@

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