Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223068
b: refs/heads/master
c: 2b20982
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik committed Dec 9, 2010
1 parent 52f9000 commit 2c27bca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 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: 955256f2c3e25c94ad373c43fbc38d2ac8af2a71
refs/heads/master: 2b20982e3154266106573beac2a4d4ba57a2789a
10 changes: 6 additions & 4 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
struct btrfs_root *root = block_group->fs_info->tree_root;
struct inode *inode = NULL;
u64 alloc_hint = 0;
int dcs = BTRFS_DC_ERROR;
int num_pages = 0;
int retries = 0;
int ret = 0;
Expand Down Expand Up @@ -2796,6 +2797,8 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,

spin_lock(&block_group->lock);
if (block_group->cached != BTRFS_CACHE_FINISHED) {
/* We're not cached, don't bother trying to write stuff out */
dcs = BTRFS_DC_WRITTEN;
spin_unlock(&block_group->lock);
goto out_put;
}
Expand All @@ -2822,17 +2825,16 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
num_pages, num_pages,
&alloc_hint);
if (!ret)
dcs = BTRFS_DC_SETUP;
btrfs_free_reserved_data_space(inode, num_pages);
out_put:
iput(inode);
out_free:
btrfs_release_path(root, path);
out:
spin_lock(&block_group->lock);
if (ret)
block_group->disk_cache_state = BTRFS_DC_ERROR;
else
block_group->disk_cache_state = BTRFS_DC_SETUP;
block_group->disk_cache_state = dcs;
spin_unlock(&block_group->lock);

return ret;
Expand Down
12 changes: 7 additions & 5 deletions trunk/fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
(unsigned long long)BTRFS_I(inode)->generation,
(unsigned long long)generation,
(unsigned long long)block_group->key.objectid);
goto out;
goto free_cache;
}

if (!num_entries)
Expand Down Expand Up @@ -524,6 +524,12 @@ int btrfs_write_out_cache(struct btrfs_root *root,
return 0;
}

node = rb_first(&block_group->free_space_offset);
if (!node) {
iput(inode);
return 0;
}

last_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
filemap_write_and_wait(inode->i_mapping);
btrfs_wait_ordered_range(inode, inode->i_size &
Expand All @@ -543,10 +549,6 @@ int btrfs_write_out_cache(struct btrfs_root *root,
*/
first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64);

node = rb_first(&block_group->free_space_offset);
if (!node)
goto out_free;

/*
* Lock all pages first so we can lock the extent safely.
*
Expand Down

0 comments on commit 2c27bca

Please sign in to comment.