]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: pass transaction to xfs_defer_add()
authorBrian Foster <bfoster@redhat.com>
Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)
Source kernel commit: 0f37d1780c3d864599fb377dcb47ad1aa0686b4e

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h
libxfs/xfs_bmap_btree.c
libxfs/xfs_defer.c
libxfs/xfs_defer.h
libxfs/xfs_ialloc.c
libxfs/xfs_refcount.c
libxfs/xfs_refcount.h
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h

index cbcf2346cdeb11b164bb5fbe68b0ea47c7a25624..ff6ab858c4a7d2d46cd089a9303cfaddcfb08de9 100644 (file)
@@ -2194,12 +2194,12 @@ xfs_agfl_reset(
  */
 STATIC void
 xfs_defer_agfl_block(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        xfs_agnumber_t                  agno,
        xfs_fsblock_t                   agbno,
        struct xfs_owner_info           *oinfo)
 {
+       struct xfs_mount                *mp = tp->t_mountp;
        struct xfs_extent_free_item     *new;           /* new element */
 
        ASSERT(xfs_bmap_free_item_zone != NULL);
@@ -2212,7 +2212,7 @@ xfs_defer_agfl_block(
 
        trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
 
-       xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_AGFL_FREE, &new->xefi_list);
+       xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &new->xefi_list);
 }
 
 /*
@@ -2321,8 +2321,7 @@ xfs_alloc_fix_freelist(
 
                /* defer agfl frees if dfops is provided */
                if (tp->t_dfops) {
-                       xfs_defer_agfl_block(mp, tp->t_dfops, args->agno,
-                                            bno, &targs.oinfo);
+                       xfs_defer_agfl_block(tp, args->agno, bno, &targs.oinfo);
                } else {
                        error = xfs_free_agfl_block(tp, args->agno, bno, agbp,
                                                    &targs.oinfo);
index a93aee323183778e24285d0b9c1e516f05e1ea66..2c3bc099cdbbae47d6acf3b1846c45b0f60b3029 100644 (file)
@@ -524,8 +524,7 @@ xfs_bmap_validate_ret(
  */
 void
 __xfs_bmap_add_free(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        xfs_fsblock_t                   bno,
        xfs_filblks_t                   len,
        struct xfs_owner_info           *oinfo,
@@ -533,8 +532,9 @@ __xfs_bmap_add_free(
 {
        struct xfs_extent_free_item     *new;           /* new element */
 #ifdef DEBUG
-       xfs_agnumber_t          agno;
-       xfs_agblock_t           agbno;
+       struct xfs_mount                *mp = tp->t_mountp;
+       xfs_agnumber_t                  agno;
+       xfs_agblock_t                   agbno;
 
        ASSERT(bno != NULLFSBLOCK);
        ASSERT(len > 0);
@@ -557,9 +557,10 @@ __xfs_bmap_add_free(
        else
                xfs_rmap_skip_owner_update(&new->xefi_oinfo);
        new->xefi_skip_discard = skip_discard;
-       trace_xfs_bmap_free_defer(mp, XFS_FSB_TO_AGNO(mp, bno), 0,
-                       XFS_FSB_TO_AGBNO(mp, bno), len);
-       xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list);
+       trace_xfs_bmap_free_defer(tp->t_mountp,
+                       XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
+                       XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len);
+       xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list);
 }
 
 /*
@@ -615,7 +616,7 @@ xfs_bmap_btree_to_extents(
        if ((error = xfs_btree_check_block(cur, cblock, 0, cbp)))
                return error;
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
-       xfs_bmap_add_free(mp, cur->bc_tp->t_dfops, cbno, 1, &oinfo);
+       xfs_bmap_add_free(cur->bc_tp, cbno, 1, &oinfo);
        ip->i_d.di_nblocks--;
        xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
        xfs_trans_binval(tp, cbp);
@@ -1952,8 +1953,7 @@ xfs_bmap_add_extent_delay_real(
 
        /* add reverse mapping unless caller opted out */
        if (!(bma->flags & XFS_BMAPI_NORMAP)) {
-               error = xfs_rmap_map_extent(mp, bma->tp->t_dfops, bma->ip,
-                               whichfork, new);
+               error = xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new);
                if (error)
                        goto done;
        }
@@ -2017,7 +2017,6 @@ xfs_bmap_add_extent_unwritten_real(
        int                     state = xfs_bmap_fork_to_state(whichfork);
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_bmbt_irec    old;
-       struct xfs_defer_ops    *dfops = tp ? tp->t_dfops : NULL;
 
        *logflagsp = 0;
 
@@ -2436,7 +2435,7 @@ xfs_bmap_add_extent_unwritten_real(
        }
 
        /* update reverse mappings */
-       error = xfs_rmap_convert_extent(mp, dfops, ip, whichfork, new);
+       error = xfs_rmap_convert_extent(mp, tp, ip, whichfork, new);
        if (error)
                goto done;
 
@@ -2797,8 +2796,7 @@ xfs_bmap_add_extent_hole_real(
 
        /* add reverse mapping unless caller opted out */
        if (!(flags & XFS_BMAPI_NORMAP)) {
-               error = xfs_rmap_map_extent(mp, tp->t_dfops, ip, whichfork,
-                               new);
+               error = xfs_rmap_map_extent(tp, ip, whichfork, new);
                if (error)
                        goto done;
        }
@@ -4355,9 +4353,8 @@ xfs_bmapi_write(
                         * the refcount btree for orphan recovery.
                         */
                        if (whichfork == XFS_COW_FORK) {
-                               error = xfs_refcount_alloc_cow_extent(mp,
-                                               tp->t_dfops, bma.blkno,
-                                               bma.length);
+                               error = xfs_refcount_alloc_cow_extent(tp,
+                                               bma.blkno, bma.length);
                                if (error)
                                        goto error0;
                        }
@@ -4843,7 +4840,6 @@ xfs_bmap_del_extent_real(
        uint                    qfield; /* quota field to update */
        int                     state = xfs_bmap_fork_to_state(whichfork);
        struct xfs_bmbt_irec    old;
-       struct xfs_defer_ops    *dfops = tp ? tp->t_dfops : NULL;
 
        mp = ip->i_mount;
        XFS_STATS_INC(mp, xs_del_exlist);
@@ -5027,7 +5023,7 @@ xfs_bmap_del_extent_real(
        }
 
        /* remove reverse mapping */
-       error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, del);
+       error = xfs_rmap_unmap_extent(tp, ip, whichfork, del);
        if (error)
                goto done;
 
@@ -5036,11 +5032,11 @@ xfs_bmap_del_extent_real(
         */
        if (do_fx && !(bflags & XFS_BMAPI_REMAP)) {
                if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
-                       error = xfs_refcount_decrease_extent(mp, dfops, del);
+                       error = xfs_refcount_decrease_extent(tp, del);
                        if (error)
                                goto done;
                } else {
-                       __xfs_bmap_add_free(mp, dfops, del->br_startblock,
+                       __xfs_bmap_add_free(tp, del->br_startblock,
                                        del->br_blockcount, NULL,
                                        (bflags & XFS_BMAPI_NODISCARD) ||
                                        del->br_state == XFS_EXT_UNWRITTEN);
@@ -5480,6 +5476,7 @@ xfs_bmse_can_merge(
  */
 STATIC int
 xfs_bmse_merge(
+       struct xfs_trans                *tp,
        struct xfs_inode                *ip,
        int                             whichfork,
        xfs_fileoff_t                   shift,          /* shift fsb */
@@ -5487,8 +5484,7 @@ xfs_bmse_merge(
        struct xfs_bmbt_irec            *got,           /* extent to shift */
        struct xfs_bmbt_irec            *left,          /* preceding extent */
        struct xfs_btree_cur            *cur,
-       int                             *logflags,      /* output */
-       struct xfs_defer_ops            *dfops)
+       int                             *logflags)      /* output */
 {
        struct xfs_bmbt_irec            new;
        xfs_filblks_t                   blockcount;
@@ -5544,23 +5540,23 @@ done:
                        &new);
 
        /* update reverse mapping. rmap functions merge the rmaps for us */
-       error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got);
+       error = xfs_rmap_unmap_extent(tp, ip, whichfork, got);
        if (error)
                return error;
        memcpy(&new, got, sizeof(new));
        new.br_startoff = left->br_startoff + left->br_blockcount;
-       return xfs_rmap_map_extent(mp, dfops, ip, whichfork, &new);
+       return xfs_rmap_map_extent(tp, ip, whichfork, &new);
 }
 
 static int
 xfs_bmap_shift_update_extent(
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        int                     whichfork,
        struct xfs_iext_cursor  *icur,
        struct xfs_bmbt_irec    *got,
        struct xfs_btree_cur    *cur,
        int                     *logflags,
-       struct xfs_defer_ops    *dfops,
        xfs_fileoff_t           startoff)
 {
        struct xfs_mount        *mp = ip->i_mount;
@@ -5588,10 +5584,10 @@ xfs_bmap_shift_update_extent(
                        got);
 
        /* update reverse mapping */
-       error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, &prev);
+       error = xfs_rmap_unmap_extent(tp, ip, whichfork, &prev);
        if (error)
                return error;
-       return xfs_rmap_map_extent(mp, dfops, ip, whichfork, got);
+       return xfs_rmap_map_extent(tp, ip, whichfork, got);
 }
 
 int
@@ -5651,9 +5647,9 @@ xfs_bmap_collapse_extents(
                }
 
                if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) {
-                       error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
-                                       &icur, &got, &prev, cur, &logflags,
-                                       tp->t_dfops);
+                       error = xfs_bmse_merge(tp, ip, whichfork,
+                                       offset_shift_fsb, &icur, &got, &prev,
+                                       cur, &logflags);
                        if (error)
                                goto del_cursor;
                        goto done;
@@ -5665,8 +5661,8 @@ xfs_bmap_collapse_extents(
                }
        }
 
-       error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur,
-                       &logflags, tp->t_dfops, new_startoff);
+       error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
+                       cur, &logflags, new_startoff);
        if (error)
                goto del_cursor;
 
@@ -5792,8 +5788,8 @@ xfs_bmap_insert_extents(
                        WARN_ON_ONCE(1);
        }
 
-       error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur,
-                       &logflags, tp->t_dfops, new_startoff);
+       error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
+                       cur, &logflags, new_startoff);
        if (error)
                goto del_cursor;
 
