aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/super.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9771eb8694b6..ff3dd55f294d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -752,14 +752,37 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
752{ 752{
753 struct btrfs_root *root = btrfs_sb(dentry->d_sb); 753 struct btrfs_root *root = btrfs_sb(dentry->d_sb);
754 struct btrfs_super_block *disk_super = &root->fs_info->super_copy; 754 struct btrfs_super_block *disk_super = &root->fs_info->super_copy;
755 struct list_head *head = &root->fs_info->space_info;
756 struct btrfs_space_info *found;
757 u64 total_used = 0;
758 u64 data_used = 0;
755 int bits = dentry->d_sb->s_blocksize_bits; 759 int bits = dentry->d_sb->s_blocksize_bits;
756 __be32 *fsid = (__be32 *)root->fs_info->fsid; 760 __be32 *fsid = (__be32 *)root->fs_info->fsid;
757 761
762 rcu_read_lock();
763 list_for_each_entry_rcu(found, head, list) {
764 if (found->flags & (BTRFS_BLOCK_GROUP_DUP|
765 BTRFS_BLOCK_GROUP_RAID10|
766 BTRFS_BLOCK_GROUP_RAID1)) {
767 total_used += found->bytes_used;
768 if (found->flags & BTRFS_BLOCK_GROUP_DATA)
769 data_used += found->bytes_used;
770 else
771 data_used += found->total_bytes;
772 }
773
774 total_used += found->bytes_used;
775 if (found->flags & BTRFS_BLOCK_GROUP_DATA)
776 data_used += found->bytes_used;
777 else
778 data_used += found->total_bytes;
779 }
780 rcu_read_unlock();
781
758 buf->f_namelen = BTRFS_NAME_LEN; 782 buf->f_namelen = BTRFS_NAME_LEN;
759 buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; 783 buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits;
760 buf->f_bfree = buf->f_blocks - 784 buf->f_bfree = buf->f_blocks - (total_used >> bits);
761 (btrfs_super_bytes_used(disk_super) >> bits); 785 buf->f_bavail = buf->f_blocks - (data_used >> bits);
762 buf->f_bavail = buf->f_bfree;
763 buf->f_bsize = dentry->d_sb->s_blocksize; 786 buf->f_bsize = dentry->d_sb->s_blocksize;
764 buf->f_type = BTRFS_SUPER_MAGIC; 787 buf->f_type = BTRFS_SUPER_MAGIC;
765 788