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"
24 #include "radix-tree.h"
25 #include "extent-cache.h"
26 #include "extent_io.h"
29 struct btrfs_trans_handle;
30 #define BTRFS_MAGIC "_B4RfS_M"
32 #define BTRFS_MAX_LEVEL 8
34 /* holds pointers to all of the tree roots */
35 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
37 /* stores information about which extents are in use, and reference counts */
38 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
40 /* one per subvolume, storing files and directories */
41 #define BTRFS_FS_TREE_OBJECTID 3ULL
43 /* directory objectid inside the root tree */
44 #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
48 * chunk tree stores translations from logical -> physical block numbering
49 * the super block points to the chunk tree
51 #define BTRFS_CHUNK_TREE_OBJECTID 5ULL
54 * stores information about which areas of a given device are in use.
55 * one per device. The tree of tree roots points to the device tree
57 #define BTRFS_DEV_TREE_OBJECTID 6ULL
60 * All files have objectids higher than this.
62 #define BTRFS_FIRST_FREE_OBJECTID 256ULL
66 * the device items go into the chunk tree. The key is in the form
67 * [ 1 BTRFS_DEV_ITEM_KEY device_id ]
69 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL
72 * we can actually store much bigger names, but lets not confuse the rest
75 #define BTRFS_NAME_LEN 255
77 /* 32 bytes in various csum fields */
78 #define BTRFS_CSUM_SIZE 32
79 /* four bytes for CRC32 */
80 #define BTRFS_CRC32_SIZE 4
81 #define BTRFS_EMPTY_DIR_SIZE 0
83 #define BTRFS_FT_UNKNOWN 0
84 #define BTRFS_FT_REG_FILE 1
85 #define BTRFS_FT_DIR 2
86 #define BTRFS_FT_CHRDEV 3
87 #define BTRFS_FT_BLKDEV 4
88 #define BTRFS_FT_FIFO 5
89 #define BTRFS_FT_SOCK 6
90 #define BTRFS_FT_SYMLINK 7
91 #define BTRFS_FT_XATTR 8
92 #define BTRFS_FT_MAX 9
95 * the key defines the order in the tree, and so it also defines (optimal)
96 * block layout. objectid corresonds to the inode number. The flags
97 * tells us things about the object, and is a kind of stream selector.
98 * so for a given inode, keys with flags of 1 might refer to the inode
99 * data, flags of 2 may point to file data in the btree and flags == 3
100 * may point to extents.
102 * offset is the starting byte offset for this key in the stream.
104 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
105 * in cpu native order. Otherwise they are identical and their sizes
106 * should be the same (ie both packed)
108 struct btrfs_disk_key {
112 } __attribute__ ((__packed__));
118 } __attribute__ ((__packed__));
120 struct btrfs_mapping_tree {
121 struct cache_tree cache_tree;
124 #define BTRFS_DEV_UUID_SIZE 16
125 struct btrfs_dev_item {
126 /* the internal btrfs device id */
129 /* size of the device */
135 /* optimal io alignment for this device */
138 /* optimal io width for this device */
141 /* minimal io size for this device */
144 /* the kernel device number */
147 /* type and info about this device */
150 /* partition number, 0 for whole dev */
153 /* length of the name data at the end of the item */
156 /* physical drive uuid (or lvm uuid) */
157 u8 uuid[BTRFS_DEV_UUID_SIZE];
159 } __attribute__ ((__packed__));
161 struct btrfs_stripe {
164 } __attribute__ ((__packed__));
171 /* optimal io alignment for this chunk */
174 /* optimal io width for this chunk */
177 /* minimal io size for this chunk */
180 /* 2^16 stripes is quite a lot, a second limit is the size of a single
184 struct btrfs_stripe stripe;
185 /* additional stripes go here */
186 } __attribute__ ((__packed__));
188 static inline unsigned long btrfs_chunk_item_size(int num_stripes)
190 BUG_ON(num_stripes == 0);
191 return sizeof(struct btrfs_chunk) +
192 sizeof(struct btrfs_stripe) * (num_stripes - 1);
195 #define BTRFS_FSID_SIZE 16
197 * every tree block (leaf or node) starts with this header.
199 struct btrfs_header {
200 u8 csum[BTRFS_CSUM_SIZE];
201 u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
202 __le64 bytenr; /* which block this node is supposed to live in */
208 } __attribute__ ((__packed__));
210 #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
211 sizeof(struct btrfs_header)) / \
212 sizeof(struct btrfs_key_ptr))
213 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
214 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
215 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
216 sizeof(struct btrfs_item) - \
217 sizeof(struct btrfs_file_extent_item))
220 * this is a very generous portion of the super block, giving us
221 * room to translate 14 chunks with 3 stripes each.
223 #define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
226 * the super block basically lists the main trees of the FS
227 * it currently lacks any block count etc etc
229 struct btrfs_super_block {
230 u8 csum[BTRFS_CSUM_SIZE];
231 /* the first 3 fields must match struct btrfs_header */
232 u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
233 __le64 bytenr; /* this block number */
240 __le64 root_dir_objectid;
245 __le32 sys_chunk_array_size;
248 u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
249 } __attribute__ ((__packed__));
252 * A leaf is full of items. offset and size tell us where to find
253 * the item in the leaf (relative to the start of the data area)
256 struct btrfs_disk_key key;
259 } __attribute__ ((__packed__));
262 * leaves have an item area and a data area:
263 * [item0, item1....itemN] [free space] [dataN...data1, data0]
265 * The data is separate from the items to get the keys closer together
269 struct btrfs_header header;
270 struct btrfs_item items[];
271 } __attribute__ ((__packed__));
274 * all non-leaf blocks are nodes, they hold only keys and pointers to
277 struct btrfs_key_ptr {
278 struct btrfs_disk_key key;
281 } __attribute__ ((__packed__));
284 struct btrfs_header header;
285 struct btrfs_key_ptr ptrs[];
286 } __attribute__ ((__packed__));
289 * btrfs_paths remember the path taken from the root down to the leaf.
290 * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point
291 * to any other levels that are present.
293 * The slots array records the index of the item or block pointer
294 * used while walking the tree.
297 struct extent_buffer *nodes[BTRFS_MAX_LEVEL];
298 int slots[BTRFS_MAX_LEVEL];
304 * items in the extent btree are used to record the objectid of the
305 * owner of the block and the number of references
307 struct btrfs_extent_item {
309 } __attribute__ ((__packed__));
311 struct btrfs_extent_ref {
316 } __attribute__ ((__packed__));
318 /* dev extents record free space on individual devices. The owner
319 * field points back to the chunk allocation mapping tree that allocated
322 struct btrfs_dev_extent {
325 } __attribute__ ((__packed__));
328 struct btrfs_inode_ref {
331 } __attribute__ ((__packed__));
333 struct btrfs_timespec {
336 } __attribute__ ((__packed__));
339 * there is no padding here on purpose. If you want to extent the inode,
340 * make a new item type
342 struct btrfs_inode_item {
354 struct btrfs_timespec atime;
355 struct btrfs_timespec ctime;
356 struct btrfs_timespec mtime;
357 struct btrfs_timespec otime;
358 } __attribute__ ((__packed__));
360 struct btrfs_dir_item {
361 struct btrfs_disk_key location;
365 } __attribute__ ((__packed__));
367 struct btrfs_root_item {
368 struct btrfs_inode_item inode;
375 struct btrfs_disk_key drop_progress;
378 } __attribute__ ((__packed__));
380 #define BTRFS_FILE_EXTENT_REG 0
381 #define BTRFS_FILE_EXTENT_INLINE 1
383 struct btrfs_file_extent_item {
387 * disk space consumed by the extent, checksum blocks are included
391 __le64 disk_num_bytes;
393 * the logical offset in file blocks (no csums)
394 * this extent record is for. This allows a file extent to point
395 * into the middle of an existing extent on disk, sharing it
396 * between two snapshots (useful if some bytes in the middle of the
397 * extent have changed
401 * the logical number of file blocks (no csums included)
404 } __attribute__ ((__packed__));
406 struct btrfs_csum_item {
408 } __attribute__ ((__packed__));
410 /* tag for the radix tree of block groups in ram */
411 #define BTRFS_BLOCK_GROUP_DATA (1 << 0)
412 #define BTRFS_BLOCK_GROUP_SYSTEM (1 << 1)
413 #define BTRFS_BLOCK_GROUP_METADATA (1 << 2)
415 struct btrfs_block_group_item {
418 __le64 chunk_objectid;
420 } __attribute__ ((__packed__));
422 struct btrfs_block_group_cache {
423 struct cache_extent cache;
424 struct btrfs_key key;
425 struct btrfs_block_group_item item;
431 struct btrfs_extent_ops {
432 int (*alloc_extent)(struct btrfs_root *root, u64 num_bytes,
433 u64 hint_byte, struct btrfs_key *ins);
434 int (*free_extent)(struct btrfs_root *root, u64 bytenr,
439 struct btrfs_fs_info {
440 u8 fsid[BTRFS_FSID_SIZE];
441 struct btrfs_root *fs_root;
442 struct btrfs_root *extent_root;
443 struct btrfs_root *tree_root;
444 struct btrfs_root *chunk_root;
445 struct btrfs_root *dev_root;
447 struct extent_io_tree extent_cache;
448 struct extent_io_tree free_space_cache;
449 struct extent_io_tree block_group_cache;
450 struct extent_io_tree pinned_extents;
451 struct extent_io_tree pending_del;
452 struct extent_io_tree extent_ins;
454 /* logical->physical extent mapping */
455 struct btrfs_mapping_tree mapping_tree;
458 u64 last_trans_committed;
459 struct btrfs_trans_handle *running_transaction;
460 struct btrfs_super_block super_copy;
461 struct extent_buffer *sb_buffer;
462 struct mutex fs_mutex;
465 struct btrfs_extent_ops *extent_ops;
466 struct list_head dirty_cowonly_roots;
468 struct list_head devices;
469 struct list_head *last_device;
471 int force_system_allocs;
476 * in ram representation of the tree. extent_root is used for all allocations
477 * and for the extent tree extent_root root.
480 struct extent_buffer *node;
481 struct extent_buffer *commit_root;
482 struct btrfs_root_item root_item;
483 struct btrfs_key root_key;
484 struct btrfs_fs_info *fs_info;
488 /* data allocations are done in sectorsize units */
491 /* node allocations are done in nodesize units */
494 /* leaf allocations are done in leafsize units */
497 /* leaf allocations are done in leafsize units */
506 u64 last_inode_alloc;
508 /* the dirty list is only used by non-reference counted roots */
509 struct list_head dirty_list;
513 * inode items have the data typically returned from stat and store other
514 * info about object characteristics. There is one for every file and dir in
517 #define BTRFS_INODE_ITEM_KEY 1
518 #define BTRFS_INODE_REF_KEY 2
519 #define BTRFS_XATTR_ITEM_KEY 8
521 /* reserve 3-15 close to the inode for later flexibility */
524 * dir items are the name -> inode pointers in a directory. There is one
525 * for every name in a directory.
527 #define BTRFS_DIR_ITEM_KEY 16
528 #define BTRFS_DIR_INDEX_KEY 17
530 * extent data is for file data
532 #define BTRFS_EXTENT_DATA_KEY 18
534 * csum items have the checksums for data in the extents
536 #define BTRFS_CSUM_ITEM_KEY 19
538 /* reserve 20-31 for other file stuff */
541 * root items point to tree roots. There are typically in the root
542 * tree used by the super block to find all the other trees
544 #define BTRFS_ROOT_ITEM_KEY 32
546 * extent items are in the extent map tree. These record which blocks
547 * are used, and how many references there are to each block
549 #define BTRFS_EXTENT_ITEM_KEY 33
550 #define BTRFS_EXTENT_REF_KEY 34
553 * block groups give us hints into the extent allocation trees. Which
554 * blocks are free etc etc
556 #define BTRFS_BLOCK_GROUP_ITEM_KEY 50
558 #define BTRFS_DEV_EXTENT_KEY 75
559 #define BTRFS_DEV_ITEM_KEY 76
560 #define BTRFS_CHUNK_ITEM_KEY 77
563 * string items are for debugging. They just store a short string of
566 #define BTRFS_STRING_ITEM_KEY 253
570 #define BTRFS_INODE_NODATASUM (1 << 0)
571 #define BTRFS_INODE_NODATACOW (1 << 1)
572 #define BTRFS_INODE_READONLY (1 << 2)
574 #define read_eb_member(eb, ptr, type, member, result) ( \
575 read_extent_buffer(eb, (char *)(result), \
576 ((unsigned long)(ptr)) + \
577 offsetof(type, member), \
578 sizeof(((type *)0)->member)))
580 #define write_eb_member(eb, ptr, type, member, result) ( \
581 write_extent_buffer(eb, (char *)(result), \
582 ((unsigned long)(ptr)) + \
583 offsetof(type, member), \
584 sizeof(((type *)0)->member)))
586 #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
587 static inline u##bits btrfs_##name(struct extent_buffer *eb) \
589 struct btrfs_header *h = (struct btrfs_header *)eb->data; \
590 return le##bits##_to_cpu(h->member); \
592 static inline void btrfs_set_##name(struct extent_buffer *eb, \
595 struct btrfs_header *h = (struct btrfs_header *)eb->data; \
596 h->member = cpu_to_le##bits(val); \
599 #define BTRFS_SETGET_FUNCS(name, type, member, bits) \
600 static inline u##bits btrfs_##name(struct extent_buffer *eb, \
603 unsigned long offset = (unsigned long)s; \
604 type *p = (type *) (eb->data + offset); \
605 return le##bits##_to_cpu(p->member); \
607 static inline void btrfs_set_##name(struct extent_buffer *eb, \
608 type *s, u##bits val) \
610 unsigned long offset = (unsigned long)s; \
611 type *p = (type *) (eb->data + offset); \
612 p->member = cpu_to_le##bits(val); \
615 #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \
616 static inline u##bits btrfs_##name(type *s) \
618 return le##bits##_to_cpu(s->member); \
620 static inline void btrfs_set_##name(type *s, u##bits val) \
622 s->member = cpu_to_le##bits(val); \
625 BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64);
626 BTRFS_SETGET_FUNCS(device_total_bytes, struct btrfs_dev_item, total_bytes, 64);
627 BTRFS_SETGET_FUNCS(device_bytes_used, struct btrfs_dev_item, bytes_used, 64);
628 BTRFS_SETGET_FUNCS(device_io_align, struct btrfs_dev_item, io_align, 32);
629 BTRFS_SETGET_FUNCS(device_io_width, struct btrfs_dev_item, io_width, 32);
630 BTRFS_SETGET_FUNCS(device_sector_size, struct btrfs_dev_item, sector_size, 32);
631 BTRFS_SETGET_FUNCS(device_id, struct btrfs_dev_item, devid, 64);
632 BTRFS_SETGET_FUNCS(device_rdev, struct btrfs_dev_item, rdev, 64);
633 BTRFS_SETGET_FUNCS(device_partition, struct btrfs_dev_item, partition, 32);
634 BTRFS_SETGET_FUNCS(device_name_len, struct btrfs_dev_item, name_len, 16);
636 static inline char *btrfs_device_uuid(struct btrfs_dev_item *d)
638 return (char *)d + offsetof(struct btrfs_dev_item, uuid);
641 static inline char *btrfs_device_name(struct btrfs_dev_item *d)
643 return (char *)(d + 1);
646 BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64);
647 BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64);
648 BTRFS_SETGET_FUNCS(chunk_io_align, struct btrfs_chunk, io_align, 32);
649 BTRFS_SETGET_FUNCS(chunk_io_width, struct btrfs_chunk, io_width, 32);
650 BTRFS_SETGET_FUNCS(chunk_sector_size, struct btrfs_chunk, sector_size, 32);
651 BTRFS_SETGET_FUNCS(chunk_type, struct btrfs_chunk, type, 64);
652 BTRFS_SETGET_FUNCS(chunk_num_stripes, struct btrfs_chunk, num_stripes, 16);
653 BTRFS_SETGET_FUNCS(stripe_devid, struct btrfs_stripe, devid, 64);
654 BTRFS_SETGET_FUNCS(stripe_offset, struct btrfs_stripe, offset, 64);
656 BTRFS_SETGET_STACK_FUNCS(stack_chunk_owner, struct btrfs_chunk, owner, 64);
657 BTRFS_SETGET_STACK_FUNCS(stack_chunk_stripe_len, struct btrfs_chunk,
659 BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_align, struct btrfs_chunk,
661 BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_width, struct btrfs_chunk,
663 BTRFS_SETGET_STACK_FUNCS(stack_chunk_sector_size, struct btrfs_chunk,
665 BTRFS_SETGET_STACK_FUNCS(stack_chunk_type, struct btrfs_chunk, type, 64);
666 BTRFS_SETGET_STACK_FUNCS(stack_chunk_num_stripes, struct btrfs_chunk,
668 BTRFS_SETGET_STACK_FUNCS(stack_stripe_devid, struct btrfs_stripe, devid, 64);
669 BTRFS_SETGET_STACK_FUNCS(stack_stripe_offset, struct btrfs_stripe, offset, 64);
671 static inline struct btrfs_stripe *btrfs_stripe_nr(struct btrfs_chunk *c,
674 unsigned long offset = (unsigned long)c;
675 offset += offsetof(struct btrfs_chunk, stripe);
676 offset += nr * sizeof(struct btrfs_stripe);
677 return (struct btrfs_stripe *)offset;
680 static inline u64 btrfs_stripe_offset_nr(struct extent_buffer *eb,
681 struct btrfs_chunk *c, int nr)
683 return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr));
686 static inline void btrfs_set_stripe_offset_nr(struct extent_buffer *eb,
687 struct btrfs_chunk *c, int nr,
690 btrfs_set_stripe_offset(eb, btrfs_stripe_nr(c, nr), val);
693 static inline u64 btrfs_stripe_devid_nr(struct extent_buffer *eb,
694 struct btrfs_chunk *c, int nr)
696 return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr));
699 static inline void btrfs_set_stripe_devid_nr(struct extent_buffer *eb,
700 struct btrfs_chunk *c, int nr,
703 btrfs_set_stripe_devid(eb, btrfs_stripe_nr(c, nr), val);
706 /* struct btrfs_block_group_item */
707 BTRFS_SETGET_STACK_FUNCS(block_group_used, struct btrfs_block_group_item,
709 BTRFS_SETGET_FUNCS(disk_block_group_used, struct btrfs_block_group_item,
711 BTRFS_SETGET_STACK_FUNCS(block_group_chunk_tree, struct btrfs_block_group_item,
713 BTRFS_SETGET_FUNCS(disk_block_group_chunk_tree, struct btrfs_block_group_item,
715 BTRFS_SETGET_STACK_FUNCS(block_group_chunk_objectid,
716 struct btrfs_block_group_item, chunk_objectid, 64);
717 BTRFS_SETGET_FUNCS(disk_block_group_chunk_objecitd,
718 struct btrfs_block_group_item, chunk_objectid, 64);
719 BTRFS_SETGET_FUNCS(disk_block_group_flags,
720 struct btrfs_block_group_item, flags, 64);
721 BTRFS_SETGET_STACK_FUNCS(block_group_flags,
722 struct btrfs_block_group_item, flags, 64);
724 /* struct btrfs_inode_ref */
725 BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
727 /* struct btrfs_inode_item */
728 BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64);
729 BTRFS_SETGET_FUNCS(inode_size, struct btrfs_inode_item, size, 64);
730 BTRFS_SETGET_FUNCS(inode_nblocks, struct btrfs_inode_item, nblocks, 64);
731 BTRFS_SETGET_FUNCS(inode_block_group, struct btrfs_inode_item, block_group, 64);
732 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
733 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
734 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
735 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
736 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
737 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 16);
738 BTRFS_SETGET_FUNCS(inode_compat_flags, struct btrfs_inode_item,
741 BTRFS_SETGET_STACK_FUNCS(stack_inode_generation,
742 struct btrfs_inode_item, generation, 64);
743 BTRFS_SETGET_STACK_FUNCS(stack_inode_size,
744 struct btrfs_inode_item, size, 64);
745 BTRFS_SETGET_STACK_FUNCS(stack_inode_nblocks,
746 struct btrfs_inode_item, nblocks, 64);
747 BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group,
748 struct btrfs_inode_item, block_group, 64);
749 BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink,
750 struct btrfs_inode_item, nlink, 32);
751 BTRFS_SETGET_STACK_FUNCS(stack_inode_uid,
752 struct btrfs_inode_item, uid, 32);
753 BTRFS_SETGET_STACK_FUNCS(stack_inode_gid,
754 struct btrfs_inode_item, gid, 32);
755 BTRFS_SETGET_STACK_FUNCS(stack_inode_mode,
756 struct btrfs_inode_item, mode, 32);
757 BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev,
758 struct btrfs_inode_item, rdev, 64);
759 BTRFS_SETGET_STACK_FUNCS(stack_inode_flags,
760 struct btrfs_inode_item, flags, 16);
761 BTRFS_SETGET_STACK_FUNCS(stack_inode_compat_flags,
762 struct btrfs_inode_item, compat_flags, 16);
764 static inline struct btrfs_timespec *
765 btrfs_inode_atime(struct btrfs_inode_item *inode_item)
767 unsigned long ptr = (unsigned long)inode_item;
768 ptr += offsetof(struct btrfs_inode_item, atime);
769 return (struct btrfs_timespec *)ptr;
772 static inline struct btrfs_timespec *
773 btrfs_inode_mtime(struct btrfs_inode_item *inode_item)
775 unsigned long ptr = (unsigned long)inode_item;
776 ptr += offsetof(struct btrfs_inode_item, mtime);
777 return (struct btrfs_timespec *)ptr;
780 static inline struct btrfs_timespec *
781 btrfs_inode_ctime(struct btrfs_inode_item *inode_item)
783 unsigned long ptr = (unsigned long)inode_item;
784 ptr += offsetof(struct btrfs_inode_item, ctime);
785 return (struct btrfs_timespec *)ptr;
788 static inline struct btrfs_timespec *
789 btrfs_inode_otime(struct btrfs_inode_item *inode_item)
791 unsigned long ptr = (unsigned long)inode_item;
792 ptr += offsetof(struct btrfs_inode_item, otime);
793 return (struct btrfs_timespec *)ptr;
796 BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
797 BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
798 BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec,
800 BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec,
803 /* struct btrfs_dev_extent */
804 BTRFS_SETGET_FUNCS(dev_extent_owner, struct btrfs_dev_extent, owner, 64);
805 BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64);
807 /* struct btrfs_extent_item */
808 BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32);
810 /* struct btrfs_extent_ref */
811 BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64);
812 BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64);
813 BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64);
814 BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64);
816 BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 64);
817 BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref,
819 BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref,
821 BTRFS_SETGET_STACK_FUNCS(stack_ref_offset, struct btrfs_extent_ref, offset, 64);
823 BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item,
826 /* struct btrfs_node */
827 BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64);
828 BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64);
830 static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr)
833 ptr = offsetof(struct btrfs_node, ptrs) +
834 sizeof(struct btrfs_key_ptr) * nr;
835 return btrfs_key_blockptr(eb, (struct btrfs_key_ptr *)ptr);
838 static inline void btrfs_set_node_blockptr(struct extent_buffer *eb,
842 ptr = offsetof(struct btrfs_node, ptrs) +
843 sizeof(struct btrfs_key_ptr) * nr;
844 btrfs_set_key_blockptr(eb, (struct btrfs_key_ptr *)ptr, val);
847 static inline u64 btrfs_node_ptr_generation(struct extent_buffer *eb, int nr)
850 ptr = offsetof(struct btrfs_node, ptrs) +
851 sizeof(struct btrfs_key_ptr) * nr;
852 return btrfs_key_generation(eb, (struct btrfs_key_ptr *)ptr);
855 static inline void btrfs_set_node_ptr_generation(struct extent_buffer *eb,
859 ptr = offsetof(struct btrfs_node, ptrs) +
860 sizeof(struct btrfs_key_ptr) * nr;
861 btrfs_set_key_generation(eb, (struct btrfs_key_ptr *)ptr, val);
864 static inline unsigned long btrfs_node_key_ptr_offset(int nr)
866 return offsetof(struct btrfs_node, ptrs) +
867 sizeof(struct btrfs_key_ptr) * nr;
870 static inline void btrfs_node_key(struct extent_buffer *eb,
871 struct btrfs_disk_key *disk_key, int nr)
874 ptr = btrfs_node_key_ptr_offset(nr);
875 read_eb_member(eb, (struct btrfs_key_ptr *)ptr,
876 struct btrfs_key_ptr, key, disk_key);
879 static inline void btrfs_set_node_key(struct extent_buffer *eb,
880 struct btrfs_disk_key *disk_key, int nr)
883 ptr = btrfs_node_key_ptr_offset(nr);
884 write_eb_member(eb, (struct btrfs_key_ptr *)ptr,
885 struct btrfs_key_ptr, key, disk_key);
888 /* struct btrfs_item */
889 BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32);
890 BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32);
892 static inline unsigned long btrfs_item_nr_offset(int nr)
894 return offsetof(struct btrfs_leaf, items) +
895 sizeof(struct btrfs_item) * nr;
898 static inline struct btrfs_item *btrfs_item_nr(struct extent_buffer *eb,
901 return (struct btrfs_item *)btrfs_item_nr_offset(nr);
904 static inline u32 btrfs_item_end(struct extent_buffer *eb,
905 struct btrfs_item *item)
907 return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item);
910 static inline u32 btrfs_item_end_nr(struct extent_buffer *eb, int nr)
912 return btrfs_item_end(eb, btrfs_item_nr(eb, nr));
915 static inline u32 btrfs_item_offset_nr(struct extent_buffer *eb, int nr)
917 return btrfs_item_offset(eb, btrfs_item_nr(eb, nr));
920 static inline u32 btrfs_item_size_nr(struct extent_buffer *eb, int nr)
922 return btrfs_item_size(eb, btrfs_item_nr(eb, nr));
925 static inline void btrfs_item_key(struct extent_buffer *eb,
926 struct btrfs_disk_key *disk_key, int nr)
928 struct btrfs_item *item = btrfs_item_nr(eb, nr);
929 read_eb_member(eb, item, struct btrfs_item, key, disk_key);
932 static inline void btrfs_set_item_key(struct extent_buffer *eb,
933 struct btrfs_disk_key *disk_key, int nr)
935 struct btrfs_item *item = btrfs_item_nr(eb, nr);
936 write_eb_member(eb, item, struct btrfs_item, key, disk_key);
939 /* struct btrfs_dir_item */
940 BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16);
941 BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8);
942 BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16);
944 static inline void btrfs_dir_item_key(struct extent_buffer *eb,
945 struct btrfs_dir_item *item,
946 struct btrfs_disk_key *key)
948 read_eb_member(eb, item, struct btrfs_dir_item, location, key);
951 static inline void btrfs_set_dir_item_key(struct extent_buffer *eb,
952 struct btrfs_dir_item *item,
953 struct btrfs_disk_key *key)
955 write_eb_member(eb, item, struct btrfs_dir_item, location, key);
958 /* struct btrfs_disk_key */
959 BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key,
961 BTRFS_SETGET_STACK_FUNCS(disk_key_offset, struct btrfs_disk_key, offset, 64);
962 BTRFS_SETGET_STACK_FUNCS(disk_key_type, struct btrfs_disk_key, type, 8);
964 static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
965 struct btrfs_disk_key *disk)
967 cpu->offset = le64_to_cpu(disk->offset);
968 cpu->type = disk->type;
969 cpu->objectid = le64_to_cpu(disk->objectid);
972 static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,
973 struct btrfs_key *cpu)
975 disk->offset = cpu_to_le64(cpu->offset);
976 disk->type = cpu->type;
977 disk->objectid = cpu_to_le64(cpu->objectid);
980 static inline void btrfs_node_key_to_cpu(struct extent_buffer *eb,
981 struct btrfs_key *key, int nr)
983 struct btrfs_disk_key disk_key;
984 btrfs_node_key(eb, &disk_key, nr);
985 btrfs_disk_key_to_cpu(key, &disk_key);
988 static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb,
989 struct btrfs_key *key, int nr)
991 struct btrfs_disk_key disk_key;
992 btrfs_item_key(eb, &disk_key, nr);
993 btrfs_disk_key_to_cpu(key, &disk_key);
996 static inline void btrfs_dir_item_key_to_cpu(struct extent_buffer *eb,
997 struct btrfs_dir_item *item,
998 struct btrfs_key *key)
1000 struct btrfs_disk_key disk_key;
1001 btrfs_dir_item_key(eb, item, &disk_key);
1002 btrfs_disk_key_to_cpu(key, &disk_key);
1006 static inline u8 btrfs_key_type(struct btrfs_key *key)
1011 static inline void btrfs_set_key_type(struct btrfs_key *key, u8 val)
1016 /* struct btrfs_header */
1017 BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64);
1018 BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header,
1020 BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
1021 BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
1022 BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 16);
1023 BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
1025 static inline u8 *btrfs_header_fsid(struct extent_buffer *eb)
1027 unsigned long ptr = offsetof(struct btrfs_header, fsid);
1031 static inline u8 *btrfs_super_fsid(struct extent_buffer *eb)
1033 unsigned long ptr = offsetof(struct btrfs_super_block, fsid);
1037 static inline u8 *btrfs_header_csum(struct extent_buffer *eb)
1039 unsigned long ptr = offsetof(struct btrfs_header, csum);
1043 static inline struct btrfs_node *btrfs_buffer_node(struct extent_buffer *eb)
1048 static inline struct btrfs_leaf *btrfs_buffer_leaf(struct extent_buffer *eb)
1053 static inline struct btrfs_header *btrfs_buffer_header(struct extent_buffer *eb)
1058 static inline int btrfs_is_leaf(struct extent_buffer *eb)
1060 return (btrfs_header_level(eb) == 0);
1063 /* struct btrfs_root_item */
1064 BTRFS_SETGET_FUNCS(disk_root_refs, struct btrfs_root_item, refs, 32);
1065 BTRFS_SETGET_FUNCS(disk_root_bytenr, struct btrfs_root_item, bytenr, 64);
1066 BTRFS_SETGET_FUNCS(disk_root_level, struct btrfs_root_item, level, 8);
1068 BTRFS_SETGET_STACK_FUNCS(root_bytenr, struct btrfs_root_item, bytenr, 64);
1069 BTRFS_SETGET_STACK_FUNCS(root_level, struct btrfs_root_item, level, 8);
1070 BTRFS_SETGET_STACK_FUNCS(root_dirid, struct btrfs_root_item, root_dirid, 64);
1071 BTRFS_SETGET_STACK_FUNCS(root_refs, struct btrfs_root_item, refs, 32);
1072 BTRFS_SETGET_STACK_FUNCS(root_flags, struct btrfs_root_item, flags, 32);
1073 BTRFS_SETGET_STACK_FUNCS(root_used, struct btrfs_root_item, bytes_used, 64);
1074 BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64);
1076 /* struct btrfs_super_block */
1077 BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64);
1078 BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block,
1080 BTRFS_SETGET_STACK_FUNCS(super_root, struct btrfs_super_block, root, 64);
1081 BTRFS_SETGET_STACK_FUNCS(super_sys_array_size,
1082 struct btrfs_super_block, sys_chunk_array_size, 32);
1083 BTRFS_SETGET_STACK_FUNCS(super_root_level, struct btrfs_super_block,
1085 BTRFS_SETGET_STACK_FUNCS(super_chunk_root, struct btrfs_super_block,
1087 BTRFS_SETGET_STACK_FUNCS(super_chunk_root_level, struct btrfs_super_block,
1088 chunk_root_level, 64);
1089 BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block,
1091 BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block,
1093 BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
1095 BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
1097 BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block,
1099 BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
1101 BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
1102 root_dir_objectid, 64);
1104 static inline unsigned long btrfs_leaf_data(struct extent_buffer *l)
1106 return offsetof(struct btrfs_leaf, items);
1109 /* struct btrfs_file_extent_item */
1110 BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8);
1112 static inline unsigned long btrfs_file_extent_inline_start(struct
1113 btrfs_file_extent_item *e)
1115 unsigned long offset = (unsigned long)e;
1116 offset += offsetof(struct btrfs_file_extent_item, disk_bytenr);
1120 static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
1122 return offsetof(struct btrfs_file_extent_item, disk_bytenr) + datasize;
1125 static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb,
1126 struct btrfs_item *e)
1128 unsigned long offset;
1129 offset = offsetof(struct btrfs_file_extent_item, disk_bytenr);
1130 return btrfs_item_size(eb, e) - offset;
1133 BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item,
1135 BTRFS_SETGET_FUNCS(file_extent_generation, struct btrfs_file_extent_item,
1137 BTRFS_SETGET_FUNCS(file_extent_disk_num_bytes, struct btrfs_file_extent_item,
1138 disk_num_bytes, 64);
1139 BTRFS_SETGET_FUNCS(file_extent_offset, struct btrfs_file_extent_item,
1141 BTRFS_SETGET_FUNCS(file_extent_num_bytes, struct btrfs_file_extent_item,
1144 static inline u32 btrfs_level_size(struct btrfs_root *root, int level) {
1146 return root->leafsize;
1147 return root->nodesize;
1150 /* helper function to cast into the data area of the leaf. */
1151 #define btrfs_item_ptr(leaf, slot, type) \
1152 ((type *)(btrfs_leaf_data(leaf) + \
1153 btrfs_item_offset_nr(leaf, slot)))
1155 #define btrfs_item_ptr_offset(leaf, slot) \
1156 ((unsigned long)(btrfs_leaf_data(leaf) + \
1157 btrfs_item_offset_nr(leaf, slot)))
1160 u32 btrfs_count_snapshots_in_path(struct btrfs_root *root,
1161 struct btrfs_path *count_path,
1163 int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
1164 struct btrfs_root *root);
1165 int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy);
1166 struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
1167 btrfs_fs_info *info,
1169 struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
1170 struct btrfs_block_group_cache
1171 *hint, u64 search_start,
1172 int data, int owner);
1173 int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
1174 struct btrfs_root *root, u64 owner_objectid);
1175 struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1176 struct btrfs_root *root, u32 size,
1178 u64 hint, u64 empty_size);
1179 struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1180 struct btrfs_root *root,
1188 int btrfs_grow_extent_tree(struct btrfs_trans_handle *trans,
1189 struct btrfs_root *root, u64 new_size);
1190 int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size);
1191 int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans,
1192 struct btrfs_root *root,
1193 struct btrfs_path *path, u64 bytenr,
1194 u64 root_objectid, u64 ref_generation,
1195 u64 owner, u64 owner_offset);
1196 int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1197 struct btrfs_root *root,
1198 u64 num_bytes, u64 root_objectid, u64 ref_generation,
1199 u64 owner, u64 owner_offset,
1200 u64 empty_size, u64 hint_byte,
1201 u64 search_end, struct btrfs_key *ins, int data);
1202 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1203 struct extent_buffer *buf);
1204 int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
1205 *root, u64 bytenr, u64 num_bytes,
1206 u64 root_objectid, u64 ref_generation,
1207 u64 owner_objectid, u64 owner_offset, int pin);
1208 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
1209 struct btrfs_root *root,
1210 struct extent_io_tree *unpin);
1211 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
1212 struct btrfs_root *root,
1213 u64 bytenr, u64 num_bytes,
1214 u64 root_objectid, u64 ref_generation,
1215 u64 owner, u64 owner_offset);
1216 int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1217 struct btrfs_root *root);
1218 int btrfs_free_block_groups(struct btrfs_fs_info *info);
1219 int btrfs_read_block_groups(struct btrfs_root *root);
1220 int btrfs_make_block_group(struct btrfs_trans_handle *trans,
1221 struct btrfs_root *root, u64 bytes_used,
1222 u64 type, u64 chunk_tree, u64 chunk_objectid,
1224 u64 btrfs_hash_extent_ref(u64 root_objectid, u64 ref_generation,
1225 u64 owner, u64 owner_offset);
1226 int btrfs_update_block_group(struct btrfs_trans_handle *trans,
1227 struct btrfs_root *root, u64 bytenr, u64 num,
1228 int alloc, int mark_free);
1230 int btrfs_previous_item(struct btrfs_root *root,
1231 struct btrfs_path *path, u64 min_objectid,
1233 int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2);
1234 int btrfs_cow_block(struct btrfs_trans_handle *trans,
1235 struct btrfs_root *root, struct extent_buffer *buf,
1236 struct extent_buffer *parent, int parent_slot,
1237 struct extent_buffer **cow_ret);
1238 int btrfs_copy_root(struct btrfs_trans_handle *trans,
1239 struct btrfs_root *root,
1240 struct extent_buffer *buf,
1241 struct extent_buffer **cow_ret, u64 new_root_objectid);
1242 int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
1243 *root, struct btrfs_path *path, u32 data_size);
1244 int btrfs_truncate_item(struct btrfs_trans_handle *trans,
1245 struct btrfs_root *root,
1246 struct btrfs_path *path,
1247 u32 new_size, int from_end);
1248 int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
1249 *root, struct btrfs_key *key, struct btrfs_path *p, int
1251 int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1252 struct btrfs_root *root, struct extent_buffer *parent,
1253 int start_slot, int cache_only, u64 *last_ret,
1254 struct btrfs_key *progress);
1255 void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
1256 struct btrfs_path *btrfs_alloc_path(void);
1257 void btrfs_free_path(struct btrfs_path *p);
1258 void btrfs_init_path(struct btrfs_path *p);
1259 int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1260 struct btrfs_path *path, int slot, int nr);
1262 static inline int btrfs_del_item(struct btrfs_trans_handle *trans,
1263 struct btrfs_root *root,
1264 struct btrfs_path *path)
1266 return btrfs_del_items(trans, root, path, path->slots[0], 1);
1269 int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
1270 *root, struct btrfs_key *key, void *data, u32 data_size);
1271 int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
1272 struct btrfs_root *root,
1273 struct btrfs_path *path,
1274 struct btrfs_key *cpu_key, u32 *data_size, int nr);
1276 static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
1277 struct btrfs_root *root,
1278 struct btrfs_path *path,
1279 struct btrfs_key *key,
1282 return btrfs_insert_empty_items(trans, root, path, key, &data_size, 1);
1285 int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
1286 int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
1287 int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
1288 int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
1293 int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1294 struct btrfs_key *key);
1295 int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
1296 *root, struct btrfs_key *key, struct btrfs_root_item
1298 int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
1299 *root, struct btrfs_key *key, struct btrfs_root_item
1301 int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
1302 btrfs_root_item *item, struct btrfs_key *key);
1303 int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
1304 struct btrfs_root *latest_root);
1306 int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
1307 *root, const char *name, int name_len, u64 dir,
1308 struct btrfs_key *location, u8 type);
1309 struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
1310 struct btrfs_root *root,
1311 struct btrfs_path *path, u64 dir,
1312 const char *name, int name_len,
1314 struct btrfs_dir_item *
1315 btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
1316 struct btrfs_root *root,
1317 struct btrfs_path *path, u64 dir,
1318 u64 objectid, const char *name, int name_len,
1320 struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
1321 struct btrfs_path *path,
1322 const char *name, int name_len);
1323 int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
1324 struct btrfs_root *root,
1325 struct btrfs_path *path,
1326 struct btrfs_dir_item *di);
1327 int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
1328 struct btrfs_root *root, const char *name,
1329 u16 name_len, const void *data, u16 data_len,
1331 struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
1332 struct btrfs_root *root,
1333 struct btrfs_path *path, u64 dir,
1334 const char *name, u16 name_len,
1337 int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
1338 struct btrfs_root *fs_root,
1339 u64 dirid, u64 *objectid);
1340 int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid);
1343 int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
1344 struct btrfs_root *root,
1345 const char *name, int name_len,
1346 u64 inode_objectid, u64 ref_objectid);
1347 int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
1348 struct btrfs_root *root,
1349 const char *name, int name_len,
1350 u64 inode_objectid, u64 ref_objectid);
1351 int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
1352 struct btrfs_root *root,
1353 struct btrfs_path *path, u64 objectid);
1354 int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
1355 *root, u64 objectid, struct btrfs_inode_item
1357 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
1358 *root, struct btrfs_path *path,
1359 struct btrfs_key *location, int mod);
1362 int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
1363 struct btrfs_root *root,
1364 u64 objectid, u64 pos, u64 offset,
1367 int btrfs_insert_inline_extent(struct btrfs_trans_handle *trans,
1368 struct btrfs_root *root, u64 objectid,
1369 u64 offset, char *buffer, size_t size);
1370 int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
1371 struct btrfs_root *root,
1372 struct btrfs_path *path, u64 objectid,
1373 u64 bytenr, int mod);
1374 int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
1375 struct btrfs_root *root,
1376 struct btrfs_inode_item *inode,
1377 u64 objectid, u64 offset,
1378 char *data, size_t len);
1379 struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
1380 struct btrfs_root *root,
1381 struct btrfs_path *path,
1382 u64 objectid, u64 offset,
1384 int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
1385 struct btrfs_root *root, struct btrfs_path *path,