aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-07 16:15:09 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-07 16:15:09 -0400
commit6702ed490ca0bb44e17131818a5a18b773957c5a (patch)
treef6bc4b77e58506a68f1ab539ca6c96854f39f92d /fs/btrfs/ctree.h
parent3c69faecb8d83cb2ef085a98b196a3fecea67725 (diff)
Btrfs: Add run time btree defrag, and an ioctl to force btree defrag
This adds two types of btree defrag, a run time form that tries to defrag recently allocated blocks in the btree when they are still in ram, and an ioctl that forces defrag of all btree blocks. File data blocks are not defragged yet, but this can make a huge difference in sequential btree reads. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c5a18d5d7f7c..42aa20301bc9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -178,6 +178,7 @@ struct btrfs_path {
178 struct buffer_head *nodes[BTRFS_MAX_LEVEL]; 178 struct buffer_head *nodes[BTRFS_MAX_LEVEL];
179 int slots[BTRFS_MAX_LEVEL]; 179 int slots[BTRFS_MAX_LEVEL];
180 int reada; 180 int reada;
181 int lowest_level;
181}; 182};
182 183
183/* 184/*
@@ -338,6 +339,9 @@ struct btrfs_root {
338 u64 highest_inode; 339 u64 highest_inode;
339 u64 last_inode_alloc; 340 u64 last_inode_alloc;
340 int ref_cows; 341 int ref_cows;
342 struct btrfs_key defrag_progress;
343 int defrag_running;
344 int defrag_level;
341}; 345};
342 346
343/* the lower bits in the key flags defines the item type */ 347/* the lower bits in the key flags defines the item type */
@@ -1031,10 +1035,11 @@ struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
1031int btrfs_inc_root_ref(struct btrfs_trans_handle *trans, 1035int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
1032 struct btrfs_root *root); 1036 struct btrfs_root *root);
1033struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, 1037struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1034 struct btrfs_root *root, u64 hint); 1038 struct btrfs_root *root, u64 hint,
1039 u64 empty_size);
1035int btrfs_alloc_extent(struct btrfs_trans_handle *trans, 1040int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1036 struct btrfs_root *root, u64 owner, 1041 struct btrfs_root *root, u64 owner,
1037 u64 num_blocks, u64 search_start, 1042 u64 num_blocks, u64 empty_size, u64 search_start,
1038 u64 search_end, struct btrfs_key *ins, int data); 1043 u64 search_end, struct btrfs_key *ins, int data);
1039int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1044int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1040 struct buffer_head *buf); 1045 struct buffer_head *buf);
@@ -1051,6 +1056,10 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1051int btrfs_free_block_groups(struct btrfs_fs_info *info); 1056int btrfs_free_block_groups(struct btrfs_fs_info *info);
1052int btrfs_read_block_groups(struct btrfs_root *root); 1057int btrfs_read_block_groups(struct btrfs_root *root);
1053/* ctree.c */ 1058/* ctree.c */
1059int btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root
1060 *root, struct buffer_head *buf, struct buffer_head
1061 *parent, int parent_slot, struct buffer_head
1062 **cow_ret);
1054int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root 1063int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
1055 *root, struct btrfs_path *path, u32 data_size); 1064 *root, struct btrfs_path *path, u32 data_size);
1056int btrfs_truncate_item(struct btrfs_trans_handle *trans, 1065int btrfs_truncate_item(struct btrfs_trans_handle *trans,
@@ -1060,6 +1069,9 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
1060int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root 1069int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
1061 *root, struct btrfs_key *key, struct btrfs_path *p, int 1070 *root, struct btrfs_key *key, struct btrfs_path *p, int
1062 ins_len, int cow); 1071 ins_len, int cow);
1072int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1073 struct btrfs_root *root, struct buffer_head *parent,
1074 int cache_only);
1063void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p); 1075void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
1064struct btrfs_path *btrfs_alloc_path(void); 1076struct btrfs_path *btrfs_alloc_path(void);
1065void btrfs_free_path(struct btrfs_path *p); 1077void btrfs_free_path(struct btrfs_path *p);
@@ -1171,4 +1183,7 @@ extern struct file_operations btrfs_file_operations;
1171int btrfs_drop_extents(struct btrfs_trans_handle *trans, 1183int btrfs_drop_extents(struct btrfs_trans_handle *trans,
1172 struct btrfs_root *root, struct inode *inode, 1184 struct btrfs_root *root, struct inode *inode,
1173 u64 start, u64 end, u64 *hint_block); 1185 u64 start, u64 end, u64 *hint_block);
1186/* tree-defrag.c */
1187int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
1188 struct btrfs_root *root, int cache_only);
1174#endif 1189#endif