Skip to content

Commit 44e69c9

Browse files
author
Darrick J. Wong
committed
xfs: use realtime EFI to free extents when rtgroups are enabled
When rmap is enabled, XFS expects a certain order of operations, which is: 1) remove the file mapping, 2) remove the reverse mapping, and then 3) free the blocks. When reflink is enabled, XFS replaces (3) with a deferred refcount decrement operation that can schedule freeing the blocks if that was the last refcount. For realtime files, xfs_bmap_del_extent_real tries to do 1 and 3 in the same transaction, which will break both rmap and reflink unless we switch it to use realtime EFIs. Both rmap and reflink depend on the rtgroups feature, so let's turn on EFIs for all rtgroups filesystems. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent fc91d94 commit 44e69c9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5383,9 +5383,11 @@ xfs_bmap_del_extent_real(
53835383
* If we need to, add to list of extents to delete.
53845384
*/
53855385
if (!(bflags & XFS_BMAPI_REMAP)) {
5386+
bool isrt = xfs_ifork_is_realtime(ip, whichfork);
5387+
53865388
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
53875389
xfs_refcount_decrease_extent(tp, del);
5388-
} else if (xfs_ifork_is_realtime(ip, whichfork)) {
5390+
} else if (isrt && !xfs_has_rtgroups(mp)) {
53895391
error = xfs_bmap_free_rtblocks(tp, del);
53905392
} else {
53915393
unsigned int efi_flags = 0;
@@ -5394,6 +5396,19 @@ xfs_bmap_del_extent_real(
53945396
del->br_state == XFS_EXT_UNWRITTEN)
53955397
efi_flags |= XFS_FREE_EXTENT_SKIP_DISCARD;
53965398

5399+
/*
5400+
* Historically, we did not use EFIs to free realtime
5401+
* extents. However, when reverse mapping is enabled,
5402+
* we must maintain the same order of operations as the
5403+
* data device, which is: Remove the file mapping,
5404+
* remove the reverse mapping, and then free the
5405+
* blocks. Reflink for realtime volumes requires the
5406+
* same sort of ordering. Both features rely on
5407+
* rtgroups, so let's gate rt EFI usage on rtgroups.
5408+
*/
5409+
if (isrt)
5410+
efi_flags |= XFS_FREE_EXTENT_REALTIME;
5411+
53975412
error = xfs_free_extent_later(tp, del->br_startblock,
53985413
del->br_blockcount, NULL,
53995414
XFS_AG_RESV_NONE, efi_flags);

0 commit comments

Comments
 (0)