aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h67
1 files changed, 51 insertions, 16 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b3bc65b08c6a..ad2cbe63503c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -469,6 +469,15 @@ struct btrfs_root_item {
469 u8 level; 469 u8 level;
470} __attribute__ ((__packed__)); 470} __attribute__ ((__packed__));
471 471
472/*
473 * this is used for both forward and backward root refs
474 */
475struct btrfs_root_ref {
476 __le64 dirid;
477 __le64 sequence;
478 __le16 name_len;
479} __attribute__ ((__packed__));
480
472#define BTRFS_FILE_EXTENT_INLINE 0 481#define BTRFS_FILE_EXTENT_INLINE 0
473#define BTRFS_FILE_EXTENT_REG 1 482#define BTRFS_FILE_EXTENT_REG 1
474#define BTRFS_FILE_EXTENT_PREALLOC 2 483#define BTRFS_FILE_EXTENT_PREALLOC 2
@@ -814,27 +823,27 @@ struct btrfs_root {
814 * the FS 823 * the FS
815 */ 824 */
816#define BTRFS_INODE_ITEM_KEY 1 825#define BTRFS_INODE_ITEM_KEY 1
817#define BTRFS_INODE_REF_KEY 2 826#define BTRFS_INODE_REF_KEY 12
818#define BTRFS_XATTR_ITEM_KEY 8 827#define BTRFS_XATTR_ITEM_KEY 24
819#define BTRFS_ORPHAN_ITEM_KEY 9 828#define BTRFS_ORPHAN_ITEM_KEY 48
820/* reserve 2-15 close to the inode for later flexibility */ 829/* reserve 2-15 close to the inode for later flexibility */
821 830
822/* 831/*
823 * dir items are the name -> inode pointers in a directory. There is one 832 * dir items are the name -> inode pointers in a directory. There is one
824 * for every name in a directory. 833 * for every name in a directory.
825 */ 834 */
826#define BTRFS_DIR_LOG_ITEM_KEY 14 835#define BTRFS_DIR_LOG_ITEM_KEY 60
827#define BTRFS_DIR_LOG_INDEX_KEY 15 836#define BTRFS_DIR_LOG_INDEX_KEY 72
828#define BTRFS_DIR_ITEM_KEY 16 837#define BTRFS_DIR_ITEM_KEY 84
829#define BTRFS_DIR_INDEX_KEY 17 838#define BTRFS_DIR_INDEX_KEY 96
830/* 839/*
831 * extent data is for file data 840 * extent data is for file data
832 */ 841 */
833#define BTRFS_EXTENT_DATA_KEY 18 842#define BTRFS_EXTENT_DATA_KEY 108
834/* 843/*
835 * csum items have the checksums for data in the extents 844 * csum items have the checksums for data in the extents
836 */ 845 */
837#define BTRFS_CSUM_ITEM_KEY 19 846#define BTRFS_CSUM_ITEM_KEY 120
838 847
839 848
840/* reserve 21-31 for other file/dir stuff */ 849/* reserve 21-31 for other file/dir stuff */
@@ -843,23 +852,37 @@ struct btrfs_root {
843 * root items point to tree roots. There are typically in the root 852 * root items point to tree roots. There are typically in the root
844 * tree used by the super block to find all the other trees 853 * tree used by the super block to find all the other trees
845 */ 854 */
846#define BTRFS_ROOT_ITEM_KEY 32 855#define BTRFS_ROOT_ITEM_KEY 132
856
857/*
858 * root backrefs tie subvols and snapshots to the directory entries that
859 * reference them
860 */
861#define BTRFS_ROOT_BACKREF_KEY 144
862
863/*
864 * root refs make a fast index for listing all of the snapshots and
865 * subvolumes referenced by a given root. They point directly to the
866 * directory item in the root that references the subvol
867 */
868#define BTRFS_ROOT_REF_KEY 156
869
847/* 870/*
848 * extent items are in the extent map tree. These record which blocks 871 * extent items are in the extent map tree. These record which blocks
849 * are used, and how many references there are to each block 872 * are used, and how many references there are to each block
850 */ 873 */
851#define BTRFS_EXTENT_ITEM_KEY 33 874#define BTRFS_EXTENT_ITEM_KEY 168
852#define BTRFS_EXTENT_REF_KEY 34 875#define BTRFS_EXTENT_REF_KEY 180
853 876
854/* 877/*
855 * block groups give us hints into the extent allocation trees. Which 878 * block groups give us hints into the extent allocation trees. Which
856 * blocks are free etc etc 879 * blocks are free etc etc
857 */ 880 */
858#define BTRFS_BLOCK_GROUP_ITEM_KEY 50 881#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
859 882
860#define BTRFS_DEV_EXTENT_KEY 75 883#define BTRFS_DEV_EXTENT_KEY 204
861#define BTRFS_DEV_ITEM_KEY 76 884#define BTRFS_DEV_ITEM_KEY 216
862#define BTRFS_CHUNK_ITEM_KEY 77 885#define BTRFS_CHUNK_ITEM_KEY 228
863 886
864/* 887/*
865 * string items are for debugging. They just store a short string of 888 * string items are for debugging. They just store a short string of
@@ -1274,6 +1297,13 @@ static inline void btrfs_set_item_key(struct extent_buffer *eb,
1274 1297
1275BTRFS_SETGET_FUNCS(dir_log_end, struct btrfs_dir_log_item, end, 64); 1298BTRFS_SETGET_FUNCS(dir_log_end, struct btrfs_dir_log_item, end, 64);
1276 1299
1300/*
1301 * struct btrfs_root_ref
1302 */
1303BTRFS_SETGET_FUNCS(root_ref_dirid, struct btrfs_root_ref, dirid, 64);
1304BTRFS_SETGET_FUNCS(root_ref_sequence, struct btrfs_root_ref, sequence, 64);
1305BTRFS_SETGET_FUNCS(root_ref_name_len, struct btrfs_root_ref, name_len, 16);
1306
1277/* struct btrfs_dir_item */ 1307/* struct btrfs_dir_item */
1278BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16); 1308BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16);
1279BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8); 1309BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8);
@@ -1771,6 +1801,11 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
1771 struct extent_buffer *node, 1801 struct extent_buffer *node,
1772 struct extent_buffer *parent); 1802 struct extent_buffer *parent);
1773/* root-item.c */ 1803/* root-item.c */
1804int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
1805 struct btrfs_root *tree_root,
1806 u64 root_id, u8 type, u64 ref_id,
1807 u64 dirid, u64 sequence,
1808 const char *name, int name_len);
1774int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1809int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1775 struct btrfs_key *key); 1810 struct btrfs_key *key);
1776int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root 1811int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root