btrfs: fix wrong accounting of raid1 data profile in statfs
authorDavid Sterba <dsterba@suse.cz>
Fri, 14 Nov 2014 14:05:06 +0000 (15:05 +0100)
committerChris Mason <clm@fb.com>
Fri, 21 Nov 2014 01:20:09 +0000 (17:20 -0800)
The sizes that are obtained from space infos are in raw units and have
to be adjusted according to the raid factor. This was missing for
f_bavail and df reported doubled size for raid1.

Reported-by: Martin Steigerwald <Martin@lichtvoll.de>
Fixes: ba7b6e62f420 ("btrfs: adjust statfs calculations according to raid profiles")
CC: stable@vger.kernel.org
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/super.c

index dc337d14ef5cc12e3c0c9ac73a084a7a9202b0c1..21c60ee2f6644c2e610359dbfed79efa620bc332 100644 (file)
@@ -1851,7 +1851,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_bfree -= block_rsv->size >> bits;
        spin_unlock(&block_rsv->lock);
 
-       buf->f_bavail = total_free_data;
+       buf->f_bavail = div_u64(total_free_data, factor);
        ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data);
        if (ret)
                return ret;