diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-06 20:08:01 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-06 20:08:01 -0500 |
commit | a28ec19775d62d673b034082128aca95780d3737 (patch) | |
tree | 105694ca29ed0ad6563c45a86df9a7df1abf94ff /fs/btrfs/ctree.c | |
parent | 02217ed299c6340a35696e0610047eb96826de2d (diff) |
Btrfs: Fixup reference counting on cows
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 1118986d7569..72816381d203 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -50,16 +50,17 @@ int btrfs_cow_block(struct ctree_root *root, | |||
50 | memcpy(&cow->node, &buf->node, sizeof(buf->node)); | 50 | memcpy(&cow->node, &buf->node, sizeof(buf->node)); |
51 | cow->node.header.blocknr = cow->blocknr; | 51 | cow->node.header.blocknr = cow->blocknr; |
52 | *cow_ret = cow; | 52 | *cow_ret = cow; |
53 | btrfs_inc_ref(root, buf); | ||
53 | if (buf == root->node) { | 54 | if (buf == root->node) { |
54 | root->node = cow; | 55 | root->node = cow; |
55 | cow->count++; | 56 | cow->count++; |
57 | if (buf != root->commit_root) | ||
58 | free_extent(root, buf->blocknr, 1); | ||
56 | tree_block_release(root, buf); | 59 | tree_block_release(root, buf); |
57 | } else { | 60 | } else { |
58 | parent->node.blockptrs[parent_slot] = cow->blocknr; | 61 | parent->node.blockptrs[parent_slot] = cow->blocknr; |
59 | BUG_ON(list_empty(&parent->dirty)); | 62 | BUG_ON(list_empty(&parent->dirty)); |
60 | } | 63 | free_extent(root, buf->blocknr, 1); |
61 | if (0 && root != root->extent_root && !is_leaf(cow->node.header.flags)) { | ||
62 | btrfs_inc_ref(root, cow); | ||
63 | } | 64 | } |
64 | tree_block_release(root, buf); | 65 | tree_block_release(root, buf); |
65 | return 0; | 66 | return 0; |
@@ -1018,7 +1019,6 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1018 | slot = path->slots[0]; | 1019 | slot = path->slots[0]; |
1019 | nritems = l->header.nritems; | 1020 | nritems = l->header.nritems; |
1020 | mid = (nritems + 1)/ 2; | 1021 | mid = (nritems + 1)/ 2; |
1021 | |||
1022 | right_buffer = alloc_free_block(root); | 1022 | right_buffer = alloc_free_block(root); |
1023 | BUG_ON(!right_buffer); | 1023 | BUG_ON(!right_buffer); |
1024 | BUG_ON(mid == nritems); | 1024 | BUG_ON(mid == nritems); |
@@ -1170,7 +1170,6 @@ static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level, | |||
1170 | 1170 | ||
1171 | node = &parent->node; | 1171 | node = &parent->node; |
1172 | nritems = node->header.nritems; | 1172 | nritems = node->header.nritems; |
1173 | |||
1174 | if (slot != nritems -1) { | 1173 | if (slot != nritems -1) { |
1175 | memmove(node->keys + slot, node->keys + slot + 1, | 1174 | memmove(node->keys + slot, node->keys + slot + 1, |
1176 | sizeof(struct key) * (nritems - slot - 1)); | 1175 | sizeof(struct key) * (nritems - slot - 1)); |