aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-10-14 14:52:27 -0400
committerJosef Bacik <josef@redhat.com>2010-10-22 15:54:55 -0400
commit89a55897a2fbbceb94480952784004bf23911d38 (patch)
treee62ea1ced4c7941ab53e7aa7047ce8f0af0add9f /fs/btrfs/super.c
parentbf5fc093c5b625e4259203f1cee7ca73488a5620 (diff)
Btrfs: fix df regression
The new ENOSPC stuff breaks out the raid types which breaks the way we were reporting df to the system. This fixes it back so that Available is the total space available to data and used is the actual bytes used by the filesystem. This means that Available is Total - data used - all of the metadata space. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f2393b390318..afab6ca14d03 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -716,18 +716,25 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
716 struct list_head *head = &root->fs_info->space_info; 716 struct list_head *head = &root->fs_info->space_info;
717 struct btrfs_space_info *found; 717 struct btrfs_space_info *found;
718 u64 total_used = 0; 718 u64 total_used = 0;
719 u64 total_used_data = 0;
719 int bits = dentry->d_sb->s_blocksize_bits; 720 int bits = dentry->d_sb->s_blocksize_bits;
720 __be32 *fsid = (__be32 *)root->fs_info->fsid; 721 __be32 *fsid = (__be32 *)root->fs_info->fsid;
721 722
722 rcu_read_lock(); 723 rcu_read_lock();
723 list_for_each_entry_rcu(found, head, list) 724 list_for_each_entry_rcu(found, head, list) {
725 if (found->flags & (BTRFS_BLOCK_GROUP_METADATA |
726 BTRFS_BLOCK_GROUP_SYSTEM))
727 total_used_data += found->disk_total;
728 else
729 total_used_data += found->disk_used;
724 total_used += found->disk_used; 730 total_used += found->disk_used;
731 }
725 rcu_read_unlock(); 732 rcu_read_unlock();
726 733
727 buf->f_namelen = BTRFS_NAME_LEN; 734 buf->f_namelen = BTRFS_NAME_LEN;
728 buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; 735 buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits;
729 buf->f_bfree = buf->f_blocks - (total_used >> bits); 736 buf->f_bfree = buf->f_blocks - (total_used >> bits);
730 buf->f_bavail = buf->f_bfree; 737 buf->f_bavail = buf->f_blocks - (total_used_data >> bits);
731 buf->f_bsize = dentry->d_sb->s_blocksize; 738 buf->f_bsize = dentry->d_sb->s_blocksize;
732 buf->f_type = BTRFS_SUPER_MAGIC; 739 buf->f_type = BTRFS_SUPER_MAGIC;
733 740