ctree.h (e089f05c18ab36ed5fa7e2319052e03ab800d518) ctree.h (9f5fae2fe6dc35b46bf56183f11398451851cb3f)
1#ifndef __BTRFS__
2#define __BTRFS__
3
4#include "list.h"
5#include "kerncompat.h"
6
7struct btrfs_trans_handle;
8
9#define BTRFS_MAGIC "_BtRfS_M"
10
11#define BTRFS_ROOT_TREE_OBJECTID 1
12#define BTRFS_EXTENT_TREE_OBJECTID 2
1#ifndef __BTRFS__
2#define __BTRFS__
3
4#include "list.h"
5#include "kerncompat.h"
6
7struct btrfs_trans_handle;
8
9#define BTRFS_MAGIC "_BtRfS_M"
10
11#define BTRFS_ROOT_TREE_OBJECTID 1
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/*
16 * the key defines the order in the tree, and so it also defines (optimal)
17 * block layout. objectid corresonds to the inode number. The flags
18 * tells us things about the object, and is a kind of stream selector.
19 * so for a given inode, keys with flags of 1 might refer to the inode
20 * data, flags of 2 may point to file data in the btree and flags == 3
21 * may point to extents.

--- 151 unchanged lines hidden (view full) ---

173} __attribute__ ((__packed__));
174
175struct btrfs_root_item {
176 __le64 blocknr;
177 __le32 flags;
178 __le64 block_limit;
179 __le64 blocks_used;
180 __le32 refs;
15
16/*
17 * the key defines the order in the tree, and so it also defines (optimal)
18 * block layout. objectid corresonds to the inode number. The flags
19 * tells us things about the object, and is a kind of stream selector.
20 * so for a given inode, keys with flags of 1 might refer to the inode
21 * data, flags of 2 may point to file data in the btree and flags == 3
22 * may point to extents.

--- 151 unchanged lines hidden (view full) ---

174} __attribute__ ((__packed__));
175
176struct btrfs_root_item {
177 __le64 blocknr;
178 __le32 flags;
179 __le64 block_limit;
180 __le64 blocks_used;
181 __le32 refs;
181};
182} __attribute__ ((__packed__));
182
183
183/*
184 * in ram representation of the tree. extent_root is used for all allocations
185 * and for the extent tree extent_root root. current_insert is used
186 * only for the extent tree.
187 */
188struct btrfs_root {
189 struct btrfs_buffer *node;
190 struct btrfs_buffer *commit_root;
184struct btrfs_file_extent_item {
185 /*
186 * disk space consumed by the extent, checksum blocks are included
187 * in these numbers
188 */
189 __le64 disk_blocknr;
190 __le64 disk_num_blocks;
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
205struct btrfs_inode_map_item {
206 struct btrfs_disk_key key;
207} __attribute__ ((__packed__));
208
209struct btrfs_fs_info {
210 struct btrfs_root *fs_root;
191 struct btrfs_root *extent_root;
192 struct btrfs_root *tree_root;
211 struct btrfs_root *extent_root;
212 struct btrfs_root *tree_root;
213 struct btrfs_root *inode_root;
193 struct btrfs_key current_insert;
194 struct btrfs_key last_insert;
214 struct btrfs_key current_insert;
215 struct btrfs_key last_insert;
195 int fp;
196 struct radix_tree_root cache_radix;
197 struct radix_tree_root pinned_radix;
198 struct list_head trans;
199 struct list_head cache;
216 struct radix_tree_root cache_radix;
217 struct radix_tree_root pinned_radix;
218 struct list_head trans;
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 */
232struct btrfs_root {
233 struct btrfs_buffer *node;
234 struct btrfs_buffer *commit_root;
202 struct btrfs_root_item root_item;
203 struct btrfs_key root_key;
235 struct btrfs_root_item root_item;
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};
207
208/* the lower bits in the key flags defines the item type */
209#define BTRFS_KEY_TYPE_MAX 256
210#define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1)
211
212/*
213 * inode items have the data typically returned from stat and store other

--- 21 unchanged lines hidden (view full) ---

235 * tree used by the super block to find all the other trees
236 */
237#define BTRFS_ROOT_ITEM_KEY 5
238/*
239 * extent items are in the extent map tree. These record which blocks
240 * are used, and how many references there are to each block
241 */
242#define BTRFS_EXTENT_ITEM_KEY 6
241};
242
243/* the lower bits in the key flags defines the item type */
244#define BTRFS_KEY_TYPE_MAX 256
245#define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1)
246
247/*
248 * inode items have the data typically returned from stat and store other

--- 21 unchanged lines hidden (view full) ---

270 * tree used by the super block to find all the other trees
271 */
272#define BTRFS_ROOT_ITEM_KEY 5
273/*
274 * extent items are in the extent map tree. These record which blocks
275 * are used, and how many references there are to each block
276 */
277#define BTRFS_EXTENT_ITEM_KEY 6
278
243/*
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
284/*
244 * string items are for debugging. They just store a short string of
245 * data in the FS
246 */
285 * string items are for debugging. They just store a short string of
286 * data in the FS
287 */
247#define BTRFS_STRING_ITEM_KEY 7
288#define BTRFS_STRING_ITEM_KEY 8
248
249static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
250{
251 return le64_to_cpu(i->generation);
252}
253
254static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i,
255 u64 val)

--- 393 unchanged lines hidden (view full) ---

649{
650 s->blocksize = cpu_to_le32(val);
651}
652
653static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
654{
655 return (u8 *)l->items;
656}
289
290static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
291{
292 return le64_to_cpu(i->generation);
293}
294
295static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i,
296 u64 val)

--- 393 unchanged lines hidden (view full) ---

690{
691 s->blocksize = cpu_to_le32(val);
692}
693
694static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
695{
696 return (u8 *)l->items;
697}
698
699static 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
705static 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
712static 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
718static 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
725static inline u64 btrfs_file_extent_offset(struct btrfs_file_extent_item *e)
726{
727 return le64_to_cpu(e->offset);
728}
729
730static 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
736static 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
742static 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. */
658#define btrfs_item_ptr(leaf, slot, type) \
659 ((type *)(btrfs_leaf_data(leaf) + \
660 btrfs_item_offset((leaf)->items + (slot))))
661
662struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
663 struct btrfs_root *root);
664int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,

--- 31 unchanged lines hidden (view full) ---

696int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
697 *root, char *name, int name_len, u64 dir, u64
698 objectid, u8 type);
699int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
700 *root, struct btrfs_path *path, u64 dir, char *name,
701 int name_len, int mod);
702int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path,
703 char *name, int name_len);
749/* helper function to cast into the data area of the leaf. */
750#define btrfs_item_ptr(leaf, slot, type) \
751 ((type *)(btrfs_leaf_data(leaf) + \
752 btrfs_item_offset((leaf)->items + (slot))))
753
754struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
755 struct btrfs_root *root);
756int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,

--- 31 unchanged lines hidden (view full) ---

788int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
789 *root, char *name, int name_len, u64 dir, u64
790 objectid, u8 type);
791int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
792 *root, struct btrfs_path *path, u64 dir, char *name,
793 int name_len, int mod);
794int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path,
795 char *name, int name_len);
796int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
797 struct btrfs_root *fs_root,
798 u64 dirid, u64 *objectid);
799int btrfs_insert_inode_map(struct btrfs_trans_handle *trans,
800 struct btrfs_root *root,
801 u64 objectid, struct btrfs_key *location);
802int 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