]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs: implement zoned garbage collection
authorChristoph Hellwig <hch@lst.de>
Tue, 8 Apr 2025 07:16:12 +0000 (09:16 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 8 Apr 2025 07:16:12 +0000 (09:16 +0200)
commitfd7f46b65d16bef839de1484e9939fae4e7631d9
tree1902c86db2569e7255e5017c69d127655879eb43
parentb8712ebf64596ba6731fc46b6481560a95bd3cd5
xfs: implement zoned garbage collection

Source kernel commit: 080d01c41d44f0993f2c235a6bfdb681f0a66be6

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>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_group.h
libxfs/xfs_rtgroup.h