diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index ae8518cb94bf..7748eecd9304 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef __BTRFS__ | 1 | #ifndef __BTRFS__ |
2 | #define __BTRFS__ | 2 | #define __BTRFS__ |
3 | 3 | ||
4 | #include <linux/radix-tree.h> | ||
5 | #include <linux/fs.h> | ||
6 | |||
4 | struct btrfs_trans_handle; | 7 | struct btrfs_trans_handle; |
5 | 8 | ||
6 | #define BTRFS_MAGIC "_BtRfS_M" | 9 | #define BTRFS_MAGIC "_BtRfS_M" |
@@ -11,6 +14,12 @@ struct btrfs_trans_handle; | |||
11 | #define BTRFS_FS_TREE_OBJECTID 4 | 14 | #define BTRFS_FS_TREE_OBJECTID 4 |
12 | 15 | ||
13 | /* | 16 | /* |
17 | * we can actually store much bigger names, but lets not confuse the rest | ||
18 | * of linux | ||
19 | */ | ||
20 | #define BTRFS_NAME_LEN 255 | ||
21 | |||
22 | /* | ||
14 | * the key defines the order in the tree, and so it also defines (optimal) | 23 | * the key defines the order in the tree, and so it also defines (optimal) |
15 | * block layout. objectid corresonds to the inode number. The flags | 24 | * block layout. objectid corresonds to the inode number. The flags |
16 | * tells us things about the object, and is a kind of stream selector. | 25 | * tells us things about the object, and is a kind of stream selector. |
@@ -57,7 +66,7 @@ struct btrfs_header { | |||
57 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) | 66 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) |
58 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->blocksize)) | 67 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->blocksize)) |
59 | 68 | ||
60 | struct btrfs_buffer; | 69 | struct buffer_head; |
61 | /* | 70 | /* |
62 | * the super block basically lists the main trees of the FS | 71 | * the super block basically lists the main trees of the FS |
63 | * it currently lacks any block count etc etc | 72 | * it currently lacks any block count etc etc |
@@ -120,7 +129,7 @@ struct btrfs_node { | |||
120 | * used while walking the tree. | 129 | * used while walking the tree. |
121 | */ | 130 | */ |
122 | struct btrfs_path { | 131 | struct btrfs_path { |
123 | struct btrfs_buffer *nodes[BTRFS_MAX_LEVEL]; | 132 | struct buffer_head *nodes[BTRFS_MAX_LEVEL]; |
124 | int slots[BTRFS_MAX_LEVEL]; | 133 | int slots[BTRFS_MAX_LEVEL]; |
125 | }; | 134 | }; |
126 | 135 | ||
@@ -211,17 +220,14 @@ struct btrfs_fs_info { | |||
211 | struct btrfs_root *inode_root; | 220 | struct btrfs_root *inode_root; |
212 | struct btrfs_key current_insert; | 221 | struct btrfs_key current_insert; |
213 | struct btrfs_key last_insert; | 222 | struct btrfs_key last_insert; |
214 | struct radix_tree_root cache_radix; | ||
215 | struct radix_tree_root pinned_radix; | 223 | struct radix_tree_root pinned_radix; |
216 | struct list_head trans; | ||
217 | struct list_head cache; | ||
218 | u64 last_inode_alloc; | 224 | u64 last_inode_alloc; |
219 | u64 last_inode_alloc_dirid; | 225 | u64 last_inode_alloc_dirid; |
220 | u64 generation; | 226 | u64 generation; |
221 | int cache_size; | ||
222 | int fp; | ||
223 | struct btrfs_trans_handle *running_transaction; | 227 | struct btrfs_trans_handle *running_transaction; |
224 | struct btrfs_super_block *disk_super; | 228 | struct btrfs_super_block *disk_super; |
229 | struct buffer_head *sb_buffer; | ||
230 | struct super_block *sb; | ||
225 | }; | 231 | }; |
226 | 232 | ||
227 | /* | 233 | /* |
@@ -230,8 +236,8 @@ struct btrfs_fs_info { | |||
230 | * only for the extent tree. | 236 | * only for the extent tree. |
231 | */ | 237 | */ |
232 | struct btrfs_root { | 238 | struct btrfs_root { |
233 | struct btrfs_buffer *node; | 239 | struct buffer_head *node; |
234 | struct btrfs_buffer *commit_root; | 240 | struct buffer_head *commit_root; |
235 | struct btrfs_root_item root_item; | 241 | struct btrfs_root_item root_item; |
236 | struct btrfs_key root_key; | 242 | struct btrfs_key root_key; |
237 | struct btrfs_fs_info *fs_info; | 243 | struct btrfs_fs_info *fs_info; |
@@ -389,6 +395,29 @@ static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item *i, | |||
389 | i->compat_flags = cpu_to_le16(val); | 395 | i->compat_flags = cpu_to_le16(val); |
390 | } | 396 | } |
391 | 397 | ||
398 | static inline u32 btrfs_timespec_sec(struct btrfs_inode_timespec *ts) | ||
399 | { | ||
400 | return le32_to_cpu(ts->sec); | ||
401 | } | ||
402 | |||
403 | static inline void btrfs_set_timespec_sec(struct btrfs_inode_timespec *ts, | ||
404 | u32 val) | ||
405 | { | ||
406 | ts->sec = cpu_to_le32(val); | ||
407 | } | ||
408 | |||
409 | static inline u32 btrfs_timespec_nsec(struct btrfs_inode_timespec *ts) | ||
410 | { | ||
411 | return le32_to_cpu(ts->nsec); | ||
412 | } | ||
413 | |||
414 | static inline void btrfs_set_timespec_nsec(struct btrfs_inode_timespec *ts, | ||
415 | u32 val) | ||
416 | { | ||
417 | ts->nsec = cpu_to_le32(val); | ||
418 | } | ||
419 | |||
420 | |||
392 | 421 | ||
393 | static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei) | 422 | static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei) |
394 | { | 423 | { |
@@ -757,15 +786,20 @@ static inline void btrfs_set_file_extent_num_blocks(struct | |||
757 | e->num_blocks = cpu_to_le64(val); | 786 | e->num_blocks = cpu_to_le64(val); |
758 | } | 787 | } |
759 | 788 | ||
789 | static inline struct btrfs_root *btrfs_sb(struct super_block *sb) | ||
790 | { | ||
791 | return sb->s_fs_info; | ||
792 | } | ||
793 | |||
760 | /* helper function to cast into the data area of the leaf. */ | 794 | /* helper function to cast into the data area of the leaf. */ |
761 | #define btrfs_item_ptr(leaf, slot, type) \ | 795 | #define btrfs_item_ptr(leaf, slot, type) \ |
762 | ((type *)(btrfs_leaf_data(leaf) + \ | 796 | ((type *)(btrfs_leaf_data(leaf) + \ |
763 | btrfs_item_offset((leaf)->items + (slot)))) | 797 | btrfs_item_offset((leaf)->items + (slot)))) |
764 | 798 | ||
765 | struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | 799 | struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, |
766 | struct btrfs_root *root); | 800 | struct btrfs_root *root); |
767 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 801 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
768 | struct btrfs_buffer *buf); | 802 | struct buffer_head *buf); |
769 | int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | 803 | int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root |
770 | *root, u64 blocknr, u64 num_blocks, int pin); | 804 | *root, u64 blocknr, u64 num_blocks, int pin); |
771 | int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root | 805 | int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root |
@@ -783,7 +817,7 @@ int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
783 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); | 817 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); |
784 | int btrfs_leaf_free_space(struct btrfs_root *root, struct btrfs_leaf *leaf); | 818 | int btrfs_leaf_free_space(struct btrfs_root *root, struct btrfs_leaf *leaf); |
785 | int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root | 819 | int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root |
786 | *root, struct btrfs_buffer *snap); | 820 | *root, struct buffer_head *snap); |
787 | int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct | 821 | int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct |
788 | btrfs_root *root); | 822 | btrfs_root *root); |
789 | int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 823 | int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
@@ -800,8 +834,8 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
800 | *root, char *name, int name_len, u64 dir, u64 | 834 | *root, char *name, int name_len, u64 dir, u64 |
801 | objectid, u8 type); | 835 | objectid, u8 type); |
802 | int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | 836 | int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root |
803 | *root, struct btrfs_path *path, u64 dir, char *name, | 837 | *root, struct btrfs_path *path, u64 dir, |
804 | int name_len, int mod); | 838 | const char *name, int name_len, int mod); |
805 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, | 839 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, |
806 | char *name, int name_len); | 840 | char *name, int name_len); |
807 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | 841 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, |