aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.h
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-03-29 01:46:06 -0400
committerLi Zefan <lizf@cn.fujitsu.com>2011-04-25 04:46:03 -0400
commit34d52cb6c50b5a43901709998f59fb1c5a43dc4a (patch)
tree151c61795cceefc97e48e8209dc36303274fbe10 /fs/btrfs/free-space-cache.h
parentf38b6e754d8cc4605ac21d9c1094d569d88b163b (diff)
Btrfs: Make free space cache code generic
So we can re-use the code to cache free inode numbers. The change is quite straightforward. Two new structures are introduced. - struct btrfs_free_space_ctl We move those variables that are used for caching free space from struct btrfs_block_group_cache to this new struct. - struct btrfs_free_space_op We do block group specific work (e.g. calculation of extents threshold) through functions registered in this struct. And then we can remove references to struct btrfs_block_group_cache. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.h')
-rw-r--r--fs/btrfs/free-space-cache.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h
index 12b2b5165f8a..a64a23fae1eb 100644
--- a/fs/btrfs/free-space-cache.h
+++ b/fs/btrfs/free-space-cache.h
@@ -27,6 +27,25 @@ struct btrfs_free_space {
27 struct list_head list; 27 struct list_head list;
28}; 28};
29 29
30struct btrfs_free_space_ctl {
31 spinlock_t tree_lock;
32 struct rb_root free_space_offset;
33 u64 free_space;
34 int extents_thresh;
35 int free_extents;
36 int total_bitmaps;
37 int unit;
38 u64 start;
39 struct btrfs_free_space_op *op;
40 void *private;
41};
42
43struct btrfs_free_space_op {
44 void (*recalc_thresholds)(struct btrfs_free_space_ctl *ctl);
45 bool (*use_bitmap)(struct btrfs_free_space_ctl *ctl,
46 struct btrfs_free_space *info);
47};
48
30struct inode *lookup_free_space_inode(struct btrfs_root *root, 49struct inode *lookup_free_space_inode(struct btrfs_root *root,
31 struct btrfs_block_group_cache 50 struct btrfs_block_group_cache
32 *block_group, struct btrfs_path *path); 51 *block_group, struct btrfs_path *path);
@@ -45,6 +64,7 @@ int btrfs_write_out_cache(struct btrfs_root *root,
45 struct btrfs_trans_handle *trans, 64 struct btrfs_trans_handle *trans,
46 struct btrfs_block_group_cache *block_group, 65 struct btrfs_block_group_cache *block_group,
47 struct btrfs_path *path); 66 struct btrfs_path *path);
67void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group);
48int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, 68int btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
49 u64 bytenr, u64 size); 69 u64 bytenr, u64 size);
50int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, 70int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,