Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233009
b: refs/heads/master
c: 3c14874
h: refs/heads/master
i:
  233007: 8714b84
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Feb 6, 2011
1 parent 763de8a commit 19a50ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 13dbc08987f25d9dba488a34b44b43e3844b027c
refs/heads/master: 3c14874acc71180553fb5aba528e3cf57c5b958b
26 changes: 18 additions & 8 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,6 @@ static int caching_kthread(void *data)
if (!path)
return -ENOMEM;

exclude_super_stripes(extent_root, block_group);
spin_lock(&block_group->space_info->lock);
block_group->space_info->bytes_readonly += block_group->bytes_super;
spin_unlock(&block_group->space_info->lock);

last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET);

/*
Expand Down Expand Up @@ -467,8 +462,10 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
cache->cached = BTRFS_CACHE_NO;
}
spin_unlock(&cache->lock);
if (ret == 1)
if (ret == 1) {
free_excluded_extents(fs_info->extent_root, cache);
return 0;
}
}

if (load_cache_only)
Expand Down Expand Up @@ -4036,6 +4033,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)

num_bytes = ALIGN(num_bytes, root->sectorsize);
atomic_dec(&BTRFS_I(inode)->outstanding_extents);
WARN_ON(atomic_read(&BTRFS_I(inode)->outstanding_extents) < 0);

spin_lock(&BTRFS_I(inode)->accounting_lock);
nr_extents = atomic_read(&BTRFS_I(inode)->outstanding_extents);
Expand Down Expand Up @@ -8325,6 +8323,13 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
if (block_group->cached == BTRFS_CACHE_STARTED)
wait_block_group_cache_done(block_group);

/*
* We haven't cached this block group, which means we could
* possibly have excluded extents on this block group.
*/
if (block_group->cached == BTRFS_CACHE_NO)
free_excluded_extents(info->extent_root, block_group);

btrfs_remove_free_space_cache(block_group);
btrfs_put_block_group(block_group);

Expand Down Expand Up @@ -8439,6 +8444,13 @@ int btrfs_read_block_groups(struct btrfs_root *root)
cache->flags = btrfs_block_group_flags(&cache->item);
cache->sectorsize = root->sectorsize;

/*
* We need to exclude the super stripes now so that the space
* info has super bytes accounted for, otherwise we'll think
* we have more space than we actually do.
*/
exclude_super_stripes(root, cache);

/*
* check for two cases, either we are full, and therefore
* don't need to bother with the caching work since we won't
Expand All @@ -8447,12 +8459,10 @@ int btrfs_read_block_groups(struct btrfs_root *root)
* time, particularly in the full case.
*/
if (found_key.offset == btrfs_block_group_used(&cache->item)) {
exclude_super_stripes(root, cache);
cache->last_byte_to_unpin = (u64)-1;
cache->cached = BTRFS_CACHE_FINISHED;
free_excluded_extents(root, cache);
} else if (btrfs_block_group_used(&cache->item) == 0) {
exclude_super_stripes(root, cache);
cache->last_byte_to_unpin = (u64)-1;
cache->cached = BTRFS_CACHE_FINISHED;
add_new_free_space(cache, root->fs_info,
Expand Down

0 comments on commit 19a50ae

Please sign in to comment.