Commit 72ba4555 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: pass xfs_extent_free_item directly through the log intent code

Pass the incore xfs_extent_free_item through the EFI logging code
instead of repeatedly boxing and unboxing parameters.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent f3ebac4c
...@@ -345,23 +345,30 @@ static int ...@@ -345,23 +345,30 @@ static int
xfs_trans_free_extent( xfs_trans_free_extent(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_efd_log_item *efdp, struct xfs_efd_log_item *efdp,
xfs_fsblock_t start_block, struct xfs_extent_free_item *free)
xfs_extlen_t ext_len,
const struct xfs_owner_info *oinfo,
bool skip_discard)
{ {
struct xfs_owner_info oinfo = { };
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_extent *extp; struct xfs_extent *extp;
uint next_extent; uint next_extent;
xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, start_block); xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp,
free->xefi_startblock);
xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp, xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp,
start_block); free->xefi_startblock);
int error; int error;
trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len); oinfo.oi_owner = free->xefi_owner;
if (free->xefi_flags & XFS_EFI_ATTR_FORK)
oinfo.oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
if (free->xefi_flags & XFS_EFI_BMBT_BLOCK)
oinfo.oi_flags |= XFS_OWNER_INFO_BMBT_BLOCK;
trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno,
free->xefi_blockcount);
error = __xfs_free_extent(tp, start_block, ext_len, error = __xfs_free_extent(tp, free->xefi_startblock,
oinfo, XFS_AG_RESV_NONE, skip_discard); free->xefi_blockcount, &oinfo, XFS_AG_RESV_NONE,
free->xefi_flags & XFS_EFI_SKIP_DISCARD);
/* /*
* Mark the transaction dirty, even on error. This ensures the * Mark the transaction dirty, even on error. This ensures the
* transaction is aborted, which: * transaction is aborted, which:
...@@ -375,8 +382,8 @@ xfs_trans_free_extent( ...@@ -375,8 +382,8 @@ xfs_trans_free_extent(
next_extent = efdp->efd_next_extent; next_extent = efdp->efd_next_extent;
ASSERT(next_extent < efdp->efd_format.efd_nextents); ASSERT(next_extent < efdp->efd_format.efd_nextents);
extp = &(efdp->efd_format.efd_extents[next_extent]); extp = &(efdp->efd_format.efd_extents[next_extent]);
extp->ext_start = start_block; extp->ext_start = free->xefi_startblock;
extp->ext_len = ext_len; extp->ext_len = free->xefi_blockcount;
efdp->efd_next_extent++; efdp->efd_next_extent++;
return error; return error;
...@@ -463,20 +470,12 @@ xfs_extent_free_finish_item( ...@@ -463,20 +470,12 @@ xfs_extent_free_finish_item(
struct list_head *item, struct list_head *item,
struct xfs_btree_cur **state) struct xfs_btree_cur **state)
{ {
struct xfs_owner_info oinfo = { };
struct xfs_extent_free_item *free; struct xfs_extent_free_item *free;
int error; int error;
free = container_of(item, struct xfs_extent_free_item, xefi_list); free = container_of(item, struct xfs_extent_free_item, xefi_list);
oinfo.oi_owner = free->xefi_owner;
if (free->xefi_flags & XFS_EFI_ATTR_FORK) error = xfs_trans_free_extent(tp, EFD_ITEM(done), free);
oinfo.oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
if (free->xefi_flags & XFS_EFI_BMBT_BLOCK)
oinfo.oi_flags |= XFS_OWNER_INFO_BMBT_BLOCK;
error = xfs_trans_free_extent(tp, EFD_ITEM(done),
free->xefi_startblock,
free->xefi_blockcount,
&oinfo, free->xefi_flags & XFS_EFI_SKIP_DISCARD);
kmem_cache_free(xfs_extfree_item_cache, free); kmem_cache_free(xfs_extfree_item_cache, free);
return error; return error;
} }
...@@ -599,7 +598,6 @@ xfs_efi_item_recover( ...@@ -599,7 +598,6 @@ xfs_efi_item_recover(
struct xfs_mount *mp = lip->li_log->l_mp; struct xfs_mount *mp = lip->li_log->l_mp;
struct xfs_efd_log_item *efdp; struct xfs_efd_log_item *efdp;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_extent *extp;
int i; int i;
int error = 0; int error = 0;
...@@ -624,10 +622,17 @@ xfs_efi_item_recover( ...@@ -624,10 +622,17 @@ xfs_efi_item_recover(
efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents); efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
for (i = 0; i < efip->efi_format.efi_nextents; i++) { for (i = 0; i < efip->efi_format.efi_nextents; i++) {
struct xfs_extent_free_item fake = {
.xefi_owner = XFS_RMAP_OWN_UNKNOWN,
};
struct xfs_extent *extp;
extp = &efip->efi_format.efi_extents[i]; extp = &efip->efi_format.efi_extents[i];
error = xfs_trans_free_extent(tp, efdp, extp->ext_start,
extp->ext_len, fake.xefi_startblock = extp->ext_start;
&XFS_RMAP_OINFO_ANY_OWNER, false); fake.xefi_blockcount = extp->ext_len;
error = xfs_trans_free_extent(tp, efdp, &fake);
if (error == -EFSCORRUPTED) if (error == -EFSCORRUPTED)
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
extp, sizeof(*extp)); extp, sizeof(*extp));
......
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