public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Stuart Brodsky <sbrodsky@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH] xfs: negative_icount.patch V2
Date: Thu, 29 Jul 2010 15:18:38 -0500	[thread overview]
Message-ID: <1280434718.7149.4.camel@superior.americas.sgi.com> (raw)

can somebody please review this for me?

Thanks,
------------

Because of delayed updates to sb_icount field in the super block, it is
possible to allocate over maxicount number of inodes.  This causes the
arithmetic to calculate a negative number of free inodes in user
commands like df or stat -f.  

Since maxicount is a somewhat arbitrary number, a slight over allocation
is not critical but user commands should be displayed as 0 or greater
and never go negative.  To do this the value in the stats buffer f_ffree
is capped to never go negative.

Signed-off-by: Stu Brodsky <sbrodsky@sgi.com>

--- a/fa/xfs/linux-2.6/xfs_super.c.orig 2010-07-20 06:06:19.269572013
-0500
+++ b/fa/xfs/linux-2.6/xfs_super.c 2010-07-20 08:09:17.773570840 -0500
@@ -1226,6 +1226,7 @@
        struct xfs_inode        *ip = XFS_I(dentry->d_inode);
        __uint64_t              fakeinos, id;
        xfs_extlen_t            lsize;
+       long long               i;
 
        statp->f_type = XFS_SB_MAGIC;
        statp->f_namelen = MAXNAMELEN - 1;
@@ -1249,7 +1250,12 @@
                statp->f_files = min_t(typeof(statp->f_files),
                                        statp->f_files,
                                        mp->m_maxicount);
-       statp->f_ffree = statp->f_files - (sbp->sb_icount -
sbp->sb_ifree);
+       i = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
+       if( i < 0 )
+               statp->f_ffree = 0;     /* cap at 0 */
+       else
+               statp->f_ffree = (__u64)i;
+
        spin_unlock(&mp->m_sb_lock);
 
        if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) ||
        
-- 
Stuart Brodsky
2750 Blue Water Road
Eagan, MN. 55121
651-683-7910
<sbrodsky@sgi.com>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2010-07-29 20:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 20:18 Stuart Brodsky [this message]
2010-07-29 20:55 ` [PATCH] xfs: negative_icount.patch V2 Christoph Hellwig

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=1280434718.7149.4.camel@superior.americas.sgi.com \
    --to=sbrodsky@sgi.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