diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-23 15:56:19 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-23 15:56:19 -0400 |
commit | 7f5c15160e1436a53d01f9190db11c2a3a4d788a (patch) | |
tree | ae9894ab743aca4ff4c1f50ada5a5ed665a88c21 /fs/btrfs/ctree.c | |
parent | df2ce34c8801af8e00c7f82435fcb1e4b45a2759 (diff) |
Add generation number to btrfs_header, readdir fixes, hash collision fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 052434a328ec..b33a6bfaf327 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include "ctree.h" | 2 | #include "ctree.h" |
3 | #include "disk-io.h" | 3 | #include "disk-io.h" |
4 | #include "transaction.h" | ||
4 | 5 | ||
5 | static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root | 6 | static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root |
6 | *root, struct btrfs_path *path, int level); | 7 | *root, struct btrfs_path *path, int level); |
@@ -39,7 +40,8 @@ static int btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root | |||
39 | struct buffer_head *cow; | 40 | struct buffer_head *cow; |
40 | struct btrfs_node *cow_node; | 41 | struct btrfs_node *cow_node; |
41 | 42 | ||
42 | if (buffer_dirty(buf)) { | 43 | if (btrfs_header_generation(btrfs_buffer_header(buf)) == |
44 | trans->transid) { | ||
43 | *cow_ret = buf; | 45 | *cow_ret = buf; |
44 | return 0; | 46 | return 0; |
45 | } | 47 | } |
@@ -47,6 +49,7 @@ static int btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root | |||
47 | cow_node = btrfs_buffer_node(cow); | 49 | cow_node = btrfs_buffer_node(cow); |
48 | memcpy(cow_node, btrfs_buffer_node(buf), root->blocksize); | 50 | memcpy(cow_node, btrfs_buffer_node(buf), root->blocksize); |
49 | btrfs_set_header_blocknr(&cow_node->header, cow->b_blocknr); | 51 | btrfs_set_header_blocknr(&cow_node->header, cow->b_blocknr); |
52 | btrfs_set_header_generation(&cow_node->header, trans->transid); | ||
50 | *cow_ret = cow; | 53 | *cow_ret = cow; |
51 | mark_buffer_dirty(cow); | 54 | mark_buffer_dirty(cow); |
52 | btrfs_inc_ref(trans, root, buf); | 55 | btrfs_inc_ref(trans, root, buf); |
@@ -661,6 +664,7 @@ static int insert_new_root(struct btrfs_trans_handle *trans, struct btrfs_root | |||
661 | btrfs_set_header_nritems(&c->header, 1); | 664 | btrfs_set_header_nritems(&c->header, 1); |
662 | btrfs_set_header_level(&c->header, level); | 665 | btrfs_set_header_level(&c->header, level); |
663 | btrfs_set_header_blocknr(&c->header, t->b_blocknr); | 666 | btrfs_set_header_blocknr(&c->header, t->b_blocknr); |
667 | btrfs_set_header_generation(&c->header, trans->transid); | ||
664 | btrfs_set_header_parentid(&c->header, | 668 | btrfs_set_header_parentid(&c->header, |
665 | btrfs_header_parentid(btrfs_buffer_header(root->node))); | 669 | btrfs_header_parentid(btrfs_buffer_header(root->node))); |
666 | lower = btrfs_buffer_node(path->nodes[level-1]); | 670 | lower = btrfs_buffer_node(path->nodes[level-1]); |
@@ -750,6 +754,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root | |||
750 | split = btrfs_buffer_node(split_buffer); | 754 | split = btrfs_buffer_node(split_buffer); |
751 | btrfs_set_header_flags(&split->header, btrfs_header_flags(&c->header)); | 755 | btrfs_set_header_flags(&split->header, btrfs_header_flags(&c->header)); |
752 | btrfs_set_header_blocknr(&split->header, split_buffer->b_blocknr); | 756 | btrfs_set_header_blocknr(&split->header, split_buffer->b_blocknr); |
757 | btrfs_set_header_generation(&split->header, trans->transid); | ||
753 | btrfs_set_header_parentid(&split->header, | 758 | btrfs_set_header_parentid(&split->header, |
754 | btrfs_header_parentid(btrfs_buffer_header(root->node))); | 759 | btrfs_header_parentid(btrfs_buffer_header(root->node))); |
755 | mid = (c_nritems + 1) / 2; | 760 | mid = (c_nritems + 1) / 2; |
@@ -1096,6 +1101,7 @@ static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1096 | } | 1101 | } |
1097 | btrfs_set_header_nritems(&right->header, nritems - mid); | 1102 | btrfs_set_header_nritems(&right->header, nritems - mid); |
1098 | btrfs_set_header_blocknr(&right->header, right_buffer->b_blocknr); | 1103 | btrfs_set_header_blocknr(&right->header, right_buffer->b_blocknr); |
1104 | btrfs_set_header_generation(&right->header, trans->transid); | ||
1099 | btrfs_set_header_level(&right->header, 0); | 1105 | btrfs_set_header_level(&right->header, 0); |
1100 | btrfs_set_header_parentid(&right->header, | 1106 | btrfs_set_header_parentid(&right->header, |
1101 | btrfs_header_parentid(btrfs_buffer_header(root->node))); | 1107 | btrfs_header_parentid(btrfs_buffer_header(root->node))); |