diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-12-11 09:25:06 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:58 -0400 |
commit | 74493f7a59bfd4d1c7029c74ab2cd0e400612c6b (patch) | |
tree | b5fc75b08d2edcf8218c814ea02ab6c548e73652 /fs/btrfs/ctree.c | |
parent | 17636e03f42a1a42fed3834859de4702bd655fd1 (diff) |
Btrfs: Implement generation numbers in block pointers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 3b16051b121b..5697705f7530 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -114,6 +114,9 @@ static int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
114 | } else { | 114 | } else { |
115 | btrfs_set_node_blockptr(parent, parent_slot, | 115 | btrfs_set_node_blockptr(parent, parent_slot, |
116 | cow->start); | 116 | cow->start); |
117 | WARN_ON(trans->transid == 0); | ||
118 | btrfs_set_node_ptr_generation(parent, parent_slot, | ||
119 | trans->transid); | ||
117 | btrfs_mark_buffer_dirty(parent); | 120 | btrfs_mark_buffer_dirty(parent); |
118 | WARN_ON(btrfs_header_generation(parent) != trans->transid); | 121 | WARN_ON(btrfs_header_generation(parent) != trans->transid); |
119 | btrfs_free_extent(trans, root, buf->start, buf->len, 1); | 122 | btrfs_free_extent(trans, root, buf->start, buf->len, 1); |
@@ -967,6 +970,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root | |||
967 | { | 970 | { |
968 | struct extent_buffer *b; | 971 | struct extent_buffer *b; |
969 | u64 bytenr; | 972 | u64 bytenr; |
973 | u64 ptr_gen; | ||
970 | int slot; | 974 | int slot; |
971 | int ret; | 975 | int ret; |
972 | int level; | 976 | int level; |
@@ -1031,10 +1035,18 @@ again: | |||
1031 | if (level == lowest_level) | 1035 | if (level == lowest_level) |
1032 | break; | 1036 | break; |
1033 | bytenr = btrfs_node_blockptr(b, slot); | 1037 | bytenr = btrfs_node_blockptr(b, slot); |
1038 | ptr_gen = btrfs_node_ptr_generation(b, slot); | ||
1034 | if (should_reada) | 1039 | if (should_reada) |
1035 | reada_for_search(root, p, level, slot); | 1040 | reada_for_search(root, p, level, slot); |
1036 | b = read_tree_block(root, bytenr, | 1041 | b = read_tree_block(root, bytenr, |
1037 | btrfs_level_size(root, level - 1)); | 1042 | btrfs_level_size(root, level - 1)); |
1043 | if (ptr_gen != btrfs_header_generation(b)) { | ||
1044 | printk("block %llu bad gen wanted %llu " | ||
1045 | "found %llu\n", | ||
1046 | (unsigned long long)b->start, | ||
1047 | (unsigned long long)ptr_gen, | ||
1048 | (unsigned long long)btrfs_header_generation(b)); | ||
1049 | } | ||
1038 | } else { | 1050 | } else { |
1039 | p->slots[level] = slot; | 1051 | p->slots[level] = slot; |
1040 | if (ins_len > 0 && btrfs_leaf_free_space(root, b) < | 1052 | if (ins_len > 0 && btrfs_leaf_free_space(root, b) < |
@@ -1218,6 +1230,8 @@ static int insert_new_root(struct btrfs_trans_handle *trans, | |||
1218 | btrfs_node_key(lower, &lower_key, 0); | 1230 | btrfs_node_key(lower, &lower_key, 0); |
1219 | btrfs_set_node_key(c, &lower_key, 0); | 1231 | btrfs_set_node_key(c, &lower_key, 0); |
1220 | btrfs_set_node_blockptr(c, 0, lower->start); | 1232 | btrfs_set_node_blockptr(c, 0, lower->start); |
1233 | WARN_ON(btrfs_header_generation(lower) == 0); | ||
1234 | btrfs_set_node_ptr_generation(c, 0, btrfs_header_generation(lower)); | ||
1221 | 1235 | ||
1222 | btrfs_mark_buffer_dirty(c); | 1236 | btrfs_mark_buffer_dirty(c); |
1223 | 1237 | ||
@@ -1261,6 +1275,8 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1261 | } | 1275 | } |
1262 | btrfs_set_node_key(lower, key, slot); | 1276 | btrfs_set_node_key(lower, key, slot); |
1263 | btrfs_set_node_blockptr(lower, slot, bytenr); | 1277 | btrfs_set_node_blockptr(lower, slot, bytenr); |
1278 | WARN_ON(trans->transid == 0); | ||
1279 | btrfs_set_node_ptr_generation(lower, slot, trans->transid); | ||
1264 | btrfs_set_header_nritems(lower, nritems + 1); | 1280 | btrfs_set_header_nritems(lower, nritems + 1); |
1265 | btrfs_mark_buffer_dirty(lower); | 1281 | btrfs_mark_buffer_dirty(lower); |
1266 | return 0; | 1282 | return 0; |