5 #include "kerncompat.h"
7 struct btrfs_trans_handle
;
9 #define BTRFS_MAGIC "_BtRfS_M"
11 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
12 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
13 #define BTRFS_FS_TREE_OBJECTID 3ULL
14 #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
15 #define BTRFS_FIRST_FREE_OBJECTID 5ULL
18 * we can actually store much bigger names, but lets not confuse the rest
21 #define BTRFS_NAME_LEN 255
23 /* 32 bytes in various csum fields */
24 #define BTRFS_CSUM_SIZE 32
26 #define BTRFS_FT_UNKNOWN 0
27 #define BTRFS_FT_REG_FILE 1
28 #define BTRFS_FT_DIR 2
29 #define BTRFS_FT_CHRDEV 3
30 #define BTRFS_FT_BLKDEV 4
31 #define BTRFS_FT_FIFO 5
32 #define BTRFS_FT_SOCK 6
33 #define BTRFS_FT_SYMLINK 7
34 #define BTRFS_FT_MAX 8
37 * the key defines the order in the tree, and so it also defines (optimal)
38 * block layout. objectid corresonds to the inode number. The flags
39 * tells us things about the object, and is a kind of stream selector.
40 * so for a given inode, keys with flags of 1 might refer to the inode
41 * data, flags of 2 may point to file data in the btree and flags == 3
42 * may point to extents.
44 * offset is the starting byte offset for this key in the stream.
46 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
47 * in cpu native order. Otherwise they are identical and their sizes
48 * should be the same (ie both packed)
50 struct btrfs_disk_key
{
54 } __attribute__ ((__packed__
));
60 } __attribute__ ((__packed__
));
63 * every tree block (leaf or node) starts with this header.
66 u8 csum
[BTRFS_CSUM_SIZE
];
67 u8 fsid
[16]; /* FS specific uuid */
68 __le64 blocknr
; /* which block this node is supposed to live in */
74 } __attribute__ ((__packed__
));
76 #define BTRFS_MAX_LEVEL 8
77 #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->blocksize - \
78 sizeof(struct btrfs_header)) / \
79 (sizeof(struct btrfs_disk_key) + sizeof(u64)))
80 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
81 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->blocksize))
85 * the super block basically lists the main trees of the FS
86 * it currently lacks any block count etc etc
88 struct btrfs_super_block
{
89 u8 csum
[BTRFS_CSUM_SIZE
];
90 /* the first 3 fields must match struct btrfs_header */
91 u8 fsid
[16]; /* FS specific uuid */
92 __le64 blocknr
; /* this block number */
99 __le64 root_dir_objectid
;
100 } __attribute__ ((__packed__
));
103 * A leaf is full of items. offset and size tell us where to find
104 * the item in the leaf (relative to the start of the data area)
107 struct btrfs_disk_key key
;
110 } __attribute__ ((__packed__
));
113 * leaves have an item area and a data area:
114 * [item0, item1....itemN] [free space] [dataN...data1, data0]
116 * The data is separate from the items to get the keys closer together
120 struct btrfs_header header
;
121 struct btrfs_item items
[];
122 } __attribute__ ((__packed__
));
125 * all non-leaf blocks are nodes, they hold only keys and pointers to
128 struct btrfs_key_ptr
{
129 struct btrfs_disk_key key
;
131 } __attribute__ ((__packed__
));
134 struct btrfs_header header
;
135 struct btrfs_key_ptr ptrs
[];
136 } __attribute__ ((__packed__
));
139 * btrfs_paths remember the path taken from the root down to the leaf.
140 * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point
141 * to any other levels that are present.
143 * The slots array records the index of the item or block pointer
144 * used while walking the tree.
147 struct btrfs_buffer
*nodes
[BTRFS_MAX_LEVEL
];
148 int slots
[BTRFS_MAX_LEVEL
];
152 * items in the extent btree are used to record the objectid of the
153 * owner of the block and the number of references
155 struct btrfs_extent_item
{
158 } __attribute__ ((__packed__
));
160 struct btrfs_inode_timespec
{
163 } __attribute__ ((__packed__
));
166 * there is no padding here on purpose. If you want to extent the inode,
167 * make a new item type
169 struct btrfs_inode_item
{
181 struct btrfs_inode_timespec atime
;
182 struct btrfs_inode_timespec ctime
;
183 struct btrfs_inode_timespec mtime
;
184 struct btrfs_inode_timespec otime
;
185 } __attribute__ ((__packed__
));
187 /* inline data is just a blob of bytes */
188 struct btrfs_inline_data_item
{
190 } __attribute__ ((__packed__
));
192 struct btrfs_dir_item
{
193 struct btrfs_disk_key location
;
197 } __attribute__ ((__packed__
));
199 struct btrfs_root_item
{
200 struct btrfs_inode_item inode
;
207 } __attribute__ ((__packed__
));
209 #define BTRFS_FILE_EXTENT_REG 0
210 #define BTRFS_FILE_EXTENT_INLINE 1
212 struct btrfs_file_extent_item
{
216 * disk space consumed by the extent, checksum blocks are included
220 __le64 disk_num_blocks
;
222 * the logical offset in file blocks (no csums)
223 * this extent record is for. This allows a file extent to point
224 * into the middle of an existing extent on disk, sharing it
225 * between two snapshots (useful if some bytes in the middle of the
226 * extent have changed
230 * the logical number of file blocks (no csums included)
233 } __attribute__ ((__packed__
));
235 struct btrfs_csum_item
{
236 u8 csum
[BTRFS_CSUM_SIZE
];
237 } __attribute__ ((__packed__
));
239 /* tag for the radix tree of block groups in ram */
240 #define BTRFS_BLOCK_GROUP_DIRTY 0
241 #define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
244 #define BTRFS_BLOCK_GROUP_DATA 1
245 struct btrfs_block_group_item
{
248 } __attribute__ ((__packed__
));
250 struct btrfs_block_group_cache
{
251 struct btrfs_key key
;
252 struct btrfs_block_group_item item
;
255 struct btrfs_fs_info
{
256 struct btrfs_root
*fs_root
;
257 struct btrfs_root
*extent_root
;
258 struct btrfs_root
*tree_root
;
259 struct btrfs_key current_insert
;
260 struct btrfs_key last_insert
;
261 struct radix_tree_root cache_radix
;
262 struct radix_tree_root pinned_radix
;
263 struct radix_tree_root block_group_radix
;
264 struct list_head trans
;
265 struct list_head cache
;
266 u64 last_inode_alloc
;
267 u64 last_inode_alloc_dirid
;
271 struct btrfs_trans_handle
*running_transaction
;
272 struct btrfs_super_block
*disk_super
;
276 * in ram representation of the tree. extent_root is used for all allocations
277 * and for the extent tree extent_root root. current_insert is used
278 * only for the extent tree.
281 struct btrfs_buffer
*node
;
282 struct btrfs_buffer
*commit_root
;
283 struct btrfs_root_item root_item
;
284 struct btrfs_key root_key
;
285 struct btrfs_fs_info
*fs_info
;
291 /* the lower bits in the key flags defines the item type */
292 #define BTRFS_KEY_TYPE_MAX 256
293 #define BTRFS_KEY_TYPE_SHIFT 24
294 #define BTRFS_KEY_TYPE_MASK (((u32)BTRFS_KEY_TYPE_MAX - 1) << \
295 BTRFS_KEY_TYPE_SHIFT)
298 * inode items have the data typically returned from stat and store other
299 * info about object characteristics. There is one for every file and dir in
302 #define BTRFS_INODE_ITEM_KEY 1
304 /* reserve 2-15 close to the inode for later flexibility */
307 * dir items are the name -> inode pointers in a directory. There is one
308 * for every name in a directory.
310 #define BTRFS_DIR_ITEM_KEY 16
311 #define BTRFS_DIR_INDEX_KEY 17
313 * extent data is for file data
315 #define BTRFS_EXTENT_DATA_KEY 18
317 * csum items have the checksums for data in the extents
319 #define BTRFS_CSUM_ITEM_KEY 19
321 /* reserve 20-31 for other file stuff */
324 * root items point to tree roots. There are typically in the root
325 * tree used by the super block to find all the other trees
327 #define BTRFS_ROOT_ITEM_KEY 32
329 * extent items are in the extent map tree. These record which blocks
330 * are used, and how many references there are to each block
332 #define BTRFS_EXTENT_ITEM_KEY 33
335 * block groups give us hints into the extent allocation trees. Which
336 * blocks are free etc etc
338 #define BTRFS_BLOCK_GROUP_ITEM_KEY 34
341 * string items are for debugging. They just store a short string of
344 #define BTRFS_STRING_ITEM_KEY 253
347 static inline u64
btrfs_block_group_used(struct btrfs_block_group_item
*bi
)
349 return le64_to_cpu(bi
->used
);
352 static inline void btrfs_set_block_group_used(struct
353 btrfs_block_group_item
*bi
,
356 bi
->used
= cpu_to_le64(val
);
359 static inline u64
btrfs_inode_generation(struct btrfs_inode_item
*i
)
361 return le64_to_cpu(i
->generation
);
364 static inline void btrfs_set_inode_generation(struct btrfs_inode_item
*i
,
367 i
->generation
= cpu_to_le64(val
);
370 static inline u64
btrfs_inode_size(struct btrfs_inode_item
*i
)
372 return le64_to_cpu(i
->size
);
375 static inline void btrfs_set_inode_size(struct btrfs_inode_item
*i
, u64 val
)
377 i
->size
= cpu_to_le64(val
);
380 static inline u64
btrfs_inode_nblocks(struct btrfs_inode_item
*i
)
382 return le64_to_cpu(i
->nblocks
);
385 static inline void btrfs_set_inode_nblocks(struct btrfs_inode_item
*i
, u64 val
)
387 i
->nblocks
= cpu_to_le64(val
);
390 static inline u64
btrfs_inode_block_group(struct btrfs_inode_item
*i
)
392 return le64_to_cpu(i
->block_group
);
395 static inline void btrfs_set_inode_block_group(struct btrfs_inode_item
*i
,
398 i
->block_group
= cpu_to_le64(val
);
401 static inline u32
btrfs_inode_nlink(struct btrfs_inode_item
*i
)
403 return le32_to_cpu(i
->nlink
);
406 static inline void btrfs_set_inode_nlink(struct btrfs_inode_item
*i
, u32 val
)
408 i
->nlink
= cpu_to_le32(val
);
411 static inline u32
btrfs_inode_uid(struct btrfs_inode_item
*i
)
413 return le32_to_cpu(i
->uid
);
416 static inline void btrfs_set_inode_uid(struct btrfs_inode_item
*i
, u32 val
)
418 i
->uid
= cpu_to_le32(val
);
421 static inline u32
btrfs_inode_gid(struct btrfs_inode_item
*i
)
423 return le32_to_cpu(i
->gid
);
426 static inline void btrfs_set_inode_gid(struct btrfs_inode_item
*i
, u32 val
)
428 i
->gid
= cpu_to_le32(val
);
431 static inline u32
btrfs_inode_mode(struct btrfs_inode_item
*i
)
433 return le32_to_cpu(i
->mode
);
436 static inline void btrfs_set_inode_mode(struct btrfs_inode_item
*i
, u32 val
)
438 i
->mode
= cpu_to_le32(val
);
441 static inline u32
btrfs_inode_rdev(struct btrfs_inode_item
*i
)
443 return le32_to_cpu(i
->rdev
);
446 static inline void btrfs_set_inode_rdev(struct btrfs_inode_item
*i
, u32 val
)
448 i
->rdev
= cpu_to_le32(val
);
451 static inline u16
btrfs_inode_flags(struct btrfs_inode_item
*i
)
453 return le16_to_cpu(i
->flags
);
456 static inline void btrfs_set_inode_flags(struct btrfs_inode_item
*i
, u16 val
)
458 i
->flags
= cpu_to_le16(val
);
461 static inline u16
btrfs_inode_compat_flags(struct btrfs_inode_item
*i
)
463 return le16_to_cpu(i
->compat_flags
);
466 static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item
*i
,
469 i
->compat_flags
= cpu_to_le16(val
);
472 static inline u64
btrfs_timespec_sec(struct btrfs_inode_timespec
*ts
)
474 return le64_to_cpu(ts
->sec
);
477 static inline void btrfs_set_timespec_sec(struct btrfs_inode_timespec
*ts
,
480 ts
->sec
= cpu_to_le64(val
);
483 static inline u32
btrfs_timespec_nsec(struct btrfs_inode_timespec
*ts
)
485 return le32_to_cpu(ts
->nsec
);
488 static inline void btrfs_set_timespec_nsec(struct btrfs_inode_timespec
*ts
,
491 ts
->nsec
= cpu_to_le32(val
);
494 static inline u32
btrfs_extent_refs(struct btrfs_extent_item
*ei
)
496 return le32_to_cpu(ei
->refs
);
499 static inline void btrfs_set_extent_refs(struct btrfs_extent_item
*ei
, u32 val
)
501 ei
->refs
= cpu_to_le32(val
);
504 static inline u64
btrfs_extent_owner(struct btrfs_extent_item
*ei
)
506 return le64_to_cpu(ei
->owner
);
509 static inline void btrfs_set_extent_owner(struct btrfs_extent_item
*ei
, u64 val
)
511 ei
->owner
= cpu_to_le64(val
);
514 static inline u64
btrfs_node_blockptr(struct btrfs_node
*n
, int nr
)
516 return le64_to_cpu(n
->ptrs
[nr
].blockptr
);
520 static inline void btrfs_set_node_blockptr(struct btrfs_node
*n
, int nr
,
523 n
->ptrs
[nr
].blockptr
= cpu_to_le64(val
);
526 static inline u32
btrfs_item_offset(struct btrfs_item
*item
)
528 return le32_to_cpu(item
->offset
);
531 static inline void btrfs_set_item_offset(struct btrfs_item
*item
, u32 val
)
533 item
->offset
= cpu_to_le32(val
);
536 static inline u32
btrfs_item_end(struct btrfs_item
*item
)
538 return le32_to_cpu(item
->offset
) + le16_to_cpu(item
->size
);
541 static inline u16
btrfs_item_size(struct btrfs_item
*item
)
543 return le16_to_cpu(item
->size
);
546 static inline void btrfs_set_item_size(struct btrfs_item
*item
, u16 val
)
548 item
->size
= cpu_to_le16(val
);
551 static inline u16
btrfs_dir_flags(struct btrfs_dir_item
*d
)
553 return le16_to_cpu(d
->flags
);
556 static inline void btrfs_set_dir_flags(struct btrfs_dir_item
*d
, u16 val
)
558 d
->flags
= cpu_to_le16(val
);
561 static inline u8
btrfs_dir_type(struct btrfs_dir_item
*d
)
566 static inline void btrfs_set_dir_type(struct btrfs_dir_item
*d
, u8 val
)
571 static inline u16
btrfs_dir_name_len(struct btrfs_dir_item
*d
)
573 return le16_to_cpu(d
->name_len
);
576 static inline void btrfs_set_dir_name_len(struct btrfs_dir_item
*d
, u16 val
)
578 d
->name_len
= cpu_to_le16(val
);
581 static inline void btrfs_disk_key_to_cpu(struct btrfs_key
*cpu
,
582 struct btrfs_disk_key
*disk
)
584 cpu
->offset
= le64_to_cpu(disk
->offset
);
585 cpu
->flags
= le32_to_cpu(disk
->flags
);
586 cpu
->objectid
= le64_to_cpu(disk
->objectid
);
589 static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key
*disk
,
590 struct btrfs_key
*cpu
)
592 disk
->offset
= cpu_to_le64(cpu
->offset
);
593 disk
->flags
= cpu_to_le32(cpu
->flags
);
594 disk
->objectid
= cpu_to_le64(cpu
->objectid
);
597 static inline u64
btrfs_disk_key_objectid(struct btrfs_disk_key
*disk
)
599 return le64_to_cpu(disk
->objectid
);
602 static inline void btrfs_set_disk_key_objectid(struct btrfs_disk_key
*disk
,
605 disk
->objectid
= cpu_to_le64(val
);
608 static inline u64
btrfs_disk_key_offset(struct btrfs_disk_key
*disk
)
610 return le64_to_cpu(disk
->offset
);
613 static inline void btrfs_set_disk_key_offset(struct btrfs_disk_key
*disk
,
616 disk
->offset
= cpu_to_le64(val
);
619 static inline u32
btrfs_disk_key_flags(struct btrfs_disk_key
*disk
)
621 return le32_to_cpu(disk
->flags
);
624 static inline void btrfs_set_disk_key_flags(struct btrfs_disk_key
*disk
,
627 disk
->flags
= cpu_to_le32(val
);
630 static inline u32
btrfs_disk_key_type(struct btrfs_disk_key
*key
)
632 return le32_to_cpu(key
->flags
) >> BTRFS_KEY_TYPE_SHIFT
;
635 static inline void btrfs_set_disk_key_type(struct btrfs_disk_key
*key
,
638 u32 flags
= btrfs_disk_key_flags(key
);
639 BUG_ON(val
>= BTRFS_KEY_TYPE_MAX
);
640 val
= val
<< BTRFS_KEY_TYPE_SHIFT
;
641 flags
= (flags
& ~BTRFS_KEY_TYPE_MASK
) | val
;
642 btrfs_set_disk_key_flags(key
, flags
);
645 static inline u32
btrfs_key_type(struct btrfs_key
*key
)
647 return key
->flags
>> BTRFS_KEY_TYPE_SHIFT
;
650 static inline void btrfs_set_key_type(struct btrfs_key
*key
, u32 val
)
652 BUG_ON(val
>= BTRFS_KEY_TYPE_MAX
);
653 val
= val
<< BTRFS_KEY_TYPE_SHIFT
;
654 key
->flags
= (key
->flags
& ~(BTRFS_KEY_TYPE_MASK
)) | val
;
657 static inline u64
btrfs_header_blocknr(struct btrfs_header
*h
)
659 return le64_to_cpu(h
->blocknr
);
662 static inline void btrfs_set_header_blocknr(struct btrfs_header
*h
, u64 blocknr
)
664 h
->blocknr
= cpu_to_le64(blocknr
);
667 static inline u64
btrfs_header_generation(struct btrfs_header
*h
)
669 return le64_to_cpu(h
->generation
);
672 static inline void btrfs_set_header_generation(struct btrfs_header
*h
,
675 h
->generation
= cpu_to_le64(val
);
678 static inline u64
btrfs_header_owner(struct btrfs_header
*h
)
680 return le64_to_cpu(h
->owner
);
683 static inline void btrfs_set_header_owner(struct btrfs_header
*h
,
686 h
->owner
= cpu_to_le64(val
);
689 static inline u16
btrfs_header_nritems(struct btrfs_header
*h
)
691 return le16_to_cpu(h
->nritems
);
694 static inline void btrfs_set_header_nritems(struct btrfs_header
*h
, u16 val
)
696 h
->nritems
= cpu_to_le16(val
);
699 static inline u16
btrfs_header_flags(struct btrfs_header
*h
)
701 return le16_to_cpu(h
->flags
);
704 static inline void btrfs_set_header_flags(struct btrfs_header
*h
, u16 val
)
706 h
->flags
= cpu_to_le16(val
);
709 static inline int btrfs_header_level(struct btrfs_header
*h
)
714 static inline void btrfs_set_header_level(struct btrfs_header
*h
, int level
)
716 BUG_ON(level
> BTRFS_MAX_LEVEL
);
720 static inline int btrfs_is_leaf(struct btrfs_node
*n
)
722 return (btrfs_header_level(&n
->header
) == 0);
725 static inline u64
btrfs_root_blocknr(struct btrfs_root_item
*item
)
727 return le64_to_cpu(item
->blocknr
);
730 static inline void btrfs_set_root_blocknr(struct btrfs_root_item
*item
, u64 val
)
732 item
->blocknr
= cpu_to_le64(val
);
735 static inline u64
btrfs_root_dirid(struct btrfs_root_item
*item
)
737 return le64_to_cpu(item
->root_dirid
);
740 static inline void btrfs_set_root_dirid(struct btrfs_root_item
*item
, u64 val
)
742 item
->root_dirid
= cpu_to_le64(val
);
745 static inline u32
btrfs_root_refs(struct btrfs_root_item
*item
)
747 return le32_to_cpu(item
->refs
);
750 static inline void btrfs_set_root_refs(struct btrfs_root_item
*item
, u32 val
)
752 item
->refs
= cpu_to_le32(val
);
755 static inline u64
btrfs_super_blocknr(struct btrfs_super_block
*s
)
757 return le64_to_cpu(s
->blocknr
);
760 static inline void btrfs_set_super_blocknr(struct btrfs_super_block
*s
, u64 val
)
762 s
->blocknr
= cpu_to_le64(val
);
765 static inline u64
btrfs_super_generation(struct btrfs_super_block
*s
)
767 return le64_to_cpu(s
->generation
);
770 static inline void btrfs_set_super_generation(struct btrfs_super_block
*s
,
773 s
->generation
= cpu_to_le64(val
);
776 static inline u64
btrfs_super_root(struct btrfs_super_block
*s
)
778 return le64_to_cpu(s
->root
);
781 static inline void btrfs_set_super_root(struct btrfs_super_block
*s
, u64 val
)
783 s
->root
= cpu_to_le64(val
);
786 static inline u64
btrfs_super_total_blocks(struct btrfs_super_block
*s
)
788 return le64_to_cpu(s
->total_blocks
);
791 static inline void btrfs_set_super_total_blocks(struct btrfs_super_block
*s
,
794 s
->total_blocks
= cpu_to_le64(val
);
797 static inline u64
btrfs_super_blocks_used(struct btrfs_super_block
*s
)
799 return le64_to_cpu(s
->blocks_used
);
802 static inline void btrfs_set_super_blocks_used(struct btrfs_super_block
*s
,
805 s
->blocks_used
= cpu_to_le64(val
);
808 static inline u32
btrfs_super_blocksize(struct btrfs_super_block
*s
)
810 return le32_to_cpu(s
->blocksize
);
813 static inline void btrfs_set_super_blocksize(struct btrfs_super_block
*s
,
816 s
->blocksize
= cpu_to_le32(val
);
819 static inline u64
btrfs_super_root_dir(struct btrfs_super_block
*s
)
821 return le64_to_cpu(s
->root_dir_objectid
);
824 static inline void btrfs_set_super_root_dir(struct btrfs_super_block
*s
, u64
827 s
->root_dir_objectid
= cpu_to_le64(val
);
830 static inline u8
*btrfs_leaf_data(struct btrfs_leaf
*l
)
832 return (u8
*)l
->items
;
835 static inline int btrfs_file_extent_type(struct btrfs_file_extent_item
*e
)
839 static inline void btrfs_set_file_extent_type(struct btrfs_file_extent_item
*e
,
845 static inline char *btrfs_file_extent_inline_start(struct
846 btrfs_file_extent_item
*e
)
848 return (char *)(&e
->disk_blocknr
);
851 static inline u32
btrfs_file_extent_calc_inline_size(u32 datasize
)
853 return (unsigned long)(&((struct
854 btrfs_file_extent_item
*)NULL
)->disk_blocknr
) + datasize
;
857 static inline u32
btrfs_file_extent_inline_len(struct btrfs_item
*e
)
859 struct btrfs_file_extent_item
*fe
= NULL
;
860 return btrfs_item_size(e
) - (unsigned long)(&fe
->disk_blocknr
);
863 static inline u64
btrfs_file_extent_disk_blocknr(struct btrfs_file_extent_item
866 return le64_to_cpu(e
->disk_blocknr
);
869 static inline void btrfs_set_file_extent_disk_blocknr(struct
870 btrfs_file_extent_item
873 e
->disk_blocknr
= cpu_to_le64(val
);
876 static inline u64
btrfs_file_extent_generation(struct btrfs_file_extent_item
*e
)
878 return le64_to_cpu(e
->generation
);
881 static inline void btrfs_set_file_extent_generation(struct
882 btrfs_file_extent_item
*e
,
885 e
->generation
= cpu_to_le64(val
);
888 static inline u64
btrfs_file_extent_disk_num_blocks(struct
889 btrfs_file_extent_item
*e
)
891 return le64_to_cpu(e
->disk_num_blocks
);
894 static inline void btrfs_set_file_extent_disk_num_blocks(struct
895 btrfs_file_extent_item
898 e
->disk_num_blocks
= cpu_to_le64(val
);
901 static inline u64
btrfs_file_extent_offset(struct btrfs_file_extent_item
*e
)
903 return le64_to_cpu(e
->offset
);
906 static inline void btrfs_set_file_extent_offset(struct btrfs_file_extent_item
909 e
->offset
= cpu_to_le64(val
);
912 static inline u64
btrfs_file_extent_num_blocks(struct btrfs_file_extent_item
915 return le64_to_cpu(e
->num_blocks
);
918 static inline void btrfs_set_file_extent_num_blocks(struct
919 btrfs_file_extent_item
*e
,
922 e
->num_blocks
= cpu_to_le64(val
);
925 /* helper function to cast into the data area of the leaf. */
926 #define btrfs_item_ptr(leaf, slot, type) \
927 ((type *)(btrfs_leaf_data(leaf) + \
928 btrfs_item_offset((leaf)->items + (slot))))
930 int btrfs_comp_keys(struct btrfs_disk_key
*disk
, struct btrfs_key
*k2
);
931 int btrfs_extend_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
932 *root
, struct btrfs_path
*path
, u32 data_size
);
933 struct btrfs_buffer
*btrfs_alloc_free_block(struct btrfs_trans_handle
*trans
,
934 struct btrfs_root
*root
);
935 int btrfs_inc_ref(struct btrfs_trans_handle
*trans
, struct btrfs_root
*root
,
936 struct btrfs_buffer
*buf
);
937 int btrfs_free_extent(struct btrfs_trans_handle
*trans
, struct btrfs_root
938 *root
, u64 blocknr
, u64 num_blocks
, int pin
);
939 int btrfs_search_slot(struct btrfs_trans_handle
*trans
, struct btrfs_root
940 *root
, struct btrfs_key
*key
, struct btrfs_path
*p
, int
942 void btrfs_release_path(struct btrfs_root
*root
, struct btrfs_path
*p
);
943 void btrfs_init_path(struct btrfs_path
*p
);
944 int btrfs_del_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
*root
,
945 struct btrfs_path
*path
);
946 int btrfs_insert_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
947 *root
, struct btrfs_key
*key
, void *data
, u32 data_size
);
948 int btrfs_insert_empty_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
949 *root
, struct btrfs_path
*path
, struct btrfs_key
950 *cpu_key
, u32 data_size
);
951 int btrfs_next_leaf(struct btrfs_root
*root
, struct btrfs_path
*path
);
952 int btrfs_leaf_free_space(struct btrfs_root
*root
, struct btrfs_leaf
*leaf
);
953 int btrfs_drop_snapshot(struct btrfs_trans_handle
*trans
, struct btrfs_root
954 *root
, struct btrfs_buffer
*snap
);
955 int btrfs_finish_extent_commit(struct btrfs_trans_handle
*trans
, struct
957 int btrfs_del_root(struct btrfs_trans_handle
*trans
, struct btrfs_root
*root
,
958 struct btrfs_key
*key
);
959 int btrfs_insert_root(struct btrfs_trans_handle
*trans
, struct btrfs_root
960 *root
, struct btrfs_key
*key
, struct btrfs_root_item
962 int btrfs_update_root(struct btrfs_trans_handle
*trans
, struct btrfs_root
963 *root
, struct btrfs_key
*key
, struct btrfs_root_item
965 int btrfs_find_last_root(struct btrfs_root
*root
, u64 objectid
, struct
966 btrfs_root_item
*item
, struct btrfs_key
*key
);
967 int btrfs_insert_dir_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
968 *root
, char *name
, int name_len
, u64 dir
,
969 struct btrfs_key
*location
, u8 type
);
970 int btrfs_lookup_dir_item(struct btrfs_trans_handle
*trans
, struct btrfs_root
971 *root
, struct btrfs_path
*path
, u64 dir
, char *name
,
972 int name_len
, int mod
);
973 int btrfs_match_dir_item_name(struct btrfs_root
*root
, struct btrfs_path
*path
,
974 char *name
, int name_len
);
975 int btrfs_find_free_objectid(struct btrfs_trans_handle
*trans
,
976 struct btrfs_root
*fs_root
,
977 u64 dirid
, u64
*objectid
);
978 int btrfs_insert_inode(struct btrfs_trans_handle
*trans
, struct btrfs_root
979 *root
, u64 objectid
, struct btrfs_inode_item
981 int btrfs_lookup_inode(struct btrfs_trans_handle
*trans
, struct btrfs_root
982 *root
, struct btrfs_path
*path
, u64 objectid
, int mod
);
983 int btrfs_write_dirty_block_groups(struct btrfs_trans_handle
*trans
,
984 struct btrfs_root
*root
);
985 int btrfs_free_block_groups(struct btrfs_fs_info
*info
);
986 int btrfs_read_block_groups(struct btrfs_root
*root
);
987 int btrfs_insert_block_group(struct btrfs_trans_handle
*trans
,
988 struct btrfs_root
*root
,
989 struct btrfs_key
*key
,
990 struct btrfs_block_group_item
*bi
);