Skip to contentSkip to conversation

xfs: cache open zone in inode->i_private

PATCH Superseded Christoph Hellwig 1 participant 2 messages Oct 17, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: cache open zone in inode->i_private

The MRU cache for open zones is unfortunately still not ideal, as it can time out pretty easily when doing heavy I/O to hard disks using up most or all open zones. One option would be to just increase the timeout, but while looking into that I realized we're just better off caching it indefinitely as there is no real downside to that once we don't hold a reference to the cache open zone.

So switch the open zone to RCU freeing, and then stash the last used open zone into inode->i_private. This helps to significantly reduce fragmentation by keeping I/O localized to zones for workloads that write using many open files to HDD.

Fixes 4e4d52075577 ("xfs: add the zoned space allocator")

---

Changes since v1:
- keep the is_gc assert and update the comment for it

 fs/xfs/xfs_mount.h      |   1 -
 fs/xfs/xfs_super.c      |   6 ++
 fs/xfs/xfs_zone_alloc.c | 123 +++++++++++++---------------------------
 fs/xfs/xfs_zone_priv.h  |   2 +
 4 files changed, 46 insertions(+), 86 deletions(-)
fs/xfs/xfs_mount.h +0 -1
index f046d1215b04..b871dfde372b 100644
@@ -236,7 +236,6 @@ typedef struct xfs_mount {
 	bool			m_update_sb;	/* sb needs update in mount */
 	unsigned int		m_max_open_zones;
 	unsigned int		m_zonegc_low_space;
-	struct xfs_mru_cache	*m_zone_cache;  /* Inode to open zone cache */
 
 	/* max_atomic_write mount option value */
 	unsigned long long	m_awu_max_bytes;
fs/xfs/xfs_super.c +6 -0
index e85a156dc17d..464ae1e657d9 100644
@@ -786,6 +786,12 @@ xfs_fs_evict_inode(
 
 	truncate_inode_pages_final(&inode->i_data);
 	clear_inode(inode);
+
+	if (IS_ENABLED(CONFIG_XFS_RT) &&
+	    S_ISREG(inode->i_mode) && inode->i_private) {
+		xfs_open_zone_put(inode->i_private);
+		inode->i_private = NULL;
+	}
 }
 
 static void
fs/xfs/xfs_zone_alloc.c +38 -85

190 lines not on this page · raw message

fs/xfs/xfs_zone_priv.h +2 -0
index 35e6de3d25ed..4322e26dd99a 100644
@@ -44,6 +44,8 @@ struct xfs_open_zone {
 	 * the life time of an open zone.
 	 */
 	struct xfs_rtgroup	*oz_rtg;
+
+	struct rcu_head		oz_rcu;
 };
 
 /*
Signature · 1 line
2.47.3
#1 lore raw

Disregard this version, it was missing the fold of the comment update. I though I had stopped git-send-email before it went out, but that seems to have failed.