19 #ifndef __BTRFS_CTREE__
20 #define __BTRFS_CTREE__
28 #include <linux/wait.h>
29 #include <linux/slab.h>
32 #include <asm/kmap_types.h>
49 #define BTRFS_MAGIC "_BHRfS_M"
51 #define BTRFS_MAX_MIRRORS 2
53 #define BTRFS_MAX_LEVEL 8
55 #define BTRFS_COMPAT_EXTENT_TREE_V0
62 #define BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT (8 * 1024 * 1024)
65 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
68 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
74 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL
80 #define BTRFS_DEV_TREE_OBJECTID 4ULL
83 #define BTRFS_FS_TREE_OBJECTID 5ULL
86 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
89 #define BTRFS_CSUM_TREE_OBJECTID 7ULL
92 #define BTRFS_BALANCE_OBJECTID -4ULL
95 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
98 #define BTRFS_ORPHAN_OBJECTID -5ULL
101 #define BTRFS_TREE_LOG_OBJECTID -6ULL
102 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL
105 #define BTRFS_TREE_RELOC_OBJECTID -8ULL
106 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL
113 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
116 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
122 #define BTRFS_FREE_INO_OBJECTID -12ULL
125 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL
130 #define BTRFS_FIRST_FREE_OBJECTID 256ULL
131 #define BTRFS_LAST_FREE_OBJECTID -256ULL
132 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
139 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL
141 #define BTRFS_BTREE_INODE_OBJECTID 1
143 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
149 #define BTRFS_MAX_METADATA_BLOCKSIZE 65536
155 #define BTRFS_NAME_LEN 255
162 #define BTRFS_LINK_MAX 65535U
165 #define BTRFS_CSUM_SIZE 32
168 #define BTRFS_CSUM_TYPE_CRC32 0
170 static int btrfs_csum_sizes[] = { 4, 0 };
173 #define BTRFS_EMPTY_DIR_SIZE 0
175 #define BTRFS_FT_UNKNOWN 0
176 #define BTRFS_FT_REG_FILE 1
177 #define BTRFS_FT_DIR 2
178 #define BTRFS_FT_CHRDEV 3
179 #define BTRFS_FT_BLKDEV 4
180 #define BTRFS_FT_FIFO 5
181 #define BTRFS_FT_SOCK 6
182 #define BTRFS_FT_SYMLINK 7
183 #define BTRFS_FT_XATTR 8
184 #define BTRFS_FT_MAX 9
187 #define BTRFS_IOPRIO_READA (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0))
305 #define BTRFS_FREE_SPACE_EXTENT 1
306 #define BTRFS_FREE_SPACE_BITMAP 2
321 static inline unsigned long btrfs_chunk_item_size(
int num_stripes)
328 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
329 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
336 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
338 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
339 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
341 #define BTRFS_BACKREF_REV_MAX 256
342 #define BTRFS_BACKREF_REV_SHIFT 56
343 #define BTRFS_BACKREF_REV_MASK (((u64)BTRFS_BACKREF_REV_MAX - 1) << \
344 BTRFS_BACKREF_REV_SHIFT)
346 #define BTRFS_OLD_BACKREF_REV 0
347 #define BTRFS_MIXED_BACKREF_REV 1
367 #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
368 sizeof(struct btrfs_header)) / \
369 sizeof(struct btrfs_key_ptr))
370 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
371 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
372 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
373 sizeof(struct btrfs_item) - \
374 sizeof(struct btrfs_file_extent_item))
375 #define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
376 sizeof(struct btrfs_item) -\
377 sizeof(struct btrfs_dir_item))
384 #define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
385 #define BTRFS_LABEL_SIZE 256
392 #define BTRFS_NUM_BACKUP_ROOTS 4
481 #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
482 #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
483 #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
484 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
491 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZOv2 (1ULL << 4)
497 #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
499 #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
501 #define BTRFS_FEATURE_COMPAT_SUPP 0ULL
502 #define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
503 #define BTRFS_FEATURE_INCOMPAT_SUPP \
504 (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
505 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
506 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
507 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
508 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
509 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)
591 #define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r) >> 4) - \
592 sizeof(struct btrfs_item))
594 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
595 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
600 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
606 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
718 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
822 #define BTRFS_FILE_EXTENT_INLINE 0
823 #define BTRFS_FILE_EXTENT_REG 1
824 #define BTRFS_FILE_EXTENT_PREALLOC 2
889 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
890 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
891 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
892 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
893 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
894 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
895 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
896 #define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE
897 #define BTRFS_NR_RAID_TYPES 5
899 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
900 BTRFS_BLOCK_GROUP_SYSTEM | \
901 BTRFS_BLOCK_GROUP_METADATA)
903 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \
904 BTRFS_BLOCK_GROUP_RAID1 | \
905 BTRFS_BLOCK_GROUP_DUP | \
906 BTRFS_BLOCK_GROUP_RAID10)
914 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
916 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \
917 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
940 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
944 #define BTRFS_QGROUP_STATUS_FLAG_SCANNING (1ULL << 1)
952 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
954 #define BTRFS_QGROUP_STATUS_VERSION 1
985 #define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
986 #define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
987 #define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
988 #define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
989 #define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
990 #define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
1049 #define BTRFS_BLOCK_RSV_GLOBAL 1
1050 #define BTRFS_BLOCK_RSV_DELALLOC 2
1051 #define BTRFS_BLOCK_RSV_TRANS 3
1052 #define BTRFS_BLOCK_RSV_CHUNK 4
1053 #define BTRFS_BLOCK_RSV_DELOPS 5
1054 #define BTRFS_BLOCK_RSV_EMPTY 6
1055 #define BTRFS_BLOCK_RSV_TEMP 7
1433 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
1434 u32 check_integrity_print_mask;
1622 #define BTRFS_INODE_ITEM_KEY 1
1623 #define BTRFS_INODE_REF_KEY 12
1624 #define BTRFS_INODE_EXTREF_KEY 13
1625 #define BTRFS_XATTR_ITEM_KEY 24
1626 #define BTRFS_ORPHAN_ITEM_KEY 48
1633 #define BTRFS_DIR_LOG_ITEM_KEY 60
1634 #define BTRFS_DIR_LOG_INDEX_KEY 72
1635 #define BTRFS_DIR_ITEM_KEY 84
1636 #define BTRFS_DIR_INDEX_KEY 96
1640 #define BTRFS_EXTENT_DATA_KEY 108
1646 #define BTRFS_EXTENT_CSUM_KEY 128
1652 #define BTRFS_ROOT_ITEM_KEY 132
1658 #define BTRFS_ROOT_BACKREF_KEY 144
1665 #define BTRFS_ROOT_REF_KEY 156
1671 #define BTRFS_EXTENT_ITEM_KEY 168
1673 #define BTRFS_TREE_BLOCK_REF_KEY 176
1675 #define BTRFS_EXTENT_DATA_REF_KEY 178
1677 #define BTRFS_EXTENT_REF_V0_KEY 180
1679 #define BTRFS_SHARED_BLOCK_REF_KEY 182
1681 #define BTRFS_SHARED_DATA_REF_KEY 184
1687 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192
1689 #define BTRFS_DEV_EXTENT_KEY 204
1690 #define BTRFS_DEV_ITEM_KEY 216
1691 #define BTRFS_CHUNK_ITEM_KEY 228
1698 #define BTRFS_QGROUP_STATUS_KEY 240
1703 #define BTRFS_QGROUP_INFO_KEY 242
1708 #define BTRFS_QGROUP_LIMIT_KEY 244
1715 #define BTRFS_QGROUP_RELATION_KEY 246
1717 #define BTRFS_BALANCE_ITEM_KEY 248
1723 #define BTRFS_DEV_STATS_KEY 249
1729 #define BTRFS_STRING_ITEM_KEY 253
1736 #define BTRFS_MOUNT_NODATASUM (1 << 0)
1737 #define BTRFS_MOUNT_NODATACOW (1 << 1)
1738 #define BTRFS_MOUNT_NOBARRIER (1 << 2)
1739 #define BTRFS_MOUNT_SSD (1 << 3)
1740 #define BTRFS_MOUNT_DEGRADED (1 << 4)
1741 #define BTRFS_MOUNT_COMPRESS (1 << 5)
1742 #define BTRFS_MOUNT_NOTREELOG (1 << 6)
1743 #define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
1744 #define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
1745 #define BTRFS_MOUNT_NOSSD (1 << 9)
1746 #define BTRFS_MOUNT_DISCARD (1 << 10)
1747 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
1748 #define BTRFS_MOUNT_SPACE_CACHE (1 << 12)
1749 #define BTRFS_MOUNT_CLEAR_CACHE (1 << 13)
1750 #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
1751 #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15)
1752 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
1753 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1754 #define BTRFS_MOUNT_RECOVERY (1 << 18)
1755 #define BTRFS_MOUNT_SKIP_BALANCE (1 << 19)
1756 #define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20)
1757 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1758 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1760 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1761 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1762 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1767 #define BTRFS_INODE_NODATASUM (1 << 0)
1768 #define BTRFS_INODE_NODATACOW (1 << 1)
1769 #define BTRFS_INODE_READONLY (1 << 2)
1770 #define BTRFS_INODE_NOCOMPRESS (1 << 3)
1771 #define BTRFS_INODE_PREALLOC (1 << 4)
1772 #define BTRFS_INODE_SYNC (1 << 5)
1773 #define BTRFS_INODE_IMMUTABLE (1 << 6)
1774 #define BTRFS_INODE_APPEND (1 << 7)
1775 #define BTRFS_INODE_NODUMP (1 << 8)
1776 #define BTRFS_INODE_NOATIME (1 << 9)
1777 #define BTRFS_INODE_DIRSYNC (1 << 10)
1778 #define BTRFS_INODE_COMPRESS (1 << 11)
1780 #define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31)
1790 memset(token, 0,
sizeof(*token));
1797 #define le8_to_cpu(v) (v)
1798 #define cpu_to_le8(v) (v)
1801 #define read_eb_member(eb, ptr, type, member, result) ( \
1802 read_extent_buffer(eb, (char *)(result), \
1803 ((unsigned long)(ptr)) + \
1804 offsetof(type, member), \
1805 sizeof(((type *)0)->member)))
1807 #define write_eb_member(eb, ptr, type, member, result) ( \
1808 write_extent_buffer(eb, (char *)(result), \
1809 ((unsigned long)(ptr)) + \
1810 offsetof(type, member), \
1811 sizeof(((type *)0)->member)))
1813 #define DECLARE_BTRFS_SETGET_BITS(bits) \
1814 u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \
1815 unsigned long off, \
1816 struct btrfs_map_token *token); \
1817 void btrfs_set_token_##bits(struct extent_buffer *eb, void *ptr, \
1818 unsigned long off, u##bits val, \
1819 struct btrfs_map_token *token); \
1820 static inline u##bits btrfs_get_##bits(struct extent_buffer *eb, void *ptr, \
1821 unsigned long off) \
1823 return btrfs_get_token_##bits(eb, ptr, off, NULL); \
1825 static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
1826 unsigned long off, u##bits val) \
1828 btrfs_set_token_##bits(eb, ptr, off, val, NULL); \
1836 #define BTRFS_SETGET_FUNCS(name, type, member, bits) \
1837 static inline u##bits btrfs_##name(struct extent_buffer *eb, type *s) \
1839 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1840 return btrfs_get_##bits(eb, s, offsetof(type, member)); \
1842 static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \
1845 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1846 btrfs_set_##bits(eb, s, offsetof(type, member), val); \
1848 static inline u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, \
1849 struct btrfs_map_token *token) \
1851 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1852 return btrfs_get_token_##bits(eb, s, offsetof(type, member), token); \
1854 static inline void btrfs_set_token_##name(struct extent_buffer *eb, \
1855 type *s, u##bits val, \
1856 struct btrfs_map_token *token) \
1858 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1859 btrfs_set_token_##bits(eb, s, offsetof(type, member), val, token); \
1862 #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
1863 static inline u##bits btrfs_##name(struct extent_buffer *eb) \
1865 type *p = page_address(eb->pages[0]); \
1866 u##bits res = le##bits##_to_cpu(p->member); \
1869 static inline void btrfs_set_##name(struct extent_buffer *eb, \
1872 type *p = page_address(eb->pages[0]); \
1873 p->member = cpu_to_le##bits(val); \
1876 #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \
1877 static inline u##bits btrfs_##name(type *s) \
1879 return le##bits##_to_cpu(s->member); \
1881 static inline void btrfs_set_##name(type *s, u##bits val) \
1883 s->member = cpu_to_le##bits(val); \
1943 static inline char *btrfs_stripe_dev_uuid(
struct btrfs_stripe *
s)
1975 static inline char *btrfs_stripe_dev_uuid_nr(
struct btrfs_chunk *c,
int nr)
1977 return btrfs_stripe_dev_uuid(btrfs_stripe_nr(c, nr));
1983 return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr));
1989 return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr));
2035 unsigned long ptr = (
unsigned long)inode_item;
2043 unsigned long ptr = (
unsigned long)inode_item;
2051 unsigned long ptr = (
unsigned long)inode_item;
2071 return (
u8 *)((
unsigned long)dev + ptr);
2084 static inline void btrfs_tree_block_key(
struct extent_buffer *eb,
2091 static inline void btrfs_set_tree_block_key(
struct extent_buffer *eb,
2115 static inline u32 btrfs_extent_inline_ref_size(
int type)
2148 static inline void btrfs_set_node_blockptr(
struct extent_buffer *eb,
2154 btrfs_set_key_blockptr(eb, (
struct btrfs_key_ptr *)ptr, val);
2157 static inline u64 btrfs_node_ptr_generation(
struct extent_buffer *eb,
int nr)
2162 return btrfs_key_generation(eb, (
struct btrfs_key_ptr *)ptr);
2165 static inline void btrfs_set_node_ptr_generation(
struct extent_buffer *eb,
2171 btrfs_set_key_generation(eb, (
struct btrfs_key_ptr *)ptr, val);
2174 static inline unsigned long btrfs_node_key_ptr_offset(
int nr)
2183 static inline void btrfs_set_node_key(
struct extent_buffer *eb,
2187 ptr = btrfs_node_key_ptr_offset(nr);
2196 static inline unsigned long btrfs_item_nr_offset(
int nr)
2205 return (
struct btrfs_item *)btrfs_item_nr_offset(nr);
2211 return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item);
2216 return btrfs_item_end(eb, btrfs_item_nr(eb, nr));
2221 return btrfs_item_offset(eb, btrfs_item_nr(eb, nr));
2226 return btrfs_item_size(eb, btrfs_item_nr(eb, nr));
2236 static inline void btrfs_set_item_key(
struct extent_buffer *eb,
2258 static inline void btrfs_dir_item_key(
struct extent_buffer *eb,
2265 static inline void btrfs_set_dir_item_key(
struct extent_buffer *eb,
2279 static inline void btrfs_free_space_key(
struct extent_buffer *eb,
2286 static inline void btrfs_set_free_space_key(
struct extent_buffer *eb,
2299 static inline void btrfs_disk_key_to_cpu(
struct btrfs_key *
cpu,
2307 static inline void btrfs_cpu_key_to_disk(
struct btrfs_disk_key *disk,
2315 static inline void btrfs_node_key_to_cpu(
struct extent_buffer *eb,
2320 btrfs_disk_key_to_cpu(key, &disk_key);
2323 static inline void btrfs_item_key_to_cpu(
struct extent_buffer *eb,
2327 btrfs_item_key(eb, &disk_key, nr);
2328 btrfs_disk_key_to_cpu(key, &disk_key);
2331 static inline void btrfs_dir_item_key_to_cpu(
struct extent_buffer *eb,
2336 btrfs_dir_item_key(eb, item, &disk_key);
2337 btrfs_disk_key_to_cpu(key, &disk_key);
2346 static inline void btrfs_set_key_type(
struct btrfs_key *
key,
u8 val)
2362 return (btrfs_header_flags(eb) & flag) ==
flag;
2365 static inline int btrfs_set_header_flag(
struct extent_buffer *eb,
u64 flag)
2367 u64 flags = btrfs_header_flags(eb);
2368 btrfs_set_header_flags(eb, flags | flag);
2369 return (flags & flag) ==
flag;
2372 static inline int btrfs_clear_header_flag(
struct extent_buffer *eb,
u64 flag)
2374 u64 flags = btrfs_header_flags(eb);
2375 btrfs_set_header_flags(eb, flags & ~flag);
2376 return (flags & flag) ==
flag;
2379 static inline int btrfs_header_backref_rev(
struct extent_buffer *eb)
2381 u64 flags = btrfs_header_flags(eb);
2385 static inline void btrfs_set_header_backref_rev(
struct extent_buffer *eb,
2388 u64 flags = btrfs_header_flags(eb);
2391 btrfs_set_header_flags(eb, flags);
2400 static inline u8 *btrfs_header_chunk_tree_uuid(
struct extent_buffer *eb)
2408 return btrfs_header_level(eb) == 0;
2440 static inline bool btrfs_root_readonly(
struct btrfs_root *root)
2497 static inline void btrfs_balance_data(
struct extent_buffer *eb,
2504 static inline void btrfs_set_balance_data(
struct extent_buffer *eb,
2511 static inline void btrfs_balance_meta(
struct extent_buffer *eb,
2518 static inline void btrfs_set_balance_meta(
struct extent_buffer *eb,
2525 static inline void btrfs_balance_sys(
struct extent_buffer *eb,
2532 static inline void btrfs_set_balance_sys(
struct extent_buffer *eb,
2543 memset(cpu, 0,
sizeof(*cpu));
2560 memset(disk, 0,
sizeof(*disk));
2624 int t = btrfs_super_csum_type(s);
2626 return btrfs_csum_sizes[
t];
2629 static inline unsigned long btrfs_leaf_data(
struct extent_buffer *
l)
2637 static inline unsigned long
2640 unsigned long offset = (
unsigned long)e;
2645 static inline u32 btrfs_file_extent_calc_inline_size(
u32 datasize)
2675 return btrfs_file_extent_ram_bytes(eb, e);
2683 static inline u32 btrfs_file_extent_inline_item_len(
struct extent_buffer *eb,
2688 return btrfs_item_size(eb, e) -
offset;
2700 ((
unsigned long)ptr) + (index *
sizeof(
u64)),
2705 static inline void btrfs_set_dev_stats_value(
struct extent_buffer *eb,
2711 ((
unsigned long)ptr) + (index *
sizeof(
u64)),
2771 #define btrfs_item_ptr(leaf, slot, type) \
2772 ((type *)(btrfs_leaf_data(leaf) + \
2773 btrfs_item_offset_nr(leaf, slot)))
2775 #define btrfs_item_ptr_offset(leaf, slot) \
2776 ((unsigned long)(btrfs_leaf_data(leaf) + \
2777 btrfs_item_offset_nr(leaf, slot)))
2781 return file->
f_path.dentry;
2784 static inline bool btrfs_mixed_space_info(
struct btrfs_space_info *space_info)
2792 return mapping_gfp_mask(mapping) & ~
__GFP_FS;
2796 static inline u64 btrfs_calc_trans_metadata_size(
struct btrfs_root *root,
2807 static inline u64 btrfs_calc_trunc_metadata_size(
struct btrfs_root *root,
2839 u64 hint,
u64 empty_size);
2843 u64 parent,
int last_ref);
2859 u64 empty_size,
u64 hint_byte,
2918 unsigned short type);
2960 int level,
int *
slot);
2972 int cache_only,
u64 min_trans);
3008 u32 new_size,
int from_end);
3013 unsigned long split_offset);
3025 int find_higher,
int return_any);
3028 int start_slot,
int cache_only,
u64 *last_ret,
3070 static inline int btrfs_next_old_item(
struct btrfs_root *root,
3074 if (p->
slots[0] >= btrfs_header_nritems(p->
nodes[0]))
3080 return btrfs_next_old_item(root, p, 0);
3086 int update_ref,
int for_reloc);
3128 u64 root_id,
u64 ref_id);
3211 u64 inode_objectid,
u64 ref_objectid,
u64 index);
3215 u64 inode_objectid,
u64 ref_objectid,
u64 *index);
3220 u64 inode_objectid,
u64 ref_objectid,
int mod,
3234 u64 inode_objectid,
u64 ref_objectid,
int ins_len,
3238 u64 ref_objectid,
const char *
name,
3246 struct bio *bio,
u32 *
dst);
3248 struct bio *bio,
u64 logical_offset);
3263 struct bio *bio,
u64 file_start,
int contig);
3279 #if defined(ClearPageFsMisc) && !defined(ClearPageChecked)
3280 #define ClearPageChecked ClearPageFsMisc
3281 #define SetPageChecked SetPageFsMisc
3282 #define PageChecked PageFsMisc
3288 pgoff_t offset,
unsigned long req_size)
3321 size_t size,
struct bio *bio,
unsigned long bio_flags);
3355 loff_t actual_len,
u64 *alloc_hint);
3359 loff_t actual_len,
u64 *alloc_hint);
3368 u64 newer_than,
unsigned long max_pages);
3386 u64 *drop_end,
int drop_cache);
3389 u64 end,
int drop_cache);
3396 loff_t
pos,
size_t write_bytes,
3414 #ifdef CONFIG_PRINTK
3426 unsigned int line,
int errno,
const char *fmt, ...);
3431 unsigned int line,
int errno);
3433 #define btrfs_set_fs_incompat(__fs_info, opt) \
3434 __btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
3436 static inline void __btrfs_set_fs_incompat(
struct btrfs_fs_info *fs_info,
3443 features = btrfs_super_incompat_flags(disk_super);
3444 if (!(features & flag)) {
3446 btrfs_set_super_incompat_flags(disk_super, features);
3455 #define btrfs_abort_transaction(trans, root, errno) \
3457 __btrfs_abort_transaction(trans, root, __func__, \
3461 #define btrfs_std_error(fs_info, errno) \
3464 __btrfs_std_error((fs_info), __func__, \
3465 __LINE__, (errno), NULL); \
3468 #define btrfs_error(fs_info, errno, fmt, args...) \
3470 __btrfs_std_error((fs_info), __func__, __LINE__, \
3471 (errno), fmt, ##args); \
3476 unsigned int line,
int errno,
const char *fmt, ...);
3478 #define btrfs_panic(fs_info, errno, fmt, args...) \
3480 struct btrfs_fs_info *_i = (fs_info); \
3481 __btrfs_panic(_i, __func__, __LINE__, errno, fmt, ##args); \
3482 BUG_ON(!(_i->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)); \
3486 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
3492 #define btrfs_get_acl NULL
3517 u64 *bytes_to_reserve);
3595 static inline int is_fstree(
u64 rootid)