@@ -5970,8 +5966,7 @@ xfs_bmap_is_update_needed(
 /* Record a bmap intent. */
 static int
 __xfs_bmap_add(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        enum xfs_bmap_intent_type       type,
        struct xfs_inode                *ip,
        int                             whichfork,
@@ -5979,10 +5974,10 @@ __xfs_bmap_add(
 {
        struct xfs_bmap_intent          *bi;
 
-       trace_xfs_bmap_defer(mp,
-                       XFS_FSB_TO_AGNO(mp, bmap->br_startblock),
+       trace_xfs_bmap_defer(tp->t_mountp,
+                       XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
                        type,
-                       XFS_FSB_TO_AGBNO(mp, bmap->br_startblock),
+                       XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
                        ip->i_ino, whichfork,
                        bmap->br_startoff,
                        bmap->br_blockcount,
@@ -5995,38 +5990,34 @@ __xfs_bmap_add(
        bi->bi_whichfork = whichfork;
        bi->bi_bmap = *bmap;
 
-       xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list);
+       xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list);
        return 0;
 }
 
 /* Map an extent into a file. */
 int
 xfs_bmap_map_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        struct xfs_bmbt_irec    *PREV)
 {
        if (!xfs_bmap_is_update_needed(PREV))
                return 0;
 
-       return __xfs_bmap_add(mp, dfops, XFS_BMAP_MAP, ip,
-                       XFS_DATA_FORK, PREV);
+       return __xfs_bmap_add(tp, XFS_BMAP_MAP, ip, XFS_DATA_FORK, PREV);
 }
 
 /* Unmap an extent out of a file. */
 int
 xfs_bmap_unmap_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        struct xfs_bmbt_irec    *PREV)
 {
        if (!xfs_bmap_is_update_needed(PREV))
                return 0;
 
-       return __xfs_bmap_add(mp, dfops, XFS_BMAP_UNMAP, ip,
-                       XFS_DATA_FORK, PREV);
+       return __xfs_bmap_add(tp, XFS_BMAP_UNMAP, ip, XFS_DATA_FORK, PREV);
 }
 
 /*
index 9165a878edcdab0f5c76b8dc9b4ca2d88b5d3c8a..b6e9b639e731a1fafd1116b9decb22872dc765af 100644 (file)
@@ -184,9 +184,9 @@ void        xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
 void   xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *);
 int    xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
 void   xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
-void   __xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-                         xfs_fsblock_t bno, xfs_filblks_t len,
-                         struct xfs_owner_info *oinfo, bool skip_discard);
+void   __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
+               xfs_filblks_t len, struct xfs_owner_info *oinfo,
+               bool skip_discard);
 void   xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
 int    xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
                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,
 
 static inline void
 xfs_bmap_add_free(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        xfs_fsblock_t                   bno,
        xfs_filblks_t                   len,
        struct xfs_owner_info           *oinfo)
 {
-       __xfs_bmap_add_free(mp, dfops, bno, len, oinfo, false);
+       __xfs_bmap_add_free(tp, bno, len, oinfo, false);
 }
 
 enum xfs_bmap_intent_type {
@@ -256,10 +255,10 @@ int       xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip,
                enum xfs_bmap_intent_type type, int whichfork,
                xfs_fileoff_t startoff, xfs_fsblock_t startblock,
                xfs_filblks_t *blockcount, xfs_exntst_t state);
-int    xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               struct xfs_inode *ip, struct xfs_bmbt_irec *imap);
-int    xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               struct xfs_inode *ip, struct xfs_bmbt_irec *imap);
+int    xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
+               struct xfs_bmbt_irec *imap);
+int    xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
+               struct xfs_bmbt_irec *imap);
 
 static inline int xfs_bmap_fork_to_state(int whichfork)
 {
index 91cc40f94f491ad708c1a4990fd835dfe9788c82..24c32a9c0c32d55c8d934e43c906157a6ae568d0 100644 (file)
@@ -286,7 +286,7 @@ xfs_bmbt_free_block(
        struct xfs_owner_info   oinfo;
 
        xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_private.b.whichfork);
-       xfs_bmap_add_free(mp, cur->bc_tp->t_dfops, fsbno, 1, &oinfo);
+       xfs_bmap_add_free(cur->bc_tp, fsbno, 1, &oinfo);
        ip->i_d.di_nblocks--;
 
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
index a8af454d2fdcd8ed6557a9d6f65bcb9328125e83..c8e34ceac8cde7c7df47b1071f535a59c319c764 100644 (file)
@@ -484,12 +484,15 @@ xfs_defer_cancel(
 /* Add an item for later deferred processing. */
 void
 xfs_defer_add(
-       struct xfs_defer_ops            *dop,
+       struct xfs_trans                *tp,
        enum xfs_defer_ops_type         type,
        struct list_head                *li)
 {
+       struct xfs_defer_ops            *dop = tp->t_dfops;
        struct xfs_defer_pending        *dfp = NULL;
 
+       ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
+
        /*
         * Add the item to a pending item at the end of the intake list.
         * If the last pending item has the same type, reuse it.  Else,
index f091bf3abeaf346b7c42f7a63c88245e6f8b636f..b2675f1ca9094b89013bfddfc9fdd67e7ffaa289 100644 (file)
@@ -35,7 +35,7 @@ enum xfs_defer_ops_type {
        XFS_DEFER_OPS_TYPE_MAX,
 };
 
-void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
+void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
                struct list_head *h);
 int xfs_defer_finish_noroll(struct xfs_trans **tp);
 int xfs_defer_finish(struct xfs_trans **tp);
index 3095f3735c6654d63cfdbc0f85a8494f8869037a..9640a872daeeb7cb5e23949ef9cb756f1011dc28 100644 (file)
@@ -1832,23 +1832,24 @@ out_error:
  */
 STATIC void
 xfs_difree_inode_chunk(
-       struct xfs_mount                *mp,
+       struct xfs_trans                *tp,
        xfs_agnumber_t                  agno,
-       struct xfs_inobt_rec_incore     *rec,
-       struct xfs_defer_ops            *dfops)
+       struct xfs_inobt_rec_incore     *rec)
 {
-       xfs_agblock_t   sagbno = XFS_AGINO_TO_AGBNO(mp, rec->ir_startino);
-       int             startidx, endidx;
-       int             nextbit;
-       xfs_agblock_t   agbno;
-       int             contigblk;
-       struct xfs_owner_info   oinfo;
+       struct xfs_mount                *mp = tp->t_mountp;
+       xfs_agblock_t                   sagbno = XFS_AGINO_TO_AGBNO(mp,
+                                                       rec->ir_startino);
+       int                             startidx, endidx;
+       int                             nextbit;
+       xfs_agblock_t                   agbno;
+       int                             contigblk;
+       struct xfs_owner_info           oinfo;
        DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS);
        xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES);
 
        if (!xfs_inobt_issparse(rec->ir_holemask)) {
                /* not sparse, calculate extent info directly */
-               xfs_bmap_add_free(mp, dfops, XFS_AGB_TO_FSB(mp, agno, sagbno),
+               xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno),
                                  mp->m_ialloc_blks, &oinfo);
                return;
        }
