From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: xfs <linux-xfs@vger.kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Subject: [RFC PATCH] xfs: account for per-AG reservation in statfs f_blocks
Date: Wed, 1 Nov 2017 14:16:42 -0700 [thread overview]
Message-ID: <20171101211642.GK4911@magnolia> (raw)
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;
next reply other threads:[~2017-11-01 21:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 21:16 Darrick J. Wong [this message]
2017-11-01 21:42 ` [RFC PATCH] xfs: account for per-AG reservation in statfs f_blocks Dave Chinner
2017-11-01 22:50 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171101211642.GK4911@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).