diff options
Diffstat (limited to 'fs/btrfs/super.c')
| -rw-r--r-- | fs/btrfs/super.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5f56213908e7..65b62daa3f80 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -638,7 +638,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 638 | if (IS_ERR(root)) { | 638 | if (IS_ERR(root)) { |
| 639 | error = PTR_ERR(root); | 639 | error = PTR_ERR(root); |
| 640 | deactivate_locked_super(s); | 640 | deactivate_locked_super(s); |
| 641 | goto error; | 641 | goto error_free_subvol_name; |
| 642 | } | 642 | } |
| 643 | /* if they gave us a subvolume name bind mount into that */ | 643 | /* if they gave us a subvolume name bind mount into that */ |
| 644 | if (strcmp(subvol_name, ".")) { | 644 | if (strcmp(subvol_name, ".")) { |
| @@ -652,14 +652,14 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 652 | deactivate_locked_super(s); | 652 | deactivate_locked_super(s); |
| 653 | error = PTR_ERR(new_root); | 653 | error = PTR_ERR(new_root); |
| 654 | dput(root); | 654 | dput(root); |
| 655 | goto error_close_devices; | 655 | goto error_free_subvol_name; |
| 656 | } | 656 | } |
| 657 | if (!new_root->d_inode) { | 657 | if (!new_root->d_inode) { |
| 658 | dput(root); | 658 | dput(root); |
| 659 | dput(new_root); | 659 | dput(new_root); |
| 660 | deactivate_locked_super(s); | 660 | deactivate_locked_super(s); |
| 661 | error = -ENXIO; | 661 | error = -ENXIO; |
| 662 | goto error_close_devices; | 662 | goto error_free_subvol_name; |
| 663 | } | 663 | } |
| 664 | dput(root); | 664 | dput(root); |
| 665 | root = new_root; | 665 | root = new_root; |
| @@ -677,7 +677,6 @@ error_close_devices: | |||
| 677 | btrfs_close_devices(fs_devices); | 677 | btrfs_close_devices(fs_devices); |
| 678 | error_free_subvol_name: | 678 | error_free_subvol_name: |
| 679 | kfree(subvol_name); | 679 | kfree(subvol_name); |
| 680 | error: | ||
| 681 | return error; | 680 | return error; |
| 682 | } | 681 | } |
| 683 | 682 | ||
| @@ -725,18 +724,25 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 725 | struct list_head *head = &root->fs_info->space_info; | 724 | struct list_head *head = &root->fs_info->space_info; |
| 726 | struct btrfs_space_info *found; | 725 | struct btrfs_space_info *found; |
| 727 | u64 total_used = 0; | 726 | u64 total_used = 0; |
| 727 | u64 total_used_data = 0; | ||
| 728 | int bits = dentry->d_sb->s_blocksize_bits; | 728 | int bits = dentry->d_sb->s_blocksize_bits; |
| 729 | __be32 *fsid = (__be32 *)root->fs_info->fsid; | 729 | __be32 *fsid = (__be32 *)root->fs_info->fsid; |
| 730 | 730 | ||
| 731 | rcu_read_lock(); | 731 | rcu_read_lock(); |
| 732 | list_for_each_entry_rcu(found, head, list) | 732 | list_for_each_entry_rcu(found, head, list) { |
| 733 | if (found->flags & (BTRFS_BLOCK_GROUP_METADATA | | ||
| 734 | BTRFS_BLOCK_GROUP_SYSTEM)) | ||
| 735 | total_used_data += found->disk_total; | ||
| 736 | else | ||
| 737 | total_used_data += found->disk_used; | ||
| 733 | total_used += found->disk_used; | 738 | total_used += found->disk_used; |
| 739 | } | ||
| 734 | rcu_read_unlock(); | 740 | rcu_read_unlock(); |
| 735 | 741 | ||
| 736 | buf->f_namelen = BTRFS_NAME_LEN; | 742 | buf->f_namelen = BTRFS_NAME_LEN; |
| 737 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; | 743 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; |
| 738 | buf->f_bfree = buf->f_blocks - (total_used >> bits); | 744 | buf->f_bfree = buf->f_blocks - (total_used >> bits); |
| 739 | buf->f_bavail = buf->f_bfree; | 745 | buf->f_bavail = buf->f_blocks - (total_used_data >> bits); |
| 740 | buf->f_bsize = dentry->d_sb->s_blocksize; | 746 | buf->f_bsize = dentry->d_sb->s_blocksize; |
| 741 | buf->f_type = BTRFS_SUPER_MAGIC; | 747 | buf->f_type = BTRFS_SUPER_MAGIC; |
| 742 | 748 | ||