@@ -1892,7 +1893,7 @@ xfs_difree_inode_chunk(
 
                ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
                ASSERT(contigblk % mp->m_sb.sb_spino_align == 0);
-               xfs_bmap_add_free(mp, dfops, XFS_AGB_TO_FSB(mp, agno, agbno),
+               xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, agbno),
                                  contigblk, &oinfo);
 
                /* reset range to current bit and carry on... */
@@ -1996,7 +1997,7 @@ xfs_difree_inobt(
                        goto error0;
                }
 
-               xfs_difree_inode_chunk(mp, agno, &rec, tp->t_dfops);
+               xfs_difree_inode_chunk(tp, agno, &rec);
        } else {
                xic->deleted = false;
 
index ed1ebf424cd63d4b85870988be6e3f42b07730d5..0a517f5a34cb06c1a838818d4407c4cc0a550e13 100644 (file)
@@ -33,11 +33,9 @@ enum xfs_refc_adjust_op {
 };
 
 STATIC int __xfs_refcount_cow_alloc(struct xfs_btree_cur *rcur,
-               xfs_agblock_t agbno, xfs_extlen_t aglen,
-               struct xfs_defer_ops *dfops);
+               xfs_agblock_t agbno, xfs_extlen_t aglen);
 STATIC int __xfs_refcount_cow_free(struct xfs_btree_cur *rcur,
-               xfs_agblock_t agbno, xfs_extlen_t aglen,
-               struct xfs_defer_ops *dfops);
+               xfs_agblock_t agbno, xfs_extlen_t aglen);
 
 /*
  * Look up the first record less than or equal to [bno, len] in the btree
@@ -869,7 +867,6 @@ xfs_refcount_adjust_extents(
        xfs_agblock_t           *agbno,
        xfs_extlen_t            *aglen,
        enum xfs_refc_adjust_op adj,
-       struct xfs_defer_ops    *dfops,
        struct xfs_owner_info   *oinfo)
 {
        struct xfs_refcount_irec        ext, tmp;
@@ -924,8 +921,8 @@ xfs_refcount_adjust_extents(
                                fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
                                                cur->bc_private.a.agno,
                                                tmp.rc_startblock);
-                               xfs_bmap_add_free(cur->bc_mp, dfops, fsbno,
-                                               tmp.rc_blockcount, oinfo);
+                               xfs_bmap_add_free(cur->bc_tp, fsbno,
+                                                 tmp.rc_blockcount, oinfo);
                        }
 
                        (*agbno) += tmp.rc_blockcount;
@@ -967,8 +964,8 @@ xfs_refcount_adjust_extents(
                        fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
                                        cur->bc_private.a.agno,
                                        ext.rc_startblock);
-                       xfs_bmap_add_free(cur->bc_mp, dfops, fsbno,
-                                       ext.rc_blockcount, oinfo);
+                       xfs_bmap_add_free(cur->bc_tp, fsbno, ext.rc_blockcount,
+                                         oinfo);
                }
 
 skip:
@@ -997,7 +994,6 @@ xfs_refcount_adjust(
        xfs_agblock_t           *new_agbno,
        xfs_extlen_t            *new_aglen,
        enum xfs_refc_adjust_op adj,
-       struct xfs_defer_ops    *dfops,
        struct xfs_owner_info   *oinfo)
 {
        bool                    shape_changed;
@@ -1042,7 +1038,7 @@ xfs_refcount_adjust(
 
        /* Now that we've taken care of the ends, adjust the middle extents */
        error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen,
