diff options
Diffstat (limited to 'fs/ocfs2/alloc.h')
-rw-r--r-- | fs/ocfs2/alloc.h | 101 |
1 files changed, 82 insertions, 19 deletions
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 353254ba29e1..9c122d574464 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -45,7 +45,8 @@ | |||
45 | * | 45 | * |
46 | * ocfs2_extent_tree contains info for the root of the b-tree, it must have a | 46 | * ocfs2_extent_tree contains info for the root of the b-tree, it must have a |
47 | * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree | 47 | * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree |
48 | * functions. With metadata ecc, we now call different journal_access | 48 | * functions. It needs the ocfs2_caching_info structure associated with |
49 | * I/O on the tree. With metadata ecc, we now call different journal_access | ||
49 | * functions for each type of metadata, so it must have the | 50 | * functions for each type of metadata, so it must have the |
50 | * root_journal_access function. | 51 | * root_journal_access function. |
51 | * ocfs2_extent_tree_operations abstract the normal operations we do for | 52 | * ocfs2_extent_tree_operations abstract the normal operations we do for |
@@ -56,6 +57,7 @@ struct ocfs2_extent_tree { | |||
56 | struct ocfs2_extent_tree_operations *et_ops; | 57 | struct ocfs2_extent_tree_operations *et_ops; |
57 | struct buffer_head *et_root_bh; | 58 | struct buffer_head *et_root_bh; |
58 | struct ocfs2_extent_list *et_root_el; | 59 | struct ocfs2_extent_list *et_root_el; |
60 | struct ocfs2_caching_info *et_ci; | ||
59 | ocfs2_journal_access_func et_root_journal_access; | 61 | ocfs2_journal_access_func et_root_journal_access; |
60 | void *et_object; | 62 | void *et_object; |
61 | unsigned int et_max_leaf_clusters; | 63 | unsigned int et_max_leaf_clusters; |
@@ -66,31 +68,32 @@ struct ocfs2_extent_tree { | |||
66 | * specified object buffer. | 68 | * specified object buffer. |
67 | */ | 69 | */ |
68 | void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | 70 | void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, |
69 | struct inode *inode, | 71 | struct ocfs2_caching_info *ci, |
70 | struct buffer_head *bh); | 72 | struct buffer_head *bh); |
71 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | 73 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, |
72 | struct inode *inode, | 74 | struct ocfs2_caching_info *ci, |
73 | struct buffer_head *bh); | 75 | struct buffer_head *bh); |
74 | struct ocfs2_xattr_value_buf; | 76 | struct ocfs2_xattr_value_buf; |
75 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | 77 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, |
76 | struct inode *inode, | 78 | struct ocfs2_caching_info *ci, |
77 | struct ocfs2_xattr_value_buf *vb); | 79 | struct ocfs2_xattr_value_buf *vb); |
78 | void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et, | 80 | void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et, |
79 | struct inode *inode, | 81 | struct ocfs2_caching_info *ci, |
80 | struct buffer_head *bh); | 82 | struct buffer_head *bh); |
83 | void ocfs2_init_refcount_extent_tree(struct ocfs2_extent_tree *et, | ||
84 | struct ocfs2_caching_info *ci, | ||
85 | struct buffer_head *bh); | ||
81 | 86 | ||
82 | /* | 87 | /* |
83 | * Read an extent block into *bh. If *bh is NULL, a bh will be | 88 | * Read an extent block into *bh. If *bh is NULL, a bh will be |
84 | * allocated. This is a cached read. The extent block will be validated | 89 | * allocated. This is a cached read. The extent block will be validated |
85 | * with ocfs2_validate_extent_block(). | 90 | * with ocfs2_validate_extent_block(). |
86 | */ | 91 | */ |
87 | int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno, | 92 | int ocfs2_read_extent_block(struct ocfs2_caching_info *ci, u64 eb_blkno, |
88 | struct buffer_head **bh); | 93 | struct buffer_head **bh); |
89 | 94 | ||
90 | struct ocfs2_alloc_context; | 95 | struct ocfs2_alloc_context; |
91 | int ocfs2_insert_extent(struct ocfs2_super *osb, | 96 | int ocfs2_insert_extent(handle_t *handle, |
92 | handle_t *handle, | ||
93 | struct inode *inode, | ||
94 | struct ocfs2_extent_tree *et, | 97 | struct ocfs2_extent_tree *et, |
95 | u32 cpos, | 98 | u32 cpos, |
96 | u64 start_blk, | 99 | u64 start_blk, |
@@ -103,25 +106,36 @@ enum ocfs2_alloc_restarted { | |||
103 | RESTART_TRANS, | 106 | RESTART_TRANS, |
104 | RESTART_META | 107 | RESTART_META |
105 | }; | 108 | }; |
106 | int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | 109 | int ocfs2_add_clusters_in_btree(handle_t *handle, |
107 | struct inode *inode, | 110 | struct ocfs2_extent_tree *et, |
108 | u32 *logical_offset, | 111 | u32 *logical_offset, |
109 | u32 clusters_to_add, | 112 | u32 clusters_to_add, |
110 | int mark_unwritten, | 113 | int mark_unwritten, |
111 | struct ocfs2_extent_tree *et, | ||
112 | handle_t *handle, | ||
113 | struct ocfs2_alloc_context *data_ac, | 114 | struct ocfs2_alloc_context *data_ac, |
114 | struct ocfs2_alloc_context *meta_ac, | 115 | struct ocfs2_alloc_context *meta_ac, |
115 | enum ocfs2_alloc_restarted *reason_ret); | 116 | enum ocfs2_alloc_restarted *reason_ret); |
116 | struct ocfs2_cached_dealloc_ctxt; | 117 | struct ocfs2_cached_dealloc_ctxt; |
118 | struct ocfs2_path; | ||
119 | int ocfs2_split_extent(handle_t *handle, | ||
120 | struct ocfs2_extent_tree *et, | ||
121 | struct ocfs2_path *path, | ||
122 | int split_index, | ||
123 | struct ocfs2_extent_rec *split_rec, | ||
124 | struct ocfs2_alloc_context *meta_ac, | ||
125 | struct ocfs2_cached_dealloc_ctxt *dealloc); | ||
117 | int ocfs2_mark_extent_written(struct inode *inode, | 126 | int ocfs2_mark_extent_written(struct inode *inode, |
118 | struct ocfs2_extent_tree *et, | 127 | struct ocfs2_extent_tree *et, |
119 | handle_t *handle, u32 cpos, u32 len, u32 phys, | 128 | handle_t *handle, u32 cpos, u32 len, u32 phys, |
120 | struct ocfs2_alloc_context *meta_ac, | 129 | struct ocfs2_alloc_context *meta_ac, |
121 | struct ocfs2_cached_dealloc_ctxt *dealloc); | 130 | struct ocfs2_cached_dealloc_ctxt *dealloc); |
122 | int ocfs2_remove_extent(struct inode *inode, | 131 | int ocfs2_change_extent_flag(handle_t *handle, |
123 | struct ocfs2_extent_tree *et, | 132 | struct ocfs2_extent_tree *et, |
124 | u32 cpos, u32 len, handle_t *handle, | 133 | u32 cpos, u32 len, u32 phys, |
134 | struct ocfs2_alloc_context *meta_ac, | ||
135 | struct ocfs2_cached_dealloc_ctxt *dealloc, | ||
136 | int new_flags, int clear_flags); | ||
137 | int ocfs2_remove_extent(handle_t *handle, struct ocfs2_extent_tree *et, | ||
138 | u32 cpos, u32 len, | ||
125 | struct ocfs2_alloc_context *meta_ac, | 139 | struct ocfs2_alloc_context *meta_ac, |
126 | struct ocfs2_cached_dealloc_ctxt *dealloc); | 140 | struct ocfs2_cached_dealloc_ctxt *dealloc); |
127 | int ocfs2_remove_btree_range(struct inode *inode, | 141 | int ocfs2_remove_btree_range(struct inode *inode, |
@@ -130,7 +144,6 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
130 | struct ocfs2_cached_dealloc_ctxt *dealloc); | 144 | struct ocfs2_cached_dealloc_ctxt *dealloc); |
131 | 145 | ||
132 | int ocfs2_num_free_extents(struct ocfs2_super *osb, | 146 | int ocfs2_num_free_extents(struct ocfs2_super *osb, |
133 | struct inode *inode, | ||
134 | struct ocfs2_extent_tree *et); | 147 | struct ocfs2_extent_tree *et); |
135 | 148 | ||
136 | /* | 149 | /* |
@@ -195,6 +208,9 @@ static inline void ocfs2_init_dealloc_ctxt(struct ocfs2_cached_dealloc_ctxt *c) | |||
195 | } | 208 | } |
196 | int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, | 209 | int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, |
197 | u64 blkno, unsigned int bit); | 210 | u64 blkno, unsigned int bit); |
211 | int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, | ||
212 | int type, int slot, u64 blkno, | ||
213 | unsigned int bit); | ||
198 | static inline int ocfs2_dealloc_has_cluster(struct ocfs2_cached_dealloc_ctxt *c) | 214 | static inline int ocfs2_dealloc_has_cluster(struct ocfs2_cached_dealloc_ctxt *c) |
199 | { | 215 | { |
200 | return c->c_global_allocator != NULL; | 216 | return c->c_global_allocator != NULL; |
@@ -222,8 +238,9 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
222 | int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, | 238 | int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, |
223 | unsigned int start, unsigned int end, int trunc); | 239 | unsigned int start, unsigned int end, int trunc); |
224 | 240 | ||
225 | int ocfs2_find_leaf(struct inode *inode, struct ocfs2_extent_list *root_el, | 241 | int ocfs2_find_leaf(struct ocfs2_caching_info *ci, |
226 | u32 cpos, struct buffer_head **leaf_bh); | 242 | struct ocfs2_extent_list *root_el, u32 cpos, |
243 | struct buffer_head **leaf_bh); | ||
227 | int ocfs2_search_extent_list(struct ocfs2_extent_list *el, u32 v_cluster); | 244 | int ocfs2_search_extent_list(struct ocfs2_extent_list *el, u32 v_cluster); |
228 | 245 | ||
229 | /* | 246 | /* |
@@ -254,4 +271,50 @@ static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec) | |||
254 | return !rec->e_leaf_clusters; | 271 | return !rec->e_leaf_clusters; |
255 | } | 272 | } |
256 | 273 | ||
274 | int ocfs2_grab_pages(struct inode *inode, loff_t start, loff_t end, | ||
275 | struct page **pages, int *num); | ||
276 | void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | ||
277 | unsigned int from, unsigned int to, | ||
278 | struct page *page, int zero, u64 *phys); | ||
279 | /* | ||
280 | * Structures which describe a path through a btree, and functions to | ||
281 | * manipulate them. | ||
282 | * | ||
283 | * The idea here is to be as generic as possible with the tree | ||
284 | * manipulation code. | ||
285 | */ | ||
286 | struct ocfs2_path_item { | ||
287 | struct buffer_head *bh; | ||
288 | struct ocfs2_extent_list *el; | ||
289 | }; | ||
290 | |||
291 | #define OCFS2_MAX_PATH_DEPTH 5 | ||
292 | |||
293 | struct ocfs2_path { | ||
294 | int p_tree_depth; | ||
295 | ocfs2_journal_access_func p_root_access; | ||
296 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | ||
297 | }; | ||
298 | |||
299 | #define path_root_bh(_path) ((_path)->p_node[0].bh) | ||
300 | #define path_root_el(_path) ((_path)->p_node[0].el) | ||
301 | #define path_root_access(_path)((_path)->p_root_access) | ||
302 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) | ||
303 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) | ||
304 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) | ||
305 | |||
306 | void ocfs2_reinit_path(struct ocfs2_path *path, int keep_root); | ||
307 | void ocfs2_free_path(struct ocfs2_path *path); | ||
308 | int ocfs2_find_path(struct ocfs2_caching_info *ci, | ||
309 | struct ocfs2_path *path, | ||
310 | u32 cpos); | ||
311 | struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path); | ||
312 | struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et); | ||
313 | int ocfs2_path_bh_journal_access(handle_t *handle, | ||
314 | struct ocfs2_caching_info *ci, | ||
315 | struct ocfs2_path *path, | ||
316 | int idx); | ||
317 | int ocfs2_journal_access_path(struct ocfs2_caching_info *ci, | ||
318 | handle_t *handle, | ||
319 | struct ocfs2_path *path); | ||
257 | #endif /* OCFS2_ALLOC_H */ | 320 | #endif /* OCFS2_ALLOC_H */ |