diff options
Diffstat (limited to 'ctree.h')
-rw-r--r-- | ctree.h | 85 |
1 files changed, 23 insertions, 62 deletions
@@ -26,6 +26,7 @@ #include "extent-cache.h" #include "extent_io.h" #include "ioctl.h" +#include "sizes.h" #else #include <btrfs/list.h> #include <btrfs/kerncompat.h> @@ -33,6 +34,7 @@ #include <btrfs/extent-cache.h> #include <btrfs/extent_io.h> #include <btrfs/ioctl.h> +#include <btrfs/sizes.h> #endif /* BTRFS_FLAT_INCLUDES */ struct btrfs_root; @@ -350,11 +352,11 @@ struct btrfs_header { u8 level; } __attribute__ ((__packed__)); -#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ +#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->fs_info->nodesize - \ sizeof(struct btrfs_header)) / \ sizeof(struct btrfs_key_ptr)) #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) -#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize)) +#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->fs_info->nodesize)) #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ sizeof(struct btrfs_item) - \ sizeof(struct btrfs_file_extent_item)) @@ -438,7 +440,7 @@ struct btrfs_super_block { __le32 sectorsize; __le32 nodesize; /* Unused and must be equal to nodesize */ - __le32 leafsize; + __le32 __unused_leafsize; __le32 stripesize; __le32 sys_chunk_array_size; __le64 chunk_root_generation; @@ -601,7 +603,7 @@ struct btrfs_extent_item_v0 { #define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r) >> 4) - \ sizeof(struct btrfs_item)) -#define BTRFS_MAX_EXTENT_SIZE (128 * 1024 * 1024) +#define BTRFS_MAX_EXTENT_SIZE SZ_128M #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0) #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1) @@ -952,7 +954,7 @@ struct btrfs_csum_item { * - the first 64k blank is useful for some boot loader/manager * - the first 1M could be scratched by buggy partitioner or somesuch */ -#define BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ((u64)1024 * 1024) +#define BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ((u64)SZ_1M) /* tag for the radix tree of block groups in ram */ #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) @@ -1145,6 +1147,10 @@ struct btrfs_fs_info { struct cache_tree *fsck_extent_cache; struct cache_tree *corrupt_blocks; + /* Cached block sizes */ + u32 nodesize; + u32 sectorsize; + u32 stripesize; }; /* @@ -1160,18 +1166,6 @@ struct btrfs_root { u64 objectid; u64 last_trans; - /* data allocations are done in sectorsize units */ - u32 sectorsize; - - /* node allocations are done in nodesize units */ - u32 nodesize; - - /* Unused, equal to nodesize */ - u32 leafsize; - - /* leaf allocations are done in nodesize units */ - u32 stripesize; - int ref_cows; int track_dirty; @@ -2037,33 +2031,12 @@ static inline unsigned long btrfs_header_chunk_tree_uuid(struct extent_buffer *e return offsetof(struct btrfs_header, chunk_tree_uuid); } -static inline u8 *btrfs_super_fsid(struct extent_buffer *eb) -{ - unsigned long ptr = offsetof(struct btrfs_super_block, fsid); - return (u8 *)ptr; -} - static inline u8 *btrfs_header_csum(struct extent_buffer *eb) { unsigned long ptr = offsetof(struct btrfs_header, csum); return (u8 *)ptr; } -static inline struct btrfs_node *btrfs_buffer_node(struct extent_buffer *eb) -{ - return NULL; -} - -static inline struct btrfs_leaf *btrfs_buffer_leaf(struct extent_buffer *eb) -{ - return NULL; -} - -static inline struct btrfs_header *btrfs_buffer_header(struct extent_buffer *eb) -{ - return NULL; -} - static inline int btrfs_is_leaf(struct extent_buffer *eb) { return (btrfs_header_level(eb) == 0); @@ -2178,8 +2151,6 @@ BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block, sectorsize, 32); BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block, nodesize, 32); -BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block, - leafsize, 32); BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block, stripesize, 32); BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block, @@ -2429,17 +2400,6 @@ static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb, return btrfs_file_extent_ram_bytes(eb, fi); } -/* - * NOTE: Backward compatibility, do not use. - * Replacement: read nodesize directly - */ -__attribute__((deprecated)) -static inline u32 btrfs_level_size(struct btrfs_root *root, int level) { - if (level == 0) - return root->leafsize; - return root->nodesize; -} - #define btrfs_fs_incompat(fs_info, opt) \ __btrfs_fs_incompat((fs_info), BTRFS_FEATURE_INCOMPAT_##opt) @@ -2538,11 +2498,11 @@ struct btrfs_block_group_cache * btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset, u64 size); int btrfs_make_block_group(struct btrfs_trans_handle *trans, - struct btrfs_root *root, u64 bytes_used, + struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset, u64 size); int btrfs_make_block_groups(struct btrfs_trans_handle *trans, - struct btrfs_root *root); + struct btrfs_fs_info *fs_info); int btrfs_update_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytenr, u64 num, int alloc, int mark_free); @@ -2563,8 +2523,8 @@ u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset); /* ctree.c */ int btrfs_comp_cpu_keys(struct btrfs_key *k1, struct btrfs_key *k2); -int btrfs_del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct btrfs_path *path, int level, int slot); +int btrfs_del_ptr(struct btrfs_root *root, struct btrfs_path *path, + int level, int slot); enum btrfs_tree_block_status btrfs_check_node(struct btrfs_root *root, struct btrfs_disk_key *parent_key, struct extent_buffer *buf); @@ -2573,7 +2533,7 @@ btrfs_check_leaf(struct btrfs_root *root, struct btrfs_disk_key *parent_key, struct extent_buffer *buf); void reada_for_search(struct btrfs_root *root, struct btrfs_path *path, int level, int slot, u64 objectid); -struct extent_buffer *read_node_slot(struct btrfs_root *root, +struct extent_buffer *read_node_slot(struct btrfs_fs_info *fs_info, struct extent_buffer *parent, int slot); int btrfs_previous_item(struct btrfs_root *root, struct btrfs_path *path, u64 min_objectid, @@ -2596,11 +2556,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *buf, struct extent_buffer **cow_ret, u64 new_root_objectid); -int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root - *root, struct btrfs_path *path, u32 data_size); -int btrfs_truncate_item(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct btrfs_path *path, +int btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path, + u32 data_size); +int btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path, u32 new_size, int from_end); int btrfs_split_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, @@ -2734,7 +2692,7 @@ int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans, struct btrfs_inode_ref *btrfs_lookup_inode_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, const char *name, int namelen, u64 ino, u64 parent_ino, - u64 index, int ins_len); + int ins_len); int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, const char *name, int name_len, u64 ino, u64 parent_ino, u64 *index); @@ -2797,4 +2755,7 @@ int btrfs_get_extent(struct btrfs_trans_handle *trans, int btrfs_punch_hole(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 ino, u64 offset, u64 len); +int btrfs_read_file(struct btrfs_root *root, u64 ino, u64 start, int len, + char *dest); + #endif |