-                       adj, dfops, oinfo);
+                       adj, oinfo);
        if (error)
                goto out_error;
 
@@ -1089,7 +1085,6 @@ xfs_refcount_finish_one(
        struct xfs_btree_cur            **pcur)
 {
        struct xfs_mount                *mp = tp->t_mountp;
-       struct xfs_defer_ops            *dfops = tp->t_dfops;
        struct xfs_btree_cur            *rcur;
        struct xfs_buf                  *agbp = NULL;
        int                             error = 0;
@@ -1144,23 +1139,23 @@ xfs_refcount_finish_one(
        switch (type) {
        case XFS_REFCOUNT_INCREASE:
                error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
-                       new_len, XFS_REFCOUNT_ADJUST_INCREASE, dfops, NULL);
+                       new_len, XFS_REFCOUNT_ADJUST_INCREASE, NULL);
                *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
                break;
        case XFS_REFCOUNT_DECREASE:
                error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
-                       new_len, XFS_REFCOUNT_ADJUST_DECREASE, dfops, NULL);
+                       new_len, XFS_REFCOUNT_ADJUST_DECREASE, NULL);
                *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
                break;
        case XFS_REFCOUNT_ALLOC_COW:
                *new_fsb = startblock + blockcount;
                *new_len = 0;
-               error = __xfs_refcount_cow_alloc(rcur, bno, blockcount, dfops);
+               error = __xfs_refcount_cow_alloc(rcur, bno, blockcount);
                break;
        case XFS_REFCOUNT_FREE_COW:
                *new_fsb = startblock + blockcount;
                *new_len = 0;
