Skip to content

Commit 9c3cfb9

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: add a xfs_bmap_free_rtblocks helper
Split the RT extent freeing logic from xfs_bmap_del_extent_real because it will become more complicated when adding RT group. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent cd5b26f commit 9c3cfb9

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5116,6 +5116,27 @@ xfs_bmap_del_extent_cow(
51165116
ip->i_delayed_blks -= del->br_blockcount;
51175117
}
51185118

5119+
static int
5120+
xfs_bmap_free_rtblocks(
5121+
struct xfs_trans *tp,
5122+
struct xfs_bmbt_irec *del)
5123+
{
5124+
int error;
5125+
5126+
/*
5127+
* Ensure the bitmap and summary inodes are locked and joined to the
5128+
* transaction before modifying them.
5129+
*/
5130+
if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
5131+
tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
5132+
xfs_rtbitmap_lock(tp->t_mountp);
5133+
xfs_rtbitmap_trans_join(tp);
5134+
}
5135+
5136+
error = xfs_rtfree_blocks(tp, del->br_startblock, del->br_blockcount);
5137+
return error;
5138+
}
5139+
51195140
/*
51205141
* Called by xfs_bmapi to update file extent records and the btree
51215142
* after removing space.
@@ -5331,17 +5352,7 @@ xfs_bmap_del_extent_real(
53315352
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
53325353
xfs_refcount_decrease_extent(tp, del);
53335354
} else if (xfs_ifork_is_realtime(ip, whichfork)) {
5334-
/*
5335-
* Ensure the bitmap and summary inodes are locked
5336-
* and joined to the transaction before modifying them.
5337-
*/
5338-
if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
5339-
tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
5340-
xfs_rtbitmap_lock(mp);
5341-
xfs_rtbitmap_trans_join(tp);
5342-
}
5343-
error = xfs_rtfree_blocks(tp, del->br_startblock,
5344-
del->br_blockcount);
5355+
error = xfs_bmap_free_rtblocks(tp, del);
53455356
} else {
53465357
unsigned int efi_flags = 0;
53475358

0 commit comments

Comments
 (0)