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.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fa2907d531a2..9e23ffea7f54 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2677,6 +2677,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
2677 2677
2678 INIT_LIST_HEAD(&found->block_groups); 2678 INIT_LIST_HEAD(&found->block_groups);
2679 init_rwsem(&found->groups_sem); 2679 init_rwsem(&found->groups_sem);
2680 init_waitqueue_head(&found->flush_wait);
2681 init_waitqueue_head(&found->allocate_wait);
2680 spin_lock_init(&found->lock); 2682 spin_lock_init(&found->lock);
2681 found->flags = flags; 2683 found->flags = flags;
2682 found->total_bytes = total_bytes; 2684 found->total_bytes = total_bytes;
@@ -2847,7 +2849,7 @@ int btrfs_unreserve_metadata_for_delalloc(struct btrfs_root *root,
2847 } 2849 }
2848 spin_unlock(&BTRFS_I(inode)->accounting_lock); 2850 spin_unlock(&BTRFS_I(inode)->accounting_lock);
2849 2851
2850 BTRFS_I(inode)->reserved_extents--; 2852 BTRFS_I(inode)->reserved_extents -= num_items;
2851 BUG_ON(BTRFS_I(inode)->reserved_extents < 0); 2853 BUG_ON(BTRFS_I(inode)->reserved_extents < 0);
2852 2854
2853 if (meta_sinfo->bytes_delalloc < num_bytes) { 2855 if (meta_sinfo->bytes_delalloc < num_bytes) {
@@ -2945,12 +2947,10 @@ static void flush_delalloc(struct btrfs_root *root,
2945 2947
2946 spin_lock(&info->lock); 2948 spin_lock(&info->lock);
2947 2949
2948 if (!info->flushing) { 2950 if (!info->flushing)
2949 info->flushing = 1; 2951 info->flushing = 1;
2950 init_waitqueue_head(&info->flush_wait); 2952 else
2951 } else {
2952 wait = true; 2953 wait = true;
2953 }
2954 2954
2955 spin_unlock(&info->lock); 2955 spin_unlock(&info->lock);
2956 2956
@@ -3012,7 +3012,6 @@ static int maybe_allocate_chunk(struct btrfs_root *root,
3012 if (!info->allocating_chunk) { 3012 if (!info->allocating_chunk) {
3013 info->force_alloc = 1; 3013 info->force_alloc = 1;
3014 info->allocating_chunk = 1; 3014 info->allocating_chunk = 1;
3015 init_waitqueue_head(&info->allocate_wait);
3016 } else { 3015 } else {
3017 wait = true; 3016 wait = true;
3018 } 3017 }
@@ -3112,7 +3111,7 @@ again:
3112 return -ENOSPC; 3111 return -ENOSPC;
3113 } 3112 }
3114 3113
3115 BTRFS_I(inode)->reserved_extents++; 3114 BTRFS_I(inode)->reserved_extents += num_items;
3116 check_force_delalloc(meta_sinfo); 3115 check_force_delalloc(meta_sinfo);
3117 spin_unlock(&meta_sinfo->lock); 3116 spin_unlock(&meta_sinfo->lock);
3118 3117
@@ -4171,6 +4170,10 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
4171 ins->offset = 0; 4170 ins->offset = 0;
4172 4171
4173 space_info = __find_space_info(root->fs_info, data); 4172 space_info = __find_space_info(root->fs_info, data);
4173 if (!space_info) {
4174 printk(KERN_ERR "No space info for %d\n", data);
4175 return -ENOSPC;
4176 }
4174 4177
4175 if (orig_root->ref_cows || empty_size) 4178 if (orig_root->ref_cows || empty_size)
4176 allowed_chunk_alloc = 1; 4179 allowed_chunk_alloc = 1;
@@ -5206,6 +5209,8 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
5206 next = btrfs_find_tree_block(root, bytenr, blocksize); 5209 next = btrfs_find_tree_block(root, bytenr, blocksize);
5207 if (!next) { 5210 if (!next) {
5208 next = btrfs_find_create_tree_block(root, bytenr, blocksize); 5211 next = btrfs_find_create_tree_block(root, bytenr, blocksize);
5212 if (!next)
5213 return -ENOMEM;
5209 reada = 1; 5214 reada = 1;
5210 } 5215 }
5211 btrfs_tree_lock(next); 5216 btrfs_tree_lock(next);
@@ -5418,7 +5423,8 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
5418 if (ret > 0) { 5423 if (ret > 0) {
5419 path->slots[level]++; 5424 path->slots[level]++;
5420 continue; 5425 continue;
5421 } 5426 } else if (ret < 0)
5427 return ret;
5422 level = wc->level; 5428 level = wc->level;
5423 } 5429 }
5424 return 0; 5430 return 0;
@@ -7370,7 +7376,6 @@ static int find_first_block_group(struct btrfs_root *root,
7370 } 7376 }
7371 path->slots[0]++; 7377 path->slots[0]++;
7372 } 7378 }
7373 ret = -ENOENT;
7374out: 7379out:
7375 return ret; 7380 return ret;
7376} 7381}