xfs: add the zoned space allocator
authorChristoph Hellwig <hch@lst.de>
Thu, 13 Feb 2025 04:49:17 +0000 (05:49 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Mar 2025 15:16:56 +0000 (08:16 -0700)
commit4e4d52075577707f8393e3fc74c1ef79ca1d3ce6
tree812806a08ae9e7ed6ec21d64c1544b5ba45245c8
parent720c2d58348329ce57bfa7ecef93ee0c9bf4b405
xfs: add the zoned space allocator

For zoned RT devices space is always allocated at the write pointer, that
is right after the last written block and only recorded on I/O completion.

Because the actual allocation algorithm is very simple and just involves
picking a good zone - preferably the one used for the last write to the
inode.  As the number of zones that can written at the same time is
usually limited by the hardware, selecting a zone is done as late as
possible from the iomap dio and buffered writeback bio submissions
helpers just before submitting the bio.

Given that the writers already took a reservation before acquiring the
iolock, space will always be readily available if an open zone slot is
available.  A new structure is used to track these open zones, and
pointed to by the xfs_rtgroup.  Because zoned file systems don't have
a rsum cache the space for that pointer can be reused.

Allocations are only recorded at I/O completion time.  The scheme used
for that is very similar to the reflink COW end I/O path.

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>
12 files changed:
fs/xfs/Makefile
fs/xfs/libxfs/xfs_rtgroup.h
fs/xfs/libxfs/xfs_types.h
fs/xfs/xfs_log.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_trace.c
fs/xfs/xfs_trace.h
fs/xfs/xfs_zone_alloc.c [new file with mode: 0644]
fs/xfs/xfs_zone_alloc.h [new file with mode: 0644]
fs/xfs/xfs_zone_priv.h [new file with mode: 0644]