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.h84
1 files changed, 49 insertions, 35 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9417713542a2..ad96495dedc5 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -143,12 +143,15 @@ static int btrfs_csum_sizes[] = { 4, 0 };
143#define BTRFS_FT_MAX 9 143#define BTRFS_FT_MAX 9
144 144
145/* 145/*
146 * the key defines the order in the tree, and so it also defines (optimal) 146 * The key defines the order in the tree, and so it also defines (optimal)
147 * block layout. objectid corresonds to the inode number. The flags 147 * block layout.
148 * tells us things about the object, and is a kind of stream selector. 148 *
149 * so for a given inode, keys with flags of 1 might refer to the inode 149 * objectid corresponds to the inode number.
150 * data, flags of 2 may point to file data in the btree and flags == 3 150 *
151 * may point to extents. 151 * type tells us things about the object, and is a kind of stream selector.
152 * so for a given inode, keys with type of 1 might refer to the inode data,
153 * type of 2 may point to file data in the btree and type == 3 may point to
154 * extents.
152 * 155 *
153 * offset is the starting byte offset for this key in the stream. 156 * offset is the starting byte offset for this key in the stream.
154 * 157 *
@@ -200,7 +203,7 @@ struct btrfs_dev_item {
200 203
201 /* 204 /*
202 * starting byte of this partition on the device, 205 * starting byte of this partition on the device,
203 * to allowr for stripe alignment in the future 206 * to allow for stripe alignment in the future
204 */ 207 */
205 __le64 start_offset; 208 __le64 start_offset;
206 209
@@ -633,18 +636,35 @@ struct btrfs_space_info {
633 struct rw_semaphore groups_sem; 636 struct rw_semaphore groups_sem;
634}; 637};
635 638
636struct btrfs_free_space { 639/*
637 struct rb_node bytes_index; 640 * free clusters are used to claim free space in relatively large chunks,
638 struct rb_node offset_index; 641 * allowing us to do less seeky writes. They are used for all metadata
639 u64 offset; 642 * allocations and data allocations in ssd mode.
640 u64 bytes; 643 */
644struct btrfs_free_cluster {
645 spinlock_t lock;
646 spinlock_t refill_lock;
647 struct rb_root root;
648
649 /* largest extent in this cluster */
650 u64 max_size;
651
652 /* first extent starting offset */
653 u64 window_start;
654
655 struct btrfs_block_group_cache *block_group;
656 /*
657 * when a cluster is allocated from a block group, we put the
658 * cluster onto a list in the block group so that it can
659 * be freed before the block group is freed.
660 */
661 struct list_head block_group_list;
641}; 662};
642 663
643struct btrfs_block_group_cache { 664struct btrfs_block_group_cache {
644 struct btrfs_key key; 665 struct btrfs_key key;
645 struct btrfs_block_group_item item; 666 struct btrfs_block_group_item item;
646 spinlock_t lock; 667 spinlock_t lock;
647 struct mutex alloc_mutex;
648 struct mutex cache_mutex; 668 struct mutex cache_mutex;
649 u64 pinned; 669 u64 pinned;
650 u64 reserved; 670 u64 reserved;
@@ -656,6 +676,7 @@ struct btrfs_block_group_cache {
656 struct btrfs_space_info *space_info; 676 struct btrfs_space_info *space_info;
657 677
658 /* free space cache stuff */ 678 /* free space cache stuff */
679 spinlock_t tree_lock;
659 struct rb_root free_space_bytes; 680 struct rb_root free_space_bytes;
660 struct rb_root free_space_offset; 681 struct rb_root free_space_offset;
661 682
@@ -667,6 +688,11 @@ struct btrfs_block_group_cache {
667 688
668 /* usage count */ 689 /* usage count */
669 atomic_t count; 690 atomic_t count;
691
692 /* List of struct btrfs_free_clusters for this block group.
693 * Today it will only have one thing on it, but that may change
694 */
695 struct list_head cluster_list;
670}; 696};
671 697
672struct btrfs_leaf_ref_tree { 698struct btrfs_leaf_ref_tree {
@@ -728,7 +754,6 @@ struct btrfs_fs_info {
728 struct mutex tree_log_mutex; 754 struct mutex tree_log_mutex;
729 struct mutex transaction_kthread_mutex; 755 struct mutex transaction_kthread_mutex;
730 struct mutex cleaner_mutex; 756 struct mutex cleaner_mutex;
731 struct mutex pinned_mutex;
732 struct mutex chunk_mutex; 757 struct mutex chunk_mutex;
733 struct mutex drop_mutex; 758 struct mutex drop_mutex;
734 struct mutex volume_mutex; 759 struct mutex volume_mutex;
@@ -839,8 +864,12 @@ struct btrfs_fs_info {
839 spinlock_t delalloc_lock; 864 spinlock_t delalloc_lock;
840 spinlock_t new_trans_lock; 865 spinlock_t new_trans_lock;
841 u64 delalloc_bytes; 866 u64 delalloc_bytes;
842 u64 last_alloc; 867
843 u64 last_data_alloc; 868 /* data_alloc_cluster is only used in ssd mode */
869 struct btrfs_free_cluster data_alloc_cluster;
870
871 /* all metadata allocations go through this cluster */
872 struct btrfs_free_cluster meta_alloc_cluster;
844 873
845 spinlock_t ref_cache_lock; 874 spinlock_t ref_cache_lock;
846 u64 total_ref_cache_size; 875 u64 total_ref_cache_size;
@@ -932,7 +961,6 @@ struct btrfs_root {
932}; 961};
933 962
934/* 963/*
935
936 * inode items have the data typically returned from stat and store other 964 * inode items have the data typically returned from stat and store other
937 * info about object characteristics. There is one for every file and dir in 965 * info about object characteristics. There is one for every file and dir in
938 * the FS 966 * the FS
@@ -963,7 +991,7 @@ struct btrfs_root {
963#define BTRFS_EXTENT_CSUM_KEY 128 991#define BTRFS_EXTENT_CSUM_KEY 128
964 992
965/* 993/*
966 * root items point to tree roots. There are typically in the root 994 * root items point to tree roots. They are typically in the root
967 * tree used by the super block to find all the other trees 995 * tree used by the super block to find all the other trees
968 */ 996 */
969#define BTRFS_ROOT_ITEM_KEY 132 997#define BTRFS_ROOT_ITEM_KEY 132
@@ -1010,6 +1038,8 @@ struct btrfs_root {
1010#define BTRFS_MOUNT_SSD (1 << 3) 1038#define BTRFS_MOUNT_SSD (1 << 3)
1011#define BTRFS_MOUNT_DEGRADED (1 << 4) 1039#define BTRFS_MOUNT_DEGRADED (1 << 4)
1012#define BTRFS_MOUNT_COMPRESS (1 << 5) 1040#define BTRFS_MOUNT_COMPRESS (1 << 5)
1041#define BTRFS_MOUNT_NOTREELOG (1 << 6)
1042#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
1013 1043
1014#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 1044#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1015#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) 1045#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
@@ -1748,6 +1778,7 @@ static inline struct dentry *fdentry(struct file *file)
1748} 1778}
1749 1779
1750/* extent-tree.c */ 1780/* extent-tree.c */
1781void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
1751int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, 1782int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
1752 struct btrfs_root *root, unsigned long count); 1783 struct btrfs_root *root, unsigned long count);
1753int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 1784int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
@@ -2174,21 +2205,4 @@ int btrfs_check_acl(struct inode *inode, int mask);
2174int btrfs_init_acl(struct inode *inode, struct inode *dir); 2205int btrfs_init_acl(struct inode *inode, struct inode *dir);
2175int btrfs_acl_chmod(struct inode *inode); 2206int btrfs_acl_chmod(struct inode *inode);
2176 2207
2177/* free-space-cache.c */
2178int btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
2179 u64 bytenr, u64 size);
2180int btrfs_add_free_space_lock(struct btrfs_block_group_cache *block_group,
2181 u64 offset, u64 bytes);
2182int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
2183 u64 bytenr, u64 size);
2184int btrfs_remove_free_space_lock(struct btrfs_block_group_cache *block_group,
2185 u64 offset, u64 bytes);
2186void btrfs_remove_free_space_cache(struct btrfs_block_group_cache
2187 *block_group);
2188struct btrfs_free_space *btrfs_find_free_space(struct btrfs_block_group_cache
2189 *block_group, u64 offset,
2190 u64 bytes);
2191void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
2192 u64 bytes);
2193u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group);
2194#endif 2208#endif