diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f07ba21cbf0..565e22d77b1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -320,11 +320,6 @@ static int caching_kthread(void *data) | |||
320 | if (!path) | 320 | if (!path) |
321 | return -ENOMEM; | 321 | return -ENOMEM; |
322 | 322 | ||
323 | exclude_super_stripes(extent_root, block_group); | ||
324 | spin_lock(&block_group->space_info->lock); | ||
325 | block_group->space_info->bytes_readonly += block_group->bytes_super; | ||
326 | spin_unlock(&block_group->space_info->lock); | ||
327 | |||
328 | last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); | 323 | last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); |
329 | 324 | ||
330 | /* | 325 | /* |
@@ -467,8 +462,10 @@ static int cache_block_group(struct btrfs_block_group_cache *cache, | |||
467 | cache->cached = BTRFS_CACHE_NO; | 462 | cache->cached = BTRFS_CACHE_NO; |
468 | } | 463 | } |
469 | spin_unlock(&cache->lock); | 464 | spin_unlock(&cache->lock); |
470 | if (ret == 1) | 465 | if (ret == 1) { |
466 | free_excluded_extents(fs_info->extent_root, cache); | ||
471 | return 0; | 467 | return 0; |
468 | } | ||
472 | } | 469 | } |
473 | 470 | ||
474 | if (load_cache_only) | 471 | if (load_cache_only) |
@@ -4036,6 +4033,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) | |||
4036 | 4033 | ||
4037 | num_bytes = ALIGN(num_bytes, root->sectorsize); | 4034 | num_bytes = ALIGN(num_bytes, root->sectorsize); |
4038 | atomic_dec(&BTRFS_I(inode)->outstanding_extents); | 4035 | atomic_dec(&BTRFS_I(inode)->outstanding_extents); |
4036 | WARN_ON(atomic_read(&BTRFS_I(inode)->outstanding_extents) < 0); | ||
4039 | 4037 | ||
4040 | spin_lock(&BTRFS_I(inode)->accounting_lock); | 4038 | spin_lock(&BTRFS_I(inode)->accounting_lock); |
4041 | nr_extents = atomic_read(&BTRFS_I(inode)->outstanding_extents); | 4039 | nr_extents = atomic_read(&BTRFS_I(inode)->outstanding_extents); |
@@ -8325,6 +8323,13 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) | |||
8325 | if (block_group->cached == BTRFS_CACHE_STARTED) | 8323 | if (block_group->cached == BTRFS_CACHE_STARTED) |
8326 | wait_block_group_cache_done(block_group); | 8324 | wait_block_group_cache_done(block_group); |
8327 | 8325 | ||
8326 | /* | ||
8327 | * We haven't cached this block group, which means we could | ||
8328 | * possibly have excluded extents on this block group. | ||
8329 | */ | ||
8330 | if (block_group->cached == BTRFS_CACHE_NO) | ||
8331 | free_excluded_extents(info->extent_root, block_group); | ||
8332 | |||
8328 | btrfs_remove_free_space_cache(block_group); | 8333 | btrfs_remove_free_space_cache(block_group); |
8329 | btrfs_put_block_group(block_group); | 8334 | btrfs_put_block_group(block_group); |
8330 | 8335 | ||
@@ -8440,6 +8445,13 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
8440 | cache->sectorsize = root->sectorsize; | 8445 | cache->sectorsize = root->sectorsize; |
8441 | 8446 | ||
8442 | /* | 8447 | /* |
8448 | * We need to exclude the super stripes now so that the space | ||
8449 | * info has super bytes accounted for, otherwise we'll think | ||
8450 | * we have more space than we actually do. | ||
8451 | */ | ||
8452 | exclude_super_stripes(root, cache); | ||
8453 | |||
8454 | /* | ||
8443 | * check for two cases, either we are full, and therefore | 8455 | * check for two cases, either we are full, and therefore |
8444 | * don't need to bother with the caching work since we won't | 8456 | * don't need to bother with the caching work since we won't |
8445 | * find any space, or we are empty, and we can just add all | 8457 | * find any space, or we are empty, and we can just add all |
@@ -8447,12 +8459,10 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
8447 | * time, particularly in the full case. | 8459 | * time, particularly in the full case. |
8448 | */ | 8460 | */ |
8449 | if (found_key.offset == btrfs_block_group_used(&cache->item)) { | 8461 | if (found_key.offset == btrfs_block_group_used(&cache->item)) { |
8450 | exclude_super_stripes(root, cache); | ||
8451 | cache->last_byte_to_unpin = (u64)-1; | 8462 | cache->last_byte_to_unpin = (u64)-1; |
8452 | cache->cached = BTRFS_CACHE_FINISHED; | 8463 | cache->cached = BTRFS_CACHE_FINISHED; |
8453 | free_excluded_extents(root, cache); | 8464 | free_excluded_extents(root, cache); |
8454 | } else if (btrfs_block_group_used(&cache->item) == 0) { | 8465 | } else if (btrfs_block_group_used(&cache->item) == 0) { |
8455 | exclude_super_stripes(root, cache); | ||
8456 | cache->last_byte_to_unpin = (u64)-1; | 8466 | cache->last_byte_to_unpin = (u64)-1; |
8457 | cache->cached = BTRFS_CACHE_FINISHED; | 8467 | cache->cached = BTRFS_CACHE_FINISHED; |
8458 | add_new_free_space(cache, root->fs_info, | 8468 | add_new_free_space(cache, root->fs_info, |