diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 161 |
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 | ||
1193 | enum btrfs_disk_cache_state { | 1199 | enum 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, | |||
2130 | BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item, | 2164 | BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item, |
2131 | generation, 64); | 2165 | generation, 64); |
2132 | 2166 | ||
2133 | static inline char *btrfs_device_uuid(struct btrfs_dev_item *d) | 2167 | static 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 | ||
2138 | static inline char *btrfs_device_fsid(struct btrfs_dev_item *d) | 2172 | static 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 | ||
2143 | BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64); | 2177 | BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64); |
@@ -2240,6 +2274,23 @@ BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32); | |||
2240 | BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32); | 2274 | BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32); |
2241 | BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64); | 2275 | BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64); |
2242 | BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64); | 2276 | BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64); |
2277 | BTRFS_SETGET_STACK_FUNCS(stack_inode_generation, struct btrfs_inode_item, | ||
2278 | generation, 64); | ||
2279 | BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, struct btrfs_inode_item, | ||
2280 | sequence, 64); | ||
2281 | BTRFS_SETGET_STACK_FUNCS(stack_inode_transid, struct btrfs_inode_item, | ||
2282 | transid, 64); | ||
2283 | BTRFS_SETGET_STACK_FUNCS(stack_inode_size, struct btrfs_inode_item, size, 64); | ||
2284 | BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes, struct btrfs_inode_item, | ||
2285 | nbytes, 64); | ||
2286 | BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group, struct btrfs_inode_item, | ||
2287 | block_group, 64); | ||
2288 | BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink, struct btrfs_inode_item, nlink, 32); | ||
2289 | BTRFS_SETGET_STACK_FUNCS(stack_inode_uid, struct btrfs_inode_item, uid, 32); | ||
2290 | BTRFS_SETGET_STACK_FUNCS(stack_inode_gid, struct btrfs_inode_item, gid, 32); | ||
2291 | BTRFS_SETGET_STACK_FUNCS(stack_inode_mode, struct btrfs_inode_item, mode, 32); | ||
2292 | BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev, struct btrfs_inode_item, rdev, 64); | ||
2293 | BTRFS_SETGET_STACK_FUNCS(stack_inode_flags, struct btrfs_inode_item, flags, 64); | ||
2243 | 2294 | ||
2244 | static inline struct btrfs_timespec * | 2295 | static inline struct btrfs_timespec * |
2245 | btrfs_inode_atime(struct btrfs_inode_item *inode_item) | 2296 | btrfs_inode_atime(struct btrfs_inode_item *inode_item) |
@@ -2267,6 +2318,8 @@ btrfs_inode_ctime(struct btrfs_inode_item *inode_item) | |||
2267 | 2318 | ||
2268 | BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); | 2319 | BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); |
2269 | BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); | 2320 | BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); |
2321 | BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64); | ||
2322 | BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32); | ||
2270 | 2323 | ||
2271 | /* struct btrfs_dev_extent */ | 2324 | /* struct btrfs_dev_extent */ |
2272 | BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, | 2325 | BTRFS_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); |
2278 | BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64); | 2331 | BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64); |
2279 | 2332 | ||
2280 | static inline u8 *btrfs_dev_extent_chunk_tree_uuid(struct btrfs_dev_extent *dev) | 2333 | static 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 | ||
2286 | BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64); | 2339 | BTRFS_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 */ |
2349 | BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); | 2402 | BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); |
2350 | BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64); | 2403 | BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64); |
2404 | BTRFS_SETGET_STACK_FUNCS(stack_key_blockptr, struct btrfs_key_ptr, | ||
2405 | blockptr, 64); | ||
2406 | BTRFS_SETGET_STACK_FUNCS(stack_key_generation, struct btrfs_key_ptr, | ||
2407 | generation, 64); | ||
2351 | 2408 | ||
2352 | static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr) | 2409 | static 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 */ |
2405 | BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32); | 2462 | BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32); |
2406 | BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32); | 2463 | BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32); |
2464 | BTRFS_SETGET_STACK_FUNCS(stack_item_offset, struct btrfs_item, offset, 32); | ||
2465 | BTRFS_SETGET_STACK_FUNCS(stack_item_size, struct btrfs_item, size, 32); | ||
2407 | 2466 | ||
2408 | static inline unsigned long btrfs_item_nr_offset(int nr) | 2467 | static 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); | |||
2466 | BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8); | 2525 | BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8); |
2467 | BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16); | 2526 | BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16); |
2468 | BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64); | 2527 | BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64); |
2528 | BTRFS_SETGET_STACK_FUNCS(stack_dir_type, struct btrfs_dir_item, type, 8); | ||
2529 | BTRFS_SETGET_STACK_FUNCS(stack_dir_data_len, struct btrfs_dir_item, | ||
2530 | data_len, 16); | ||
2531 | BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, | ||
2532 | name_len, 16); | ||
2533 | BTRFS_SETGET_STACK_FUNCS(stack_dir_transid, struct btrfs_dir_item, | ||
2534 | transid, 64); | ||
2469 | 2535 | ||
2470 | static inline void btrfs_dir_item_key(struct extent_buffer *eb, | 2536 | static 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); | |||
2568 | BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32); | 2634 | BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32); |
2569 | BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64); | 2635 | BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64); |
2570 | BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8); | 2636 | BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8); |
2637 | BTRFS_SETGET_STACK_FUNCS(stack_header_generation, struct btrfs_header, | ||
2638 | generation, 64); | ||
2639 | BTRFS_SETGET_STACK_FUNCS(stack_header_owner, struct btrfs_header, owner, 64); | ||
2640 | BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header, | ||
2641 | nritems, 32); | ||
2642 | BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64); | ||
2571 | 2643 | ||
2572 | static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag) | 2644 | static 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 | ||
2606 | static inline u8 *btrfs_header_fsid(struct extent_buffer *eb) | 2678 | static 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 | ||
2612 | static inline u8 *btrfs_header_chunk_tree_uuid(struct extent_buffer *eb) | 2683 | static 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 | ||
2618 | static inline int btrfs_is_leaf(struct extent_buffer *eb) | 2688 | static 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); |
2831 | BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, | 2901 | BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, |
2832 | cache_generation, 64); | 2902 | cache_generation, 64); |
2903 | BTRFS_SETGET_STACK_FUNCS(super_magic, struct btrfs_super_block, magic, 64); | ||
2904 | BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block, | ||
2905 | uuid_tree_generation, 64); | ||
2833 | 2906 | ||
2834 | static inline int btrfs_super_csum_size(struct btrfs_super_block *s) | 2907 | static 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 */ |
2849 | BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8); | 2922 | BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8); |
2923 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_bytenr, | ||
2924 | struct btrfs_file_extent_item, disk_bytenr, 64); | ||
2925 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_offset, | ||
2926 | struct btrfs_file_extent_item, offset, 64); | ||
2927 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_generation, | ||
2928 | struct btrfs_file_extent_item, generation, 64); | ||
2929 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_num_bytes, | ||
2930 | struct btrfs_file_extent_item, num_bytes, 64); | ||
2850 | 2931 | ||
2851 | static inline unsigned long | 2932 | static inline unsigned long |
2852 | btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) | 2933 | btrfs_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); |
3110 | int btrfs_reserve_extent(struct btrfs_trans_handle *trans, | 3191 | int 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); | ||
3115 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 3194 | int 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); |
3117 | int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 3196 | int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
@@ -3175,7 +3254,7 @@ void btrfs_orphan_release_metadata(struct inode *inode); | |||
3175 | int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, | 3254 | int 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); |
3179 | void btrfs_subvolume_release_metadata(struct btrfs_root *root, | 3258 | void 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 | }; |
3249 | typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root, | 3329 | typedef 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); |
3417 | void btrfs_read_root_item(struct extent_buffer *eb, int slot, | ||
3418 | struct btrfs_root_item *item); | ||
3419 | int btrfs_find_root(struct btrfs_root *root, struct btrfs_key *search_key, | 3498 | int 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); | |||
3426 | void btrfs_update_root_times(struct btrfs_trans_handle *trans, | 3505 | void 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 */ | ||
3509 | int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, | ||
3510 | struct btrfs_root *uuid_root, u8 *uuid, u8 type, | ||
3511 | u64 subid); | ||
3512 | int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans, | ||
3513 | struct btrfs_root *uuid_root, u8 *uuid, u8 type, | ||
3514 | u64 subid); | ||
3515 | int 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 */ |
3430 | int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir, | 3520 | int 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 */ |
3602 | struct btrfs_dio_private; | ||
3512 | int btrfs_del_csums(struct btrfs_trans_handle *trans, | 3603 | int 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); |
3514 | int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, | 3605 | int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, |
3515 | struct bio *bio, u32 *dst); | 3606 | struct bio *bio, u32 *dst); |
3516 | int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode, | 3607 | int 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); | ||
3518 | int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, | 3610 | int 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); | |||
3552 | struct extent_map *btrfs_get_extent_fiemap(struct inode *inode, struct page *page, | 3644 | struct 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); |
3555 | noinline int can_nocow_extent(struct btrfs_trans_handle *trans, | 3647 | noinline 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; | |||
3643 | long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | 3734 | long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
3644 | void btrfs_update_iflags(struct inode *inode); | 3735 | void btrfs_update_iflags(struct inode *inode); |
3645 | void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); | 3736 | void btrfs_inherit_iflags(struct inode *inode, struct inode *dir); |
3737 | int btrfs_is_empty_uuid(u8 *uuid); | ||
3646 | int btrfs_defrag_file(struct inode *inode, struct file *file, | 3738 | int 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); |
3649 | void btrfs_get_block_group_info(struct list_head *groups_list, | 3741 | void btrfs_get_block_group_info(struct list_head *groups_list, |
3650 | struct btrfs_ioctl_space_info *space); | 3742 | struct btrfs_ioctl_space_info *space); |
3743 | void 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 */ |
3653 | int btrfs_auto_defrag_init(void); | 3748 | int 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 | |||
3820 | static 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) |
3724 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | 3835 | void __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, ...); |