diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 105 |
1 files changed, 86 insertions, 19 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d6dd49b51ba8..e795bf135e80 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -961,8 +961,8 @@ struct btrfs_dev_replace_item { | |||
961 | #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) | 961 | #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) |
962 | #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) | 962 | #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) |
963 | #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) | 963 | #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) |
964 | #define BTRFS_BLOCK_GROUP_RAID5 (1 << 7) | 964 | #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) |
965 | #define BTRFS_BLOCK_GROUP_RAID6 (1 << 8) | 965 | #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) |
966 | #define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE | 966 | #define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE |
967 | 967 | ||
968 | enum btrfs_raid_types { | 968 | enum btrfs_raid_types { |
@@ -1102,6 +1102,18 @@ struct btrfs_space_info { | |||
1102 | account */ | 1102 | account */ |
1103 | 1103 | ||
1104 | /* | 1104 | /* |
1105 | * bytes_pinned is kept in line with what is actually pinned, as in | ||
1106 | * we've called update_block_group and dropped the bytes_used counter | ||
1107 | * and increased the bytes_pinned counter. However this means that | ||
1108 | * bytes_pinned does not reflect the bytes that will be pinned once the | ||
1109 | * delayed refs are flushed, so this counter is inc'ed everytime we call | ||
1110 | * btrfs_free_extent so it is a realtime count of what will be freed | ||
1111 | * once the transaction is committed. It will be zero'ed everytime the | ||
1112 | * transaction commits. | ||
1113 | */ | ||
1114 | struct percpu_counter total_bytes_pinned; | ||
1115 | |||
1116 | /* | ||
1105 | * we bump reservation progress every time we decrement | 1117 | * we bump reservation progress every time we decrement |
1106 | * bytes_reserved. This way people waiting for reservations | 1118 | * bytes_reserved. This way people waiting for reservations |
1107 | * know something good has happened and they can check | 1119 | * know something good has happened and they can check |
@@ -1437,25 +1449,22 @@ struct btrfs_fs_info { | |||
1437 | atomic_t open_ioctl_trans; | 1449 | atomic_t open_ioctl_trans; |
1438 | 1450 | ||
1439 | /* | 1451 | /* |
1440 | * this is used by the balancing code to wait for all the pending | 1452 | * this is used to protect the following list -- ordered_roots. |
1441 | * ordered extents | ||
1442 | */ | 1453 | */ |
1443 | spinlock_t ordered_extent_lock; | 1454 | spinlock_t ordered_root_lock; |
1444 | 1455 | ||
1445 | /* | 1456 | /* |
1446 | * all of the data=ordered extents pending writeback | 1457 | * all fs/file tree roots in which there are data=ordered extents |
1458 | * pending writeback are added into this list. | ||
1459 | * | ||
1447 | * these can span multiple transactions and basically include | 1460 | * these can span multiple transactions and basically include |
1448 | * every dirty data page that isn't from nodatacow | 1461 | * every dirty data page that isn't from nodatacow |
1449 | */ | 1462 | */ |
1450 | struct list_head ordered_extents; | 1463 | struct list_head ordered_roots; |
1451 | 1464 | ||
1452 | spinlock_t delalloc_lock; | 1465 | spinlock_t delalloc_root_lock; |
1453 | /* | 1466 | /* all fs/file tree roots that have delalloc inodes. */ |
1454 | * all of the inodes that have delalloc bytes. It is possible for | 1467 | struct list_head delalloc_roots; |
1455 | * this list to be empty even when there is still dirty data=ordered | ||
1456 | * extents waiting to finish IO. | ||
1457 | */ | ||
1458 | struct list_head delalloc_inodes; | ||
1459 | 1468 | ||
1460 | /* | 1469 | /* |
1461 | * there is a pool of worker threads for checksumming during writes | 1470 | * there is a pool of worker threads for checksumming during writes |
@@ -1498,8 +1507,6 @@ struct btrfs_fs_info { | |||
1498 | int do_barriers; | 1507 | int do_barriers; |
1499 | int closing; | 1508 | int closing; |
1500 | int log_root_recovering; | 1509 | int log_root_recovering; |
1501 | int enospc_unlink; | ||
1502 | int trans_no_join; | ||
1503 | 1510 | ||
1504 | u64 total_pinned; | 1511 | u64 total_pinned; |
1505 | 1512 | ||
@@ -1594,6 +1601,12 @@ struct btrfs_fs_info { | |||
1594 | struct rb_root qgroup_tree; | 1601 | struct rb_root qgroup_tree; |
1595 | spinlock_t qgroup_lock; | 1602 | spinlock_t qgroup_lock; |
1596 | 1603 | ||
1604 | /* | ||
1605 | * used to avoid frequently calling ulist_alloc()/ulist_free() | ||
1606 | * when doing qgroup accounting, it must be protected by qgroup_lock. | ||
1607 | */ | ||
1608 | struct ulist *qgroup_ulist; | ||
1609 | |||
1597 | /* protect user change for quota operations */ | 1610 | /* protect user change for quota operations */ |
1598 | struct mutex qgroup_ioctl_lock; | 1611 | struct mutex qgroup_ioctl_lock; |
1599 | 1612 | ||
@@ -1607,6 +1620,8 @@ struct btrfs_fs_info { | |||
1607 | struct mutex qgroup_rescan_lock; /* protects the progress item */ | 1620 | struct mutex qgroup_rescan_lock; /* protects the progress item */ |
1608 | struct btrfs_key qgroup_rescan_progress; | 1621 | struct btrfs_key qgroup_rescan_progress; |
1609 | struct btrfs_workers qgroup_rescan_workers; | 1622 | struct btrfs_workers qgroup_rescan_workers; |
1623 | struct completion qgroup_rescan_completion; | ||
1624 | struct btrfs_work qgroup_rescan_work; | ||
1610 | 1625 | ||
1611 | /* filesystem state */ | 1626 | /* filesystem state */ |
1612 | unsigned long fs_state; | 1627 | unsigned long fs_state; |
@@ -1739,6 +1754,31 @@ struct btrfs_root { | |||
1739 | int force_cow; | 1754 | int force_cow; |
1740 | 1755 | ||
1741 | spinlock_t root_item_lock; | 1756 | spinlock_t root_item_lock; |
1757 | atomic_t refs; | ||
1758 | |||
1759 | spinlock_t delalloc_lock; | ||
1760 | /* | ||
1761 | * all of the inodes that have delalloc bytes. It is possible for | ||
1762 | * this list to be empty even when there is still dirty data=ordered | ||
1763 | * extents waiting to finish IO. | ||
1764 | */ | ||
1765 | struct list_head delalloc_inodes; | ||
1766 | struct list_head delalloc_root; | ||
1767 | u64 nr_delalloc_inodes; | ||
1768 | /* | ||
1769 | * this is used by the balancing code to wait for all the pending | ||
1770 | * ordered extents | ||
1771 | */ | ||
1772 | spinlock_t ordered_extent_lock; | ||
1773 | |||
1774 | /* | ||
1775 | * all of the data=ordered extents pending writeback | ||
1776 | * these can span multiple transactions and basically include | ||
1777 | * every dirty data page that isn't from nodatacow | ||
1778 | */ | ||
1779 | struct list_head ordered_extents; | ||
1780 | struct list_head ordered_root; | ||
1781 | u64 nr_ordered_extents; | ||
1742 | }; | 1782 | }; |
1743 | 1783 | ||
1744 | struct btrfs_ioctl_defrag_range_args { | 1784 | struct btrfs_ioctl_defrag_range_args { |
@@ -3028,6 +3068,8 @@ static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root, | |||
3028 | num_items; | 3068 | num_items; |
3029 | } | 3069 | } |
3030 | 3070 | ||
3071 | int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, | ||
3072 | struct btrfs_root *root); | ||
3031 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); | 3073 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); |
3032 | int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, | 3074 | int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, |
3033 | struct btrfs_root *root, unsigned long count); | 3075 | struct btrfs_root *root, unsigned long count); |
@@ -3039,6 +3081,8 @@ int btrfs_pin_extent(struct btrfs_root *root, | |||
3039 | u64 bytenr, u64 num, int reserved); | 3081 | u64 bytenr, u64 num, int reserved); |
3040 | int btrfs_pin_extent_for_log_replay(struct btrfs_root *root, | 3082 | int btrfs_pin_extent_for_log_replay(struct btrfs_root *root, |
3041 | u64 bytenr, u64 num_bytes); | 3083 | u64 bytenr, u64 num_bytes); |
3084 | int btrfs_exclude_logged_extents(struct btrfs_root *root, | ||
3085 | struct extent_buffer *eb); | ||
3042 | int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, | 3086 | int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, |
3043 | struct btrfs_root *root, | 3087 | struct btrfs_root *root, |
3044 | u64 objectid, u64 offset, u64 bytenr); | 3088 | u64 objectid, u64 offset, u64 bytenr); |
@@ -3155,6 +3199,9 @@ int btrfs_block_rsv_refill(struct btrfs_root *root, | |||
3155 | int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv, | 3199 | int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv, |
3156 | struct btrfs_block_rsv *dst_rsv, | 3200 | struct btrfs_block_rsv *dst_rsv, |
3157 | u64 num_bytes); | 3201 | u64 num_bytes); |
3202 | int btrfs_cond_migrate_bytes(struct btrfs_fs_info *fs_info, | ||
3203 | struct btrfs_block_rsv *dest, u64 num_bytes, | ||
3204 | int min_factor); | ||
3158 | void btrfs_block_rsv_release(struct btrfs_root *root, | 3205 | void btrfs_block_rsv_release(struct btrfs_root *root, |
3159 | struct btrfs_block_rsv *block_rsv, | 3206 | struct btrfs_block_rsv *block_rsv, |
3160 | u64 num_bytes); | 3207 | u64 num_bytes); |
@@ -3311,6 +3358,18 @@ static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) | |||
3311 | smp_mb(); | 3358 | smp_mb(); |
3312 | return fs_info->closing; | 3359 | return fs_info->closing; |
3313 | } | 3360 | } |
3361 | |||
3362 | /* | ||
3363 | * If we remount the fs to be R/O or umount the fs, the cleaner needn't do | ||
3364 | * anything except sleeping. This function is used to check the status of | ||
3365 | * the fs. | ||
3366 | */ | ||
3367 | static inline int btrfs_need_cleaner_sleep(struct btrfs_root *root) | ||
3368 | { | ||
3369 | return (root->fs_info->sb->s_flags & MS_RDONLY || | ||
3370 | btrfs_fs_closing(root->fs_info)); | ||
3371 | } | ||
3372 | |||
3314 | static inline void free_fs_info(struct btrfs_fs_info *fs_info) | 3373 | static inline void free_fs_info(struct btrfs_fs_info *fs_info) |
3315 | { | 3374 | { |
3316 | kfree(fs_info->balance_ctl); | 3375 | kfree(fs_info->balance_ctl); |
@@ -3357,9 +3416,9 @@ int __must_check btrfs_update_root(struct btrfs_trans_handle *trans, | |||
3357 | struct btrfs_root_item *item); | 3416 | struct btrfs_root_item *item); |
3358 | void btrfs_read_root_item(struct extent_buffer *eb, int slot, | 3417 | void btrfs_read_root_item(struct extent_buffer *eb, int slot, |
3359 | struct btrfs_root_item *item); | 3418 | struct btrfs_root_item *item); |
3360 | int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct | 3419 | int btrfs_find_root(struct btrfs_root *root, struct btrfs_key *search_key, |
3361 | btrfs_root_item *item, struct btrfs_key *key); | 3420 | struct btrfs_path *path, struct btrfs_root_item *root_item, |
3362 | int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); | 3421 | struct btrfs_key *root_key); |
3363 | int btrfs_find_orphan_roots(struct btrfs_root *tree_root); | 3422 | int btrfs_find_orphan_roots(struct btrfs_root *tree_root); |
3364 | void btrfs_set_root_node(struct btrfs_root_item *item, | 3423 | void btrfs_set_root_node(struct btrfs_root_item *item, |
3365 | struct extent_buffer *node); | 3424 | struct extent_buffer *node); |
@@ -3493,6 +3552,10 @@ void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work); | |||
3493 | struct extent_map *btrfs_get_extent_fiemap(struct inode *inode, struct page *page, | 3552 | struct extent_map *btrfs_get_extent_fiemap(struct inode *inode, struct page *page, |
3494 | size_t pg_offset, u64 start, u64 len, | 3553 | size_t pg_offset, u64 start, u64 len, |
3495 | int create); | 3554 | int create); |
3555 | noinline int can_nocow_extent(struct btrfs_trans_handle *trans, | ||
3556 | struct inode *inode, u64 offset, u64 *len, | ||
3557 | u64 *orig_start, u64 *orig_block_len, | ||
3558 | u64 *ram_bytes); | ||
3496 | 3559 | ||
3497 | /* RHEL and EL kernels have a patch that renames PG_checked to FsMisc */ | 3560 | /* RHEL and EL kernels have a patch that renames PG_checked to FsMisc */ |
3498 | #if defined(ClearPageFsMisc) && !defined(ClearPageChecked) | 3561 | #if defined(ClearPageFsMisc) && !defined(ClearPageChecked) |
@@ -3530,6 +3593,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
3530 | u32 min_type); | 3593 | u32 min_type); |
3531 | 3594 | ||
3532 | int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); | 3595 | int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); |
3596 | int btrfs_start_all_delalloc_inodes(struct btrfs_fs_info *fs_info, | ||
3597 | int delay_iput); | ||
3533 | int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, | 3598 | int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, |
3534 | struct extent_state **cached_state); | 3599 | struct extent_state **cached_state); |
3535 | int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, | 3600 | int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, |
@@ -3814,6 +3879,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, | |||
3814 | int btrfs_quota_disable(struct btrfs_trans_handle *trans, | 3879 | int btrfs_quota_disable(struct btrfs_trans_handle *trans, |
3815 | struct btrfs_fs_info *fs_info); | 3880 | struct btrfs_fs_info *fs_info); |
3816 | int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); | 3881 | int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); |
3882 | void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info); | ||
3883 | int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info); | ||
3817 | int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, | 3884 | int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, |
3818 | struct btrfs_fs_info *fs_info, u64 src, u64 dst); | 3885 | struct btrfs_fs_info *fs_info, u64 src, u64 dst); |
3819 | int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, | 3886 | int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, |