aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h161
1 files changed, 136 insertions, 25 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e795bf135e80..3c1da6f98a4d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -23,6 +23,7 @@
23#include <linux/highmem.h> 23#include <linux/highmem.h>
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/rwsem.h> 25#include <linux/rwsem.h>
26#include <linux/semaphore.h>
26#include <linux/completion.h> 27#include <linux/completion.h>
27#include <linux/backing-dev.h> 28#include <linux/backing-dev.h>
28#include <linux/wait.h> 29#include <linux/wait.h>
@@ -91,6 +92,9 @@ struct btrfs_ordered_sum;
91/* holds quota configuration and tracking */ 92/* holds quota configuration and tracking */
92#define BTRFS_QUOTA_TREE_OBJECTID 8ULL 93#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
93 94
95/* for storing items that use the BTRFS_UUID_KEY* types */
96#define BTRFS_UUID_TREE_OBJECTID 9ULL
97
94/* for storing balance parameters in the root tree */ 98/* for storing balance parameters in the root tree */
95#define BTRFS_BALANCE_OBJECTID -4ULL 99#define BTRFS_BALANCE_OBJECTID -4ULL
96 100
@@ -142,7 +146,7 @@ struct btrfs_ordered_sum;
142 146
143#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2 147#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
144 148
145#define BTRFS_DEV_REPLACE_DEVID 0 149#define BTRFS_DEV_REPLACE_DEVID 0ULL
146 150
147/* 151/*
148 * the max metadata block size. This limit is somewhat artificial, 152 * the max metadata block size. This limit is somewhat artificial,
@@ -478,9 +482,10 @@ struct btrfs_super_block {
478 char label[BTRFS_LABEL_SIZE]; 482 char label[BTRFS_LABEL_SIZE];
479 483
480 __le64 cache_generation; 484 __le64 cache_generation;
485 __le64 uuid_tree_generation;
481 486
482 /* future expansion */ 487 /* future expansion */
483 __le64 reserved[31]; 488 __le64 reserved[30];
484 u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; 489 u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
485 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; 490 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
486} __attribute__ ((__packed__)); 491} __attribute__ ((__packed__));
@@ -1188,6 +1193,7 @@ enum btrfs_caching_type {
1188 BTRFS_CACHE_STARTED = 1, 1193 BTRFS_CACHE_STARTED = 1,
1189 BTRFS_CACHE_FAST = 2, 1194 BTRFS_CACHE_FAST = 2,
1190 BTRFS_CACHE_FINISHED = 3, 1195 BTRFS_CACHE_FINISHED = 3,
1196 BTRFS_CACHE_ERROR = 4,
1191}; 1197};
1192 1198
1193enum btrfs_disk_cache_state { 1199enum btrfs_disk_cache_state {
@@ -1302,6 +1308,7 @@ struct btrfs_fs_info {
1302 struct btrfs_root *fs_root; 1308 struct btrfs_root *fs_root;
1303 struct btrfs_root *csum_root; 1309 struct btrfs_root *csum_root;
1304 struct btrfs_root *quota_root; 1310 struct btrfs_root *quota_root;
1311 struct btrfs_root *uuid_root;
1305 1312
1306 /* the log root tree is a directory of all the other log roots */ 1313 /* the log root tree is a directory of all the other log roots */
1307 struct btrfs_root *log_root_tree; 1314 struct btrfs_root *log_root_tree;
@@ -1350,6 +1357,7 @@ struct btrfs_fs_info {
1350 u64 last_trans_log_full_commit; 1357 u64 last_trans_log_full_commit;
1351 unsigned long mount_opt; 1358 unsigned long mount_opt;
1352 unsigned long compress_type:4; 1359 unsigned long compress_type:4;
1360 int commit_interval;
1353 /* 1361 /*
1354 * It is a suggestive number, the read side is safe even it gets a 1362 * It is a suggestive number, the read side is safe even it gets a
1355 * wrong number because we will write out the data into a regular 1363 * wrong number because we will write out the data into a regular
@@ -1411,6 +1419,13 @@ struct btrfs_fs_info {
1411 * before jumping into the main commit. 1419 * before jumping into the main commit.
1412 */ 1420 */
1413 struct mutex ordered_operations_mutex; 1421 struct mutex ordered_operations_mutex;
1422
1423 /*
1424 * Same as ordered_operations_mutex except this is for ordered extents
1425 * and not the operations.
1426 */
1427 struct mutex ordered_extent_flush_mutex;
1428
1414 struct rw_semaphore extent_commit_sem; 1429 struct rw_semaphore extent_commit_sem;
1415 1430
1416 struct rw_semaphore cleanup_work_sem; 1431 struct rw_semaphore cleanup_work_sem;
@@ -1641,6 +1656,9 @@ struct btrfs_fs_info {
1641 struct btrfs_dev_replace dev_replace; 1656 struct btrfs_dev_replace dev_replace;
1642 1657
1643 atomic_t mutually_exclusive_operation_running; 1658 atomic_t mutually_exclusive_operation_running;
1659
1660 struct semaphore uuid_tree_rescan_sem;
1661 unsigned int update_uuid_tree_gen:1;
1644}; 1662};
1645 1663
1646/* 1664/*
@@ -1934,6 +1952,19 @@ struct btrfs_ioctl_defrag_range_args {
1934#define BTRFS_DEV_REPLACE_KEY 250 1952#define BTRFS_DEV_REPLACE_KEY 250
1935 1953
1936/* 1954/*
1955 * Stores items that allow to quickly map UUIDs to something else.
1956 * These items are part of the filesystem UUID tree.
1957 * The key is built like this:
1958 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits).
1959 */
1960#if BTRFS_UUID_SIZE != 16
1961#error "UUID items require BTRFS_UUID_SIZE == 16!"
1962#endif
1963#define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */
1964#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to
1965 * received subvols */
1966
1967/*
1937 * string items are for debugging. They just store a short string of 1968 * string items are for debugging. They just store a short string of
1938 * data in the FS 1969 * data in the FS
1939 */ 1970 */
@@ -1967,6 +1998,9 @@ struct btrfs_ioctl_defrag_range_args {
1967#define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) 1998#define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20)
1968#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) 1999#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1969#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22) 2000#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
2001#define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23)
2002
2003#define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
1970 2004
1971#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 2005#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1972#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) 2006#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
@@ -2130,14 +2164,14 @@ BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item,
2130BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item, 2164BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item,
2131 generation, 64); 2165 generation, 64);
2132 2166
2133static inline char *btrfs_device_uuid(struct btrfs_dev_item *d) 2167static inline unsigned long btrfs_device_uuid(struct btrfs_dev_item *d)
2134{ 2168{
2135 return (char *)d + offsetof(struct btrfs_dev_item, uuid); 2169 return (unsigned long)d + offsetof(struct btrfs_dev_item, uuid);
2136} 2170}
2137 2171
2138static inline char *btrfs_device_fsid(struct btrfs_dev_item *d) 2172static inline unsigned long btrfs_device_fsid(struct btrfs_dev_item *d)
2139{ 2173{
2140 return (char *)d + offsetof(struct btrfs_dev_item, fsid); 2174 return (unsigned long)d + offsetof(struct btrfs_dev_item, fsid);
2141} 2175}
2142 2176
2143BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64); 2177BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64);
@@ -2240,6 +2274,23 @@ BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2240BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32); 2274BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2241BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64); 2275BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2242BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64); 2276BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2277BTRFS_SETGET_STACK_FUNCS(stack_inode_generation, struct btrfs_inode_item,
2278 generation, 64);
2279BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, struct btrfs_inode_item,
2280 sequence, 64);
2281BTRFS_SETGET_STACK_FUNCS(stack_inode_transid, struct btrfs_inode_item,
2282 transid, 64);
2283BTRFS_SETGET_STACK_FUNCS(stack_inode_size, struct btrfs_inode_item, size, 64);
2284BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes, struct btrfs_inode_item,
2285 nbytes, 64);
2286BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group, struct btrfs_inode_item,
2287 block_group, 64);
2288BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink, struct btrfs_inode_item, nlink, 32);
2289BTRFS_SETGET_STACK_FUNCS(stack_inode_uid, struct btrfs_inode_item, uid, 32);
2290BTRFS_SETGET_STACK_FUNCS(stack_inode_gid, struct btrfs_inode_item, gid, 32);
2291BTRFS_SETGET_STACK_FUNCS(stack_inode_mode, struct btrfs_inode_item, mode, 32);
2292BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev, struct btrfs_inode_item, rdev, 64);
2293BTRFS_SETGET_STACK_FUNCS(stack_inode_flags, struct btrfs_inode_item, flags, 64);
2243 2294
2244static inline struct btrfs_timespec * 2295static inline struct btrfs_timespec *
2245btrfs_inode_atime(struct btrfs_inode_item *inode_item) 2296btrfs_inode_atime(struct btrfs_inode_item *inode_item)
@@ -2267,6 +2318,8 @@ btrfs_inode_ctime(struct btrfs_inode_item *inode_item)
2267 2318
2268BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); 2319BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
2269BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); 2320BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
2321BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64);
2322BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32);
2270 2323
2271/* struct btrfs_dev_extent */ 2324/* struct btrfs_dev_extent */
2272BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, 2325BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent,
@@ -2277,10 +2330,10 @@ BTRFS_SETGET_FUNCS(dev_extent_chunk_offset, struct btrfs_dev_extent,
2277 chunk_offset, 64); 2330 chunk_offset, 64);
2278BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64); 2331BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64);
2279 2332
2280static inline u8 *btrfs_dev_extent_chunk_tree_uuid(struct btrfs_dev_extent *dev) 2333static inline unsigned long btrfs_dev_extent_chunk_tree_uuid(struct btrfs_dev_extent *dev)
2281{ 2334{
2282 unsigned long ptr = offsetof(struct btrfs_dev_extent, chunk_tree_uuid); 2335 unsigned long ptr = offsetof(struct btrfs_dev_extent, chunk_tree_uuid);
2283 return (u8 *)((unsigned long)dev + ptr); 2336 return (unsigned long)dev + ptr;
2284} 2337}
2285 2338
2286BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64); 2339BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64);
@@ -2348,6 +2401,10 @@ BTRFS_SETGET_FUNCS(ref_count_v0, struct btrfs_extent_ref_v0, count, 32);
2348/* struct btrfs_node */ 2401/* struct btrfs_node */
2349BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); 2402BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64);
2350BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64); 2403BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64);
2404BTRFS_SETGET_STACK_FUNCS(stack_key_blockptr, struct btrfs_key_ptr,
2405 blockptr, 64);
2406BTRFS_SETGET_STACK_FUNCS(stack_key_generation, struct btrfs_key_ptr,
2407 generation, 64);
2351 2408
2352static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr) 2409static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr)
2353{ 2410{
@@ -2404,6 +2461,8 @@ static inline void btrfs_set_node_key(struct extent_buffer *eb,
2404/* struct btrfs_item */ 2461/* struct btrfs_item */
2405BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32); 2462BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32);
2406BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32); 2463BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32);
2464BTRFS_SETGET_STACK_FUNCS(stack_item_offset, struct btrfs_item, offset, 32);
2465BTRFS_SETGET_STACK_FUNCS(stack_item_size, struct btrfs_item, size, 32);
2407 2466
2408static inline unsigned long btrfs_item_nr_offset(int nr) 2467static inline unsigned long btrfs_item_nr_offset(int nr)
2409{ 2468{
@@ -2466,6 +2525,13 @@ BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16);
2466BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8); 2525BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8);
2467BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16); 2526BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16);
2468BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64); 2527BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64);
2528BTRFS_SETGET_STACK_FUNCS(stack_dir_type, struct btrfs_dir_item, type, 8);
2529BTRFS_SETGET_STACK_FUNCS(stack_dir_data_len, struct btrfs_dir_item,
2530 data_len, 16);
2531BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item,
2532 name_len, 16);
2533BTRFS_SETGET_STACK_FUNCS(stack_dir_transid, struct btrfs_dir_item,
2534 transid, 64);
2469 2535
2470static inline void btrfs_dir_item_key(struct extent_buffer *eb, 2536static inline void btrfs_dir_item_key(struct extent_buffer *eb,
2471 struct btrfs_dir_item *item, 2537 struct btrfs_dir_item *item,
@@ -2568,6 +2634,12 @@ BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
2568BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32); 2634BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
2569BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64); 2635BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
2570BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8); 2636BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
2637BTRFS_SETGET_STACK_FUNCS(stack_header_generation, struct btrfs_header,
2638 generation, 64);
2639BTRFS_SETGET_STACK_FUNCS(stack_header_owner, struct btrfs_header, owner, 64);
2640BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header,
2641 nritems, 32);
2642BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64);
2571 2643
2572static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag) 2644static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag)
2573{ 2645{
@@ -2603,16 +2675,14 @@ static inline void btrfs_set_header_backref_rev(struct extent_buffer *eb,
2603 btrfs_set_header_flags(eb, flags); 2675 btrfs_set_header_flags(eb, flags);
2604} 2676}
2605 2677
2606static inline u8 *btrfs_header_fsid(struct extent_buffer *eb) 2678static inline unsigned long btrfs_header_fsid(struct extent_buffer *eb)
2607{ 2679{
2608 unsigned long ptr = offsetof(struct btrfs_header, fsid); 2680 return offsetof(struct btrfs_header, fsid);
2609 return (u8 *)ptr;
2610} 2681}
2611 2682
2612static inline u8 *btrfs_header_chunk_tree_uuid(struct extent_buffer *eb) 2683static inline unsigned long btrfs_header_chunk_tree_uuid(struct extent_buffer *eb)
2613{ 2684{
2614 unsigned long ptr = offsetof(struct btrfs_header, chunk_tree_uuid); 2685 return offsetof(struct btrfs_header, chunk_tree_uuid);
2615 return (u8 *)ptr;
2616} 2686}
2617 2687
2618static inline int btrfs_is_leaf(struct extent_buffer *eb) 2688static inline int btrfs_is_leaf(struct extent_buffer *eb)
@@ -2830,6 +2900,9 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block,
2830 csum_type, 16); 2900 csum_type, 16);
2831BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, 2901BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block,
2832 cache_generation, 64); 2902 cache_generation, 64);
2903BTRFS_SETGET_STACK_FUNCS(super_magic, struct btrfs_super_block, magic, 64);
2904BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block,
2905 uuid_tree_generation, 64);
2833 2906
2834static inline int btrfs_super_csum_size(struct btrfs_super_block *s) 2907static inline int btrfs_super_csum_size(struct btrfs_super_block *s)
2835{ 2908{
@@ -2847,6 +2920,14 @@ static inline unsigned long btrfs_leaf_data(struct extent_buffer *l)
2847 2920
2848/* struct btrfs_file_extent_item */ 2921/* struct btrfs_file_extent_item */
2849BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8); 2922BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8);
2923BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_bytenr,
2924 struct btrfs_file_extent_item, disk_bytenr, 64);
2925BTRFS_SETGET_STACK_FUNCS(stack_file_extent_offset,
2926 struct btrfs_file_extent_item, offset, 64);
2927BTRFS_SETGET_STACK_FUNCS(stack_file_extent_generation,
2928 struct btrfs_file_extent_item, generation, 64);
2929BTRFS_SETGET_STACK_FUNCS(stack_file_extent_num_bytes,
2930 struct btrfs_file_extent_item, num_bytes, 64);
2850 2931
2851static inline unsigned long 2932static inline unsigned long
2852btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) 2933btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e)
@@ -3107,11 +3188,9 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
3107 struct btrfs_root *root, 3188 struct btrfs_root *root,
3108 u64 root_objectid, u64 owner, u64 offset, 3189 u64 root_objectid, u64 owner, u64 offset,
3109 struct btrfs_key *ins); 3190 struct btrfs_key *ins);
3110int btrfs_reserve_extent(struct btrfs_trans_handle *trans, 3191int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes,
3111 struct btrfs_root *root, 3192 u64 min_alloc_size, u64 empty_size, u64 hint_byte,
3112 u64 num_bytes, u64 min_alloc_size, 3193 struct btrfs_key *ins, int is_data);
3113 u64 empty_size, u64 hint_byte,
3114 struct btrfs_key *ins, int is_data);
3115int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 3194int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3116 struct extent_buffer *buf, int full_backref, int for_cow); 3195 struct extent_buffer *buf, int full_backref, int for_cow);
3117int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 3196int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -3175,7 +3254,7 @@ void btrfs_orphan_release_metadata(struct inode *inode);
3175int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, 3254int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
3176 struct btrfs_block_rsv *rsv, 3255 struct btrfs_block_rsv *rsv,
3177 int nitems, 3256 int nitems,
3178 u64 *qgroup_reserved); 3257 u64 *qgroup_reserved, bool use_global_rsv);
3179void btrfs_subvolume_release_metadata(struct btrfs_root *root, 3258void btrfs_subvolume_release_metadata(struct btrfs_root *root,
3180 struct btrfs_block_rsv *rsv, 3259 struct btrfs_block_rsv *rsv,
3181 u64 qgroup_reserved); 3260 u64 qgroup_reserved);
@@ -3245,6 +3324,7 @@ enum btrfs_compare_tree_result {
3245 BTRFS_COMPARE_TREE_NEW, 3324 BTRFS_COMPARE_TREE_NEW,
3246 BTRFS_COMPARE_TREE_DELETED, 3325 BTRFS_COMPARE_TREE_DELETED,
3247 BTRFS_COMPARE_TREE_CHANGED, 3326 BTRFS_COMPARE_TREE_CHANGED,
3327 BTRFS_COMPARE_TREE_SAME,
3248}; 3328};
3249typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root, 3329typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root,
3250 struct btrfs_root *right_root, 3330 struct btrfs_root *right_root,
@@ -3380,6 +3460,7 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info)
3380 kfree(fs_info->dev_root); 3460 kfree(fs_info->dev_root);
3381 kfree(fs_info->csum_root); 3461 kfree(fs_info->csum_root);
3382 kfree(fs_info->quota_root); 3462 kfree(fs_info->quota_root);
3463 kfree(fs_info->uuid_root);
3383 kfree(fs_info->super_copy); 3464 kfree(fs_info->super_copy);
3384 kfree(fs_info->super_for_commit); 3465 kfree(fs_info->super_for_commit);
3385 kfree(fs_info); 3466 kfree(fs_info);
@@ -3414,8 +3495,6 @@ int __must_check btrfs_update_root(struct btrfs_trans_handle *trans,
3414 struct btrfs_root *root, 3495 struct btrfs_root *root,
3415 struct btrfs_key *key, 3496 struct btrfs_key *key,
3416 struct btrfs_root_item *item); 3497 struct btrfs_root_item *item);
3417void btrfs_read_root_item(struct extent_buffer *eb, int slot,
3418 struct btrfs_root_item *item);
3419int btrfs_find_root(struct btrfs_root *root, struct btrfs_key *search_key, 3498int btrfs_find_root(struct btrfs_root *root, struct btrfs_key *search_key,
3420 struct btrfs_path *path, struct btrfs_root_item *root_item, 3499 struct btrfs_path *path, struct btrfs_root_item *root_item,
3421 struct btrfs_key *root_key); 3500 struct btrfs_key *root_key);
@@ -3426,6 +3505,17 @@ void btrfs_check_and_init_root_item(struct btrfs_root_item *item);
3426void btrfs_update_root_times(struct btrfs_trans_handle *trans, 3505void btrfs_update_root_times(struct btrfs_trans_handle *trans,
3427 struct btrfs_root *root); 3506 struct btrfs_root *root);
3428 3507
3508/* uuid-tree.c */
3509int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans,
3510 struct btrfs_root *uuid_root, u8 *uuid, u8 type,
3511 u64 subid);
3512int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans,
3513 struct btrfs_root *uuid_root, u8 *uuid, u8 type,
3514 u64 subid);
3515int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
3516 int (*check_func)(struct btrfs_fs_info *, u8 *, u8,
3517 u64));
3518
3429/* dir-item.c */ 3519/* dir-item.c */
3430int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir, 3520int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
3431 const char *name, int name_len); 3521 const char *name, int name_len);
@@ -3509,12 +3599,14 @@ int btrfs_find_name_in_ext_backref(struct btrfs_path *path,
3509 struct btrfs_inode_extref **extref_ret); 3599 struct btrfs_inode_extref **extref_ret);
3510 3600
3511/* file-item.c */ 3601/* file-item.c */
3602struct btrfs_dio_private;
3512int btrfs_del_csums(struct btrfs_trans_handle *trans, 3603int btrfs_del_csums(struct btrfs_trans_handle *trans,
3513 struct btrfs_root *root, u64 bytenr, u64 len); 3604 struct btrfs_root *root, u64 bytenr, u64 len);
3514int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, 3605int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
3515 struct bio *bio, u32 *dst); 3606 struct bio *bio, u32 *dst);
3516int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode, 3607int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
3517 struct bio *bio, u64 logical_offset); 3608 struct btrfs_dio_private *dip, struct bio *bio,
3609 u64 logical_offset);
3518int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, 3610int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
3519 struct btrfs_root *root, 3611 struct btrfs_root *root,
3520 u64 objectid, u64 pos, 3612 u64 objectid, u64 pos,
@@ -3552,8 +3644,7 @@ void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work);
3552struct extent_map *btrfs_get_extent_fiemap(struct inode *inode, struct page *page, 3644struct extent_map *btrfs_get_extent_fiemap(struct inode *inode, struct page *page,
3553 size_t pg_offset, u64 start, u64 len, 3645 size_t pg_offset, u64 start, u64 len,
3554 int create); 3646 int create);
3555noinline int can_nocow_extent(struct btrfs_trans_handle *trans, 3647noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
3556 struct inode *inode, u64 offset, u64 *len,
3557 u64 *orig_start, u64 *orig_block_len, 3648 u64 *orig_start, u64 *orig_block_len,
3558 u64 *ram_bytes); 3649 u64 *ram_bytes);
3559 3650
@@ -3643,11 +3734,15 @@ extern const struct dentry_operations btrfs_dentry_operations;
3643long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 3734long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3644void btrfs_update_iflags(struct inode *inode); 3735void btrfs_update_iflags(struct inode *inode);
3645void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); 3736void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3737int btrfs_is_empty_uuid(u8 *uuid);
3646int btrfs_defrag_file(struct inode *inode, struct file *file, 3738int btrfs_defrag_file(struct inode *inode, struct file *file,
3647 struct btrfs_ioctl_defrag_range_args *range, 3739 struct btrfs_ioctl_defrag_range_args *range,
3648 u64 newer_than, unsigned long max_pages); 3740 u64 newer_than, unsigned long max_pages);
3649void btrfs_get_block_group_info(struct list_head *groups_list, 3741void btrfs_get_block_group_info(struct list_head *groups_list,
3650 struct btrfs_ioctl_space_info *space); 3742 struct btrfs_ioctl_space_info *space);
3743void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock,
3744 struct btrfs_ioctl_balance_args *bargs);
3745
3651 3746
3652/* file.c */ 3747/* file.c */
3653int btrfs_auto_defrag_init(void); 3748int btrfs_auto_defrag_init(void);
@@ -3720,6 +3815,22 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
3720#define btrfs_debug(fs_info, fmt, args...) \ 3815#define btrfs_debug(fs_info, fmt, args...) \
3721 btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) 3816 btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
3722 3817
3818#ifdef CONFIG_BTRFS_ASSERT
3819
3820static inline void assfail(char *expr, char *file, int line)
3821{
3822 printk(KERN_ERR "BTRFS assertion failed: %s, file: %s, line: %d",
3823 expr, file, line);
3824 BUG();
3825}
3826
3827#define ASSERT(expr) \
3828 (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
3829#else
3830#define ASSERT(expr) ((void)0)
3831#endif
3832
3833#define btrfs_assert()
3723__printf(5, 6) 3834__printf(5, 6)
3724void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, 3835void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
3725 unsigned int line, int errno, const char *fmt, ...); 3836 unsigned int line, int errno, const char *fmt, ...);