Commit 0f37d178 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

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: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
[darrick: fix unused variable warnings with ftrace disabled]
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 1ae093cb
...@@ -2198,12 +2198,12 @@ xfs_agfl_reset( ...@@ -2198,12 +2198,12 @@ xfs_agfl_reset(
*/ */
STATIC void STATIC void
xfs_defer_agfl_block( xfs_defer_agfl_block(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_agnumber_t agno, xfs_agnumber_t agno,
xfs_fsblock_t agbno, xfs_fsblock_t agbno,
struct xfs_owner_info *oinfo) struct xfs_owner_info *oinfo)
{ {
struct xfs_mount *mp = tp->t_mountp;
struct xfs_extent_free_item *new; /* new element */ struct xfs_extent_free_item *new; /* new element */
ASSERT(xfs_bmap_free_item_zone != NULL); ASSERT(xfs_bmap_free_item_zone != NULL);
...@@ -2216,7 +2216,7 @@ xfs_defer_agfl_block( ...@@ -2216,7 +2216,7 @@ xfs_defer_agfl_block(
trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1); 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);
} }
/* /*
...@@ -2325,8 +2325,7 @@ xfs_alloc_fix_freelist( ...@@ -2325,8 +2325,7 @@ xfs_alloc_fix_freelist(
/* defer agfl frees if dfops is provided */ /* defer agfl frees if dfops is provided */
if (tp->t_dfops) { if (tp->t_dfops) {
xfs_defer_agfl_block(mp, tp->t_dfops, args->agno, xfs_defer_agfl_block(tp, args->agno, bno, &targs.oinfo);
bno, &targs.oinfo);
} else { } else {
error = xfs_free_agfl_block(tp, args->agno, bno, agbp, error = xfs_free_agfl_block(tp, args->agno, bno, agbp,
&targs.oinfo); &targs.oinfo);
......
...@@ -533,8 +533,7 @@ xfs_bmap_validate_ret( ...@@ -533,8 +533,7 @@ xfs_bmap_validate_ret(
*/ */
void void
__xfs_bmap_add_free( __xfs_bmap_add_free(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_fsblock_t bno, xfs_fsblock_t bno,
xfs_filblks_t len, xfs_filblks_t len,
struct xfs_owner_info *oinfo, struct xfs_owner_info *oinfo,
...@@ -542,8 +541,9 @@ __xfs_bmap_add_free( ...@@ -542,8 +541,9 @@ __xfs_bmap_add_free(
{ {
struct xfs_extent_free_item *new; /* new element */ struct xfs_extent_free_item *new; /* new element */
#ifdef DEBUG #ifdef DEBUG
xfs_agnumber_t agno; struct xfs_mount *mp = tp->t_mountp;
xfs_agblock_t agbno; xfs_agnumber_t agno;
xfs_agblock_t agbno;
ASSERT(bno != NULLFSBLOCK); ASSERT(bno != NULLFSBLOCK);
ASSERT(len > 0); ASSERT(len > 0);
...@@ -566,9 +566,10 @@ __xfs_bmap_add_free( ...@@ -566,9 +566,10 @@ __xfs_bmap_add_free(
else else
xfs_rmap_skip_owner_update(&new->xefi_oinfo); xfs_rmap_skip_owner_update(&new->xefi_oinfo);
new->xefi_skip_discard = skip_discard; new->xefi_skip_discard = skip_discard;
trace_xfs_bmap_free_defer(mp, XFS_FSB_TO_AGNO(mp, bno), 0, trace_xfs_bmap_free_defer(tp->t_mountp,
XFS_FSB_TO_AGBNO(mp, bno), len); XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list); XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len);
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list);
} }
/* /*
...@@ -624,7 +625,7 @@ xfs_bmap_btree_to_extents( ...@@ -624,7 +625,7 @@ xfs_bmap_btree_to_extents(
if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) if ((error = xfs_btree_check_block(cur, cblock, 0, cbp)))
return error; return error;
xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); 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--; ip->i_d.di_nblocks--;
xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L);
xfs_trans_binval(tp, cbp); xfs_trans_binval(tp, cbp);
...@@ -1961,8 +1962,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1961,8 +1962,7 @@ xfs_bmap_add_extent_delay_real(
/* add reverse mapping unless caller opted out */ /* add reverse mapping unless caller opted out */
if (!(bma->flags & XFS_BMAPI_NORMAP)) { if (!(bma->flags & XFS_BMAPI_NORMAP)) {
error = xfs_rmap_map_extent(mp, bma->tp->t_dfops, bma->ip, error = xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new);
whichfork, new);
if (error) if (error)
goto done; goto done;
} }
...@@ -2026,7 +2026,6 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2026,7 +2026,6 @@ xfs_bmap_add_extent_unwritten_real(
int state = xfs_bmap_fork_to_state(whichfork); int state = xfs_bmap_fork_to_state(whichfork);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_bmbt_irec old; struct xfs_bmbt_irec old;
struct xfs_defer_ops *dfops = tp ? tp->t_dfops : NULL;
*logflagsp = 0; *logflagsp = 0;
...@@ -2445,7 +2444,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2445,7 +2444,7 @@ xfs_bmap_add_extent_unwritten_real(
} }
/* update reverse mappings */ /* 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) if (error)
goto done; goto done;
...@@ -2806,8 +2805,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2806,8 +2805,7 @@ xfs_bmap_add_extent_hole_real(
/* add reverse mapping unless caller opted out */ /* add reverse mapping unless caller opted out */
if (!(flags & XFS_BMAPI_NORMAP)) { if (!(flags & XFS_BMAPI_NORMAP)) {
error = xfs_rmap_map_extent(mp, tp->t_dfops, ip, whichfork, error = xfs_rmap_map_extent(tp, ip, whichfork, new);
new);
if (error) if (error)
goto done; goto done;
} }
...@@ -4364,9 +4362,8 @@ xfs_bmapi_write( ...@@ -4364,9 +4362,8 @@ xfs_bmapi_write(
* the refcount btree for orphan recovery. * the refcount btree for orphan recovery.
*/ */
if (whichfork == XFS_COW_FORK) { if (whichfork == XFS_COW_FORK) {
error = xfs_refcount_alloc_cow_extent(mp, error = xfs_refcount_alloc_cow_extent(tp,
tp->t_dfops, bma.blkno, bma.blkno, bma.length);
bma.length);
if (error) if (error)
goto error0; goto error0;
} }
...@@ -4852,7 +4849,6 @@ xfs_bmap_del_extent_real( ...@@ -4852,7 +4849,6 @@ xfs_bmap_del_extent_real(
uint qfield; /* quota field to update */ uint qfield; /* quota field to update */
int state = xfs_bmap_fork_to_state(whichfork); int state = xfs_bmap_fork_to_state(whichfork);
struct xfs_bmbt_irec old; struct xfs_bmbt_irec old;
struct xfs_defer_ops *dfops = tp ? tp->t_dfops : NULL;
mp = ip->i_mount; mp = ip->i_mount;
XFS_STATS_INC(mp, xs_del_exlist); XFS_STATS_INC(mp, xs_del_exlist);
...@@ -5036,7 +5032,7 @@ xfs_bmap_del_extent_real( ...@@ -5036,7 +5032,7 @@ xfs_bmap_del_extent_real(
} }
/* remove reverse mapping */ /* remove reverse mapping */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, del); error = xfs_rmap_unmap_extent(tp, ip, whichfork, del);
if (error) if (error)
goto done; goto done;
...@@ -5045,11 +5041,11 @@ xfs_bmap_del_extent_real( ...@@ -5045,11 +5041,11 @@ xfs_bmap_del_extent_real(
*/ */
if (do_fx && !(bflags & XFS_BMAPI_REMAP)) { if (do_fx && !(bflags & XFS_BMAPI_REMAP)) {
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) { 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) if (error)
goto done; goto done;
} else { } else {
__xfs_bmap_add_free(mp, dfops, del->br_startblock, __xfs_bmap_add_free(tp, del->br_startblock,
del->br_blockcount, NULL, del->br_blockcount, NULL,
(bflags & XFS_BMAPI_NODISCARD) || (bflags & XFS_BMAPI_NODISCARD) ||
del->br_state == XFS_EXT_UNWRITTEN); del->br_state == XFS_EXT_UNWRITTEN);
...@@ -5489,6 +5485,7 @@ xfs_bmse_can_merge( ...@@ -5489,6 +5485,7 @@ xfs_bmse_can_merge(
*/ */
STATIC int STATIC int
xfs_bmse_merge( xfs_bmse_merge(
struct xfs_trans *tp,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
xfs_fileoff_t shift, /* shift fsb */ xfs_fileoff_t shift, /* shift fsb */
...@@ -5496,8 +5493,7 @@ xfs_bmse_merge( ...@@ -5496,8 +5493,7 @@ xfs_bmse_merge(
struct xfs_bmbt_irec *got, /* extent to shift */ struct xfs_bmbt_irec *got, /* extent to shift */
struct xfs_bmbt_irec *left, /* preceding extent */ struct xfs_bmbt_irec *left, /* preceding extent */
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
int *logflags, /* output */ int *logflags) /* output */
struct xfs_defer_ops *dfops)
{ {
struct xfs_bmbt_irec new; struct xfs_bmbt_irec new;
xfs_filblks_t blockcount; xfs_filblks_t blockcount;
...@@ -5553,23 +5549,23 @@ xfs_bmse_merge( ...@@ -5553,23 +5549,23 @@ xfs_bmse_merge(
&new); &new);
/* update reverse mapping. rmap functions merge the rmaps for us */ /* 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) if (error)
return error; return error;
memcpy(&new, got, sizeof(new)); memcpy(&new, got, sizeof(new));
new.br_startoff = left->br_startoff + left->br_blockcount; 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 static int
xfs_bmap_shift_update_extent( xfs_bmap_shift_update_extent(
struct xfs_trans *tp,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
struct xfs_iext_cursor *icur, struct xfs_iext_cursor *icur,
struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *got,
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
int *logflags, int *logflags,
struct xfs_defer_ops *dfops,
xfs_fileoff_t startoff) xfs_fileoff_t startoff)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
...@@ -5597,10 +5593,10 @@ xfs_bmap_shift_update_extent( ...@@ -5597,10 +5593,10 @@ xfs_bmap_shift_update_extent(
got); got);
/* update reverse mapping */ /* update reverse mapping */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, &prev); error = xfs_rmap_unmap_extent(tp, ip, whichfork, &prev);
if (error) if (error)
return error; return error;
return xfs_rmap_map_extent(mp, dfops, ip, whichfork, got); return xfs_rmap_map_extent(tp, ip, whichfork, got);
} }
int int
...@@ -5660,9 +5656,9 @@ xfs_bmap_collapse_extents( ...@@ -5660,9 +5656,9 @@ xfs_bmap_collapse_extents(
} }
if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) { if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) {
error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb, error = xfs_bmse_merge(tp, ip, whichfork,
&icur, &got, &prev, cur, &logflags, offset_shift_fsb, &icur, &got, &prev,
tp->t_dfops); cur, &logflags);
if (error) if (error)
goto del_cursor; goto del_cursor;
goto done; goto done;
...@@ -5674,8 +5670,8 @@ xfs_bmap_collapse_extents( ...@@ -5674,8 +5670,8 @@ xfs_bmap_collapse_extents(
} }
} }
error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur, error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
&logflags, tp->t_dfops, new_startoff); cur, &logflags, new_startoff);
if (error) if (error)
goto del_cursor; goto del_cursor;
...@@ -5801,8 +5797,8 @@ xfs_bmap_insert_extents( ...@@ -5801,8 +5797,8 @@ xfs_bmap_insert_extents(
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
} }
error = xfs_bmap_shift_update_extent(ip, whichfork, &icur, &got, cur, error = xfs_bmap_shift_update_extent(tp, ip, whichfork, &icur, &got,
&logflags, tp->t_dfops, new_startoff); cur, &logflags, new_startoff);
if (error) if (error)
goto del_cursor; goto del_cursor;
...@@ -5979,8 +5975,7 @@ xfs_bmap_is_update_needed( ...@@ -5979,8 +5975,7 @@ xfs_bmap_is_update_needed(
/* Record a bmap intent. */ /* Record a bmap intent. */
static int static int
__xfs_bmap_add( __xfs_bmap_add(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
enum xfs_bmap_intent_type type, enum xfs_bmap_intent_type type,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
...@@ -5988,10 +5983,10 @@ __xfs_bmap_add( ...@@ -5988,10 +5983,10 @@ __xfs_bmap_add(
{ {
struct xfs_bmap_intent *bi; struct xfs_bmap_intent *bi;
trace_xfs_bmap_defer(mp, trace_xfs_bmap_defer(tp->t_mountp,
XFS_FSB_TO_AGNO(mp, bmap->br_startblock), XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
type, type,
XFS_FSB_TO_AGBNO(mp, bmap->br_startblock), XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
ip->i_ino, whichfork, ip->i_ino, whichfork,
bmap->br_startoff, bmap->br_startoff,
bmap->br_blockcount, bmap->br_blockcount,
...@@ -6004,38 +5999,34 @@ __xfs_bmap_add( ...@@ -6004,38 +5999,34 @@ __xfs_bmap_add(
bi->bi_whichfork = whichfork; bi->bi_whichfork = whichfork;
bi->bi_bmap = *bmap; 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; return 0;
} }
/* Map an extent into a file. */ /* Map an extent into a file. */
int int
xfs_bmap_map_extent( xfs_bmap_map_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_bmbt_irec *PREV) struct xfs_bmbt_irec *PREV)
{ {
if (!xfs_bmap_is_update_needed(PREV)) if (!xfs_bmap_is_update_needed(PREV))
return 0; return 0;
return __xfs_bmap_add(mp, dfops, XFS_BMAP_MAP, ip, return __xfs_bmap_add(tp, XFS_BMAP_MAP, ip, XFS_DATA_FORK, PREV);
XFS_DATA_FORK, PREV);
} }
/* Unmap an extent out of a file. */ /* Unmap an extent out of a file. */
int int
xfs_bmap_unmap_extent( xfs_bmap_unmap_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_bmbt_irec *PREV) struct xfs_bmbt_irec *PREV)
{ {
if (!xfs_bmap_is_update_needed(PREV)) if (!xfs_bmap_is_update_needed(PREV))
return 0; return 0;
return __xfs_bmap_add(mp, dfops, XFS_BMAP_UNMAP, ip, return __xfs_bmap_add(tp, XFS_BMAP_UNMAP, ip, XFS_DATA_FORK, PREV);
XFS_DATA_FORK, PREV);
} }
/* /*
......
...@@ -184,9 +184,9 @@ void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, ...@@ -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 *); 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); 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_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
void __xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, void __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
xfs_fsblock_t bno, xfs_filblks_t len, xfs_filblks_t len, struct xfs_owner_info *oinfo,
struct xfs_owner_info *oinfo, bool skip_discard); bool skip_discard);
void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); 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,13 +230,12 @@ int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
static inline void static inline void
xfs_bmap_add_free( xfs_bmap_add_free(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_fsblock_t bno, xfs_fsblock_t bno,
xfs_filblks_t len, xfs_filblks_t len,
struct xfs_owner_info *oinfo) 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 { enum xfs_bmap_intent_type {
...@@ -256,10 +255,10 @@ int xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip, ...@@ -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, enum xfs_bmap_intent_type type, int whichfork,
xfs_fileoff_t startoff, xfs_fsblock_t startblock, xfs_fileoff_t startoff, xfs_fsblock_t startblock,
xfs_filblks_t *blockcount, xfs_exntst_t state); xfs_filblks_t *blockcount, xfs_exntst_t state);
int xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, int xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
struct xfs_inode *ip, struct xfs_bmbt_irec *imap); struct xfs_bmbt_irec *imap);
int xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, int xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
struct xfs_inode *ip, struct xfs_bmbt_irec *imap); struct xfs_bmbt_irec *imap);
static inline int xfs_bmap_fork_to_state(int whichfork) static inline int xfs_bmap_fork_to_state(int whichfork)
{ {
......
...@@ -289,7 +289,7 @@ xfs_bmbt_free_block( ...@@ -289,7 +289,7 @@ xfs_bmbt_free_block(
struct xfs_owner_info oinfo; struct xfs_owner_info oinfo;
xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_private.b.whichfork); 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--; ip->i_d.di_nblocks--;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
......
...@@ -487,12 +487,15 @@ xfs_defer_cancel( ...@@ -487,12 +487,15 @@ xfs_defer_cancel(
/* Add an item for later deferred processing. */ /* Add an item for later deferred processing. */
void void
xfs_defer_add( xfs_defer_add(
struct xfs_defer_ops *dop, struct xfs_trans *tp,
enum xfs_defer_ops_type type, enum xfs_defer_ops_type type,
struct list_head *li) struct list_head *li)
{ {
struct xfs_defer_ops *dop = tp->t_dfops;
struct xfs_defer_pending *dfp = NULL; 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. * 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, * If the last pending item has the same type, reuse it. Else,
......
...@@ -35,7 +35,7 @@ enum xfs_defer_ops_type { ...@@ -35,7 +35,7 @@ enum xfs_defer_ops_type {
XFS_DEFER_OPS_TYPE_MAX, 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); struct list_head *h);
int xfs_defer_finish_noroll(struct xfs_trans **tp); int xfs_defer_finish_noroll(struct xfs_trans **tp);
int xfs_defer_finish(struct xfs_trans **tp); int xfs_defer_finish(struct xfs_trans **tp);
......
...@@ -1838,23 +1838,24 @@ xfs_dialloc( ...@@ -1838,23 +1838,24 @@ xfs_dialloc(
*/ */
STATIC void STATIC void
xfs_difree_inode_chunk( xfs_difree_inode_chunk(
struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, xfs_agnumber_t agno,
struct xfs_inobt_rec_incore *rec, struct xfs_inobt_rec_incore *rec)
struct xfs_defer_ops *dfops)
{ {
xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp, rec->ir_startino); struct xfs_mount *mp = tp->t_mountp;
int startidx, endidx; xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp,
int nextbit; rec->ir_startino);
xfs_agblock_t agbno; int startidx, endidx;
int contigblk; int nextbit;
struct xfs_owner_info oinfo; xfs_agblock_t agbno;
int contigblk;
struct xfs_owner_info oinfo;
DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS); DECLARE_BITMAP(holemask, XFS_INOBT_HOLEMASK_BITS);
xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES); xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES);
if (!xfs_inobt_issparse(rec->ir_holemask)) { if (!xfs_inobt_issparse(rec->ir_holemask)) {
/* not sparse, calculate extent info directly */ /* 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); mp->m_ialloc_blks, &oinfo);
return; return;
} }
...@@ -1898,7 +1899,7 @@ xfs_difree_inode_chunk( ...@@ -1898,7 +1899,7 @@ xfs_difree_inode_chunk(
ASSERT(agbno % mp->m_sb.sb_spino_align == 0); ASSERT(agbno % mp->m_sb.sb_spino_align == 0);
ASSERT(contigblk % 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); contigblk, &oinfo);
/* reset range to current bit and carry on... */ /* reset range to current bit and carry on... */
...@@ -2002,7 +2003,7 @@ xfs_difree_inobt( ...@@ -2002,7 +2003,7 @@ xfs_difree_inobt(
goto error0; goto error0;
} }
xfs_difree_inode_chunk(mp, agno, &rec, tp->t_dfops); xfs_difree_inode_chunk(tp, agno, &rec);
} else { } else {
xic->deleted = false; xic->deleted = false;
......
...@@ -34,11 +34,9 @@ enum xfs_refc_adjust_op { ...@@ -34,11 +34,9 @@ enum xfs_refc_adjust_op {
}; };
STATIC int __xfs_refcount_cow_alloc(struct xfs_btree_cur *rcur, STATIC int __xfs_refcount_cow_alloc(struct xfs_btree_cur *rcur,
xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t agbno, xfs_extlen_t aglen);
struct xfs_defer_ops *dfops);
STATIC int __xfs_refcount_cow_free(struct xfs_btree_cur *rcur, STATIC int __xfs_refcount_cow_free(struct xfs_btree_cur *rcur,
xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t agbno, xfs_extlen_t aglen);
struct xfs_defer_ops *dfops);
/* /*
* Look up the first record less than or equal to [bno, len] in the btree * Look up the first record less than or equal to [bno, len] in the btree
...@@ -870,7 +868,6 @@ xfs_refcount_adjust_extents( ...@@ -870,7 +868,6 @@ xfs_refcount_adjust_extents(
xfs_agblock_t *agbno, xfs_agblock_t *agbno,
xfs_extlen_t *aglen, xfs_extlen_t *aglen,
enum xfs_refc_adjust_op adj, enum xfs_refc_adjust_op adj,
struct xfs_defer_ops *dfops,
struct xfs_owner_info *oinfo) struct xfs_owner_info *oinfo)
{ {
struct xfs_refcount_irec ext, tmp; struct xfs_refcount_irec ext, tmp;
...@@ -925,8 +922,8 @@ xfs_refcount_adjust_extents( ...@@ -925,8 +922,8 @@ xfs_refcount_adjust_extents(
fsbno = XFS_AGB_TO_FSB(cur->bc_mp, fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
cur->bc_private.a.agno, cur->bc_private.a.agno,
tmp.rc_startblock); tmp.rc_startblock);
xfs_bmap_add_free(cur->bc_mp, dfops, fsbno, xfs_bmap_add_free(cur->bc_tp, fsbno,
tmp.rc_blockcount, oinfo); tmp.rc_blockcount, oinfo);
} }
(*agbno) += tmp.rc_blockcount; (*agbno) += tmp.rc_blockcount;
...@@ -968,8 +965,8 @@ xfs_refcount_adjust_extents( ...@@ -968,8 +965,8 @@ xfs_refcount_adjust_extents(
fsbno = XFS_AGB_TO_FSB(cur->bc_mp, fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
cur->bc_private.a.agno, cur->bc_private.a.agno,
ext.rc_startblock); ext.rc_startblock);
xfs_bmap_add_free(cur->bc_mp, dfops, fsbno, xfs_bmap_add_free(cur->bc_tp, fsbno, ext.rc_blockcount,
ext.rc_blockcount, oinfo); oinfo);
} }
skip: skip:
...@@ -998,7 +995,6 @@ xfs_refcount_adjust( ...@@ -998,7 +995,6 @@ xfs_refcount_adjust(
xfs_agblock_t *new_agbno, xfs_agblock_t *new_agbno,
xfs_extlen_t *new_aglen, xfs_extlen_t *new_aglen,
enum xfs_refc_adjust_op adj, enum xfs_refc_adjust_op adj,
struct xfs_defer_ops *dfops,
struct xfs_owner_info *oinfo) struct xfs_owner_info *oinfo)
{ {
bool shape_changed; bool shape_changed;
...@@ -1043,7 +1039,7 @@ xfs_refcount_adjust( ...@@ -1043,7 +1039,7 @@ xfs_refcount_adjust(
/* Now that we've taken care of the ends, adjust the middle extents */ /* Now that we've taken care of the ends, adjust the middle extents */
error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen,
adj, dfops, oinfo); adj, oinfo);
if (error) if (error)
goto out_error; goto out_error;
...@@ -1090,7 +1086,6 @@ xfs_refcount_finish_one( ...@@ -1090,7 +1086,6 @@ xfs_refcount_finish_one(
struct xfs_btree_cur **pcur) struct xfs_btree_cur **pcur)
{ {
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_defer_ops *dfops = tp->t_dfops;
struct xfs_btree_cur *rcur; struct xfs_btree_cur *rcur;
struct xfs_buf *agbp = NULL; struct xfs_buf *agbp = NULL;
int error = 0; int error = 0;
...@@ -1145,23 +1140,23 @@ xfs_refcount_finish_one( ...@@ -1145,23 +1140,23 @@ xfs_refcount_finish_one(
switch (type) { switch (type) {
case XFS_REFCOUNT_INCREASE: case XFS_REFCOUNT_INCREASE:
error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, 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); *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
break; break;
case XFS_REFCOUNT_DECREASE: case XFS_REFCOUNT_DECREASE:
error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, 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); *new_fsb = XFS_AGB_TO_FSB(mp, agno, new_agbno);
break; break;
case XFS_REFCOUNT_ALLOC_COW: case XFS_REFCOUNT_ALLOC_COW:
*new_fsb = startblock + blockcount; *new_fsb = startblock + blockcount;
*new_len = 0; *new_len = 0;
error = __xfs_refcount_cow_alloc(rcur, bno, blockcount, dfops); error = __xfs_refcount_cow_alloc(rcur, bno, blockcount);
break; break;
case XFS_REFCOUNT_FREE_COW: case XFS_REFCOUNT_FREE_COW:
*new_fsb = startblock + blockcount; *new_fsb = startblock + blockcount;
*new_len = 0; *new_len = 0;
error = __xfs_refcount_cow_free(rcur, bno, blockcount, dfops); error = __xfs_refcount_cow_free(rcur, bno, blockcount);
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -1183,16 +1178,16 @@ xfs_refcount_finish_one( ...@@ -1183,16 +1178,16 @@ xfs_refcount_finish_one(
*/ */
static int static int
__xfs_refcount_add( __xfs_refcount_add(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
enum xfs_refcount_intent_type type, enum xfs_refcount_intent_type type,
xfs_fsblock_t startblock, xfs_fsblock_t startblock,
xfs_extlen_t blockcount) xfs_extlen_t blockcount)
{ {
struct xfs_refcount_intent *ri; struct xfs_refcount_intent *ri;
trace_xfs_refcount_defer(mp, XFS_FSB_TO_AGNO(mp, startblock), trace_xfs_refcount_defer(tp->t_mountp,
type, XFS_FSB_TO_AGBNO(mp, startblock), XFS_FSB_TO_AGNO(tp->t_mountp, startblock),
type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
blockcount); blockcount);
ri = kmem_alloc(sizeof(struct xfs_refcount_intent), ri = kmem_alloc(sizeof(struct xfs_refcount_intent),
...@@ -1202,7 +1197,7 @@ __xfs_refcount_add( ...@@ -1202,7 +1197,7 @@ __xfs_refcount_add(
ri->ri_startblock = startblock; ri->ri_startblock = startblock;
ri->ri_blockcount = blockcount; 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; return 0;
} }
...@@ -1211,14 +1206,13 @@ __xfs_refcount_add( ...@@ -1211,14 +1206,13 @@ __xfs_refcount_add(
*/ */
int int
xfs_refcount_increase_extent( xfs_refcount_increase_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_bmbt_irec *PREV) 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 0;
return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_INCREASE, return __xfs_refcount_add(tp, XFS_REFCOUNT_INCREASE,
PREV->br_startblock, PREV->br_blockcount); PREV->br_startblock, PREV->br_blockcount);
} }
...@@ -1227,14 +1221,13 @@ xfs_refcount_increase_extent( ...@@ -1227,14 +1221,13 @@ xfs_refcount_increase_extent(
*/ */
int int
xfs_refcount_decrease_extent( xfs_refcount_decrease_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_bmbt_irec *PREV) 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 0;
return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_DECREASE, return __xfs_refcount_add(tp, XFS_REFCOUNT_DECREASE,
PREV->br_startblock, PREV->br_blockcount); PREV->br_startblock, PREV->br_blockcount);
} }
...@@ -1522,8 +1515,7 @@ STATIC int ...@@ -1522,8 +1515,7 @@ STATIC int
__xfs_refcount_cow_alloc( __xfs_refcount_cow_alloc(
struct xfs_btree_cur *rcur, struct xfs_btree_cur *rcur,
xfs_agblock_t agbno, xfs_agblock_t agbno,
xfs_extlen_t aglen, xfs_extlen_t aglen)
struct xfs_defer_ops *dfops)
{ {
trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_private.a.agno, trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_private.a.agno,
agbno, aglen); agbno, aglen);
...@@ -1540,8 +1532,7 @@ STATIC int ...@@ -1540,8 +1532,7 @@ STATIC int
__xfs_refcount_cow_free( __xfs_refcount_cow_free(
struct xfs_btree_cur *rcur, struct xfs_btree_cur *rcur,
xfs_agblock_t agbno, xfs_agblock_t agbno,
xfs_extlen_t aglen, xfs_extlen_t aglen)
struct xfs_defer_ops *dfops)
{ {
trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_private.a.agno, trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_private.a.agno,
agbno, aglen); agbno, aglen);
...@@ -1554,47 +1545,45 @@ __xfs_refcount_cow_free( ...@@ -1554,47 +1545,45 @@ __xfs_refcount_cow_free(
/* Record a CoW staging extent in the refcount btree. */ /* Record a CoW staging extent in the refcount btree. */
int int
xfs_refcount_alloc_cow_extent( xfs_refcount_alloc_cow_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_fsblock_t fsb, xfs_fsblock_t fsb,
xfs_extlen_t len) xfs_extlen_t len)
{ {
struct xfs_mount *mp = tp->t_mountp;
int error; int error;
if (!xfs_sb_version_hasreflink(&mp->m_sb)) if (!xfs_sb_version_hasreflink(&mp->m_sb))
return 0; return 0;
error = __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_ALLOC_COW, error = __xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len);
fsb, len);
if (error) if (error)
return error; return error;
/* Add rmap entry */ /* 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); XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
} }
/* Forget a CoW staging event in the refcount btree. */ /* Forget a CoW staging event in the refcount btree. */
int int
xfs_refcount_free_cow_extent( xfs_refcount_free_cow_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_fsblock_t fsb, xfs_fsblock_t fsb,
xfs_extlen_t len) xfs_extlen_t len)
{ {
struct xfs_mount *mp = tp->t_mountp;
int error; int error;
if (!xfs_sb_version_hasreflink(&mp->m_sb)) if (!xfs_sb_version_hasreflink(&mp->m_sb))
return 0; return 0;
/* Remove rmap entry */ /* 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); XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
if (error) if (error)
return error; return error;
return __xfs_refcount_add(mp, dfops, XFS_REFCOUNT_FREE_COW, return __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
fsb, len);
} }
struct xfs_refcount_recovery { struct xfs_refcount_recovery {
...@@ -1692,14 +1681,13 @@ xfs_refcount_recover_cow_leftovers( ...@@ -1692,14 +1681,13 @@ xfs_refcount_recover_cow_leftovers(
/* Free the orphan record */ /* Free the orphan record */
agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START; agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
fsb = XFS_AGB_TO_FSB(mp, agno, agbno); 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); rr->rr_rrec.rc_blockcount);
if (error) if (error)
goto out_trans; goto out_trans;
/* Free the block. */ /* Free the block. */
xfs_bmap_add_free(mp, tp->t_dfops, fsb, xfs_bmap_add_free(tp, fsb, rr->rr_rrec.rc_blockcount, NULL);
rr->rr_rrec.rc_blockcount, NULL);
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
......
...@@ -29,10 +29,10 @@ struct xfs_refcount_intent { ...@@ -29,10 +29,10 @@ struct xfs_refcount_intent {
xfs_extlen_t ri_blockcount; xfs_extlen_t ri_blockcount;
}; };
extern int xfs_refcount_increase_extent(struct xfs_mount *mp, extern int xfs_refcount_increase_extent(struct xfs_trans *tp,
struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec); struct xfs_bmbt_irec *irec);
extern int xfs_refcount_decrease_extent(struct xfs_mount *mp, extern int xfs_refcount_decrease_extent(struct xfs_trans *tp,
struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec); struct xfs_bmbt_irec *irec);
extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp, extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
struct xfs_btree_cur *rcur, int error); struct xfs_btree_cur *rcur, int error);
...@@ -45,12 +45,10 @@ extern int xfs_refcount_find_shared(struct xfs_btree_cur *cur, ...@@ -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_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,
xfs_extlen_t *flen, bool find_end_of_shared); xfs_extlen_t *flen, bool find_end_of_shared);
extern int xfs_refcount_alloc_cow_extent(struct xfs_mount *mp, extern int xfs_refcount_alloc_cow_extent(struct xfs_trans *tp,
struct xfs_defer_ops *dfops, xfs_fsblock_t fsb, xfs_fsblock_t fsb, xfs_extlen_t len);
xfs_extlen_t len); extern int xfs_refcount_free_cow_extent(struct xfs_trans *tp,
extern int xfs_refcount_free_cow_extent(struct xfs_mount *mp, xfs_fsblock_t fsb, xfs_extlen_t len);
struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
xfs_extlen_t len);
extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp, extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
xfs_agnumber_t agno); xfs_agnumber_t agno);
......
...@@ -2277,18 +2277,18 @@ xfs_rmap_update_is_needed( ...@@ -2277,18 +2277,18 @@ xfs_rmap_update_is_needed(
*/ */
static int static int
__xfs_rmap_add( __xfs_rmap_add(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
enum xfs_rmap_intent_type type, enum xfs_rmap_intent_type type,
uint64_t owner, uint64_t owner,
int whichfork, int whichfork,
struct xfs_bmbt_irec *bmap) 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, type,
XFS_FSB_TO_AGBNO(mp, bmap->br_startblock), XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
owner, whichfork, owner, whichfork,
bmap->br_startoff, bmap->br_startoff,
bmap->br_blockcount, bmap->br_blockcount,
...@@ -2301,23 +2301,22 @@ __xfs_rmap_add( ...@@ -2301,23 +2301,22 @@ __xfs_rmap_add(
ri->ri_whichfork = whichfork; ri->ri_whichfork = whichfork;
ri->ri_bmap = *bmap; 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; return 0;
} }
/* Map an extent into a file. */ /* Map an extent into a file. */
int int
xfs_rmap_map_extent( xfs_rmap_map_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
struct xfs_bmbt_irec *PREV) 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 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, XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino,
whichfork, PREV); whichfork, PREV);
} }
...@@ -2325,25 +2324,29 @@ xfs_rmap_map_extent( ...@@ -2325,25 +2324,29 @@ xfs_rmap_map_extent(
/* Unmap an extent out of a file. */ /* Unmap an extent out of a file. */
int int
xfs_rmap_unmap_extent( xfs_rmap_unmap_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
struct xfs_bmbt_irec *PREV) 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 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, XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino,
whichfork, PREV); 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 int
xfs_rmap_convert_extent( xfs_rmap_convert_extent(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_defer_ops *dfops, struct xfs_trans *tp,
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
struct xfs_bmbt_irec *PREV) struct xfs_bmbt_irec *PREV)
...@@ -2351,7 +2354,7 @@ xfs_rmap_convert_extent( ...@@ -2351,7 +2354,7 @@ xfs_rmap_convert_extent(
if (!xfs_rmap_update_is_needed(mp, whichfork)) if (!xfs_rmap_update_is_needed(mp, whichfork))
return 0; 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, XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino,
whichfork, PREV); whichfork, PREV);
} }
...@@ -2359,8 +2362,7 @@ xfs_rmap_convert_extent( ...@@ -2359,8 +2362,7 @@ xfs_rmap_convert_extent(
/* Schedule the creation of an rmap for non-file data. */ /* Schedule the creation of an rmap for non-file data. */
int int
xfs_rmap_alloc_extent( xfs_rmap_alloc_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_agnumber_t agno, xfs_agnumber_t agno,
xfs_agblock_t bno, xfs_agblock_t bno,
xfs_extlen_t len, xfs_extlen_t len,
...@@ -2368,23 +2370,21 @@ xfs_rmap_alloc_extent( ...@@ -2368,23 +2370,21 @@ xfs_rmap_alloc_extent(
{ {
struct xfs_bmbt_irec bmap; 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; 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_blockcount = len;
bmap.br_startoff = 0; bmap.br_startoff = 0;
bmap.br_state = XFS_EXT_NORM; bmap.br_state = XFS_EXT_NORM;
return __xfs_rmap_add(mp, dfops, XFS_RMAP_ALLOC, owner, return __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap);
XFS_DATA_FORK, &bmap);
} }
/* Schedule the deletion of an rmap for non-file data. */ /* Schedule the deletion of an rmap for non-file data. */
int int
xfs_rmap_free_extent( xfs_rmap_free_extent(
struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_defer_ops *dfops,
xfs_agnumber_t agno, xfs_agnumber_t agno,
xfs_agblock_t bno, xfs_agblock_t bno,
xfs_extlen_t len, xfs_extlen_t len,
...@@ -2392,16 +2392,15 @@ xfs_rmap_free_extent( ...@@ -2392,16 +2392,15 @@ xfs_rmap_free_extent(
{ {
struct xfs_bmbt_irec bmap; 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; 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_blockcount = len;
bmap.br_startoff = 0; bmap.br_startoff = 0;
bmap.br_state = XFS_EXT_NORM; bmap.br_state = XFS_EXT_NORM;
return __xfs_rmap_add(mp, dfops, XFS_RMAP_FREE, owner, return __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap);
XFS_DATA_FORK, &bmap);
} }
/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */ /* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */
......
...@@ -185,21 +185,17 @@ struct xfs_rmap_intent { ...@@ -185,21 +185,17 @@ struct xfs_rmap_intent {
}; };
/* functions for updating the rmapbt based on bmbt map/unmap operations */ /* 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_inode *ip, int whichfork,
struct xfs_bmbt_irec *imap); struct xfs_bmbt_irec *imap);
int xfs_rmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, int xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
struct xfs_inode *ip, int whichfork, xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
struct xfs_bmbt_irec *imap); int xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
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);
void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp, void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,
struct xfs_btree_cur *rcur, int error); struct xfs_btree_cur *rcur, int error);
......
...@@ -486,8 +486,7 @@ xfs_bui_recover( ...@@ -486,8 +486,7 @@ xfs_bui_recover(
irec.br_blockcount = count; irec.br_blockcount = count;
irec.br_startoff = bmap->me_startoff; irec.br_startoff = bmap->me_startoff;
irec.br_state = state; irec.br_state = state;
error = xfs_bmap_unmap_extent(tp->t_mountp, tp->t_dfops, ip, error = xfs_bmap_unmap_extent(tp, ip, &irec);
&irec);
if (error) if (error)
goto err_inode; goto err_inode;
} }
......
...@@ -1534,7 +1534,6 @@ xfs_swap_extent_rmap( ...@@ -1534,7 +1534,6 @@ xfs_swap_extent_rmap(
struct xfs_inode *tip) struct xfs_inode *tip)
{ {
struct xfs_trans *tp = *tpp; struct xfs_trans *tp = *tpp;
struct xfs_mount *mp = tp->t_mountp;
struct xfs_bmbt_irec irec; struct xfs_bmbt_irec irec;
struct xfs_bmbt_irec uirec; struct xfs_bmbt_irec uirec;
struct xfs_bmbt_irec tirec; struct xfs_bmbt_irec tirec;
...@@ -1598,26 +1597,22 @@ xfs_swap_extent_rmap( ...@@ -1598,26 +1597,22 @@ xfs_swap_extent_rmap(
trace_xfs_swap_extent_rmap_remap_piece(tip, &uirec); trace_xfs_swap_extent_rmap_remap_piece(tip, &uirec);
/* Remove the mapping from the donor file. */ /* Remove the mapping from the donor file. */
error = xfs_bmap_unmap_extent(mp, tp->t_dfops, tip, error = xfs_bmap_unmap_extent(tp, tip, &uirec);
&uirec);
if (error) if (error)
goto out_defer; goto out_defer;
/* Remove the mapping from the source file. */ /* Remove the mapping from the source file. */
error = xfs_bmap_unmap_extent(mp, tp->t_dfops, ip, error = xfs_bmap_unmap_extent(tp, ip, &irec);
&irec);
if (error) if (error)
goto out_defer; goto out_defer;
/* Map the donor file's blocks into the source file. */ /* Map the donor file's blocks into the source file. */
error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, error = xfs_bmap_map_extent(tp, ip, &uirec);
&uirec);
if (error) if (error)
goto out_defer; goto out_defer;
/* Map the source file's blocks into the donor file. */ /* Map the source file's blocks into the donor file. */
error = xfs_bmap_map_extent(mp, tp->t_dfops, tip, error = xfs_bmap_map_extent(tp, tip, &irec);
&irec);
if (error) if (error)
goto out_defer; goto out_defer;
......
...@@ -490,24 +490,18 @@ xfs_cui_recover( ...@@ -490,24 +490,18 @@ xfs_cui_recover(
irec.br_blockcount = new_len; irec.br_blockcount = new_len;
switch (type) { switch (type) {
case XFS_REFCOUNT_INCREASE: case XFS_REFCOUNT_INCREASE:
error = xfs_refcount_increase_extent( error = xfs_refcount_increase_extent(tp, &irec);
tp->t_mountp, tp->t_dfops,
&irec);
break; break;
case XFS_REFCOUNT_DECREASE: case XFS_REFCOUNT_DECREASE:
error = xfs_refcount_decrease_extent( error = xfs_refcount_decrease_extent(tp, &irec);
tp->t_mountp, tp->t_dfops,
&irec);
break; break;
case XFS_REFCOUNT_ALLOC_COW: case XFS_REFCOUNT_ALLOC_COW:
error = xfs_refcount_alloc_cow_extent( error = xfs_refcount_alloc_cow_extent(tp,
tp->t_mountp, tp->t_dfops,
irec.br_startblock, irec.br_startblock,
irec.br_blockcount); irec.br_blockcount);
break; break;
case XFS_REFCOUNT_FREE_COW: case XFS_REFCOUNT_FREE_COW:
error = xfs_refcount_free_cow_extent( error = xfs_refcount_free_cow_extent(tp,
tp->t_mountp, tp->t_dfops,
irec.br_startblock, irec.br_startblock,
irec.br_blockcount); irec.br_blockcount);
break; break;
......
...@@ -506,15 +506,13 @@ xfs_reflink_cancel_cow_blocks( ...@@ -506,15 +506,13 @@ xfs_reflink_cancel_cow_blocks(
ASSERT((*tpp)->t_firstblock == NULLFSBLOCK); ASSERT((*tpp)->t_firstblock == NULLFSBLOCK);
/* Free the CoW orphan record. */ /* Free the CoW orphan record. */
error = xfs_refcount_free_cow_extent(ip->i_mount, error = xfs_refcount_free_cow_extent(*tpp,
(*tpp)->t_dfops, del.br_startblock, del.br_startblock, del.br_blockcount);
del.br_blockcount);
if (error) if (error)
break; break;
xfs_bmap_add_free(ip->i_mount, (*tpp)->t_dfops, xfs_bmap_add_free(*tpp, del.br_startblock,
del.br_startblock, del.br_blockcount, del.br_blockcount, NULL);
NULL);
/* Roll the transaction */ /* Roll the transaction */
error = xfs_defer_finish(tpp); error = xfs_defer_finish(tpp);
...@@ -694,14 +692,13 @@ xfs_reflink_end_cow( ...@@ -694,14 +692,13 @@ xfs_reflink_end_cow(
trace_xfs_reflink_cow_remap(ip, &del); trace_xfs_reflink_cow_remap(ip, &del);
/* Free the CoW orphan record. */ /* Free the CoW orphan record. */
error = xfs_refcount_free_cow_extent(tp->t_mountp, tp->t_dfops, error = xfs_refcount_free_cow_extent(tp, del.br_startblock,
del.br_startblock, del.br_blockcount); del.br_blockcount);
if (error) if (error)
goto out_cancel; goto out_cancel;
/* Map the new blocks into the data fork. */ /* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(tp->t_mountp, tp->t_dfops, ip, error = xfs_bmap_map_extent(tp, ip, &del);
&del);
if (error) if (error)
goto out_cancel; goto out_cancel;
...@@ -1046,12 +1043,12 @@ xfs_reflink_remap_extent( ...@@ -1046,12 +1043,12 @@ xfs_reflink_remap_extent(
uirec.br_blockcount, uirec.br_startblock); uirec.br_blockcount, uirec.br_startblock);
/* Update the refcount tree */ /* Update the refcount tree */
error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec); error = xfs_refcount_increase_extent(tp, &uirec);
if (error) if (error)
goto out_cancel; goto out_cancel;
/* Map the new blocks into the data fork. */ /* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec); error = xfs_bmap_map_extent(tp, ip, &uirec);
if (error) if (error)
goto out_cancel; goto out_cancel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment