aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorZheng Yan <zheng.yan@oracle.com>2008-09-23 13:14:14 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:07 -0400
commit31840ae1a6b433ca0e6a8d341756ff478bbf959e (patch)
tree9343db596aec175e9640aa2800b80f01496d7047 /fs/btrfs/ctree.h
parent1c2308f8e7d8491467e0095af2b01500f1b70819 (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.h62
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;
40extern struct kmem_cache *btrfs_path_cachep; 40extern struct kmem_cache *btrfs_path_cachep;
41struct btrfs_ordered_sum; 41struct 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)
1047BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); 1051BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
1048BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); 1052BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
1049 1053
1050/* struct btrfs_extent_item */
1051BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32);
1052
1053/* struct btrfs_dev_extent */ 1054/* struct btrfs_dev_extent */
1054BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, 1055BTRFS_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);
1070BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64); 1071BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64);
1071BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); 1072BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64);
1072BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64); 1073BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64);
1074BTRFS_SETGET_FUNCS(ref_num_refs, struct btrfs_extent_ref, num_refs, 32);
1073 1075
1074BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 64); 1076BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 64);
1075BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref, 1077BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref,
1076 generation, 64); 1078 generation, 64);
1077BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref, 1079BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref,
1078 objectid, 64); 1080 objectid, 64);
1079BTRFS_SETGET_STACK_FUNCS(stack_ref_offset, struct btrfs_extent_ref, offset, 64); 1081BTRFS_SETGET_STACK_FUNCS(stack_ref_offset, struct btrfs_extent_ref,
1082 offset, 64);
1083BTRFS_SETGET_STACK_FUNCS(stack_ref_num_refs, struct btrfs_extent_ref,
1084 num_refs, 32);
1080 1085
1086/* struct btrfs_extent_item */
1087BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32);
1081BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, 1088BTRFS_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 */
1477int btrfs_lookup_extent(struct btrfs_root *root, struct btrfs_path *path, 1484int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
1478 u64 start, u64 len);
1479int btrfs_update_pinned_extents(struct btrfs_root *root, 1485int btrfs_update_pinned_extents(struct btrfs_root *root,
1480 u64 bytenr, u64 num, int pin); 1486 u64 bytenr, u64 num, int pin);
1481int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, 1487int 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);
1496struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, 1502struct 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,
1508int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size); 1513int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size);
1509int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans, 1514int 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);
1514int btrfs_alloc_extent(struct btrfs_trans_handle *trans, 1520int 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);
1521int btrfs_alloc_reserved_extent(struct btrfs_trans_handle *trans, 1527int 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);
1526int btrfs_alloc_logged_extent(struct btrfs_trans_handle *trans, 1532int 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);
1537int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1543int 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,
1539int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root 1545 u32 *nr_extents);
1540 *root, u64 bytenr, u64 num_bytes, 1546int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1547 struct extent_buffer *buf, u32 nr_extents);
1548int 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);
1551int 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);
1543int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); 1556int 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);
1547int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, 1560int 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);
1565int 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);
1552int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, 1570int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1553 struct btrfs_root *root); 1571 struct btrfs_root *root);
1554int btrfs_free_block_groups(struct btrfs_fs_info *info); 1572int btrfs_free_block_groups(struct btrfs_fs_info *info);
@@ -1561,7 +1579,9 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
1561int btrfs_previous_item(struct btrfs_root *root, 1579int 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 1582int 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);
1565struct extent_buffer *btrfs_root_node(struct btrfs_root *root); 1585struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
1566struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); 1586struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
1567int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, 1587int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,