Commit 37ea7a1f6b84ffc6f8e45b5377e29609b58330a4

Authored by David Sterba
Committed by Greg Kroah-Hartman
1 parent d77fe802ae

btrfs: fix wrong accounting of raid1 data profile in statfs

commit 0d95c1bec906dd1ad951c9c001e798ca52baeb0f upstream.

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")
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -1824,7 +1824,7 @@
1824 1824 buf->f_bfree -= block_rsv->size >> bits;
1825 1825 spin_unlock(&block_rsv->lock);
1826 1826  
1827   - buf->f_bavail = total_free_data;
  1827 + buf->f_bavail = div_u64(total_free_data, factor);
1828 1828 ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data);
1829 1829 if (ret) {
1830 1830 mutex_unlock(&fs_info->chunk_mutex);