If aufs is mounted in sum mode, but the source file systems have different 
block sizes, the result of the statfs is the sum of all block counts which does 
not make sense. This patch corrects this problem by normalizing the block 
counts to the same block size and then adds them.
Index: aufs3-standalone.git/fs/aufs/super.c
===================================================================
--- aufs3-standalone.git.orig/fs/aufs/super.c   2012-03-13 01:52:16.000000000 
+0100
+++ aufs3-standalone.git/fs/aufs/super.c        2012-03-13 01:53:06.000000000 
+0100
@@ -326,7 +326,7 @@
 static int au_statfs_sum(struct super_block *sb, struct kstatfs *buf)
 {
        int err;
-       u64 blocks, bfree, bavail, files, ffree;
+       u64 blocks, bfree, bavail, files, ffree, bsize;
        aufs_bindex_t bend, bindex, i;
        unsigned char shared;
        struct path h_path;
@@ -338,6 +338,14 @@
        files = 0;
        ffree = 0;
 
+       // we need an initial bsize to calculate correct f_blocks
+       h_path.mnt = au_sbr_mnt(sb, 0);
+       h_path.dentry = h_path.mnt->mnt_root;
+       err = vfs_statfs(&h_path, buf);
+       if (unlikely(err))
+               goto out;
+       bsize = buf->f_bsize;
+
        err = 0;
        bend = au_sbend(sb);
        for (bindex = bend; bindex >= 0; bindex--) {
@@ -355,9 +363,9 @@
                if (unlikely(err))
                        goto out;
 
-               blocks = au_add_till_max(blocks, buf->f_blocks);
-               bfree = au_add_till_max(bfree, buf->f_bfree);
-               bavail = au_add_till_max(bavail, buf->f_bavail);
+               blocks = au_add_muldiv_till_max(blocks, buf->f_blocks, 
buf->f_bsize, bsize );
+               bfree  = au_add_muldiv_till_max(bfree,  buf->f_bfree,  
buf->f_bsize, bsize );
+               bavail = au_add_muldiv_till_max(bavail, buf->f_bavail, 
buf->f_bsize, bsize );
                files = au_add_till_max(files, buf->f_files);
                ffree = au_add_till_max(ffree, buf->f_ffree);
        }



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d

Reply via email to