From: Eric Sandeen <sandeen@sandeen.net>
To: Brian Foster <bfoster@redhat.com>, Eric Sandeen <sandeen@redhat.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: be honest about used inodes in statfs
Date: Mon, 24 Feb 2014 14:38:18 -0600 [thread overview]
Message-ID: <530BADBA.60402@sandeen.net> (raw)
In-Reply-To: <20140224160047.GA13221@bfoster.bfoster>
On 2/24/14, 10:01 AM, Brian Foster wrote:
> On Thu, Feb 20, 2014 at 04:12:16PM -0600, Eric Sandeen wrote:
>> Because we have lazy counters, it's possible that we over-allocate
>> inodes past the maxicount (imaxpct) limit.
>>
>> A previous commit,
>>
>> 2fe3366 xfs: ensure f_ffree returned by statfs() is non-negative
>>
>> stopped statfs from underflowing f_ffree in this case, but that
>> only happened when we mis-reported f_files, capped at maxicount.
>>
>> Change statfs to report the actual number of inodes allocated,
>> even if it is greater than maxicount. It's reality.
>> Deal with it. ;)
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>> index f317488..7c7a810 100644
>> --- a/fs/xfs/xfs_super.c
>> +++ b/fs/xfs/xfs_super.c
>> @@ -1083,7 +1083,6 @@ xfs_fs_statfs(
>> struct xfs_inode *ip = XFS_I(dentry->d_inode);
>> __uint64_t fakeinos, id;
>> xfs_extlen_t lsize;
>> - __int64_t ffree;
>>
>> statp->f_type = XFS_SB_MAGIC;
>> statp->f_namelen = MAXNAMELEN - 1;
>> @@ -1100,17 +1099,24 @@ xfs_fs_statfs(
>> statp->f_blocks = sbp->sb_dblocks - lsize;
>> statp->f_bfree = statp->f_bavail =
>> sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
>> +
>> + /* Potential number of new inodes in free blocks */
>> fakeinos = statp->f_bfree << sbp->sb_inopblog;
>> + /* Total possible files is current inodes + potential new inodes */
>> statp->f_files =
>> MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
>> + /* Unless we have maxicount! Then cap it at that */
>> if (mp->m_maxicount)
>> statp->f_files = min_t(typeof(statp->f_files),
>> statp->f_files,
>> mp->m_maxicount);
>>
>> - /* make sure statp->f_ffree does not underflow */
>> - ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
>> - statp->f_ffree = max_t(__int64_t, ffree, 0);
>> + /* But if we already managed to allocate more, let's be honest */
>> + statp->f_files = max_t(typeof(statp->f_files),
>> + sbp->sb_icount,
>> + statp->f_files);
>> +
>> + statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
>
> Hi Eric,
>
> Would something like the following be equivalent (and accurate?):
>
> /*
> * Potential number of new inodes in free blocks, limited by maxicount.
> */
> fakeinos = statp->f_bfree << sbp->sb_inopblog;
> if (mp->m_maxicount)
> fakeinos = mp->m_maxicount > sbp->sb_icount ?
> MIN(mp->m_maxicount - sbp->sb_icount, fakeinos) : 0;
> /* Total possible files is current inodes + potential new inodes */
> statp->f_files = MIN(sbp->sb_icount + fakeinos,
> (__uint64_t) XFS_MAXINUMBER);
>
> statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
Yeah, I think that's better. Want to send that patch? You did the hard work of
making it look sane. ;)
-Eric
> Brian
>
>>
>> spin_unlock(&mp->m_sb_lock);
>>
>>
>> _______________________________________________
>> xfs mailing list
>> xfs@oss.sgi.com
>> http://oss.sgi.com/mailman/listinfo/xfs
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-02-24 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 22:12 [PATCH] xfs: be honest about used inodes in statfs Eric Sandeen
2014-02-24 16:01 ` Brian Foster
2014-02-24 20:38 ` Eric Sandeen [this message]
2014-02-24 23:10 ` [PATCH V2] " Eric Sandeen
2014-02-24 23:55 ` Brian Foster
2014-02-24 23:56 ` Dave Chinner
2014-02-25 0:02 ` Eric Sandeen
2014-02-25 0:15 ` [PATCH V3] " Eric Sandeen
2014-02-25 0:27 ` [PATCH V4] " Eric Sandeen
2014-02-25 0:52 ` Dave Chinner
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=530BADBA.60402@sandeen.net \
--to=sandeen@sandeen.net \
--cc=bfoster@redhat.com \
--cc=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/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