xfs: reduce metafile reservations
authorChristoph Hellwig <hch@lst.de>
Fri, 17 Jan 2025 05:55:08 +0000 (06:55 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Mar 2025 15:16:43 +0000 (08:16 -0700)
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 <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
fs/xfs/libxfs/xfs_metafile.c

index 88f011750add5c4efc7298a5ddfa5b6310d3c78d..225923e463c41e39feceb740c781c06c8acdd6cc 100644 (file)
@@ -260,6 +260,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))
@@ -297,6 +298,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);