diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 239 |
1 files changed, 217 insertions, 22 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 67385033323d..27ebe61d3ccc 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -86,6 +86,9 @@ struct btrfs_ordered_sum; | |||
86 | /* holds checksums of all the data extents */ | 86 | /* holds checksums of all the data extents */ |
87 | #define BTRFS_CSUM_TREE_OBJECTID 7ULL | 87 | #define BTRFS_CSUM_TREE_OBJECTID 7ULL |
88 | 88 | ||
89 | /* for storing balance parameters in the root tree */ | ||
90 | #define BTRFS_BALANCE_OBJECTID -4ULL | ||
91 | |||
89 | /* orhpan objectid for tracking unlinked/truncated files */ | 92 | /* orhpan objectid for tracking unlinked/truncated files */ |
90 | #define BTRFS_ORPHAN_OBJECTID -5ULL | 93 | #define BTRFS_ORPHAN_OBJECTID -5ULL |
91 | 94 | ||
@@ -692,6 +695,54 @@ struct btrfs_root_ref { | |||
692 | __le16 name_len; | 695 | __le16 name_len; |
693 | } __attribute__ ((__packed__)); | 696 | } __attribute__ ((__packed__)); |
694 | 697 | ||
698 | struct btrfs_disk_balance_args { | ||
699 | /* | ||
700 | * profiles to operate on, single is denoted by | ||
701 | * BTRFS_AVAIL_ALLOC_BIT_SINGLE | ||
702 | */ | ||
703 | __le64 profiles; | ||
704 | |||
705 | /* usage filter */ | ||
706 | __le64 usage; | ||
707 | |||
708 | /* devid filter */ | ||
709 | __le64 devid; | ||
710 | |||
711 | /* devid subset filter [pstart..pend) */ | ||
712 | __le64 pstart; | ||
713 | __le64 pend; | ||
714 | |||
715 | /* btrfs virtual address space subset filter [vstart..vend) */ | ||
716 | __le64 vstart; | ||
717 | __le64 vend; | ||
718 | |||
719 | /* | ||
720 | * profile to convert to, single is denoted by | ||
721 | * BTRFS_AVAIL_ALLOC_BIT_SINGLE | ||
722 | */ | ||
723 | __le64 target; | ||
724 | |||
725 | /* BTRFS_BALANCE_ARGS_* */ | ||
726 | __le64 flags; | ||
727 | |||
728 | __le64 unused[8]; | ||
729 | } __attribute__ ((__packed__)); | ||
730 | |||
731 | /* | ||
732 | * store balance parameters to disk so that balance can be properly | ||
733 | * resumed after crash or unmount | ||
734 | */ | ||
735 | struct btrfs_balance_item { | ||
736 | /* BTRFS_BALANCE_* */ | ||
737 | __le64 flags; | ||
738 | |||
739 | struct btrfs_disk_balance_args data; | ||
740 | struct btrfs_disk_balance_args meta; | ||
741 | struct btrfs_disk_balance_args sys; | ||
742 | |||
743 | __le64 unused[4]; | ||
744 | } __attribute__ ((__packed__)); | ||
745 | |||
695 | #define BTRFS_FILE_EXTENT_INLINE 0 | 746 | #define BTRFS_FILE_EXTENT_INLINE 0 |
696 | #define BTRFS_FILE_EXTENT_REG 1 | 747 | #define BTRFS_FILE_EXTENT_REG 1 |
697 | #define BTRFS_FILE_EXTENT_PREALLOC 2 | 748 | #define BTRFS_FILE_EXTENT_PREALLOC 2 |
@@ -751,14 +802,32 @@ struct btrfs_csum_item { | |||
751 | } __attribute__ ((__packed__)); | 802 | } __attribute__ ((__packed__)); |
752 | 803 | ||
753 | /* different types of block groups (and chunks) */ | 804 | /* different types of block groups (and chunks) */ |
754 | #define BTRFS_BLOCK_GROUP_DATA (1 << 0) | 805 | #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) |
755 | #define BTRFS_BLOCK_GROUP_SYSTEM (1 << 1) | 806 | #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) |
756 | #define BTRFS_BLOCK_GROUP_METADATA (1 << 2) | 807 | #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2) |
757 | #define BTRFS_BLOCK_GROUP_RAID0 (1 << 3) | 808 | #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3) |
758 | #define BTRFS_BLOCK_GROUP_RAID1 (1 << 4) | 809 | #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) |
759 | #define BTRFS_BLOCK_GROUP_DUP (1 << 5) | 810 | #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) |
760 | #define BTRFS_BLOCK_GROUP_RAID10 (1 << 6) | 811 | #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) |
761 | #define BTRFS_NR_RAID_TYPES 5 | 812 | #define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE |
813 | #define BTRFS_NR_RAID_TYPES 5 | ||
814 | |||
815 | #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \ | ||
816 | BTRFS_BLOCK_GROUP_SYSTEM | \ | ||
817 | BTRFS_BLOCK_GROUP_METADATA) | ||
818 | |||
819 | #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \ | ||
820 | BTRFS_BLOCK_GROUP_RAID1 | \ | ||
821 | BTRFS_BLOCK_GROUP_DUP | \ | ||
822 | BTRFS_BLOCK_GROUP_RAID10) | ||
823 | /* | ||
824 | * We need a bit for restriper to be able to tell when chunks of type | ||
825 | * SINGLE are available. This "extended" profile format is used in | ||
826 | * fs_info->avail_*_alloc_bits (in-memory) and balance item fields | ||
827 | * (on-disk). The corresponding on-disk bit in chunk.type is reserved | ||
828 | * to avoid remappings between two formats in future. | ||
829 | */ | ||
830 | #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) | ||
762 | 831 | ||
763 | struct btrfs_block_group_item { | 832 | struct btrfs_block_group_item { |
764 | __le64 used; | 833 | __le64 used; |
@@ -916,6 +985,7 @@ struct btrfs_block_group_cache { | |||
916 | struct reloc_control; | 985 | struct reloc_control; |
917 | struct btrfs_device; | 986 | struct btrfs_device; |
918 | struct btrfs_fs_devices; | 987 | struct btrfs_fs_devices; |
988 | struct btrfs_balance_control; | ||
919 | struct btrfs_delayed_root; | 989 | struct btrfs_delayed_root; |
920 | struct btrfs_fs_info { | 990 | struct btrfs_fs_info { |
921 | u8 fsid[BTRFS_FSID_SIZE]; | 991 | u8 fsid[BTRFS_FSID_SIZE]; |
@@ -971,7 +1041,7 @@ struct btrfs_fs_info { | |||
971 | * is required instead of the faster short fsync log commits | 1041 | * is required instead of the faster short fsync log commits |
972 | */ | 1042 | */ |
973 | u64 last_trans_log_full_commit; | 1043 | u64 last_trans_log_full_commit; |
974 | unsigned long mount_opt:20; | 1044 | unsigned long mount_opt:21; |
975 | unsigned long compress_type:4; | 1045 | unsigned long compress_type:4; |
976 | u64 max_inline; | 1046 | u64 max_inline; |
977 | u64 alloc_start; | 1047 | u64 alloc_start; |
@@ -1132,12 +1202,23 @@ struct btrfs_fs_info { | |||
1132 | spinlock_t ref_cache_lock; | 1202 | spinlock_t ref_cache_lock; |
1133 | u64 total_ref_cache_size; | 1203 | u64 total_ref_cache_size; |
1134 | 1204 | ||
1205 | /* | ||
1206 | * these three are in extended format (availability of single | ||
1207 | * chunks is denoted by BTRFS_AVAIL_ALLOC_BIT_SINGLE bit, other | ||
1208 | * types are denoted by corresponding BTRFS_BLOCK_GROUP_* bits) | ||
1209 | */ | ||
1135 | u64 avail_data_alloc_bits; | 1210 | u64 avail_data_alloc_bits; |
1136 | u64 avail_metadata_alloc_bits; | 1211 | u64 avail_metadata_alloc_bits; |
1137 | u64 avail_system_alloc_bits; | 1212 | u64 avail_system_alloc_bits; |
1138 | u64 data_alloc_profile; | 1213 | |
1139 | u64 metadata_alloc_profile; | 1214 | /* restriper state */ |
1140 | u64 system_alloc_profile; | 1215 | spinlock_t balance_lock; |
1216 | struct mutex balance_mutex; | ||
1217 | atomic_t balance_running; | ||
1218 | atomic_t balance_pause_req; | ||
1219 | atomic_t balance_cancel_req; | ||
1220 | struct btrfs_balance_control *balance_ctl; | ||
1221 | wait_queue_head_t balance_wait_q; | ||
1141 | 1222 | ||
1142 | unsigned data_chunk_allocations; | 1223 | unsigned data_chunk_allocations; |
1143 | unsigned metadata_ratio; | 1224 | unsigned metadata_ratio; |
@@ -1155,6 +1236,10 @@ struct btrfs_fs_info { | |||
1155 | int scrub_workers_refcnt; | 1236 | int scrub_workers_refcnt; |
1156 | struct btrfs_workers scrub_workers; | 1237 | struct btrfs_workers scrub_workers; |
1157 | 1238 | ||
1239 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY | ||
1240 | u32 check_integrity_print_mask; | ||
1241 | #endif | ||
1242 | |||
1158 | /* filesystem state */ | 1243 | /* filesystem state */ |
1159 | u64 fs_state; | 1244 | u64 fs_state; |
1160 | 1245 | ||
@@ -1383,6 +1468,8 @@ struct btrfs_ioctl_defrag_range_args { | |||
1383 | #define BTRFS_DEV_ITEM_KEY 216 | 1468 | #define BTRFS_DEV_ITEM_KEY 216 |
1384 | #define BTRFS_CHUNK_ITEM_KEY 228 | 1469 | #define BTRFS_CHUNK_ITEM_KEY 228 |
1385 | 1470 | ||
1471 | #define BTRFS_BALANCE_ITEM_KEY 248 | ||
1472 | |||
1386 | /* | 1473 | /* |
1387 | * string items are for debugging. They just store a short string of | 1474 | * string items are for debugging. They just store a short string of |
1388 | * data in the FS | 1475 | * data in the FS |
@@ -1413,6 +1500,9 @@ struct btrfs_ioctl_defrag_range_args { | |||
1413 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) | 1500 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) |
1414 | #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) | 1501 | #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) |
1415 | #define BTRFS_MOUNT_RECOVERY (1 << 18) | 1502 | #define BTRFS_MOUNT_RECOVERY (1 << 18) |
1503 | #define BTRFS_MOUNT_SKIP_BALANCE (1 << 19) | ||
1504 | #define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) | ||
1505 | #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) | ||
1416 | 1506 | ||
1417 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) | 1507 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) |
1418 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) | 1508 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) |
@@ -2077,8 +2167,86 @@ BTRFS_SETGET_STACK_FUNCS(backup_bytes_used, struct btrfs_root_backup, | |||
2077 | BTRFS_SETGET_STACK_FUNCS(backup_num_devices, struct btrfs_root_backup, | 2167 | BTRFS_SETGET_STACK_FUNCS(backup_num_devices, struct btrfs_root_backup, |
2078 | num_devices, 64); | 2168 | num_devices, 64); |
2079 | 2169 | ||
2080 | /* struct btrfs_super_block */ | 2170 | /* struct btrfs_balance_item */ |
2171 | BTRFS_SETGET_FUNCS(balance_flags, struct btrfs_balance_item, flags, 64); | ||
2081 | 2172 | ||
2173 | static inline void btrfs_balance_data(struct extent_buffer *eb, | ||
2174 | struct btrfs_balance_item *bi, | ||
2175 | struct btrfs_disk_balance_args *ba) | ||
2176 | { | ||
2177 | read_eb_member(eb, bi, struct btrfs_balance_item, data, ba); | ||
2178 | } | ||
2179 | |||
2180 | static inline void btrfs_set_balance_data(struct extent_buffer *eb, | ||
2181 | struct btrfs_balance_item *bi, | ||
2182 | struct btrfs_disk_balance_args *ba) | ||
2183 | { | ||
2184 | write_eb_member(eb, bi, struct btrfs_balance_item, data, ba); | ||
2185 | } | ||
2186 | |||
2187 | static inline void btrfs_balance_meta(struct extent_buffer *eb, | ||
2188 | struct btrfs_balance_item *bi, | ||
2189 | struct btrfs_disk_balance_args *ba) | ||
2190 | { | ||
2191 | read_eb_member(eb, bi, struct btrfs_balance_item, meta, ba); | ||
2192 | } | ||
2193 | |||
2194 | static inline void btrfs_set_balance_meta(struct extent_buffer *eb, | ||
2195 | struct btrfs_balance_item *bi, | ||
2196 | struct btrfs_disk_balance_args *ba) | ||
2197 | { | ||
2198 | write_eb_member(eb, bi, struct btrfs_balance_item, meta, ba); | ||
2199 | } | ||
2200 | |||
2201 | static inline void btrfs_balance_sys(struct extent_buffer *eb, | ||
2202 | struct btrfs_balance_item *bi, | ||
2203 | struct btrfs_disk_balance_args *ba) | ||
2204 | { | ||
2205 | read_eb_member(eb, bi, struct btrfs_balance_item, sys, ba); | ||
2206 | } | ||
2207 | |||
2208 | static inline void btrfs_set_balance_sys(struct extent_buffer *eb, | ||
2209 | struct btrfs_balance_item *bi, | ||
2210 | struct btrfs_disk_balance_args *ba) | ||
2211 | { | ||
2212 | write_eb_member(eb, bi, struct btrfs_balance_item, sys, ba); | ||
2213 | } | ||
2214 | |||
2215 | static inline void | ||
2216 | btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu, | ||
2217 | struct btrfs_disk_balance_args *disk) | ||
2218 | { | ||
2219 | memset(cpu, 0, sizeof(*cpu)); | ||
2220 | |||
2221 | cpu->profiles = le64_to_cpu(disk->profiles); | ||
2222 | cpu->usage = le64_to_cpu(disk->usage); | ||
2223 | cpu->devid = le64_to_cpu(disk->devid); | ||
2224 | cpu->pstart = le64_to_cpu(disk->pstart); | ||
2225 | cpu->pend = le64_to_cpu(disk->pend); | ||
2226 | cpu->vstart = le64_to_cpu(disk->vstart); | ||
2227 | cpu->vend = le64_to_cpu(disk->vend); | ||
2228 | cpu->target = le64_to_cpu(disk->target); | ||
2229 | cpu->flags = le64_to_cpu(disk->flags); | ||
2230 | } | ||
2231 | |||
2232 | static inline void | ||
2233 | btrfs_cpu_balance_args_to_disk(struct btrfs_disk_balance_args *disk, | ||
2234 | struct btrfs_balance_args *cpu) | ||
2235 | { | ||
2236 | memset(disk, 0, sizeof(*disk)); | ||
2237 | |||
2238 | disk->profiles = cpu_to_le64(cpu->profiles); | ||
2239 | disk->usage = cpu_to_le64(cpu->usage); | ||
2240 | disk->devid = cpu_to_le64(cpu->devid); | ||
2241 | disk->pstart = cpu_to_le64(cpu->pstart); | ||
2242 | disk->pend = cpu_to_le64(cpu->pend); | ||
2243 | disk->vstart = cpu_to_le64(cpu->vstart); | ||
2244 | disk->vend = cpu_to_le64(cpu->vend); | ||
2245 | disk->target = cpu_to_le64(cpu->target); | ||
2246 | disk->flags = cpu_to_le64(cpu->flags); | ||
2247 | } | ||
2248 | |||
2249 | /* struct btrfs_super_block */ | ||
2082 | BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64); | 2250 | BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64); |
2083 | BTRFS_SETGET_STACK_FUNCS(super_flags, struct btrfs_super_block, flags, 64); | 2251 | BTRFS_SETGET_STACK_FUNCS(super_flags, struct btrfs_super_block, flags, 64); |
2084 | BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block, | 2252 | BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block, |
@@ -2196,7 +2364,7 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb, | |||
2196 | return btrfs_item_size(eb, e) - offset; | 2364 | return btrfs_item_size(eb, e) - offset; |
2197 | } | 2365 | } |
2198 | 2366 | ||
2199 | static inline struct btrfs_root *btrfs_sb(struct super_block *sb) | 2367 | static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb) |
2200 | { | 2368 | { |
2201 | return sb->s_fs_info; | 2369 | return sb->s_fs_info; |
2202 | } | 2370 | } |
@@ -2277,11 +2445,11 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
2277 | struct btrfs_root *root, u32 blocksize, | 2445 | struct btrfs_root *root, u32 blocksize, |
2278 | u64 parent, u64 root_objectid, | 2446 | u64 parent, u64 root_objectid, |
2279 | struct btrfs_disk_key *key, int level, | 2447 | struct btrfs_disk_key *key, int level, |
2280 | u64 hint, u64 empty_size); | 2448 | u64 hint, u64 empty_size, int for_cow); |
2281 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | 2449 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, |
2282 | struct btrfs_root *root, | 2450 | struct btrfs_root *root, |
2283 | struct extent_buffer *buf, | 2451 | struct extent_buffer *buf, |
2284 | u64 parent, int last_ref); | 2452 | u64 parent, int last_ref, int for_cow); |
2285 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, | 2453 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, |
2286 | struct btrfs_root *root, | 2454 | struct btrfs_root *root, |
2287 | u64 bytenr, u32 blocksize, | 2455 | u64 bytenr, u32 blocksize, |
@@ -2301,17 +2469,17 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans, | |||
2301 | u64 search_end, struct btrfs_key *ins, | 2469 | u64 search_end, struct btrfs_key *ins, |
2302 | u64 data); | 2470 | u64 data); |
2303 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 2471 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
2304 | struct extent_buffer *buf, int full_backref); | 2472 | struct extent_buffer *buf, int full_backref, int for_cow); |
2305 | int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 2473 | int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
2306 | struct extent_buffer *buf, int full_backref); | 2474 | struct extent_buffer *buf, int full_backref, int for_cow); |
2307 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, | 2475 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, |
2308 | struct btrfs_root *root, | 2476 | struct btrfs_root *root, |
2309 | u64 bytenr, u64 num_bytes, u64 flags, | 2477 | u64 bytenr, u64 num_bytes, u64 flags, |
2310 | int is_data); | 2478 | int is_data); |
2311 | int btrfs_free_extent(struct btrfs_trans_handle *trans, | 2479 | int btrfs_free_extent(struct btrfs_trans_handle *trans, |
2312 | struct btrfs_root *root, | 2480 | struct btrfs_root *root, |
2313 | u64 bytenr, u64 num_bytes, u64 parent, | 2481 | u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, |
2314 | u64 root_objectid, u64 owner, u64 offset); | 2482 | u64 owner, u64 offset, int for_cow); |
2315 | 2483 | ||
2316 | int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); | 2484 | int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); |
2317 | int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, | 2485 | int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, |
@@ -2323,7 +2491,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, | |||
2323 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, | 2491 | int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, |
2324 | struct btrfs_root *root, | 2492 | struct btrfs_root *root, |
2325 | u64 bytenr, u64 num_bytes, u64 parent, | 2493 | u64 bytenr, u64 num_bytes, u64 parent, |
2326 | u64 root_objectid, u64 owner, u64 offset); | 2494 | u64 root_objectid, u64 owner, u64 offset, int for_cow); |
2327 | 2495 | ||
2328 | int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, | 2496 | int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, |
2329 | struct btrfs_root *root); | 2497 | struct btrfs_root *root); |
@@ -2482,10 +2650,18 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, | |||
2482 | } | 2650 | } |
2483 | 2651 | ||
2484 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); | 2652 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); |
2653 | static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p) | ||
2654 | { | ||
2655 | ++p->slots[0]; | ||
2656 | if (p->slots[0] >= btrfs_header_nritems(p->nodes[0])) | ||
2657 | return btrfs_next_leaf(root, p); | ||
2658 | return 0; | ||
2659 | } | ||
2485 | int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); | 2660 | int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); |
2486 | int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); | 2661 | int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); |
2487 | void btrfs_drop_snapshot(struct btrfs_root *root, | 2662 | void btrfs_drop_snapshot(struct btrfs_root *root, |
2488 | struct btrfs_block_rsv *block_rsv, int update_ref); | 2663 | struct btrfs_block_rsv *block_rsv, int update_ref, |
2664 | int for_reloc); | ||
2489 | int btrfs_drop_subtree(struct btrfs_trans_handle *trans, | 2665 | int btrfs_drop_subtree(struct btrfs_trans_handle *trans, |
2490 | struct btrfs_root *root, | 2666 | struct btrfs_root *root, |
2491 | struct extent_buffer *node, | 2667 | struct extent_buffer *node, |
@@ -2500,6 +2676,7 @@ static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) | |||
2500 | } | 2676 | } |
2501 | static inline void free_fs_info(struct btrfs_fs_info *fs_info) | 2677 | static inline void free_fs_info(struct btrfs_fs_info *fs_info) |
2502 | { | 2678 | { |
2679 | kfree(fs_info->balance_ctl); | ||
2503 | kfree(fs_info->delayed_root); | 2680 | kfree(fs_info->delayed_root); |
2504 | kfree(fs_info->extent_root); | 2681 | kfree(fs_info->extent_root); |
2505 | kfree(fs_info->tree_root); | 2682 | kfree(fs_info->tree_root); |
@@ -2510,6 +2687,24 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info) | |||
2510 | kfree(fs_info->super_for_commit); | 2687 | kfree(fs_info->super_for_commit); |
2511 | kfree(fs_info); | 2688 | kfree(fs_info); |
2512 | } | 2689 | } |
2690 | /** | ||
2691 | * profile_is_valid - tests whether a given profile is valid and reduced | ||
2692 | * @flags: profile to validate | ||
2693 | * @extended: if true @flags is treated as an extended profile | ||
2694 | */ | ||
2695 | static inline int profile_is_valid(u64 flags, int extended) | ||
2696 | { | ||
2697 | u64 mask = ~BTRFS_BLOCK_GROUP_PROFILE_MASK; | ||
2698 | |||
2699 | flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK; | ||
2700 | if (extended) | ||
2701 | mask &= ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
2702 | |||
2703 | if (flags & mask) | ||
2704 | return 0; | ||
2705 | /* true if zero or exactly one bit set */ | ||
2706 | return (flags & (~flags + 1)) == flags; | ||
2707 | } | ||
2513 | 2708 | ||
2514 | /* root-item.c */ | 2709 | /* root-item.c */ |
2515 | int btrfs_find_root_ref(struct btrfs_root *tree_root, | 2710 | int btrfs_find_root_ref(struct btrfs_root *tree_root, |