-               error = __xfs_refcount_cow_free(rcur, bno, blockcount, dfops);
+               error = __xfs_refcount_cow_free(rcur, bno, blockcount);
                break;
        default:
                ASSERT(0);
@@ -1182,16 +1177,16 @@ out_cur:
  */
 static int
 __xfs_refcount_add(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        enum xfs_refcount_intent_type   type,
        xfs_fsblock_t                   startblock,
        xfs_extlen_t                    blockcount)
 {
        struct xfs_refcount_intent      *ri;
 
-       trace_xfs_refcount_defer(mp, XFS_FSB_TO_AGNO(mp, startblock),
-                       type, XFS_FSB_TO_AGBNO(mp, startblock),
+       trace_xfs_refcount_defer(tp->t_mountp,
+                       XFS_FSB_TO_AGNO(tp->t_mountp, startblock),
+                       type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
                        blockcount);
 
        ri = kmem_alloc(sizeof(struct xfs_refcount_intent),
@@ -1201,7 +1196,7 @@ __xfs_refcount_add(
        ri->ri_startblock = startblock;
        ri->ri_blockcount = blockcount;
 
-       xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_REFCOUNT, &ri->ri_list);
+       xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_REFCOUNT, &ri->ri_list);
        return 0;
 }
 
@@ -1210,14 +1205,13 @@ __xfs_refcount_add(
  */
 int
 xfs_refcount_increase_extent(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        struct xfs_bmbt_irec            *PREV)
 {
-       if (!xfs_sb_version_hasreflink(&mp->m_sb))
+       if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb))
                return 0;
 
-       return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_INCREASE,
+       return __xfs_refcount_add(tp, XFS_REFCOUNT_INCREASE,
                        PREV->br_startblock, PREV->br_blockcount);
 }
 
