]> git.hungrycats.org Git - linux/commitdiff
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)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Sun, 21 Dec 2014 22:07:37 +0000 (17:07 -0500)
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>
(cherry picked from commit 0d95c1bec906dd1ad951c9c001e798ca52baeb0f)

fs/btrfs/super.c

index 96b0be67fad168c4ba799d8fe992d89e2e906fe7..391ec4418460046f80042f40ba98d41b0a7c4ab8 100644 (file)
@@ -1859,7 +1859,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;