aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 84d7ca1fe0ba..b0e18d986e0a 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -38,11 +38,6 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
38 struct extent_buffer *src_buf); 38 struct extent_buffer *src_buf);
39static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, 39static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
40 struct btrfs_path *path, int level, int slot); 40 struct btrfs_path *path, int level, int slot);
41static int setup_items_for_insert(struct btrfs_trans_handle *trans,
42 struct btrfs_root *root, struct btrfs_path *path,
43 struct btrfs_key *cpu_key, u32 *data_size,
44 u32 total_data, u32 total_size, int nr);
45
46 41
47struct btrfs_path *btrfs_alloc_path(void) 42struct btrfs_path *btrfs_alloc_path(void)
48{ 43{
@@ -107,7 +102,7 @@ void btrfs_free_path(struct btrfs_path *p)
107{ 102{
108 if (!p) 103 if (!p)
109 return; 104 return;
110 btrfs_release_path(NULL, p); 105 btrfs_release_path(p);
111 kmem_cache_free(btrfs_path_cachep, p); 106 kmem_cache_free(btrfs_path_cachep, p);
112} 107}
113 108
@@ -117,7 +112,7 @@ void btrfs_free_path(struct btrfs_path *p)
117 * 112 *
118 * It is safe to call this on paths that no locks or extent buffers held. 113 * It is safe to call this on paths that no locks or extent buffers held.
119 */ 114 */
120noinline void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p) 115noinline void btrfs_release_path(struct btrfs_path *p)
121{ 116{
122 int i; 117 int i;
123 118
@@ -1328,7 +1323,7 @@ static noinline int reada_for_balance(struct btrfs_root *root,
1328 ret = -EAGAIN; 1323 ret = -EAGAIN;
1329 1324
1330 /* release the whole path */ 1325 /* release the whole path */
1331 btrfs_release_path(root, path); 1326 btrfs_release_path(path);
1332 1327
1333 /* read the blocks */ 1328 /* read the blocks */
1334 if (block1) 1329 if (block1)
@@ -1475,7 +1470,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1475 return 0; 1470 return 0;
1476 } 1471 }
1477 free_extent_buffer(tmp); 1472 free_extent_buffer(tmp);
1478 btrfs_release_path(NULL, p); 1473 btrfs_release_path(p);
1479 return -EIO; 1474 return -EIO;
1480 } 1475 }
1481 } 1476 }
@@ -1494,7 +1489,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1494 if (p->reada) 1489 if (p->reada)
1495 reada_for_search(root, p, level, slot, key->objectid); 1490 reada_for_search(root, p, level, slot, key->objectid);
1496 1491
1497 btrfs_release_path(NULL, p); 1492 btrfs_release_path(p);
1498 1493
1499 ret = -EAGAIN; 1494 ret = -EAGAIN;
1500 tmp = read_tree_block(root, blocknr, blocksize, 0); 1495 tmp = read_tree_block(root, blocknr, blocksize, 0);
@@ -1563,7 +1558,7 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
1563 } 1558 }
1564 b = p->nodes[level]; 1559 b = p->nodes[level];
1565 if (!b) { 1560 if (!b) {
1566 btrfs_release_path(NULL, p); 1561 btrfs_release_path(p);
1567 goto again; 1562 goto again;
1568 } 1563 }
1569 BUG_ON(btrfs_header_nritems(b) == 1); 1564 BUG_ON(btrfs_header_nritems(b) == 1);
@@ -1753,7 +1748,7 @@ done:
1753 if (!p->leave_spinning) 1748 if (!p->leave_spinning)
1754 btrfs_set_path_blocking(p); 1749 btrfs_set_path_blocking(p);
1755 if (ret < 0) 1750 if (ret < 0)
1756 btrfs_release_path(root, p); 1751 btrfs_release_path(p);
1757 return ret; 1752 return ret;
1758} 1753}
1759 1754
@@ -3026,7 +3021,7 @@ static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans,
3026 struct btrfs_file_extent_item); 3021 struct btrfs_file_extent_item);
3027 extent_len = btrfs_file_extent_num_bytes(leaf, fi); 3022 extent_len = btrfs_file_extent_num_bytes(leaf, fi);
3028 } 3023 }
3029 btrfs_release_path(root, path); 3024 btrfs_release_path(path);
3030 3025
3031 path->keep_locks = 1; 3026 path->keep_locks = 1;
3032 path->search_for_split = 1; 3027 path->search_for_split = 1;
@@ -3216,7 +3211,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
3216 struct btrfs_path *path, 3211 struct btrfs_path *path,
3217 u32 new_size, int from_end) 3212 u32 new_size, int from_end)
3218{ 3213{
3219 int ret = 0;
3220 int slot; 3214 int slot;
3221 struct extent_buffer *leaf; 3215 struct extent_buffer *leaf;
3222 struct btrfs_item *item; 3216 struct btrfs_item *item;
@@ -3314,12 +3308,11 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
3314 btrfs_set_item_size(leaf, item, new_size); 3308 btrfs_set_item_size(leaf, item, new_size);
3315 btrfs_mark_buffer_dirty(leaf); 3309 btrfs_mark_buffer_dirty(leaf);
3316 3310
3317 ret = 0;
3318 if (btrfs_leaf_free_space(root, leaf) < 0) { 3311 if (btrfs_leaf_free_space(root, leaf) < 0) {
3319 btrfs_print_leaf(root, leaf); 3312 btrfs_print_leaf(root, leaf);
3320 BUG(); 3313 BUG();
3321 } 3314 }
3322 return ret; 3315 return 0;
3323} 3316}
3324 3317
3325/* 3318/*
@@ -3329,7 +3322,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
3329 struct btrfs_root *root, struct btrfs_path *path, 3322 struct btrfs_root *root, struct btrfs_path *path,
3330 u32 data_size) 3323 u32 data_size)
3331{ 3324{
3332 int ret = 0;
3333 int slot; 3325 int slot;
3334 struct extent_buffer *leaf; 3326 struct extent_buffer *leaf;
3335 struct btrfs_item *item; 3327 struct btrfs_item *item;
@@ -3394,12 +3386,11 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
3394 btrfs_set_item_size(leaf, item, old_size + data_size); 3386 btrfs_set_item_size(leaf, item, old_size + data_size);
3395 btrfs_mark_buffer_dirty(leaf); 3387 btrfs_mark_buffer_dirty(leaf);
3396 3388
3397 ret = 0;
3398 if (btrfs_leaf_free_space(root, leaf) < 0) { 3389 if (btrfs_leaf_free_space(root, leaf) < 0) {
3399 btrfs_print_leaf(root, leaf); 3390 btrfs_print_leaf(root, leaf);
3400 BUG(); 3391 BUG();
3401 } 3392 }
3402 return ret; 3393 return 0;
3403} 3394}
3404 3395
3405/* 3396/*
@@ -3559,11 +3550,10 @@ out:
3559 * to save stack depth by doing the bulk of the work in a function 3550 * to save stack depth by doing the bulk of the work in a function
3560 * that doesn't call btrfs_search_slot 3551 * that doesn't call btrfs_search_slot
3561 */ 3552 */
3562static noinline_for_stack int 3553int setup_items_for_insert(struct btrfs_trans_handle *trans,
3563setup_items_for_insert(struct btrfs_trans_handle *trans, 3554 struct btrfs_root *root, struct btrfs_path *path,
3564 struct btrfs_root *root, struct btrfs_path *path, 3555 struct btrfs_key *cpu_key, u32 *data_size,
3565 struct btrfs_key *cpu_key, u32 *data_size, 3556 u32 total_data, u32 total_size, int nr)
3566 u32 total_data, u32 total_size, int nr)
3567{ 3557{
3568 struct btrfs_item *item; 3558 struct btrfs_item *item;
3569 int i; 3559 int i;
@@ -3647,7 +3637,6 @@ setup_items_for_insert(struct btrfs_trans_handle *trans,
3647 3637
3648 ret = 0; 3638 ret = 0;
3649 if (slot == 0) { 3639 if (slot == 0) {
3650 struct btrfs_disk_key disk_key;
3651 btrfs_cpu_key_to_disk(&disk_key, cpu_key); 3640 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
3652 ret = fixup_low_keys(trans, root, path, &disk_key, 1); 3641 ret = fixup_low_keys(trans, root, path, &disk_key, 1);
3653 } 3642 }
@@ -3949,7 +3938,7 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path)
3949 else 3938 else
3950 return 1; 3939 return 1;
3951 3940
3952 btrfs_release_path(root, path); 3941 btrfs_release_path(path);
3953 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 3942 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
3954 if (ret < 0) 3943 if (ret < 0)
3955 return ret; 3944 return ret;
@@ -4073,7 +4062,7 @@ find_next_key:
4073 sret = btrfs_find_next_key(root, path, min_key, level, 4062 sret = btrfs_find_next_key(root, path, min_key, level,
4074 cache_only, min_trans); 4063 cache_only, min_trans);
4075 if (sret == 0) { 4064 if (sret == 0) {
4076 btrfs_release_path(root, path); 4065 btrfs_release_path(path);
4077 goto again; 4066 goto again;
4078 } else { 4067 } else {
4079 goto out; 4068 goto out;
@@ -4152,7 +4141,7 @@ next:
4152 btrfs_node_key_to_cpu(c, &cur_key, slot); 4141 btrfs_node_key_to_cpu(c, &cur_key, slot);
4153 4142
4154 orig_lowest = path->lowest_level; 4143 orig_lowest = path->lowest_level;
4155 btrfs_release_path(root, path); 4144 btrfs_release_path(path);
4156 path->lowest_level = level; 4145 path->lowest_level = level;
4157 ret = btrfs_search_slot(NULL, root, &cur_key, path, 4146 ret = btrfs_search_slot(NULL, root, &cur_key, path,
4158 0, 0); 4147 0, 0);
@@ -4229,7 +4218,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
4229again: 4218again:
4230 level = 1; 4219 level = 1;
4231 next = NULL; 4220 next = NULL;
4232 btrfs_release_path(root, path); 4221 btrfs_release_path(path);
4233 4222
4234 path->keep_locks = 1; 4223 path->keep_locks = 1;
4235 4224
@@ -4285,7 +4274,7 @@ again:
4285 goto again; 4274 goto again;
4286 4275
4287 if (ret < 0) { 4276 if (ret < 0) {
4288 btrfs_release_path(root, path); 4277 btrfs_release_path(path);
4289 goto done; 4278 goto done;
4290 } 4279 }
4291 4280
@@ -4324,7 +4313,7 @@ again:
4324 goto again; 4313 goto again;
4325 4314
4326 if (ret < 0) { 4315 if (ret < 0) {
4327 btrfs_release_path(root, path); 4316 btrfs_release_path(path);
4328 goto done; 4317 goto done;
4329 } 4318 }
4330 4319