aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index ddaf6340fe7f..8c56f5b38948 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2742,6 +2742,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
2742 struct btrfs_root *root = block_group->fs_info->tree_root; 2742 struct btrfs_root *root = block_group->fs_info->tree_root;
2743 struct inode *inode = NULL; 2743 struct inode *inode = NULL;
2744 u64 alloc_hint = 0; 2744 u64 alloc_hint = 0;
2745 int dcs = BTRFS_DC_ERROR;
2745 int num_pages = 0; 2746 int num_pages = 0;
2746 int retries = 0; 2747 int retries = 0;
2747 int ret = 0; 2748 int ret = 0;
@@ -2796,6 +2797,8 @@ again:
2796 2797
2797 spin_lock(&block_group->lock); 2798 spin_lock(&block_group->lock);
2798 if (block_group->cached != BTRFS_CACHE_FINISHED) { 2799 if (block_group->cached != BTRFS_CACHE_FINISHED) {
2800 /* We're not cached, don't bother trying to write stuff out */
2801 dcs = BTRFS_DC_WRITTEN;
2799 spin_unlock(&block_group->lock); 2802 spin_unlock(&block_group->lock);
2800 goto out_put; 2803 goto out_put;
2801 } 2804 }
@@ -2822,6 +2825,8 @@ again:
2822 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages, 2825 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
2823 num_pages, num_pages, 2826 num_pages, num_pages,
2824 &alloc_hint); 2827 &alloc_hint);
2828 if (!ret)
2829 dcs = BTRFS_DC_SETUP;
2825 btrfs_free_reserved_data_space(inode, num_pages); 2830 btrfs_free_reserved_data_space(inode, num_pages);
2826out_put: 2831out_put:
2827 iput(inode); 2832 iput(inode);
@@ -2829,10 +2834,7 @@ out_free:
2829 btrfs_release_path(root, path); 2834 btrfs_release_path(root, path);
2830out: 2835out:
2831 spin_lock(&block_group->lock); 2836 spin_lock(&block_group->lock);
2832 if (ret) 2837 block_group->disk_cache_state = dcs;
2833 block_group->disk_cache_state = BTRFS_DC_ERROR;
2834 else
2835 block_group->disk_cache_state = BTRFS_DC_SETUP;
2836 spin_unlock(&block_group->lock); 2838 spin_unlock(&block_group->lock);
2837 2839
2838 return ret; 2840 return ret;