diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index fe69edda11fb..e6fbbd74b716 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -607,6 +607,7 @@ struct btrfs_path { | |||
607 | unsigned int leave_spinning:1; | 607 | unsigned int leave_spinning:1; |
608 | unsigned int search_commit_root:1; | 608 | unsigned int search_commit_root:1; |
609 | unsigned int need_commit_sem:1; | 609 | unsigned int need_commit_sem:1; |
610 | unsigned int skip_release_on_error:1; | ||
610 | }; | 611 | }; |
611 | 612 | ||
612 | /* | 613 | /* |
@@ -1170,6 +1171,7 @@ struct btrfs_space_info { | |||
1170 | struct percpu_counter total_bytes_pinned; | 1171 | struct percpu_counter total_bytes_pinned; |
1171 | 1172 | ||
1172 | struct list_head list; | 1173 | struct list_head list; |
1174 | struct list_head ro_bgs; | ||
1173 | 1175 | ||
1174 | struct rw_semaphore groups_sem; | 1176 | struct rw_semaphore groups_sem; |
1175 | /* for block groups in our same type */ | 1177 | /* for block groups in our same type */ |
@@ -1276,6 +1278,8 @@ struct btrfs_block_group_cache { | |||
1276 | unsigned int ro:1; | 1278 | unsigned int ro:1; |
1277 | unsigned int dirty:1; | 1279 | unsigned int dirty:1; |
1278 | unsigned int iref:1; | 1280 | unsigned int iref:1; |
1281 | unsigned int has_caching_ctl:1; | ||
1282 | unsigned int removed:1; | ||
1279 | 1283 | ||
1280 | int disk_cache_state; | 1284 | int disk_cache_state; |
1281 | 1285 | ||
@@ -1305,6 +1309,11 @@ struct btrfs_block_group_cache { | |||
1305 | 1309 | ||
1306 | /* For delayed block group creation or deletion of empty block groups */ | 1310 | /* For delayed block group creation or deletion of empty block groups */ |
1307 | struct list_head bg_list; | 1311 | struct list_head bg_list; |
1312 | |||
1313 | /* For read-only block groups */ | ||
1314 | struct list_head ro_list; | ||
1315 | |||
1316 | atomic_t trimming; | ||
1308 | }; | 1317 | }; |
1309 | 1318 | ||
1310 | /* delayed seq elem */ | 1319 | /* delayed seq elem */ |
@@ -1402,6 +1411,11 @@ struct btrfs_fs_info { | |||
1402 | */ | 1411 | */ |
1403 | u64 last_trans_log_full_commit; | 1412 | u64 last_trans_log_full_commit; |
1404 | unsigned long mount_opt; | 1413 | unsigned long mount_opt; |
1414 | /* | ||
1415 | * Track requests for actions that need to be done during transaction | ||
1416 | * commit (like for some mount options). | ||
1417 | */ | ||
1418 | unsigned long pending_changes; | ||
1405 | unsigned long compress_type:4; | 1419 | unsigned long compress_type:4; |
1406 | int commit_interval; | 1420 | int commit_interval; |
1407 | /* | 1421 | /* |
@@ -1729,6 +1743,12 @@ struct btrfs_fs_info { | |||
1729 | 1743 | ||
1730 | /* For btrfs to record security options */ | 1744 | /* For btrfs to record security options */ |
1731 | struct security_mnt_opts security_opts; | 1745 | struct security_mnt_opts security_opts; |
1746 | |||
1747 | /* | ||
1748 | * Chunks that can't be freed yet (under a trim/discard operation) | ||
1749 | * and will be latter freed. Protected by fs_info->chunk_mutex. | ||
1750 | */ | ||
1751 | struct list_head pinned_chunks; | ||
1732 | }; | 1752 | }; |
1733 | 1753 | ||
1734 | struct btrfs_subvolume_writers { | 1754 | struct btrfs_subvolume_writers { |
@@ -2093,7 +2113,6 @@ struct btrfs_ioctl_defrag_range_args { | |||
2093 | #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) | 2113 | #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) |
2094 | #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22) | 2114 | #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22) |
2095 | #define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23) | 2115 | #define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23) |
2096 | #define BTRFS_MOUNT_CHANGE_INODE_CACHE (1 << 24) | ||
2097 | 2116 | ||
2098 | #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) | 2117 | #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) |
2099 | #define BTRFS_DEFAULT_MAX_INLINE (8192) | 2118 | #define BTRFS_DEFAULT_MAX_INLINE (8192) |
@@ -2103,6 +2122,7 @@ struct btrfs_ioctl_defrag_range_args { | |||
2103 | #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) | 2122 | #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) |
2104 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ | 2123 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ |
2105 | BTRFS_MOUNT_##opt) | 2124 | BTRFS_MOUNT_##opt) |
2125 | |||
2106 | #define btrfs_set_and_info(root, opt, fmt, args...) \ | 2126 | #define btrfs_set_and_info(root, opt, fmt, args...) \ |
2107 | { \ | 2127 | { \ |
2108 | if (!btrfs_test_opt(root, opt)) \ | 2128 | if (!btrfs_test_opt(root, opt)) \ |
@@ -2118,6 +2138,49 @@ struct btrfs_ioctl_defrag_range_args { | |||
2118 | } | 2138 | } |
2119 | 2139 | ||
2120 | /* | 2140 | /* |
2141 | * Requests for changes that need to be done during transaction commit. | ||
2142 | * | ||
2143 | * Internal mount options that are used for special handling of the real | ||
2144 | * mount options (eg. cannot be set during remount and have to be set during | ||
2145 | * transaction commit) | ||
2146 | */ | ||
2147 | |||
2148 | #define BTRFS_PENDING_SET_INODE_MAP_CACHE (0) | ||
2149 | #define BTRFS_PENDING_CLEAR_INODE_MAP_CACHE (1) | ||
2150 | #define BTRFS_PENDING_COMMIT (2) | ||
2151 | |||
2152 | #define btrfs_test_pending(info, opt) \ | ||
2153 | test_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) | ||
2154 | #define btrfs_set_pending(info, opt) \ | ||
2155 | set_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) | ||
2156 | #define btrfs_clear_pending(info, opt) \ | ||
2157 | clear_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) | ||
2158 | |||
2159 | /* | ||
2160 | * Helpers for setting pending mount option changes. | ||
2161 | * | ||
2162 | * Expects corresponding macros | ||
2163 | * BTRFS_PENDING_SET_ and CLEAR_ + short mount option name | ||
2164 | */ | ||
2165 | #define btrfs_set_pending_and_info(info, opt, fmt, args...) \ | ||
2166 | do { \ | ||
2167 | if (!btrfs_raw_test_opt((info)->mount_opt, opt)) { \ | ||
2168 | btrfs_info((info), fmt, ##args); \ | ||
2169 | btrfs_set_pending((info), SET_##opt); \ | ||
2170 | btrfs_clear_pending((info), CLEAR_##opt); \ | ||
2171 | } \ | ||
2172 | } while(0) | ||
2173 | |||
2174 | #define btrfs_clear_pending_and_info(info, opt, fmt, args...) \ | ||
2175 | do { \ | ||
2176 | if (btrfs_raw_test_opt((info)->mount_opt, opt)) { \ | ||
2177 | btrfs_info((info), fmt, ##args); \ | ||
2178 | btrfs_set_pending((info), CLEAR_##opt); \ | ||
2179 | btrfs_clear_pending((info), SET_##opt); \ | ||
2180 | } \ | ||
2181 | } while(0) | ||
2182 | |||
2183 | /* | ||
2121 | * Inode flags | 2184 | * Inode flags |
2122 | */ | 2185 | */ |
2123 | #define BTRFS_INODE_NODATASUM (1 << 0) | 2186 | #define BTRFS_INODE_NODATASUM (1 << 0) |
@@ -3351,7 +3414,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
3351 | u64 type, u64 chunk_objectid, u64 chunk_offset, | 3414 | u64 type, u64 chunk_objectid, u64 chunk_offset, |
3352 | u64 size); | 3415 | u64 size); |
3353 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | 3416 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, |
3354 | struct btrfs_root *root, u64 group_start); | 3417 | struct btrfs_root *root, u64 group_start, |
3418 | struct extent_map *em); | ||
3355 | void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info); | 3419 | void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info); |
3356 | void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, | 3420 | void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, |
3357 | struct btrfs_root *root); | 3421 | struct btrfs_root *root); |
@@ -3427,8 +3491,8 @@ int btrfs_init_space_info(struct btrfs_fs_info *fs_info); | |||
3427 | int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans, | 3491 | int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans, |
3428 | struct btrfs_fs_info *fs_info); | 3492 | struct btrfs_fs_info *fs_info); |
3429 | int __get_raid_index(u64 flags); | 3493 | int __get_raid_index(u64 flags); |
3430 | int btrfs_start_nocow_write(struct btrfs_root *root); | 3494 | int btrfs_start_write_no_snapshoting(struct btrfs_root *root); |
3431 | void btrfs_end_nocow_write(struct btrfs_root *root); | 3495 | void btrfs_end_write_no_snapshoting(struct btrfs_root *root); |
3432 | /* ctree.c */ | 3496 | /* ctree.c */ |
3433 | int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, | 3497 | int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, |
3434 | int level, int *slot); | 3498 | int level, int *slot); |
@@ -3686,6 +3750,10 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | |||
3686 | int verify_dir_item(struct btrfs_root *root, | 3750 | int verify_dir_item(struct btrfs_root *root, |
3687 | struct extent_buffer *leaf, | 3751 | struct extent_buffer *leaf, |
3688 | struct btrfs_dir_item *dir_item); | 3752 | struct btrfs_dir_item *dir_item); |
3753 | struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, | ||
3754 | struct btrfs_path *path, | ||
3755 | const char *name, | ||
3756 | int name_len); | ||
3689 | 3757 | ||
3690 | /* orphan.c */ | 3758 | /* orphan.c */ |
3691 | int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans, | 3759 | int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans, |
@@ -3857,6 +3925,7 @@ int btrfs_prealloc_file_range_trans(struct inode *inode, | |||
3857 | struct btrfs_trans_handle *trans, int mode, | 3925 | struct btrfs_trans_handle *trans, int mode, |
3858 | u64 start, u64 num_bytes, u64 min_size, | 3926 | u64 start, u64 num_bytes, u64 min_size, |
3859 | loff_t actual_len, u64 *alloc_hint); | 3927 | loff_t actual_len, u64 *alloc_hint); |
3928 | int btrfs_inode_check_errors(struct inode *inode); | ||
3860 | extern const struct dentry_operations btrfs_dentry_operations; | 3929 | extern const struct dentry_operations btrfs_dentry_operations; |
3861 | 3930 | ||
3862 | /* ioctl.c */ | 3931 | /* ioctl.c */ |
@@ -3901,6 +3970,7 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode, | |||
3901 | struct page **pages, size_t num_pages, | 3970 | struct page **pages, size_t num_pages, |
3902 | loff_t pos, size_t write_bytes, | 3971 | loff_t pos, size_t write_bytes, |
3903 | struct extent_state **cached); | 3972 | struct extent_state **cached); |
3973 | int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); | ||
3904 | 3974 | ||
3905 | /* tree-defrag.c */ | 3975 | /* tree-defrag.c */ |
3906 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | 3976 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
@@ -4097,7 +4167,12 @@ int btrfs_scrub_progress(struct btrfs_root *root, u64 devid, | |||
4097 | /* dev-replace.c */ | 4167 | /* dev-replace.c */ |
4098 | void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info); | 4168 | void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info); |
4099 | void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info); | 4169 | void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info); |
4100 | void btrfs_bio_counter_dec(struct btrfs_fs_info *fs_info); | 4170 | void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount); |
4171 | |||
4172 | static inline void btrfs_bio_counter_dec(struct btrfs_fs_info *fs_info) | ||
4173 | { | ||
4174 | btrfs_bio_counter_sub(fs_info, 1); | ||
4175 | } | ||
4101 | 4176 | ||
4102 | /* reada.c */ | 4177 | /* reada.c */ |
4103 | struct reada_control { | 4178 | struct reada_control { |