diff options
author | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-16 11:04:52 -0400 |
---|---|---|
committer | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-26 06:17:53 -0400 |
commit | 5581a51a59a1f5f51ac3d4bacafb738d35e0350b (patch) | |
tree | d7e291e139d08f2be7870c9da602658df8f51ce8 | |
parent | 976b1908d97bd8cbd024ba7aafaa3fb637ea8e13 (diff) |
Btrfs: don't set for_cow parameter for tree block functions
Three callers of btrfs_free_tree_block or btrfs_alloc_tree_block passed
parameter for_cow = 1. In fact, these two functions should never mark
their tree modification operations as for_cow, because they can change
the number of blocks referenced by a tree.
Hence, we remove the extra for_cow parameter from these functions and
make them pass a zero down.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
-rw-r--r-- | fs/btrfs/ctree.c | 22 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 4 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 2 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 10 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 2 |
5 files changed, 20 insertions, 20 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 4106264fbc65..56485b3b7c31 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -255,7 +255,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, | |||
255 | 255 | ||
256 | cow = btrfs_alloc_free_block(trans, root, buf->len, 0, | 256 | cow = btrfs_alloc_free_block(trans, root, buf->len, 0, |
257 | new_root_objectid, &disk_key, level, | 257 | new_root_objectid, &disk_key, level, |
258 | buf->start, 0, 1); | 258 | buf->start, 0); |
259 | if (IS_ERR(cow)) | 259 | if (IS_ERR(cow)) |
260 | return PTR_ERR(cow); | 260 | return PTR_ERR(cow); |
261 | 261 | ||
@@ -467,7 +467,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
467 | 467 | ||
468 | cow = btrfs_alloc_free_block(trans, root, buf->len, parent_start, | 468 | cow = btrfs_alloc_free_block(trans, root, buf->len, parent_start, |
469 | root->root_key.objectid, &disk_key, | 469 | root->root_key.objectid, &disk_key, |
470 | level, search_start, empty_size, 1); | 470 | level, search_start, empty_size); |
471 | if (IS_ERR(cow)) | 471 | if (IS_ERR(cow)) |
472 | return PTR_ERR(cow); | 472 | return PTR_ERR(cow); |
473 | 473 | ||
@@ -509,7 +509,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
509 | rcu_assign_pointer(root->node, cow); | 509 | rcu_assign_pointer(root->node, cow); |
510 | 510 | ||
511 | btrfs_free_tree_block(trans, root, buf, parent_start, | 511 | btrfs_free_tree_block(trans, root, buf, parent_start, |
512 | last_ref, 1); | 512 | last_ref); |
513 | free_extent_buffer(buf); | 513 | free_extent_buffer(buf); |
514 | add_root_to_dirty_list(root); | 514 | add_root_to_dirty_list(root); |
515 | } else { | 515 | } else { |
@@ -525,7 +525,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
525 | trans->transid); | 525 | trans->transid); |
526 | btrfs_mark_buffer_dirty(parent); | 526 | btrfs_mark_buffer_dirty(parent); |
527 | btrfs_free_tree_block(trans, root, buf, parent_start, | 527 | btrfs_free_tree_block(trans, root, buf, parent_start, |
528 | last_ref, 1); | 528 | last_ref); |
529 | } | 529 | } |
530 | if (unlock_orig) | 530 | if (unlock_orig) |
531 | btrfs_tree_unlock(buf); | 531 | btrfs_tree_unlock(buf); |
@@ -987,7 +987,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
987 | free_extent_buffer(mid); | 987 | free_extent_buffer(mid); |
988 | 988 | ||
989 | root_sub_used(root, mid->len); | 989 | root_sub_used(root, mid->len); |
990 | btrfs_free_tree_block(trans, root, mid, 0, 1, 0); | 990 | btrfs_free_tree_block(trans, root, mid, 0, 1); |
991 | /* once for the root ptr */ | 991 | /* once for the root ptr */ |
992 | free_extent_buffer_stale(mid); | 992 | free_extent_buffer_stale(mid); |
993 | return 0; | 993 | return 0; |
@@ -1042,7 +1042,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
1042 | btrfs_tree_unlock(right); | 1042 | btrfs_tree_unlock(right); |
1043 | del_ptr(trans, root, path, level + 1, pslot + 1); | 1043 | del_ptr(trans, root, path, level + 1, pslot + 1); |
1044 | root_sub_used(root, right->len); | 1044 | root_sub_used(root, right->len); |
1045 | btrfs_free_tree_block(trans, root, right, 0, 1, 0); | 1045 | btrfs_free_tree_block(trans, root, right, 0, 1); |
1046 | free_extent_buffer_stale(right); | 1046 | free_extent_buffer_stale(right); |
1047 | right = NULL; | 1047 | right = NULL; |
1048 | } else { | 1048 | } else { |
@@ -1084,7 +1084,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
1084 | btrfs_tree_unlock(mid); | 1084 | btrfs_tree_unlock(mid); |
1085 | del_ptr(trans, root, path, level + 1, pslot); | 1085 | del_ptr(trans, root, path, level + 1, pslot); |
1086 | root_sub_used(root, mid->len); | 1086 | root_sub_used(root, mid->len); |
1087 | btrfs_free_tree_block(trans, root, mid, 0, 1, 0); | 1087 | btrfs_free_tree_block(trans, root, mid, 0, 1); |
1088 | free_extent_buffer_stale(mid); | 1088 | free_extent_buffer_stale(mid); |
1089 | mid = NULL; | 1089 | mid = NULL; |
1090 | } else { | 1090 | } else { |
@@ -2129,7 +2129,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, | |||
2129 | 2129 | ||
2130 | c = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 2130 | c = btrfs_alloc_free_block(trans, root, root->nodesize, 0, |
2131 | root->root_key.objectid, &lower_key, | 2131 | root->root_key.objectid, &lower_key, |
2132 | level, root->node->start, 0, 0); | 2132 | level, root->node->start, 0); |
2133 | if (IS_ERR(c)) | 2133 | if (IS_ERR(c)) |
2134 | return PTR_ERR(c); | 2134 | return PTR_ERR(c); |
2135 | 2135 | ||
@@ -2252,7 +2252,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans, | |||
2252 | 2252 | ||
2253 | split = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 2253 | split = btrfs_alloc_free_block(trans, root, root->nodesize, 0, |
2254 | root->root_key.objectid, | 2254 | root->root_key.objectid, |
2255 | &disk_key, level, c->start, 0, 0); | 2255 | &disk_key, level, c->start, 0); |
2256 | if (IS_ERR(split)) | 2256 | if (IS_ERR(split)) |
2257 | return PTR_ERR(split); | 2257 | return PTR_ERR(split); |
2258 | 2258 | ||
@@ -3004,7 +3004,7 @@ again: | |||
3004 | 3004 | ||
3005 | right = btrfs_alloc_free_block(trans, root, root->leafsize, 0, | 3005 | right = btrfs_alloc_free_block(trans, root, root->leafsize, 0, |
3006 | root->root_key.objectid, | 3006 | root->root_key.objectid, |
3007 | &disk_key, 0, l->start, 0, 0); | 3007 | &disk_key, 0, l->start, 0); |
3008 | if (IS_ERR(right)) | 3008 | if (IS_ERR(right)) |
3009 | return PTR_ERR(right); | 3009 | return PTR_ERR(right); |
3010 | 3010 | ||
@@ -3804,7 +3804,7 @@ static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans, | |||
3804 | root_sub_used(root, leaf->len); | 3804 | root_sub_used(root, leaf->len); |
3805 | 3805 | ||
3806 | extent_buffer_get(leaf); | 3806 | extent_buffer_get(leaf); |
3807 | btrfs_free_tree_block(trans, root, leaf, 0, 1, 0); | 3807 | btrfs_free_tree_block(trans, root, leaf, 0, 1); |
3808 | free_extent_buffer_stale(leaf); | 3808 | free_extent_buffer_stale(leaf); |
3809 | } | 3809 | } |
3810 | /* | 3810 | /* |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index ec42a24e935e..e863188a3f17 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2496,11 +2496,11 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
2496 | struct btrfs_root *root, u32 blocksize, | 2496 | struct btrfs_root *root, u32 blocksize, |
2497 | u64 parent, u64 root_objectid, | 2497 | u64 parent, u64 root_objectid, |
2498 | struct btrfs_disk_key *key, int level, | 2498 | struct btrfs_disk_key *key, int level, |
2499 | u64 hint, u64 empty_size, int for_cow); | 2499 | u64 hint, u64 empty_size); |
2500 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | 2500 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, |
2501 | struct btrfs_root *root, | 2501 | struct btrfs_root *root, |
2502 | struct extent_buffer *buf, | 2502 | struct extent_buffer *buf, |
2503 | u64 parent, int last_ref, int for_cow); | 2503 | u64 parent, int last_ref); |
2504 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, | 2504 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, |
2505 | struct btrfs_root *root, | 2505 | struct btrfs_root *root, |
2506 | u64 bytenr, u32 blocksize, | 2506 | u64 bytenr, u32 blocksize, |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a7ffc88a7dbe..f43307492518 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1252,7 +1252,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, | |||
1252 | 1252 | ||
1253 | leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0, | 1253 | leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0, |
1254 | BTRFS_TREE_LOG_OBJECTID, NULL, | 1254 | BTRFS_TREE_LOG_OBJECTID, NULL, |
1255 | 0, 0, 0, 0); | 1255 | 0, 0, 0); |
1256 | if (IS_ERR(leaf)) { | 1256 | if (IS_ERR(leaf)) { |
1257 | kfree(root); | 1257 | kfree(root); |
1258 | return ERR_CAST(leaf); | 1258 | return ERR_CAST(leaf); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 49fd7b66d57b..b68eb7ad05a7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -5217,7 +5217,7 @@ out: | |||
5217 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | 5217 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, |
5218 | struct btrfs_root *root, | 5218 | struct btrfs_root *root, |
5219 | struct extent_buffer *buf, | 5219 | struct extent_buffer *buf, |
5220 | u64 parent, int last_ref, int for_cow) | 5220 | u64 parent, int last_ref) |
5221 | { | 5221 | { |
5222 | struct btrfs_block_group_cache *cache = NULL; | 5222 | struct btrfs_block_group_cache *cache = NULL; |
5223 | int ret; | 5223 | int ret; |
@@ -5227,7 +5227,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | |||
5227 | buf->start, buf->len, | 5227 | buf->start, buf->len, |
5228 | parent, root->root_key.objectid, | 5228 | parent, root->root_key.objectid, |
5229 | btrfs_header_level(buf), | 5229 | btrfs_header_level(buf), |
5230 | BTRFS_DROP_DELAYED_REF, NULL, for_cow); | 5230 | BTRFS_DROP_DELAYED_REF, NULL, 0); |
5231 | BUG_ON(ret); /* -ENOMEM */ | 5231 | BUG_ON(ret); /* -ENOMEM */ |
5232 | } | 5232 | } |
5233 | 5233 | ||
@@ -6249,7 +6249,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
6249 | struct btrfs_root *root, u32 blocksize, | 6249 | struct btrfs_root *root, u32 blocksize, |
6250 | u64 parent, u64 root_objectid, | 6250 | u64 parent, u64 root_objectid, |
6251 | struct btrfs_disk_key *key, int level, | 6251 | struct btrfs_disk_key *key, int level, |
6252 | u64 hint, u64 empty_size, int for_cow) | 6252 | u64 hint, u64 empty_size) |
6253 | { | 6253 | { |
6254 | struct btrfs_key ins; | 6254 | struct btrfs_key ins; |
6255 | struct btrfs_block_rsv *block_rsv; | 6255 | struct btrfs_block_rsv *block_rsv; |
@@ -6297,7 +6297,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
6297 | ins.objectid, | 6297 | ins.objectid, |
6298 | ins.offset, parent, root_objectid, | 6298 | ins.offset, parent, root_objectid, |
6299 | level, BTRFS_ADD_DELAYED_EXTENT, | 6299 | level, BTRFS_ADD_DELAYED_EXTENT, |
6300 | extent_op, for_cow); | 6300 | extent_op, 0); |
6301 | BUG_ON(ret); /* -ENOMEM */ | 6301 | BUG_ON(ret); /* -ENOMEM */ |
6302 | } | 6302 | } |
6303 | return buf; | 6303 | return buf; |
@@ -6715,7 +6715,7 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans, | |||
6715 | btrfs_header_owner(path->nodes[level + 1])); | 6715 | btrfs_header_owner(path->nodes[level + 1])); |
6716 | } | 6716 | } |
6717 | 6717 | ||
6718 | btrfs_free_tree_block(trans, root, eb, parent, wc->refs[level] == 1, 0); | 6718 | btrfs_free_tree_block(trans, root, eb, parent, wc->refs[level] == 1); |
6719 | out: | 6719 | out: |
6720 | wc->refs[level] = 0; | 6720 | wc->refs[level] = 0; |
6721 | wc->flags[level] = 0; | 6721 | wc->flags[level] = 0; |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 14f8e1faa46e..7f3a91367d77 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -367,7 +367,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
367 | return PTR_ERR(trans); | 367 | return PTR_ERR(trans); |
368 | 368 | ||
369 | leaf = btrfs_alloc_free_block(trans, root, root->leafsize, | 369 | leaf = btrfs_alloc_free_block(trans, root, root->leafsize, |
370 | 0, objectid, NULL, 0, 0, 0, 0); | 370 | 0, objectid, NULL, 0, 0, 0); |
371 | if (IS_ERR(leaf)) { | 371 | if (IS_ERR(leaf)) { |
372 | ret = PTR_ERR(leaf); | 372 | ret = PTR_ERR(leaf); |
373 | goto fail; | 373 | goto fail; |