diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2010-05-16 10:46:24 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-05-25 10:34:47 -0400 |
commit | b742bb82f1676d50103ade0ba89bfb79debabe73 (patch) | |
tree | ceac53988a3c158571fb91d54e3027403363fb47 /fs/btrfs/super.c | |
parent | e40152ee1e1c7a63f4777791863215e3faa37a86 (diff) |
Btrfs: Link block groups of different raid types
The size of reserved space is stored in space_info. If block groups
of different raid types are linked to separate space_info, changing
allocation profile will corrupt reserved space accounting.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 1866dff0538e..55265c24ab96 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -714,34 +714,18 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
714 | struct list_head *head = &root->fs_info->space_info; | 714 | struct list_head *head = &root->fs_info->space_info; |
715 | struct btrfs_space_info *found; | 715 | struct btrfs_space_info *found; |
716 | u64 total_used = 0; | 716 | u64 total_used = 0; |
717 | u64 data_used = 0; | ||
718 | int bits = dentry->d_sb->s_blocksize_bits; | 717 | int bits = dentry->d_sb->s_blocksize_bits; |
719 | __be32 *fsid = (__be32 *)root->fs_info->fsid; | 718 | __be32 *fsid = (__be32 *)root->fs_info->fsid; |
720 | 719 | ||
721 | rcu_read_lock(); | 720 | rcu_read_lock(); |
722 | list_for_each_entry_rcu(found, head, list) { | 721 | list_for_each_entry_rcu(found, head, list) |
723 | if (found->flags & (BTRFS_BLOCK_GROUP_DUP| | 722 | total_used += found->disk_used; |
724 | BTRFS_BLOCK_GROUP_RAID10| | ||
725 | BTRFS_BLOCK_GROUP_RAID1)) { | ||
726 | total_used += found->bytes_used; | ||
727 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) | ||
728 | data_used += found->bytes_used; | ||
729 | else | ||
730 | data_used += found->total_bytes; | ||
731 | } | ||
732 | |||
733 | total_used += found->bytes_used; | ||
734 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) | ||
735 | data_used += found->bytes_used; | ||
736 | else | ||
737 | data_used += found->total_bytes; | ||
738 | } | ||
739 | rcu_read_unlock(); | 723 | rcu_read_unlock(); |
740 | 724 | ||
741 | buf->f_namelen = BTRFS_NAME_LEN; | 725 | buf->f_namelen = BTRFS_NAME_LEN; |
742 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; | 726 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; |
743 | buf->f_bfree = buf->f_blocks - (total_used >> bits); | 727 | buf->f_bfree = buf->f_blocks - (total_used >> bits); |
744 | buf->f_bavail = buf->f_blocks - (data_used >> bits); | 728 | buf->f_bavail = buf->f_bfree; |
745 | buf->f_bsize = dentry->d_sb->s_blocksize; | 729 | buf->f_bsize = dentry->d_sb->s_blocksize; |
746 | buf->f_type = BTRFS_SUPER_MAGIC; | 730 | buf->f_type = BTRFS_SUPER_MAGIC; |
747 | 731 | ||