linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] xfs: account for per-AG reservation in statfs f_blocks
@ 2017-11-01 21:16 Darrick J. Wong
  2017-11-01 21:42 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2017-11-01 21:16 UTC (permalink / raw)
  To: xfs; +Cc: Dave Chinner

From: Darrick J. Wong <darrick.wong@oracle.com>

Since the blocks reserved by the per-AG reservation mechanism are never
available to userspace, there's no point in reporting them via statfs.
Reduce the number of blocks reported by statfs so our space accounting
works the way it did in the old days -- f_blocks is the theoretical
upper bound on the amount of space that user programs could allocate,
and f_blocks is the current maximum.

This eliminates the regression where you format a 100T XFS and df
reports 2T are already "used".  Now it reports that you have a 98T
filesystem.

(Dave's thinp rfc might very well fix this whole problem; this is
purely a bandaid to shut down the complaints.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_ag_resv.c |    3 +++
 fs/xfs/xfs_mount.h          |    1 +
 fs/xfs/xfs_super.c          |    2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index 2291f42..1c23b9f 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -150,6 +150,7 @@ __xfs_ag_resv_free(
 	struct xfs_perag		*pag,
 	enum xfs_ag_resv_type		type)
 {
+	struct xfs_mount		*mp = pag->pag_mount;
 	struct xfs_ag_resv		*resv;
 	xfs_extlen_t			oldresv;
 	int				error;
@@ -167,6 +168,7 @@ __xfs_ag_resv_free(
 		oldresv = resv->ar_orig_reserved;
 	else
 		oldresv = resv->ar_reserved;
+	mp->m_ag_resv -= oldresv;
 	error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
 	resv->ar_reserved = 0;
 	resv->ar_asked = 0;
@@ -217,6 +219,7 @@ __xfs_ag_resv_init(
 				pag->pag_agno);
 		return error;
 	}
+	mp->m_ag_resv += reserved;
 
 	/*
 	 * Reduce the maximum per-AG allocation length by however much we're
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index e0792d0..04ceefa 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -152,6 +152,7 @@ typedef struct xfs_mount {
 	uint64_t		m_resblks;	/* total reserved blocks */
 	uint64_t		m_resblks_avail;/* available reserved blocks */
 	uint64_t		m_resblks_save;	/* reserved blks @ remount,ro */
+	uint64_t		m_ag_resv;	/* per-ag reserved blocks */
 	int			m_dalign;	/* stripe unit */
 	int			m_swidth;	/* stripe width */
 	int			m_sinoalign;	/* stripe unit inode alignment */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f663022..5bfbf05 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1126,7 +1126,7 @@ xfs_fs_statfs(
 	spin_lock(&mp->m_sb_lock);
 	statp->f_bsize = sbp->sb_blocksize;
 	lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
-	statp->f_blocks = sbp->sb_dblocks - lsize;
+	statp->f_blocks = sbp->sb_dblocks - lsize - mp->m_ag_resv;
 	spin_unlock(&mp->m_sb_lock);
 
 	statp->f_bfree = fdblocks - mp->m_alloc_set_aside;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-01 22:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-01 21:16 [RFC PATCH] xfs: account for per-AG reservation in statfs f_blocks Darrick J. Wong
2017-11-01 21:42 ` Dave Chinner
2017-11-01 22:50   ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).