diff options
author | Zheng Yan <zheng.yan@oracle.com> | 2008-09-23 13:14:14 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:07 -0400 |
commit | 31840ae1a6b433ca0e6a8d341756ff478bbf959e (patch) | |
tree | 9343db596aec175e9640aa2800b80f01496d7047 /fs/btrfs/ctree.h | |
parent | 1c2308f8e7d8491467e0095af2b01500f1b70819 (diff) |
Btrfs: Full back reference support
This patch makes the back reference system to explicit record the
location of parent node for all types of extents. The location of
parent node is placed into the offset field of backref key. Every
time a tree block is balanced, the back references for the affected
lower level extents are updated.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 730aae3bc181..138c157bbc45 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -40,7 +40,7 @@ extern struct kmem_cache *btrfs_bit_radix_cachep; | |||
40 | extern struct kmem_cache *btrfs_path_cachep; | 40 | extern struct kmem_cache *btrfs_path_cachep; |
41 | struct btrfs_ordered_sum; | 41 | struct btrfs_ordered_sum; |
42 | 42 | ||
43 | #define BTRFS_MAGIC "_B8RfS_M" | 43 | #define BTRFS_MAGIC "_B9RfS_M" |
44 | 44 | ||
45 | #define BTRFS_ACL_NOT_CACHED ((void *)-1) | 45 | #define BTRFS_ACL_NOT_CACHED ((void *)-1) |
46 | 46 | ||
@@ -81,6 +81,9 @@ struct btrfs_ordered_sum; | |||
81 | #define BTRFS_TREE_LOG_OBJECTID -6ULL | 81 | #define BTRFS_TREE_LOG_OBJECTID -6ULL |
82 | #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL | 82 | #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL |
83 | 83 | ||
84 | /* dummy objectid represents multiple objectids */ | ||
85 | #define BTRFS_MULTIPLE_OBJECTIDS -255ULL | ||
86 | |||
84 | /* | 87 | /* |
85 | * All files have objectids in this range. | 88 | * All files have objectids in this range. |
86 | */ | 89 | */ |
@@ -369,6 +372,7 @@ struct btrfs_extent_ref { | |||
369 | __le64 generation; | 372 | __le64 generation; |
370 | __le64 objectid; | 373 | __le64 objectid; |
371 | __le64 offset; | 374 | __le64 offset; |
375 | __le32 num_refs; | ||
372 | } __attribute__ ((__packed__)); | 376 | } __attribute__ ((__packed__)); |
373 | 377 | ||
374 | /* dev extents record free space on individual devices. The owner | 378 | /* dev extents record free space on individual devices. The owner |
@@ -1047,9 +1051,6 @@ btrfs_inode_otime(struct btrfs_inode_item *inode_item) | |||
1047 | BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); | 1051 | BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); |
1048 | BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); | 1052 | BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); |
1049 | 1053 | ||
1050 | /* struct btrfs_extent_item */ | ||
1051 | BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); | ||
1052 | |||
1053 | /* struct btrfs_dev_extent */ | 1054 | /* struct btrfs_dev_extent */ |
1054 | BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, | 1055 | BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, |
1055 | chunk_tree, 64); | 1056 | chunk_tree, 64); |
@@ -1070,14 +1071,20 @@ BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64); | |||
1070 | BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64); | 1071 | BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64); |
1071 | BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); | 1072 | BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); |
1072 | BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64); | 1073 | BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64); |
1074 | BTRFS_SETGET_FUNCS(ref_num_refs, struct btrfs_extent_ref, num_refs, 32); | ||
1073 | 1075 | ||
1074 | BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 64); | 1076 | BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 64); |
1075 | BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref, | 1077 | BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref, |
1076 | generation, 64); | 1078 | generation, 64); |
1077 | BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref, | 1079 | BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref, |
1078 | objectid, 64); | 1080 | objectid, 64); |
1079 | BTRFS_SETGET_STACK_FUNCS(stack_ref_offset, struct btrfs_extent_ref, offset, 64); | 1081 | BTRFS_SETGET_STACK_FUNCS(stack_ref_offset, struct btrfs_extent_ref, |
1082 | offset, 64); | ||
1083 | BTRFS_SETGET_STACK_FUNCS(stack_ref_num_refs, struct btrfs_extent_ref, | ||
1084 | num_refs, 32); | ||
1080 | 1085 | ||
1086 | /* struct btrfs_extent_item */ | ||
1087 | BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); | ||
1081 | BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, | 1088 | BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, |
1082 | refs, 32); | 1089 | refs, 32); |
1083 | 1090 | ||
@@ -1474,8 +1481,7 @@ static inline struct dentry *fdentry(struct file *file) { | |||
1474 | } | 1481 | } |
1475 | 1482 | ||
1476 | /* extent-tree.c */ | 1483 | /* extent-tree.c */ |
1477 | int btrfs_lookup_extent(struct btrfs_root *root, struct btrfs_path *path, | 1484 | int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); |
1478 | u64 start, u64 len); | ||
1479 | int btrfs_update_pinned_extents(struct btrfs_root *root, | 1485 | int btrfs_update_pinned_extents(struct btrfs_root *root, |
1480 | u64 bytenr, u64 num, int pin); | 1486 | u64 bytenr, u64 num, int pin); |
1481 | int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, | 1487 | int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, |
@@ -1495,10 +1501,9 @@ struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root, | |||
1495 | int data, int owner); | 1501 | int data, int owner); |
1496 | struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | 1502 | struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, |
1497 | struct btrfs_root *root, | 1503 | struct btrfs_root *root, |
1498 | u32 blocksize, | 1504 | u32 blocksize, u64 parent, |
1499 | u64 root_objectid, | 1505 | u64 root_objectid, |
1500 | u64 ref_generation, | 1506 | u64 ref_generation, |
1501 | u64 first_objectid, | ||
1502 | int level, | 1507 | int level, |
1503 | u64 hint, | 1508 | u64 hint, |
1504 | u64 empty_size); | 1509 | u64 empty_size); |
@@ -1508,23 +1513,24 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, | |||
1508 | int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size); | 1513 | int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size); |
1509 | int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans, | 1514 | int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans, |
1510 | struct btrfs_root *root, | 1515 | struct btrfs_root *root, |
1511 | struct btrfs_path *path, u64 bytenr, | 1516 | struct btrfs_path *path, |
1517 | u64 bytenr, u64 parent, | ||
1512 | u64 root_objectid, u64 ref_generation, | 1518 | u64 root_objectid, u64 ref_generation, |
1513 | u64 owner, u64 owner_offset); | 1519 | u64 owner, u64 owner_offset); |
1514 | int btrfs_alloc_extent(struct btrfs_trans_handle *trans, | 1520 | int btrfs_alloc_extent(struct btrfs_trans_handle *trans, |
1515 | struct btrfs_root *root, | 1521 | struct btrfs_root *root, |
1516 | u64 num_bytes, u64 min_bytes, | 1522 | u64 num_bytes, u64 parent, u64 min_bytes, |
1517 | u64 root_objectid, u64 ref_generation, | 1523 | u64 root_objectid, u64 ref_generation, |
1518 | u64 owner, u64 owner_offset, | 1524 | u64 owner, u64 owner_offset, |
1519 | u64 empty_size, u64 hint_byte, | 1525 | u64 empty_size, u64 hint_byte, |
1520 | u64 search_end, struct btrfs_key *ins, u64 data); | 1526 | u64 search_end, struct btrfs_key *ins, u64 data); |
1521 | int btrfs_alloc_reserved_extent(struct btrfs_trans_handle *trans, | 1527 | int btrfs_alloc_reserved_extent(struct btrfs_trans_handle *trans, |
1522 | struct btrfs_root *root, | 1528 | struct btrfs_root *root, u64 parent, |
1523 | u64 root_objectid, u64 ref_generation, | 1529 | u64 root_objectid, u64 ref_generation, |
1524 | u64 owner, u64 owner_offset, | 1530 | u64 owner, u64 owner_offset, |
1525 | struct btrfs_key *ins); | 1531 | struct btrfs_key *ins); |
1526 | int btrfs_alloc_logged_extent(struct btrfs_trans_handle *trans, | 1532 | int btrfs_alloc_logged_extent(struct btrfs_trans_handle *trans, |
1527 | struct btrfs_root *root, | 1533 | struct btrfs_root *root, u64 parent, |
1528 | u64 root_objectid, u64 ref_generation, | 1534 | u64 root_objectid, u64 ref_generation, |
1529 | u64 owner, u64 owner_offset, | 1535 | u64 owner, u64 owner_offset, |
1530 | struct btrfs_key *ins); | 1536 | struct btrfs_key *ins); |
@@ -1535,9 +1541,16 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans, | |||
1535 | u64 search_end, struct btrfs_key *ins, | 1541 | u64 search_end, struct btrfs_key *ins, |
1536 | u64 data); | 1542 | u64 data); |
1537 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 1543 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1538 | struct extent_buffer *buf, int cache_ref); | 1544 | struct extent_buffer *orig_buf, struct extent_buffer *buf, |
1539 | int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | 1545 | u32 *nr_extents); |
1540 | *root, u64 bytenr, u64 num_bytes, | 1546 | int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
1547 | struct extent_buffer *buf, u32 nr_extents); | ||
1548 | int btrfs_update_ref(struct btrfs_trans_handle *trans, | ||
1549 | struct btrfs_root *root, struct extent_buffer *orig_buf, | ||
1550 | struct extent_buffer *buf, int start_slot, int nr); | ||
1551 | int btrfs_free_extent(struct btrfs_trans_handle *trans, | ||
1552 | struct btrfs_root *root, | ||
1553 | u64 bytenr, u64 num_bytes, u64 parent, | ||
1541 | u64 root_objectid, u64 ref_generation, | 1554 | u64 root_objectid, u64 ref_generation, |
1542 | u64 owner_objectid, u64 owner_offset, int pin); | 1555 | u64 owner_objectid, u64 owner_offset, int pin); |
1543 | int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); | 1556 | int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); |
@@ -1545,10 +1558,15 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, | |||
1545 | struct btrfs_root *root, | 1558 | struct btrfs_root *root, |
1546 | struct extent_io_tree *unpin); | 1559 | struct extent_io_tree *unpin); |
1547 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, | 1560 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, |
1548 | struct btrfs_root *root, | 1561 | struct btrfs_root *root, |
1549 | u64 bytenr, u64 num_bytes, | 1562 | u64 bytenr, u64 num_bytes, u64 parent, |
1550 | u64 root_objectid, u64 ref_generation, | 1563 | u64 root_objectid, u64 ref_generation, |
1551 | u64 owner, u64 owner_offset); | 1564 | u64 owner, u64 owner_offset); |
1565 | int btrfs_update_extent_ref(struct btrfs_trans_handle *trans, | ||
1566 | struct btrfs_root *root, u64 bytenr, | ||
1567 | u64 orig_parent, u64 parent, | ||
1568 | u64 root_objectid, u64 ref_generation, | ||
1569 | u64 owner, u64 owner_offset); | ||
1552 | int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, | 1570 | int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, |
1553 | struct btrfs_root *root); | 1571 | struct btrfs_root *root); |
1554 | int btrfs_free_block_groups(struct btrfs_fs_info *info); | 1572 | int btrfs_free_block_groups(struct btrfs_fs_info *info); |
@@ -1561,7 +1579,9 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
1561 | int btrfs_previous_item(struct btrfs_root *root, | 1579 | int btrfs_previous_item(struct btrfs_root *root, |
1562 | struct btrfs_path *path, u64 min_objectid, | 1580 | struct btrfs_path *path, u64 min_objectid, |
1563 | int type); | 1581 | int type); |
1564 | 1582 | int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, | |
1583 | struct btrfs_root *root, struct btrfs_path *path, | ||
1584 | struct btrfs_key *new_key); | ||
1565 | struct extent_buffer *btrfs_root_node(struct btrfs_root *root); | 1585 | struct extent_buffer *btrfs_root_node(struct btrfs_root *root); |
1566 | struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); | 1586 | struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); |
1567 | int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, | 1587 | int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, |