@@ -1226,14 +1220,13 @@ xfs_refcount_increase_extent(
  */
 int
 xfs_refcount_decrease_extent(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        struct xfs_bmbt_irec            *PREV)
 {
-       if (!xfs_sb_version_hasreflink(&mp->m_sb))
+       if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb))
                return 0;
 
-       return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_DECREASE,
+       return __xfs_refcount_add(tp, XFS_REFCOUNT_DECREASE,
                        PREV->br_startblock, PREV->br_blockcount);
 }
 
@@ -1521,8 +1514,7 @@ STATIC int
 __xfs_refcount_cow_alloc(
        struct xfs_btree_cur    *rcur,
        xfs_agblock_t           agbno,
-       xfs_extlen_t            aglen,
-       struct xfs_defer_ops    *dfops)
+       xfs_extlen_t            aglen)
 {
        trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_private.a.agno,
                        agbno, aglen);
@@ -1539,8 +1531,7 @@ STATIC int
 __xfs_refcount_cow_free(
        struct xfs_btree_cur    *rcur,
        xfs_agblock_t           agbno,
-       xfs_extlen_t            aglen,
-       struct xfs_defer_ops    *dfops)
+       xfs_extlen_t            aglen)
 {
        trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_private.a.agno,
                        agbno, aglen);
@@ -1553,47 +1544,45 @@ __xfs_refcount_cow_free(
 /* Record a CoW staging extent in the refcount btree. */
 int
 xfs_refcount_alloc_cow_extent(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        xfs_fsblock_t                   fsb,
        xfs_extlen_t                    len)
 {
+       struct xfs_mount                *mp = tp->t_mountp;
        int                             error;
 
        if (!xfs_sb_version_hasreflink(&mp->m_sb))
                return 0;
 
-       error = __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_ALLOC_COW,
-                       fsb, len);
+       error = __xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len);
        if (error)
                return error;
 
        /* Add rmap entry */
