diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-20 14:38:32 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-20 14:38:32 -0400 |
commit | 9f5fae2fe6dc35b46bf56183f11398451851cb3f (patch) | |
tree | e72b03149662b8e5d4fe491c36f3cf66c5df5437 /fs/btrfs/ctree.h | |
parent | 631d7d950a2f2706f5c86858402c1ec50b9801f1 (diff) |
Btrfs: Add inode map, and the start of file extent items
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 129 |
1 files changed, 115 insertions, 14 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 68f0af39777f..68e3da274f17 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -10,7 +10,8 @@ struct btrfs_trans_handle; | |||
10 | 10 | ||
11 | #define BTRFS_ROOT_TREE_OBJECTID 1 | 11 | #define BTRFS_ROOT_TREE_OBJECTID 1 |
12 | #define BTRFS_EXTENT_TREE_OBJECTID 2 | 12 | #define BTRFS_EXTENT_TREE_OBJECTID 2 |
13 | #define BTRFS_FS_TREE_OBJECTID 3 | 13 | #define BTRFS_INODE_MAP_OBJECTID 3 |
14 | #define BTRFS_FS_TREE_OBJECTID 4 | ||
14 | 15 | ||
15 | /* | 16 | /* |
16 | * the key defines the order in the tree, and so it also defines (optimal) | 17 | * the key defines the order in the tree, and so it also defines (optimal) |
@@ -178,31 +179,65 @@ struct btrfs_root_item { | |||
178 | __le64 block_limit; | 179 | __le64 block_limit; |
179 | __le64 blocks_used; | 180 | __le64 blocks_used; |
180 | __le32 refs; | 181 | __le32 refs; |
181 | }; | 182 | } __attribute__ ((__packed__)); |
182 | 183 | ||
183 | /* | 184 | struct btrfs_file_extent_item { |
184 | * in ram representation of the tree. extent_root is used for all allocations | 185 | /* |
185 | * and for the extent tree extent_root root. current_insert is used | 186 | * disk space consumed by the extent, checksum blocks are included |
186 | * only for the extent tree. | 187 | * in these numbers |
187 | */ | 188 | */ |
188 | struct btrfs_root { | 189 | __le64 disk_blocknr; |
189 | struct btrfs_buffer *node; | 190 | __le64 disk_num_blocks; |
190 | struct btrfs_buffer *commit_root; | 191 | /* |
192 | * the logical offset in file bytes (no csums) | ||
193 | * this extent record is for. This allows a file extent to point | ||
194 | * into the middle of an existing extent on disk, sharing it | ||
195 | * between two snapshots (useful if some bytes in the middle of the | ||
196 | * extent have changed | ||
197 | */ | ||
198 | __le64 offset; | ||
199 | /* | ||
200 | * the logical number of file blocks (no csums included) | ||
201 | */ | ||
202 | __le64 num_blocks; | ||
203 | } __attribute__ ((__packed__)); | ||
204 | |||
205 | struct btrfs_inode_map_item { | ||
206 | struct btrfs_disk_key key; | ||
207 | } __attribute__ ((__packed__)); | ||
208 | |||
209 | struct btrfs_fs_info { | ||
210 | struct btrfs_root *fs_root; | ||
191 | struct btrfs_root *extent_root; | 211 | struct btrfs_root *extent_root; |
192 | struct btrfs_root *tree_root; | 212 | struct btrfs_root *tree_root; |
213 | struct btrfs_root *inode_root; | ||
193 | struct btrfs_key current_insert; | 214 | struct btrfs_key current_insert; |
194 | struct btrfs_key last_insert; | 215 | struct btrfs_key last_insert; |
195 | int fp; | ||
196 | struct radix_tree_root cache_radix; | 216 | struct radix_tree_root cache_radix; |
197 | struct radix_tree_root pinned_radix; | 217 | struct radix_tree_root pinned_radix; |
198 | struct list_head trans; | 218 | struct list_head trans; |
199 | struct list_head cache; | 219 | struct list_head cache; |
220 | u64 last_inode_alloc; | ||
221 | u64 last_inode_alloc_dirid; | ||
200 | int cache_size; | 222 | int cache_size; |
201 | int ref_cows; | 223 | int fp; |
224 | struct btrfs_trans_handle *running_transaction; | ||
225 | }; | ||
226 | |||
227 | /* | ||
228 | * in ram representation of the tree. extent_root is used for all allocations | ||
229 | * and for the extent tree extent_root root. current_insert is used | ||
230 | * only for the extent tree. | ||
231 | */ | ||
232 | struct btrfs_root { | ||
233 | struct btrfs_buffer *node; | ||
234 | struct btrfs_buffer *commit_root; | ||
202 | struct btrfs_root_item root_item; | 235 | struct btrfs_root_item root_item; |
203 | struct btrfs_key root_key; | 236 | struct btrfs_key root_key; |
237 | struct btrfs_fs_info *fs_info; | ||
204 | u32 blocksize; | 238 | u32 blocksize; |
205 | struct btrfs_trans_handle *running_transaction; | 239 | int ref_cows; |
240 | u32 type; | ||
206 | }; | 241 | }; |
207 | 242 | ||
208 | /* the lower bits in the key flags defines the item type */ | 243 | /* the lower bits in the key flags defines the item type */ |
@@ -240,11 +275,17 @@ struct btrfs_root { | |||
240 | * are used, and how many references there are to each block | 275 | * are used, and how many references there are to each block |
241 | */ | 276 | */ |
242 | #define BTRFS_EXTENT_ITEM_KEY 6 | 277 | #define BTRFS_EXTENT_ITEM_KEY 6 |
278 | |||
279 | /* | ||
280 | * the inode map records which inode numbers are in use and where | ||
281 | * they actually live on disk | ||
282 | */ | ||
283 | #define BTRFS_INODE_MAP_ITEM_KEY 7 | ||
243 | /* | 284 | /* |
244 | * string items are for debugging. They just store a short string of | 285 | * string items are for debugging. They just store a short string of |
245 | * data in the FS | 286 | * data in the FS |
246 | */ | 287 | */ |
247 | #define BTRFS_STRING_ITEM_KEY 7 | 288 | #define BTRFS_STRING_ITEM_KEY 8 |
248 | 289 | ||
249 | static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) | 290 | static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) |
250 | { | 291 | { |
@@ -654,6 +695,57 @@ static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l) | |||
654 | { | 695 | { |
655 | return (u8 *)l->items; | 696 | return (u8 *)l->items; |
656 | } | 697 | } |
698 | |||
699 | static inline u64 btrfs_file_extent_disk_blocknr(struct btrfs_file_extent_item | ||
700 | *e) | ||
701 | { | ||
702 | return le64_to_cpu(e->disk_blocknr); | ||
703 | } | ||
704 | |||
705 | static inline void btrfs_set_file_extent_disk_blocknr(struct | ||
706 | btrfs_file_extent_item | ||
707 | *e, u64 val) | ||
708 | { | ||
709 | e->disk_blocknr = cpu_to_le64(val); | ||
710 | } | ||
711 | |||
712 | static inline u64 btrfs_file_extent_disk_num_blocks(struct | ||
713 | btrfs_file_extent_item *e) | ||
714 | { | ||
715 | return le64_to_cpu(e->disk_num_blocks); | ||
716 | } | ||
717 | |||
718 | static inline void btrfs_set_file_extent_disk_num_blocks(struct | ||
719 | btrfs_file_extent_item | ||
720 | *e, u64 val) | ||
721 | { | ||
722 | e->disk_num_blocks = cpu_to_le64(val); | ||
723 | } | ||
724 | |||
725 | static inline u64 btrfs_file_extent_offset(struct btrfs_file_extent_item *e) | ||
726 | { | ||
727 | return le64_to_cpu(e->offset); | ||
728 | } | ||
729 | |||
730 | static inline void btrfs_set_file_extent_offset(struct btrfs_file_extent_item | ||
731 | *e, u64 val) | ||
732 | { | ||
733 | e->offset = cpu_to_le64(val); | ||
734 | } | ||
735 | |||
736 | static inline u64 btrfs_file_extent_num_blocks(struct btrfs_file_extent_item | ||
737 | *e) | ||
738 | { | ||
739 | return le64_to_cpu(e->num_blocks); | ||
740 | } | ||
741 | |||
742 | static inline void btrfs_set_file_extent_num_blocks(struct | ||
743 | btrfs_file_extent_item *e, | ||
744 | u64 val) | ||
745 | { | ||
746 | e->num_blocks = cpu_to_le64(val); | ||
747 | } | ||
748 | |||
657 | /* helper function to cast into the data area of the leaf. */ | 749 | /* helper function to cast into the data area of the leaf. */ |
658 | #define btrfs_item_ptr(leaf, slot, type) \ | 750 | #define btrfs_item_ptr(leaf, slot, type) \ |
659 | ((type *)(btrfs_leaf_data(leaf) + \ | 751 | ((type *)(btrfs_leaf_data(leaf) + \ |
@@ -701,4 +793,13 @@ int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
701 | int name_len, int mod); | 793 | int name_len, int mod); |
702 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, | 794 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, |
703 | char *name, int name_len); | 795 | char *name, int name_len); |
796 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | ||
797 | struct btrfs_root *fs_root, | ||
798 | u64 dirid, u64 *objectid); | ||
799 | int btrfs_insert_inode_map(struct btrfs_trans_handle *trans, | ||
800 | struct btrfs_root *root, | ||
801 | u64 objectid, struct btrfs_key *location); | ||
802 | int btrfs_lookup_inode_map(struct btrfs_trans_handle *trans, | ||
803 | struct btrfs_root *root, struct btrfs_path *path, | ||
804 | u64 objectid, int mod); | ||
704 | #endif | 805 | #endif |