]> www.infradead.org Git - users/hch/xfs.git/commit
xfs: implement zoned garbage collection
authorChristoph Hellwig <hch@lst.de>
Fri, 31 Jan 2025 06:59:59 +0000 (07:59 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Feb 2025 04:49:11 +0000 (05:49 +0100)
commita1fc293ab16ffdc2abea13a9efdfafd4e2e50e98
treef7a31b9c5714b2cc323a2da48f8b435ce8dbbc1c
parent1a88fd60df4104f488a246d2ef425c0d4c0a3f9f
xfs: implement zoned garbage collection

RT groups on a zoned file system need to be completely empty before their
space can be reused.  This means that partially empty groups need to be
emptied entirely to free up space if no entirely free groups are
available.

Add a garbage collection thread that moves all data out of the least used
zone when not enough free zones are available, and which resets all zones
that have been emptied.  To find empty zone a simple set of 10 buckets
based on the amount of space used in the zone is used.  To empty zones,
the rmap is walked to find the owners and the data is read and then
written to the new place.

To automatically defragment files the rmap records are sorted by inode
and logical offset.  This means defragmentation of parallel writes into
a single zone happens automatically when performing garbage collection.
Because holding the iolock over the entire GC cycle would inject very
noticeable latency for other accesses to the inodes, the iolock is not
taken while performing I/O.  Instead the I/O completion handler checks
that the mapping hasn't changed over the one recorded at the start of
the GC cycle and doesn't update the mapping if it change.

Co-developed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
13 files changed:
fs/xfs/Makefile
fs/xfs/libxfs/xfs_group.h
fs/xfs/libxfs/xfs_rtgroup.h
fs/xfs/xfs_extent_busy.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c
fs/xfs/xfs_trace.h
fs/xfs/xfs_zone_alloc.c
fs/xfs/xfs_zone_alloc.h
fs/xfs/xfs_zone_gc.c [new file with mode: 0644]
fs/xfs/xfs_zone_priv.h
fs/xfs/xfs_zone_space_resv.c