@@ -623,13 +623,18 @@ static int btrfs_statfs(struct dentry *dentry,
struct kstatfs *buf)
{
struct btrfs_root *root = btrfs_sb(dentry->d_sb);
struct btrfs_super_block *disk_super = &root->fs_info->super_copy;
+ struct btrfs_device *device;
int bits = dentry->d_sb->s_blocksize_bits;
__be32 *fsid = (__be32 *)root->fs_info->fsid;
buf->f_namelen = BTRFS_NAME_LEN;
buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits;
- buf->f_bfree = buf->f_blocks -
- (btrfs_super_bytes_used(disk_super) >> bits);
+ buf->f_bfree = buf->f_blocks;
+ mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
+ list_for_each_entry(device, &root->fs_info->fs_devices->devices, dev_list) {
+ buf->f_bfree -= (device->bytes_used >> bits);
+ }
+ mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
buf->f_bavail = buf->f_bfree;
buf->f_bsize = dentry->d_sb->s_blocksize;