2 * Copyright (C) 2007 Oracle. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
23 #include "kerncompat.h"
25 struct btrfs_trans_handle;
27 #define BTRFS_MAGIC "_B2RfS_M"
29 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
30 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
31 #define BTRFS_FS_TREE_OBJECTID 3ULL
32 #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
33 #define BTRFS_FIRST_FREE_OBJECTID 5ULL
36 * we can actually store much bigger names, but lets not confuse the rest
39 #define BTRFS_NAME_LEN 255
41 /* 32 bytes in various csum fields */
42 #define BTRFS_CSUM_SIZE 32
43 /* four bytes for CRC32 */
44 #define BTRFS_CRC32_SIZE 4
46 #define BTRFS_FT_UNKNOWN 0
47 #define BTRFS_FT_REG_FILE 1
48 #define BTRFS_FT_DIR 2
49 #define BTRFS_FT_CHRDEV 3
50 #define BTRFS_FT_BLKDEV 4
51 #define BTRFS_FT_FIFO 5
52 #define BTRFS_FT_SOCK 6
53 #define BTRFS_FT_SYMLINK 7
54 #define BTRFS_FT_MAX 8
57 * the key defines the order in the tree, and so it also defines (optimal)
58 * block layout. objectid corresonds to the inode number. The flags
59 * tells us things about the object, and is a kind of stream selector.
60 * so for a given inode, keys with flags of 1 might refer to the inode
61 * data, flags of 2 may point to file data in the btree and flags == 3
62 * may point to extents.
64 * offset is the starting byte offset for this key in the stream.
66 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
67 * in cpu native order. Otherwise they are identical and their sizes
68 * should be the same (ie both packed)
70 struct btrfs_disk_key {
74 } __attribute__ ((__packed__));
80 } __attribute__ ((__packed__));
83 * every tree block (leaf or node) starts with this header.
86 u8 csum[BTRFS_CSUM_SIZE];
87 u8 fsid[16]; /* FS specific uuid */
88 __le64 blocknr; /* which block this node is supposed to live in */
94 } __attribute__ ((__packed__));
96 #define BTRFS_MAX_LEVEL 8
97 #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
98 sizeof(struct btrfs_header)) / \
99 (sizeof(struct btrfs_disk_key) + sizeof(u64)))
100 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
101 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
105 * the super block basically lists the main trees of the FS
106 * it currently lacks any block count etc etc
108 struct btrfs_super_block {
109 u8 csum[BTRFS_CSUM_SIZE];
110 /* the first 3 fields must match struct btrfs_header */
111 u8 fsid[16]; /* FS specific uuid */
112 __le64 blocknr; /* this block number */
118 __le64 root_dir_objectid;
122 } __attribute__ ((__packed__));
125 * A leaf is full of items. offset and size tell us where to find
126 * the item in the leaf (relative to the start of the data area)
129 struct btrfs_disk_key key;
132 } __attribute__ ((__packed__));
135 * leaves have an item area and a data area:
136 * [item0, item1....itemN] [free space] [dataN...data1, data0]
138 * The data is separate from the items to get the keys closer together
142 struct btrfs_header header;
143 struct btrfs_item items[];
144 } __attribute__ ((__packed__));
147 * all non-leaf blocks are nodes, they hold only keys and pointers to
150 struct btrfs_key_ptr {
151 struct btrfs_disk_key key;
153 } __attribute__ ((__packed__));
156 struct btrfs_header header;
157 struct btrfs_key_ptr ptrs[];
158 } __attribute__ ((__packed__));
161 * btrfs_paths remember the path taken from the root down to the leaf.
162 * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point
163 * to any other levels that are present.
165 * The slots array records the index of the item or block pointer
166 * used while walking the tree.
169 struct btrfs_buffer *nodes[BTRFS_MAX_LEVEL];
170 int slots[BTRFS_MAX_LEVEL];
174 * items in the extent btree are used to record the objectid of the
175 * owner of the block and the number of references
177 struct btrfs_extent_item {
180 } __attribute__ ((__packed__));
182 struct btrfs_inode_timespec {
185 } __attribute__ ((__packed__));
188 * there is no padding here on purpose. If you want to extent the inode,
189 * make a new item type
191 struct btrfs_inode_item {
203 struct btrfs_inode_timespec atime;
204 struct btrfs_inode_timespec ctime;
205 struct btrfs_inode_timespec mtime;
206 struct btrfs_inode_timespec otime;
207 } __attribute__ ((__packed__));
209 /* inline data is just a blob of bytes */
210 struct btrfs_inline_data_item {
212 } __attribute__ ((__packed__));
214 struct btrfs_dir_item {
215 struct btrfs_disk_key location;
219 } __attribute__ ((__packed__));
221 struct btrfs_root_item {
222 struct btrfs_inode_item inode;
229 struct btrfs_disk_key drop_progress;
231 } __attribute__ ((__packed__));
233 #define BTRFS_FILE_EXTENT_REG 0
234 #define BTRFS_FILE_EXTENT_INLINE 1
236 struct btrfs_file_extent_item {
240 * disk space consumed by the extent, checksum blocks are included
244 __le64 disk_num_blocks;
246 * the logical offset in file blocks (no csums)
247 * this extent record is for. This allows a file extent to point
248 * into the middle of an existing extent on disk, sharing it
249 * between two snapshots (useful if some bytes in the middle of the
250 * extent have changed
254 * the logical number of file blocks (no csums included)
257 } __attribute__ ((__packed__));
259 struct btrfs_csum_item {
260 u8 csum[BTRFS_CSUM_SIZE];
261 } __attribute__ ((__packed__));
263 /* tag for the radix tree of block groups in ram */
264 #define BTRFS_BLOCK_GROUP_DIRTY 0
265 #define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
268 #define BTRFS_BLOCK_GROUP_DATA 1
269 struct btrfs_block_group_item {
272 } __attribute__ ((__packed__));
274 struct btrfs_block_group_cache {
275 struct btrfs_key key;
276 struct btrfs_block_group_item item;
279 struct btrfs_fs_info {
280 struct btrfs_root *fs_root;
281 struct btrfs_root *extent_root;
282 struct btrfs_root *tree_root;
283 struct btrfs_key current_insert;
284 struct btrfs_key last_insert;
285 struct radix_tree_root cache_radix;
286 struct radix_tree_root pinned_radix;
287 struct radix_tree_root block_group_radix;
288 struct list_head trans;
289 struct list_head cache;
290 u64 last_inode_alloc;
291 u64 last_inode_alloc_dirid;
295 struct btrfs_trans_handle *running_transaction;
296 struct btrfs_super_block *disk_super;
300 * in ram representation of the tree. extent_root is used for all allocations
301 * and for the extent tree extent_root root. current_insert is used
302 * only for the extent tree.
305 struct btrfs_buffer *node;
306 struct btrfs_buffer *commit_root;
307 struct btrfs_root_item root_item;
308 struct btrfs_key root_key;
309 struct btrfs_fs_info *fs_info;
311 /* data allocations are done in sectorsize units */
314 /* node allocations are done in nodesize units */
317 /* leaf allocations are done in leafsize units */
324 /* the lower bits in the key flags defines the item type */
325 #define BTRFS_KEY_TYPE_MAX 256
326 #define BTRFS_KEY_TYPE_SHIFT 24
327 #define BTRFS_KEY_TYPE_MASK (((u32)BTRFS_KEY_TYPE_MAX - 1) << \
328 BTRFS_KEY_TYPE_SHIFT)
331 * inode items have the data typically returned from stat and store other
332 * info about object characteristics. There is one for every file and dir in
335 #define BTRFS_INODE_ITEM_KEY 1
337 /* reserve 2-15 close to the inode for later flexibility */
340 * dir items are the name -> inode pointers in a directory. There is one
341 * for every name in a directory.
343 #define BTRFS_DIR_ITEM_KEY 16
344 #define BTRFS_DIR_INDEX_KEY 17
346 * extent data is for file data
348 #define BTRFS_EXTENT_DATA_KEY 18
350 * csum items have the checksums for data in the extents
352 #define BTRFS_CSUM_ITEM_KEY 19
354 /* reserve 20-31 for other file stuff */
357 * root items point to tree roots. There are typically in the root
358 * tree used by the super block to find all the other trees
360 #define BTRFS_ROOT_ITEM_KEY 32
362 * extent items are in the extent map tree. These record which blocks
363 * are used, and how many references there are to each block
365 #define BTRFS_EXTENT_ITEM_KEY 33
368 * block groups give us hints into the extent allocation trees. Which
369 * blocks are free etc etc
371 #define BTRFS_BLOCK_GROUP_ITEM_KEY 34
374 * string items are for debugging. They just store a short string of
377 #define BTRFS_STRING_ITEM_KEY 253
380 static inline u64 btrfs_block_group_used(struct btrfs_block_group_item *bi)
382 return le64_to_cpu(bi->used);
385 static inline void btrfs_set_block_group_used(struct
386 btrfs_block_group_item *bi,
389 bi->used = cpu_to_le64(val);
392 static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
394 return le64_to_cpu(i->generation);
397 static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i,
400 i->generation = cpu_to_le64(val);
403 static inline u64 btrfs_inode_size(struct btrfs_inode_item *i)
405 return le64_to_cpu(i->size);
408 static inline void btrfs_set_inode_size(struct btrfs_inode_item *i, u64 val)
410 i->size = cpu_to_le64(val);
413 static inline u64 btrfs_inode_nblocks(struct btrfs_inode_item *i)
415 return le64_to_cpu(i->nblocks);
418 static inline void btrfs_set_inode_nblocks(struct btrfs_inode_item *i, u64 val)
420 i->nblocks = cpu_to_le64(val);
423 static inline u64 btrfs_inode_block_group(struct btrfs_inode_item *i)
425 return le64_to_cpu(i->block_group);
428 static inline void btrfs_set_inode_block_group(struct btrfs_inode_item *i,
431 i->block_group = cpu_to_le64(val);
434 static inline u32 btrfs_inode_nlink(struct btrfs_inode_item *i)
436 return le32_to_cpu(i->nlink);
439 static inline void btrfs_set_inode_nlink(struct btrfs_inode_item *i, u32 val)
441 i->nlink = cpu_to_le32(val);
444 static inline u32 btrfs_inode_uid(struct btrfs_inode_item *i)
446 return le32_to_cpu(i->uid);
449 static inline void btrfs_set_inode_uid(struct btrfs_inode_item *i, u32 val)
451 i->uid = cpu_to_le32(val);
454 static inline u32 btrfs_inode_gid(struct btrfs_inode_item *i)
456 return le32_to_cpu(i->gid);
459 static inline void btrfs_set_inode_gid(struct btrfs_inode_item *i, u32 val)
461 i->gid = cpu_to_le32(val);
464 static inline u32 btrfs_inode_mode(struct btrfs_inode_item *i)
466 return le32_to_cpu(i->mode);
469 static inline void btrfs_set_inode_mode(struct btrfs_inode_item *i, u32 val)
471 i->mode = cpu_to_le32(val);
474 static inline u32 btrfs_inode_rdev(struct btrfs_inode_item *i)
476 return le32_to_cpu(i->rdev);
479 static inline void btrfs_set_inode_rdev(struct btrfs_inode_item *i, u32 val)
481 i->rdev = cpu_to_le32(val);
484 static inline u16 btrfs_inode_flags(struct btrfs_inode_item *i)
486 return le16_to_cpu(i->flags);
489 static inline void btrfs_set_inode_flags(struct btrfs_inode_item *i, u16 val)
491 i->flags = cpu_to_le16(val);
494 static inline u16 btrfs_inode_compat_flags(struct btrfs_inode_item *i)
496 return le16_to_cpu(i->compat_flags);
499 static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item *i,
502 i->compat_flags = cpu_to_le16(val);
505 static inline u64 btrfs_timespec_sec(struct btrfs_inode_timespec *ts)
507 return le64_to_cpu(ts->sec);
510 static inline void btrfs_set_timespec_sec(struct btrfs_inode_timespec *ts,
513 ts->sec = cpu_to_le64(val);
516 static inline u32 btrfs_timespec_nsec(struct btrfs_inode_timespec *ts)
518 return le32_to_cpu(ts->nsec);
521 static inline void btrfs_set_timespec_nsec(struct btrfs_inode_timespec *ts,
524 ts->nsec = cpu_to_le32(val);
527 static inline u32 btrfs_extent_refs(struct btrfs_extent_item *ei)
529 return le32_to_cpu(ei->refs);
532 static inline void btrfs_set_extent_refs(struct btrfs_extent_item *ei, u32 val)
534 ei->refs = cpu_to_le32(val);
537 static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei)
539 return le64_to_cpu(ei->owner);
542 static inline void btrfs_set_extent_owner(struct btrfs_extent_item *ei, u64 val)
544 ei->owner = cpu_to_le64(val);
547 static inline u64 btrfs_node_blockptr(struct btrfs_node *n, int nr)
549 return le64_to_cpu(n->ptrs[nr].blockptr);
553 static inline void btrfs_set_node_blockptr(struct btrfs_node *n, int nr,
556 n->ptrs[nr].blockptr = cpu_to_le64(val);
559 static inline u32 btrfs_item_offset(struct btrfs_item *item)
561 return le32_to_cpu(item->offset);
564 static inline void btrfs_set_item_offset(struct btrfs_item *item, u32 val)
566 item->offset = cpu_to_le32(val);
569 static inline u32 btrfs_item_end(struct btrfs_item *item)
571 return le32_to_cpu(item->offset) + le32_to_cpu(item->size);
574 static inline u32 btrfs_item_size(struct btrfs_item *item)
576 return le32_to_cpu(item->size);
579 static inline void btrfs_set_item_size(struct btrfs_item *item, u32 val)
581 item->size = cpu_to_le32(val);
584 static inline u16 btrfs_dir_flags(struct btrfs_dir_item *d)
586 return le16_to_cpu(d->flags);
589 static inline void btrfs_set_dir_flags(struct btrfs_dir_item *d, u16 val)
591 d->flags = cpu_to_le16(val);
594 static inline u8 btrfs_dir_type(struct btrfs_dir_item *d)
599 static inline void btrfs_set_dir_type(struct btrfs_dir_item *d, u8 val)
604 static inline u16 btrfs_dir_name_len(struct btrfs_dir_item *d)
606 return le16_to_cpu(d->name_len);
609 static inline void btrfs_set_dir_name_len(struct btrfs_dir_item *d, u16 val)
611 d->name_len = cpu_to_le16(val);
614 static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
615 struct btrfs_disk_key *disk)
617 cpu->offset = le64_to_cpu(disk->offset);
618 cpu->type = le32_to_cpu(disk->type);
619 cpu->objectid = le64_to_cpu(disk->objectid);
622 static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,
623 struct btrfs_key *cpu)
625 disk->offset = cpu_to_le64(cpu->offset);
626 disk->type = cpu_to_le32(cpu->type);
627 disk->objectid = cpu_to_le64(cpu->objectid);
630 static inline u64 btrfs_disk_key_objectid(struct btrfs_disk_key *disk)
632 return le64_to_cpu(disk->objectid);
635 static inline void btrfs_set_disk_key_objectid(struct btrfs_disk_key *disk,
638 disk->objectid = cpu_to_le64(val);
641 static inline u64 btrfs_disk_key_offset(struct btrfs_disk_key *disk)
643 return le64_to_cpu(disk->offset);
646 static inline void btrfs_set_disk_key_offset(struct btrfs_disk_key *disk,
649 disk->offset = cpu_to_le64(val);
652 static inline u8 btrfs_disk_key_type(struct btrfs_disk_key *key)
657 static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u8 val)
662 static inline u32 btrfs_key_type(struct btrfs_key *key)
667 static inline void btrfs_set_key_type(struct btrfs_key *key, u32 val)
672 static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
674 return le64_to_cpu(h->blocknr);
677 static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
679 h->blocknr = cpu_to_le64(blocknr);
682 static inline u64 btrfs_header_generation(struct btrfs_header *h)
684 return le64_to_cpu(h->generation);
687 static inline void btrfs_set_header_generation(struct btrfs_header *h,
690 h->generation = cpu_to_le64(val);
693 static inline u64 btrfs_header_owner(struct btrfs_header *h)
695 return le64_to_cpu(h->owner);
698 static inline void btrfs_set_header_owner(struct btrfs_header *h,
701 h->owner = cpu_to_le64(val);
704 static inline u32 btrfs_header_nritems(struct btrfs_header *h)
706 return le32_to_cpu(h->nritems);
709 static inline void btrfs_set_header_nritems(struct btrfs_header *h, u32 val)
711 h->nritems = cpu_to_le32(val);
714 static inline u16 btrfs_header_flags(struct btrfs_header *h)
716 return le16_to_cpu(h->flags);
719 static inline void btrfs_set_header_flags(struct btrfs_header *h, u16 val)
721 h->flags = cpu_to_le16(val);
724 static inline int btrfs_header_level(struct btrfs_header *h)
729 static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
731 BUG_ON(level > BTRFS_MAX_LEVEL);
735 static inline int btrfs_is_leaf(struct btrfs_node *n)
737 return (btrfs_header_level(&n->header) == 0);
740 static inline u64 btrfs_root_blocknr(struct btrfs_root_item *item)
742 return le64_to_cpu(item->blocknr);
745 static inline void btrfs_set_root_blocknr(struct btrfs_root_item *item, u64 val)
747 item->blocknr = cpu_to_le64(val);
750 static inline u64 btrfs_root_dirid(struct btrfs_root_item *item)
752 return le64_to_cpu(item->root_dirid);
755 static inline void btrfs_set_root_dirid(struct btrfs_root_item *item, u64 val)
757 item->root_dirid = cpu_to_le64(val);
760 static inline u32 btrfs_root_refs(struct btrfs_root_item *item)
762 return le32_to_cpu(item->refs);
765 static inline void btrfs_set_root_refs(struct btrfs_root_item *item, u32 val)
767 item->refs = cpu_to_le32(val);
770 static inline u32 btrfs_root_flags(struct btrfs_root_item *item)
772 return le32_to_cpu(item->flags);
775 static inline void btrfs_set_root_flags(struct btrfs_root_item *item, u32 val)
777 item->flags = cpu_to_le32(val);
780 static inline void btrfs_set_root_blocks_used(struct btrfs_root_item *item,
783 item->blocks_used = cpu_to_le64(val);
786 static inline u64 btrfs_root_blocks_used(struct btrfs_root_item *item)
788 return le64_to_cpu(item->blocks_used);
791 static inline u64 btrfs_super_blocknr(struct btrfs_super_block *s)
793 return le64_to_cpu(s->blocknr);
796 static inline void btrfs_set_super_blocknr(struct btrfs_super_block *s, u64 val)
798 s->blocknr = cpu_to_le64(val);
801 static inline u64 btrfs_super_generation(struct btrfs_super_block *s)
803 return le64_to_cpu(s->generation);
806 static inline void btrfs_set_super_generation(struct btrfs_super_block *s,
809 s->generation = cpu_to_le64(val);
812 static inline u64 btrfs_super_root(struct btrfs_super_block *s)
814 return le64_to_cpu(s->root);
817 static inline void btrfs_set_super_root(struct btrfs_super_block *s, u64 val)
819 s->root = cpu_to_le64(val);
822 static inline u64 btrfs_super_total_blocks(struct btrfs_super_block *s)
824 return le64_to_cpu(s->total_blocks);
827 static inline void btrfs_set_super_total_blocks(struct btrfs_super_block *s,
830 s->total_blocks = cpu_to_le64(val);
833 static inline u64 btrfs_super_blocks_used(struct btrfs_super_block *s)
835 return le64_to_cpu(s->blocks_used);
838 static inline void btrfs_set_super_blocks_used(struct btrfs_super_block *s,
841 s->blocks_used = cpu_to_le64(val);
844 static inline u32 btrfs_super_sectorsize(struct btrfs_super_block *s)
846 return le32_to_cpu(s->sectorsize);
849 static inline void btrfs_set_super_sectorsize(struct btrfs_super_block *s,
852 s->sectorsize = cpu_to_le32(val);
855 static inline u32 btrfs_super_nodesize(struct btrfs_super_block *s)
857 return le32_to_cpu(s->nodesize);
860 static inline void btrfs_set_super_nodesize(struct btrfs_super_block *s,
863 s->nodesize = cpu_to_le32(val);
866 static inline u32 btrfs_super_leafsize(struct btrfs_super_block *s)
868 return le32_to_cpu(s->leafsize);
871 static inline void btrfs_set_super_leafsize(struct btrfs_super_block *s,
874 s->leafsize = cpu_to_le32(val);
877 static inline u64 btrfs_super_root_dir(struct btrfs_super_block *s)
879 return le64_to_cpu(s->root_dir_objectid);
882 static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
885 s->root_dir_objectid = cpu_to_le64(val);
888 static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
890 return (u8 *)l->items;
893 static inline int btrfs_file_extent_type(struct btrfs_file_extent_item *e)
897 static inline void btrfs_set_file_extent_type(struct btrfs_file_extent_item *e,
903 static inline char *btrfs_file_extent_inline_start(struct
904 btrfs_file_extent_item *e)
906 return (char *)(&e->disk_blocknr);
909 static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
911 return (unsigned long)(&((struct
912 btrfs_file_extent_item *)NULL)->disk_blocknr) + datasize;
915 static inline u32 btrfs_file_extent_inline_len(struct btrfs_item *e)
917 struct btrfs_file_extent_item *fe = NULL;
918 return btrfs_item_size(e) - (unsigned long)(&fe->disk_blocknr);
921 static inline u64 btrfs_file_extent_disk_blocknr(struct btrfs_file_extent_item
924 return le64_to_cpu(e->disk_blocknr);
927 static inline void btrfs_set_file_extent_disk_blocknr(struct
928 btrfs_file_extent_item
931 e->disk_blocknr = cpu_to_le64(val);
934 static inline u64 btrfs_file_extent_generation(struct btrfs_file_extent_item *e)
936 return le64_to_cpu(e->generation);
939 static inline void btrfs_set_file_extent_generation(struct
940 btrfs_file_extent_item *e,
943 e->generation = cpu_to_le64(val);
946 static inline u64 btrfs_file_extent_disk_num_blocks(struct
947 btrfs_file_extent_item *e)
949 return le64_to_cpu(e->disk_num_blocks);
952 static inline void btrfs_set_file_extent_disk_num_blocks(struct
953 btrfs_file_extent_item
956 e->disk_num_blocks = cpu_to_le64(val);
959 static inline u64 btrfs_file_extent_offset(struct btrfs_file_extent_item *e)
961 return le64_to_cpu(e->offset);
964 static inline void btrfs_set_file_extent_offset(struct btrfs_file_extent_item
967 e->offset = cpu_to_le64(val);
970 static inline u64 btrfs_file_extent_num_blocks(struct btrfs_file_extent_item
973 return le64_to_cpu(e->num_blocks);
976 static inline void btrfs_set_file_extent_num_blocks(struct
977 btrfs_file_extent_item *e,
980 e->num_blocks = cpu_to_le64(val);
983 /* helper function to cast into the data area of the leaf. */
984 #define btrfs_item_ptr(leaf, slot, type) \
985 ((type *)(btrfs_leaf_data(leaf) + \
986 btrfs_item_offset((leaf)->items + (slot))))
988 int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2);
989 int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
990 *root, struct btrfs_path *path, u32 data_size);
991 struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
992 struct btrfs_root *root);
993 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
994 struct btrfs_buffer *buf);
995 int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
996 *root, u64 blocknr, u64 num_blocks, int pin);
997 int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
998 *root, struct btrfs_key *key, struct btrfs_path *p, int
1000 void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
1001 void btrfs_init_path(struct btrfs_path *p);
1002 int btrfs_del_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1003 struct btrfs_path *path);
1004 int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
1005 *root, struct btrfs_key *key, void *data, u32 data_size);
1006 int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, struct btrfs_root
1007 *root, struct btrfs_path *path, struct btrfs_key
1008 *cpu_key, u32 data_size);
1009 int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
1010 int btrfs_leaf_free_space(struct btrfs_root *root, struct btrfs_leaf *leaf);
1011 int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
1012 *root, struct btrfs_buffer *snap);
1013 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
1015 int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1016 struct btrfs_key *key);
1017 int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
1018 *root, struct btrfs_key *key, struct btrfs_root_item
1020 int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
1021 *root, struct btrfs_key *key, struct btrfs_root_item
1023 int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
1024 btrfs_root_item *item, struct btrfs_key *key);
1025 int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
1026 *root, char *name, int name_len, u64 dir,
1027 struct btrfs_key *location, u8 type);
1028 int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
1029 *root, struct btrfs_path *path, u64 dir, char *name,
1030 int name_len, int mod);
1031 int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path,
1032 char *name, int name_len);
1033 int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
1034 struct btrfs_root *fs_root,
1035 u64 dirid, u64 *objectid);
1036 int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
1037 *root, u64 objectid, struct btrfs_inode_item
1039 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
1040 *root, struct btrfs_path *path, u64 objectid, int mod);
1041 int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1042 struct btrfs_root *root);
1043 int btrfs_free_block_groups(struct btrfs_fs_info *info);
1044 int btrfs_read_block_groups(struct btrfs_root *root);
1045 int btrfs_insert_block_group(struct btrfs_trans_handle *trans,
1046 struct btrfs_root *root,
1047 struct btrfs_key *key,
1048 struct btrfs_block_group_item *bi);