From 433f46a5b7d3f6fad28518044486bbdd4b46aad9 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2025 07:35:48 +0200 Subject: [PATCH] xfs: reduce metafile reservations Source kernel commit: 272e20bb24dc895375ccc18a82596a7259b5a652 There is no point in reserving more space than actually available on the data device for the worst case scenario that is unlikely to happen. Reserve at most 1/4th of the data device blocks, which is still a heuristic. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Christoph Hellwig --- libxfs/xfs_metafile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libxfs/xfs_metafile.c b/libxfs/xfs_metafile.c index 1216a0e5..6ded87d0 100644 --- a/libxfs/xfs_metafile.c +++ b/libxfs/xfs_metafile.c @@ -258,6 +258,7 @@ xfs_metafile_resv_init( struct xfs_rtgroup *rtg = NULL; xfs_filblks_t used = 0, target = 0; xfs_filblks_t hidden_space; + xfs_rfsblock_t dblocks_avail = mp->m_sb.sb_dblocks / 4; int error = 0; if (!xfs_has_metadir(mp)) @@ -295,6 +296,8 @@ xfs_metafile_resv_init( */ if (used > target) target = used; + else if (target > dblocks_avail) + target = dblocks_avail; hidden_space = target - used; error = xfs_dec_fdblocks(mp, hidden_space, true); -- 2.47.2