Skip to content

Commit 85bcfa2

Browse files
author
Darrick J. Wong
committed
xfs: don't report reserved bnobt space as available
On a modern filesystem, we don't allow userspace to allocate blocks for data storage from the per-AG space reservations, the user-controlled reservation pool that prevents ENOSPC in the middle of internal operations, or the internal per-AG set-aside that prevents unwanted filesystem shutdowns due to ENOSPC during a bmap btree split. Since we now consider freespace btree blocks as unavailable for allocation for data storage, we shouldn't report those blocks via statfs either. This makes the numbers that we return via the statfs f_bavail and f_bfree fields a more conservative estimate of actual free space. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 82be38b commit 85bcfa2

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

fs/xfs/xfs_fsops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ xfs_fs_counts(
347347
cnt->allocino = percpu_counter_read_positive(&mp->m_icount);
348348
cnt->freeino = percpu_counter_read_positive(&mp->m_ifree);
349349
cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) -
350-
mp->m_alloc_set_aside;
350+
xfs_fdblocks_unavailable(mp);
351351

352352
spin_lock(&mp->m_sb_lock);
353353
cnt->freertx = mp->m_sb.sb_frextents;

fs/xfs/xfs_super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,8 @@ xfs_fs_statfs(
815815
spin_unlock(&mp->m_sb_lock);
816816

817817
/* make sure statp->f_bfree does not underflow */
818-
statp->f_bfree = max_t(int64_t, fdblocks - mp->m_alloc_set_aside, 0);
818+
statp->f_bfree = max_t(int64_t, 0,
819+
fdblocks - xfs_fdblocks_unavailable(mp));
819820
statp->f_bavail = statp->f_bfree;
820821

821822
fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);

0 commit comments

Comments
 (0)