diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-12-13 11:13:32 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:58 -0400 |
commit | f6dbff55d77dee363c22873481db54d3bada3ea6 (patch) | |
tree | 9a669d43101730bd48044e4943ea833fc2320c15 /fs | |
parent | 6caab489c5866788ae64a72986520b1f0e40c706 (diff) |
Btrfs: Reorder extent back refs to differentiate btree blocks from file data
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.h | 4 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 035fa1550343..052555ced44d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -37,11 +37,12 @@ extern struct kmem_cache *btrfs_path_cachep; | |||
37 | 37 | ||
38 | #define BTRFS_MAGIC "_B2RfS_M" | 38 | #define BTRFS_MAGIC "_B2RfS_M" |
39 | 39 | ||
40 | #define BTRFS_MAX_LEVEL 8 | ||
40 | #define BTRFS_ROOT_TREE_OBJECTID 1ULL | 41 | #define BTRFS_ROOT_TREE_OBJECTID 1ULL |
41 | #define BTRFS_EXTENT_TREE_OBJECTID 2ULL | 42 | #define BTRFS_EXTENT_TREE_OBJECTID 2ULL |
42 | #define BTRFS_FS_TREE_OBJECTID 3ULL | 43 | #define BTRFS_FS_TREE_OBJECTID 3ULL |
43 | #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL | 44 | #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL |
44 | #define BTRFS_FIRST_FREE_OBJECTID 5ULL | 45 | #define BTRFS_FIRST_FREE_OBJECTID 256ULL |
45 | 46 | ||
46 | /* | 47 | /* |
47 | * we can actually store much bigger names, but lets not confuse the rest | 48 | * we can actually store much bigger names, but lets not confuse the rest |
@@ -107,7 +108,6 @@ struct btrfs_header { | |||
107 | u8 level; | 108 | u8 level; |
108 | } __attribute__ ((__packed__)); | 109 | } __attribute__ ((__packed__)); |
109 | 110 | ||
110 | #define BTRFS_MAX_LEVEL 8 | ||
111 | #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ | 111 | #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ |
112 | sizeof(struct btrfs_header)) / \ | 112 | sizeof(struct btrfs_header)) / \ |
113 | sizeof(struct btrfs_key_ptr)) | 113 | sizeof(struct btrfs_key_ptr)) |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 057cdd49c09b..00414836e963 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -520,13 +520,13 @@ out: | |||
520 | * | 520 | * |
521 | * When a tree block is created, back references are inserted: | 521 | * When a tree block is created, back references are inserted: |
522 | * | 522 | * |
523 | * (root->root_key.objectid, trans->transid or zero, lowest_key_objectid, level) | 523 | * (root->root_key.objectid, trans->transid or zero, level, lowest_key_objectid) |
524 | * | 524 | * |
525 | * When a tree block is cow'd in a reference counted root, | 525 | * When a tree block is cow'd in a reference counted root, |
526 | * new back references are added for all the blocks it points to. | 526 | * new back references are added for all the blocks it points to. |
527 | * These are of the form (trans->transid will have increased since creation): | 527 | * These are of the form (trans->transid will have increased since creation): |
528 | * | 528 | * |
529 | * (root->root_key.objectid, trans->transid, lowest_key_objectid, level) | 529 | * (root->root_key.objectid, trans->transid, level, lowest_key_objectid) |
530 | * | 530 | * |
531 | * Because the lowest_key_objectid and the level are just hints | 531 | * Because the lowest_key_objectid and the level are just hints |
532 | * they are not used when backrefs are deleted. When a backref is deleted: | 532 | * they are not used when backrefs are deleted. When a backref is deleted: |
@@ -702,7 +702,7 @@ int btrfs_inc_root_ref(struct btrfs_trans_handle *trans, | |||
702 | } | 702 | } |
703 | return btrfs_inc_extent_ref(trans, root, root->node->start, | 703 | return btrfs_inc_extent_ref(trans, root, root->node->start, |
704 | root->node->len, owner_objectid, | 704 | root->node->len, owner_objectid, |
705 | generation, key_objectid, level); | 705 | generation, level, key_objectid); |
706 | } | 706 | } |
707 | 707 | ||
708 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 708 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
@@ -750,8 +750,8 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
750 | ret = btrfs_inc_extent_ref(trans, root, bytenr, | 750 | ret = btrfs_inc_extent_ref(trans, root, bytenr, |
751 | btrfs_level_size(root, level - 1), | 751 | btrfs_level_size(root, level - 1), |
752 | root->root_key.objectid, | 752 | root->root_key.objectid, |
753 | trans->transid, key.objectid, | 753 | trans->transid, |
754 | level - 1); | 754 | level - 1, key.objectid); |
755 | if (ret) { | 755 | if (ret) { |
756 | faili = i; | 756 | faili = i; |
757 | goto fail; | 757 | goto fail; |
@@ -1063,8 +1063,8 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct | |||
1063 | } | 1063 | } |
1064 | err = btrfs_insert_extent_backref(trans, extent_root, path, | 1064 | err = btrfs_insert_extent_backref(trans, extent_root, path, |
1065 | start, extent_root->root_key.objectid, | 1065 | start, extent_root->root_key.objectid, |
1066 | 0, btrfs_disk_key_objectid(&first), | 1066 | 0, level, |
1067 | level); | 1067 | btrfs_disk_key_objectid(&first)); |
1068 | BUG_ON(err); | 1068 | BUG_ON(err); |
1069 | free_extent_buffer(eb); | 1069 | free_extent_buffer(eb); |
1070 | } | 1070 | } |
@@ -1640,7 +1640,7 @@ struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
1640 | 1640 | ||
1641 | ret = btrfs_alloc_extent(trans, root, blocksize, | 1641 | ret = btrfs_alloc_extent(trans, root, blocksize, |
1642 | root_objectid, ref_generation, | 1642 | root_objectid, ref_generation, |
1643 | first_objectid, level, empty_size, hint, | 1643 | level, first_objectid, empty_size, hint, |
1644 | (u64)-1, &ins, 0); | 1644 | (u64)-1, &ins, 0); |
1645 | if (ret) { | 1645 | if (ret) { |
1646 | BUG_ON(ret > 0); | 1646 | BUG_ON(ret > 0); |