diff options
-rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 20 |
2 files changed, 20 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2b15fb97d23f..80599b4e42bd 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -674,6 +674,7 @@ struct btrfs_space_info { | |||
674 | u64 bytes_reserved; /* total bytes the allocator has reserved for | 674 | u64 bytes_reserved; /* total bytes the allocator has reserved for |
675 | current allocations */ | 675 | current allocations */ |
676 | u64 bytes_readonly; /* total bytes that are read only */ | 676 | u64 bytes_readonly; /* total bytes that are read only */ |
677 | u64 bytes_super; /* total bytes reserved for the super blocks */ | ||
677 | 678 | ||
678 | /* delalloc accounting */ | 679 | /* delalloc accounting */ |
679 | u64 bytes_delalloc; /* number of bytes reserved for allocation, | 680 | u64 bytes_delalloc; /* number of bytes reserved for allocation, |
@@ -746,6 +747,7 @@ struct btrfs_block_group_cache { | |||
746 | spinlock_t lock; | 747 | spinlock_t lock; |
747 | u64 pinned; | 748 | u64 pinned; |
748 | u64 reserved; | 749 | u64 reserved; |
750 | u64 bytes_super; | ||
749 | u64 flags; | 751 | u64 flags; |
750 | u64 sectorsize; | 752 | u64 sectorsize; |
751 | int extents_thresh; | 753 | int extents_thresh; |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 93e376ada28b..5f3544e5f3cb 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -201,6 +201,7 @@ static int exclude_super_stripes(struct btrfs_root *root, | |||
201 | BUG_ON(ret); | 201 | BUG_ON(ret); |
202 | 202 | ||
203 | while (nr--) { | 203 | while (nr--) { |
204 | cache->bytes_super += stripe_len; | ||
204 | ret = add_excluded_extent(root, logical[nr], | 205 | ret = add_excluded_extent(root, logical[nr], |
205 | stripe_len); | 206 | stripe_len); |
206 | BUG_ON(ret); | 207 | BUG_ON(ret); |
@@ -295,6 +296,9 @@ static int caching_kthread(void *data) | |||
295 | return -ENOMEM; | 296 | return -ENOMEM; |
296 | 297 | ||
297 | exclude_super_stripes(extent_root, block_group); | 298 | exclude_super_stripes(extent_root, block_group); |
299 | spin_lock(&block_group->space_info->lock); | ||
300 | block_group->space_info->bytes_super += block_group->bytes_super; | ||
301 | spin_unlock(&block_group->space_info->lock); | ||
298 | 302 | ||
299 | last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); | 303 | last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); |
300 | 304 | ||
@@ -2785,7 +2789,8 @@ again: | |||
2785 | do_div(thresh, 100); | 2789 | do_div(thresh, 100); |
2786 | 2790 | ||
2787 | if (meta_sinfo->bytes_used + meta_sinfo->bytes_reserved + | 2791 | if (meta_sinfo->bytes_used + meta_sinfo->bytes_reserved + |
2788 | meta_sinfo->bytes_pinned + meta_sinfo->bytes_readonly > thresh) { | 2792 | meta_sinfo->bytes_pinned + meta_sinfo->bytes_readonly + |
2793 | meta_sinfo->bytes_super > thresh) { | ||
2789 | struct btrfs_trans_handle *trans; | 2794 | struct btrfs_trans_handle *trans; |
2790 | if (!meta_sinfo->full) { | 2795 | if (!meta_sinfo->full) { |
2791 | meta_sinfo->force_alloc = 1; | 2796 | meta_sinfo->force_alloc = 1; |
@@ -2839,7 +2844,7 @@ again: | |||
2839 | if (data_sinfo->total_bytes - data_sinfo->bytes_used - | 2844 | if (data_sinfo->total_bytes - data_sinfo->bytes_used - |
2840 | data_sinfo->bytes_delalloc - data_sinfo->bytes_reserved - | 2845 | data_sinfo->bytes_delalloc - data_sinfo->bytes_reserved - |
2841 | data_sinfo->bytes_pinned - data_sinfo->bytes_readonly - | 2846 | data_sinfo->bytes_pinned - data_sinfo->bytes_readonly - |
2842 | data_sinfo->bytes_may_use < bytes) { | 2847 | data_sinfo->bytes_may_use - data_sinfo->bytes_super < bytes) { |
2843 | struct btrfs_trans_handle *trans; | 2848 | struct btrfs_trans_handle *trans; |
2844 | 2849 | ||
2845 | /* | 2850 | /* |
@@ -6957,8 +6962,10 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
6957 | * time, particularly in the full case. | 6962 | * time, particularly in the full case. |
6958 | */ | 6963 | */ |
6959 | if (found_key.offset == btrfs_block_group_used(&cache->item)) { | 6964 | if (found_key.offset == btrfs_block_group_used(&cache->item)) { |
6965 | exclude_super_stripes(root, cache); | ||
6960 | cache->last_byte_to_unpin = (u64)-1; | 6966 | cache->last_byte_to_unpin = (u64)-1; |
6961 | cache->cached = BTRFS_CACHE_FINISHED; | 6967 | cache->cached = BTRFS_CACHE_FINISHED; |
6968 | free_excluded_extents(root, cache); | ||
6962 | } else if (btrfs_block_group_used(&cache->item) == 0) { | 6969 | } else if (btrfs_block_group_used(&cache->item) == 0) { |
6963 | exclude_super_stripes(root, cache); | 6970 | exclude_super_stripes(root, cache); |
6964 | cache->last_byte_to_unpin = (u64)-1; | 6971 | cache->last_byte_to_unpin = (u64)-1; |
@@ -6975,6 +6982,10 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
6975 | &space_info); | 6982 | &space_info); |
6976 | BUG_ON(ret); | 6983 | BUG_ON(ret); |
6977 | cache->space_info = space_info; | 6984 | cache->space_info = space_info; |
6985 | spin_lock(&cache->space_info->lock); | ||
6986 | cache->space_info->bytes_super += cache->bytes_super; | ||
6987 | spin_unlock(&cache->space_info->lock); | ||
6988 | |||
6978 | down_write(&space_info->groups_sem); | 6989 | down_write(&space_info->groups_sem); |
6979 | list_add_tail(&cache->list, &space_info->block_groups); | 6990 | list_add_tail(&cache->list, &space_info->block_groups); |
6980 | up_write(&space_info->groups_sem); | 6991 | up_write(&space_info->groups_sem); |
@@ -7044,6 +7055,11 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
7044 | ret = update_space_info(root->fs_info, cache->flags, size, bytes_used, | 7055 | ret = update_space_info(root->fs_info, cache->flags, size, bytes_used, |
7045 | &cache->space_info); | 7056 | &cache->space_info); |
7046 | BUG_ON(ret); | 7057 | BUG_ON(ret); |
7058 | |||
7059 | spin_lock(&cache->space_info->lock); | ||
7060 | cache->space_info->bytes_super += cache->bytes_super; | ||
7061 | spin_unlock(&cache->space_info->lock); | ||
7062 | |||
7047 | down_write(&cache->space_info->groups_sem); | 7063 | down_write(&cache->space_info->groups_sem); |
7048 | list_add_tail(&cache->list, &cache->space_info->block_groups); | 7064 | list_add_tail(&cache->list, &cache->space_info->block_groups); |
7049 | up_write(&cache->space_info->groups_sem); | 7065 | up_write(&cache->space_info->groups_sem); |