From: Christoph Hellwig Date: Mon, 14 Apr 2025 05:36:01 +0000 (+0200) Subject: xfs: add the zoned space allocator X-Git-Tag: v6.15.0~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7681c8b64e8150667ea2d23e5134ffb5924b6607;p=thirdparty%2Fxfsprogs-dev.git xfs: add the zoned space allocator Source kernel commit: 4e4d52075577707f8393e3fc74c1ef79ca1d3ce6 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 Signed-off-by: Hans Holmberg Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Christoph Hellwig --- diff --git a/libxfs/xfs_rtgroup.h b/libxfs/xfs_rtgroup.h index e35d1d79..5d8777f8 100644 --- a/libxfs/xfs_rtgroup.h +++ b/libxfs/xfs_rtgroup.h @@ -37,15 +37,27 @@ struct xfs_rtgroup { xfs_rtxnum_t rtg_extents; /* - * Cache of rt summary level per bitmap block with the invariant that - * rtg_rsum_cache[bbno] > the maximum i for which rsum[i][bbno] != 0, - * or 0 if rsum[i][bbno] == 0 for all i. - * + * For bitmap based RT devices this points to a cache of rt summary + * level per bitmap block with the invariant that rtg_rsum_cache[bbno] + * > the maximum i for which rsum[i][bbno] != 0, or 0 if + * rsum[i][bbno] == 0 for all i. * Reads and writes are serialized by the rsumip inode lock. + * + * For zoned RT devices this points to the open zone structure for + * a group that is open for writers, or is NULL. */ - uint8_t *rtg_rsum_cache; + union { + uint8_t *rtg_rsum_cache; + struct xfs_open_zone *rtg_open_zone; + }; }; +/* + * For zoned RT devices this is set on groups that have no written blocks + * and can be picked by the allocator for opening. + */ +#define XFS_RTG_FREE XA_MARK_0 + static inline struct xfs_rtgroup *to_rtg(struct xfs_group *xg) { return container_of(xg, struct xfs_rtgroup, rtg_group); diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 76f3c315..dc1db15f 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -243,6 +243,7 @@ enum xfs_free_counter { * Number of free RT extents on the RT device. */ XC_FREE_RTEXTENTS, + XC_FREE_NR, };