Skip to content

Commit

Permalink
xfs: add a free space extent change reservation
Browse files Browse the repository at this point in the history
Lots of the transaction reservation code reserves space for an
extent allocation. It is inconsistently implemented, and many of
them get it wrong. Introduce a new function to calculate the log
space reservation for adding or removing an extent from the free
space btrees.

This function reserves space for logging the AGF, the AGFL and the
free space btrees, avoiding the need to account for them seperately
in every reservation that manipulates free space.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Dave Chinner authored and intel-lab-lkp committed May 27, 2021
1 parent 6045e14 commit 79189c8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fs/xfs/libxfs/xfs_trans_resv.c
Expand Up @@ -79,6 +79,23 @@ xfs_allocfree_log_count(
return blocks;
}

/*
* Log reservation required to add or remove a single extent to the free space
* btrees. This requires modifying:
*
* the agf header: 1 sector
* the agfl header: 1 sector
* the allocation btrees: 2 trees * (max depth - 1) * block size
*/
uint
xfs_allocfree_extent_res(
struct xfs_mount *mp)
{
return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
XFS_FSB_TO_B(mp, 1));
}

/*
* Logging inodes is really tricksy. They are logged in memory format,
* which means that what we write into the log doesn't directly translate into
Expand Down

0 comments on commit 79189c8

Please sign in to comment.