[RFC v1 0/4] xfs: Add support to shrink multiple empty rtgroups

Nirjhar Roy (IBM)
2026-02-19T06:05:23Z

From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>

This work is based on a previous RFC[1] by Gao Xiang and various ideas
proposed by Dave Chinner in the RFC[1].

The patch begins with the re-introduction of some of the data
structures that were removed, some code refactoring and
finally the patch that implements the multi rtgroup shrink design.
We can remove only those rtgroups which are empty.
For non-empty rtgroups the rtextents can migrated to other rtgroups
(assuming the required amount of space is available).
I am working on the patch series [2](by Darrick and
Dave) for completion of the data block migration from the end of the
filesystem for emptying an realtime group. That will be a future work
after this.
The final patch has all the details including the definition of the
terminologies and the overall design.

The design is quite similar to the design of data AG removal implemented
in the patch series[3] that I have posted earlier.
The reason for keeping [3] on hold and posting this patch series is
that (based on the discussion in [5], [6]), realtime devices won't have any
metadata/inodes and migrating data from the end of realtime devices will
be simpler. On the other hand there are challenges in moving metadata
from regular AGs especially inodes.

Please note that I have added RBs from Darrick in patch 1 which was
given in [4].

Instructions to test this patch:
$ Apply the patch for xfsprogs sent with this series and install it.
$ mkfs.xfs -f -m metadir=1 -r rtdev=/dev/loop2,extsize=4096,rgcount=4,size=1G \
-d size=1G /dev/loop1
$ mount -o rtdev=/dev/loop2 /dev/loop1 /mnt/scratch
$ # shrink by 1.5 rtgroups
$ xfs_growfs -R $(( 65536 * 2 + 32768 )) /mnt1/scratch

I have also sent the tests.

[1] https://lore.kernel.org/all/20210414195240.1802221-1-hsiangkao@redhat.com/
[2] https://lore.kernel.org/linux-xfs/173568777852.2709794.6356870909327619205.stgit@frogsfrogsfrogs/
[3] https://lore.kernel.org/linux-xfs/cover.1760640936.git.nirjhar.roy.lists@gmail.com/
[4] https://lore.kernel.org/all/20250729202632.GF2672049@frogsfrogsfrogs/
[5] https://lore.kernel.org/linux-xfs/aPnMk_2YNHLJU5wm@infradead.org/
[6] https://lore.kernel.org/linux-xfs/aPiFBxhc34RNgu5h@infradead.org/

Nirjhar Roy (IBM) (4):
xfs: Re-introduce xg_active_wq field in struct xfs_group
xfs: Introduce xfs_rtginodes_ensure_all()
xfs: Add a new state for shrinking
xfs: Add support to shrink multiple empty realtime groups

fs/xfs/libxfs/xfs_group.c | 18 +-
fs/xfs/libxfs/xfs_group.h | 4 +
fs/xfs/libxfs/xfs_rtgroup.c | 105 ++++-
fs/xfs/libxfs/xfs_rtgroup.h | 31 ++
fs/xfs/xfs_buf_item_recover.c | 25 +-
fs/xfs/xfs_extent_busy.c | 30 ++
fs/xfs/xfs_extent_busy.h | 2 +
fs/xfs/xfs_inode.c | 8 +-
fs/xfs/xfs_mount.h | 3 +
fs/xfs/xfs_rtalloc.c | 824 +++++++++++++++++++++++++++++++++-
fs/xfs/xfs_trans.c | 1 -
11 files changed, 1023 insertions(+), 28 deletions(-)

--
2.43.5