From patchwork Wed Nov 1 21:16:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10037675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D3E79603B5 for ; Wed, 1 Nov 2017 22:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C306928BFC for ; Wed, 1 Nov 2017 22:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B80D428C1D; Wed, 1 Nov 2017 22:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BA1928BFC for ; Wed, 1 Nov 2017 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933170AbdKAWL2 (ORCPT ); Wed, 1 Nov 2017 18:11:28 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:44382 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933354AbdKAVQq (ORCPT ); Wed, 1 Nov 2017 17:16:46 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA1LGioK016002 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Nov 2017 21:16:44 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA1LGhcT003159 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Nov 2017 21:16:44 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA1LGh1a001939; Wed, 1 Nov 2017 21:16:43 GMT Received: from localhost (/10.145.178.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 01 Nov 2017 14:16:43 -0700 Date: Wed, 1 Nov 2017 14:16:42 -0700 From: "Darrick J. Wong" To: xfs Cc: Dave Chinner Subject: [RFC PATCH] xfs: account for per-AG reservation in statfs f_blocks Message-ID: <20171101211642.GK4911@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 --- 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(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;