Commit 0d95c1be authored by David Sterba's avatar David Sterba Committed by Chris Mason

btrfs: fix wrong accounting of raid1 data profile in statfs

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: default avatarMartin Steigerwald <Martin@lichtvoll.de>
Fixes: ba7b6e62 ("btrfs: adjust statfs calculations according to raid profiles")
CC: stable@vger.kernel.org
Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 32159242
...@@ -1851,7 +1851,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -1851,7 +1851,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_bfree -= block_rsv->size >> bits; buf->f_bfree -= block_rsv->size >> bits;
spin_unlock(&block_rsv->lock); 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); ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment