]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add the zoned space allocator
authorChristoph Hellwig <hch@lst.de>
Mon, 14 Apr 2025 05:36:01 +0000 (07:36 +0200)
committerAndrey Albershteyn <aalbersh@kernel.org>
Tue, 29 Apr 2025 16:09:57 +0000 (18:09 +0200)
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 <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_rtgroup.h
libxfs/xfs_types.h

index e35d1d7983275ca8e8a6e2e65fb4d738b0b87459..5d8777f819f4359d9f0ddfeac161351a00f1fa0b 100644 (file)
@@ -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);
index 76f3c31573ec378d513229f518972cfce5e19ee9..dc1db15f0be521873cb05ae74e330382f9f667bf 100644 (file)
@@ -243,6 +243,7 @@ enum xfs_free_counter {
         * Number of free RT extents on the RT device.
         */
        XC_FREE_RTEXTENTS,
+
        XC_FREE_NR,
 };