@@ -1481,6 +1481,11 @@
}
kfree(devices_info);
+
+ if (type & BTRFS_BLOCK_GROUP_RAID1) {
+ do_div(avail_space, min_stripes);
+ }
+
*free_bytes = avail_space;
return 0;
}
@@ -1491,8 +1496,10 @@
struct btrfs_super_block *disk_super = fs_info->super_copy;
struct list_head *head = &fs_info->space_info;
struct btrfs_space_info *found;
+ u64 total_size;
u64 total_used = 0;
u64 total_free_data = 0;
+ u64 type;
int bits = dentry->d_sb->s_blocksize_bits;
__be32 *fsid = (__be32 *)fs_info->fsid;
int ret;
@@ -1512,7 +1519,13 @@
rcu_read_unlock();
buf->f_namelen = BTRFS_NAME_LEN;
- buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits;
+ total_size = btrfs_super_total_bytes(disk_super);
+ type = btrfs_get_alloc_profile(fs_info->tree_root, 1);
+ if (type & BTRFS_BLOCK_GROUP_RAID1) {
+ do_div(total_size, 2);
+ do_div(total_used, 2);
+ }
+ buf->f_blocks = total_size >> bits;
buf->f_bfree = buf->f_blocks - (total_used >> bits);
buf->f_bsize = dentry->d_sb->s_blocksize;
buf->f_type = BTRFS_SUPER_MAGIC;