Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 274644
b: refs/heads/master
c: 5b0e95b
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik committed Oct 19, 2011
1 parent 9ef2d88 commit c405c89
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 69 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: 9a82ca659d8bfd99afc0e89bbde2202322df5755
refs/heads/master: 5b0e95bf607ddd59b39f52d3d55e6581c817b530
1 change: 1 addition & 0 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ struct btrfs_block_group_cache {
u64 bytes_super;
u64 flags;
u64 sectorsize;
u64 cache_generation;
unsigned int ro:1;
unsigned int dirty:1;
unsigned int iref:1;
Expand Down
18 changes: 12 additions & 6 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,13 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
goto again;
}

/* We've already setup this transaction, go ahead and exit */
if (block_group->cache_generation == trans->transid &&
i_size_read(inode)) {
dcs = BTRFS_DC_SETUP;
goto out_put;
}

/*
* We want to set the generation to 0, that way if anything goes wrong
* from here on out we know not to trust this cache when we load up next
Expand Down Expand Up @@ -2756,26 +2763,25 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
num_pages *= 16;
num_pages *= PAGE_CACHE_SIZE;

ret = btrfs_delalloc_reserve_space(inode, num_pages);
ret = btrfs_check_data_free_space(inode, num_pages);
if (ret)
goto out_put;

ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
num_pages, num_pages,
&alloc_hint);
if (!ret) {
if (!ret)
dcs = BTRFS_DC_SETUP;
btrfs_free_reserved_data_space(inode, num_pages);
} else {
btrfs_delalloc_release_space(inode, num_pages);
}
btrfs_free_reserved_data_space(inode, num_pages);

out_put:
iput(inode);
out_free:
btrfs_release_path(path);
out:
spin_lock(&block_group->lock);
if (!ret)
block_group->cache_generation = trans->transid;
block_group->disk_cache_state = dcs;
spin_unlock(&block_group->lock);

Expand Down
Loading

0 comments on commit c405c89

Please sign in to comment.