-       return xfs_rmap_alloc_extent(mp, dfops, XFS_FSB_TO_AGNO(mp, fsb),
+       return xfs_rmap_alloc_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
                        XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
 }
 
 /* Forget a CoW staging event in the refcount btree. */
 int
 xfs_refcount_free_cow_extent(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        xfs_fsblock_t                   fsb,
        xfs_extlen_t                    len)
 {
+       struct xfs_mount                *mp = tp->t_mountp;
        int                             error;
 
        if (!xfs_sb_version_hasreflink(&mp->m_sb))
                return 0;
 
        /* Remove rmap entry */
-       error = xfs_rmap_free_extent(mp, dfops, XFS_FSB_TO_AGNO(mp, fsb),
+       error = xfs_rmap_free_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
                        XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
        if (error)
                return error;
 
-       return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_FREE_COW,
-                       fsb, len);
+       return __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
 }
 
 struct xfs_refcount_recovery {
@@ -1691,14 +1680,13 @@ xfs_refcount_recover_cow_leftovers(
                /* Free the orphan record */
                agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
                fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
-               error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
+               error = xfs_refcount_free_cow_extent(tp, fsb,
                                rr->rr_rrec.rc_blockcount);
                if (error)
                        goto out_trans;
 
                /* Free the block. */
-               xfs_bmap_add_free(mp, tp->t_dfops, fsb,
-                               rr->rr_rrec.rc_blockcount, NULL);
+               xfs_bmap_add_free(tp, fsb, rr->rr_rrec.rc_blockcount, NULL);
 
                error = xfs_trans_commit(tp);
                if (error)
index 3b72c6dbf6ad00862995c9085eb155b286e99fa0..1d9c518575e7922e19b8d4e8de63fb3a55995e64 100644 (file)
@@ -29,10 +29,10 @@ struct xfs_refcount_intent {
        xfs_extlen_t                            ri_blockcount;
 };
 
-extern int xfs_refcount_increase_extent(struct xfs_mount *mp,
-               struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec);
-extern int xfs_refcount_decrease_extent(struct xfs_mount *mp,
-               struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec);
+extern int xfs_refcount_increase_extent(struct xfs_trans *tp,
+               struct xfs_bmbt_irec *irec);
+extern int xfs_refcount_decrease_extent(struct xfs_trans *tp,
+               struct xfs_bmbt_irec *irec);
 
 extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
                struct xfs_btree_cur *rcur, int error);
@@ -45,12 +45,10 @@ extern int xfs_refcount_find_shared(struct xfs_btree_cur *cur,
                xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,
                xfs_extlen_t *flen, bool find_end_of_shared);
 
-extern int xfs_refcount_alloc_cow_extent(struct xfs_mount *mp,
-               struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
-               xfs_extlen_t len);
-extern int xfs_refcount_free_cow_extent(struct xfs_mount *mp,
-               struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
-               xfs_extlen_t len);
+extern int xfs_refcount_alloc_cow_extent(struct xfs_trans *tp,
+               xfs_fsblock_t fsb, xfs_extlen_t len);
+extern int xfs_refcount_free_cow_extent(struct xfs_trans *tp,
+               xfs_fsblock_t fsb, xfs_extlen_t len);
 extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
                xfs_agnumber_t agno);
 
index 50f6043e9236fcee014049663c6e7eced90c8199..76f039d1ae88a0cf8e7d9150495c8ec65a39e1a5 100644 (file)
@@ -2275,18 +2275,18 @@ xfs_rmap_update_is_needed(
  */
 static int
 __xfs_rmap_add(
-       struct xfs_mount                *mp,
-       struct xfs_defer_ops            *dfops,
+       struct xfs_trans                *tp,
        enum xfs_rmap_intent_type       type,
        uint64_t                        owner,
        int                             whichfork,
        struct xfs_bmbt_irec            *bmap)
 {
-       struct xfs_rmap_intent  *ri;
+       struct xfs_rmap_intent          *ri;
 
-       trace_xfs_rmap_defer(mp, XFS_FSB_TO_AGNO(mp, bmap->br_startblock),
+       trace_xfs_rmap_defer(tp->t_mountp,
+                       XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
                        type,
-                       XFS_FSB_TO_AGBNO(mp, bmap->br_startblock),
+                       XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
                        owner, whichfork,
                        bmap->br_startoff,
                        bmap->br_blockcount,
@@ -2299,23 +2299,22 @@ __xfs_rmap_add(
        ri->ri_whichfork = whichfork;
        ri->ri_bmap = *bmap;
 
-       xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list);
+       xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list);
        return 0;
 }
 
 /* Map an extent into a file. */
 int
 xfs_rmap_map_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
 {
-       if (!xfs_rmap_update_is_needed(mp, whichfork))
+       if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
                return 0;
 
-       return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ?
+       return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
                        XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino,
                        whichfork, PREV);
 }
@@ -2323,25 +2322,29 @@ xfs_rmap_map_extent(
 /* Unmap an extent out of a file. */
 int
 xfs_rmap_unmap_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
 {
-       if (!xfs_rmap_update_is_needed(mp, whichfork))
+       if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
                return 0;
 
-       return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ?
+       return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
                        XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino,
                        whichfork, PREV);
 }
 
-/* Convert a data fork extent from unwritten to real or vice versa. */
+/*
+ * Convert a data fork extent from unwritten to real or vice versa.
+ *
+ * Note that tp can be NULL here as no transaction is used for COW fork
+ * unwritten conversion.
+ */
 int
 xfs_rmap_convert_extent(
        struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        struct xfs_inode        *ip,
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
@@ -2349,7 +2352,7 @@ xfs_rmap_convert_extent(
        if (!xfs_rmap_update_is_needed(mp, whichfork))
                return 0;
 
-       return __xfs_rmap_add(mp, dfops, xfs_is_reflink_inode(ip) ?
+       return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
                        XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino,
                        whichfork, PREV);
 }
@@ -2357,8 +2360,7 @@ xfs_rmap_convert_extent(
 /* Schedule the creation of an rmap for non-file data. */
 int
 xfs_rmap_alloc_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        xfs_agnumber_t          agno,
        xfs_agblock_t           bno,
        xfs_extlen_t            len,
@@ -2366,23 +2368,21 @@ xfs_rmap_alloc_extent(
 {
        struct xfs_bmbt_irec    bmap;
 
-       if (!xfs_rmap_update_is_needed(mp, XFS_DATA_FORK))
+       if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
                return 0;
 
-       bmap.br_startblock = XFS_AGB_TO_FSB(mp, agno, bno);
+       bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
        bmap.br_blockcount = len;
        bmap.br_startoff = 0;
        bmap.br_state = XFS_EXT_NORM;
 
-       return __xfs_rmap_add(mp, dfops, XFS_RMAP_ALLOC, owner,
-                       XFS_DATA_FORK, &bmap);
+       return __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap);
 }
 
 /* Schedule the deletion of an rmap for non-file data. */
 int
 xfs_rmap_free_extent(
-       struct xfs_mount        *mp,
-       struct xfs_defer_ops    *dfops,
+       struct xfs_trans        *tp,
        xfs_agnumber_t          agno,
        xfs_agblock_t           bno,
        xfs_extlen_t            len,
@@ -2390,16 +2390,15 @@ xfs_rmap_free_extent(
 {
        struct xfs_bmbt_irec    bmap;
 
-       if (!xfs_rmap_update_is_needed(mp, XFS_DATA_FORK))
+       if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
                return 0;
 
-       bmap.br_startblock = XFS_AGB_TO_FSB(mp, agno, bno);
+       bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
        bmap.br_blockcount = len;
        bmap.br_startoff = 0;
        bmap.br_state = XFS_EXT_NORM;
 
-       return __xfs_rmap_add(mp, dfops, XFS_RMAP_FREE, owner,
-                       XFS_DATA_FORK, &bmap);
+       return __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap);
 }
 
 /* Compare rmap records.  Returns -1 if a < b, 1 if a > b, and 0 if equal. */
index 9f19454768b2370a169912ce191de67b7859c5d4..157dc722ad3513ac171d444c8154bbfa0254e616 100644 (file)
@@ -185,21 +185,17 @@ struct xfs_rmap_intent {
 };
 
 /* functions for updating the rmapbt based on bmbt map/unmap operations */
-int xfs_rmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
+int xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
+               int whichfork, struct xfs_bmbt_irec *imap);
+int xfs_rmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
+               int whichfork, struct xfs_bmbt_irec *imap);
+int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp,
                struct xfs_inode *ip, int whichfork,
                struct xfs_bmbt_irec *imap);
-int xfs_rmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               struct xfs_inode *ip, int whichfork,
-               struct xfs_bmbt_irec *imap);
-int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               struct xfs_inode *ip, int whichfork,
-               struct xfs_bmbt_irec *imap);
-int xfs_rmap_alloc_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
-               uint64_t owner);
-int xfs_rmap_free_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
-               xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len,
-               uint64_t owner);
+int xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
+               xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
+int xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
+               xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
 
 void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,
                struct xfs_btree_cur *rcur, int error);