diff options
author | Tao Ma <tao.ma@oracle.com> | 2009-08-17 23:22:34 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-22 23:09:32 -0400 |
commit | e2e9f6082b5ff099978774d5c0148e062344c2f9 (patch) | |
tree | 1da7dc993c77ca08cb83aba8f21e0da9fd055044 /fs/ocfs2/alloc.h | |
parent | fe924415957e60471536762172d127e85519ef78 (diff) |
ocfs2: move tree path functions to alloc.h.
Now fs/ocfs2/alloc.c has more than 7000 lines. It contains our
basic b-tree operation. Although we have already make our b-tree
operation generic, the basic structrue ocfs2_path which is used
to iterate one b-tree branch is still static and limited to only
used in alloc.c. As refcount tree need them and I don't want to
add any more b-tree unrelated code to alloc.c, export them out.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.h')
-rw-r--r-- | fs/ocfs2/alloc.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index df0e778a2b68..3f4348923b73 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -115,6 +115,14 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, | |||
115 | struct ocfs2_alloc_context *meta_ac, | 115 | struct ocfs2_alloc_context *meta_ac, |
116 | enum ocfs2_alloc_restarted *reason_ret); | 116 | enum ocfs2_alloc_restarted *reason_ret); |
117 | 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); | ||
118 | int ocfs2_mark_extent_written(struct inode *inode, | 126 | int ocfs2_mark_extent_written(struct inode *inode, |
119 | struct ocfs2_extent_tree *et, | 127 | struct ocfs2_extent_tree *et, |
120 | handle_t *handle, u32 cpos, u32 len, u32 phys, | 128 | handle_t *handle, u32 cpos, u32 len, u32 phys, |
@@ -254,4 +262,45 @@ static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec) | |||
254 | return !rec->e_leaf_clusters; | 262 | return !rec->e_leaf_clusters; |
255 | } | 263 | } |
256 | 264 | ||
265 | /* | ||
266 | * Structures which describe a path through a btree, and functions to | ||
267 | * manipulate them. | ||
268 | * | ||
269 | * The idea here is to be as generic as possible with the tree | ||
270 | * manipulation code. | ||
271 | */ | ||
272 | struct ocfs2_path_item { | ||
273 | struct buffer_head *bh; | ||
274 | struct ocfs2_extent_list *el; | ||
275 | }; | ||
276 | |||
277 | #define OCFS2_MAX_PATH_DEPTH 5 | ||
278 | |||
279 | struct ocfs2_path { | ||
280 | int p_tree_depth; | ||
281 | ocfs2_journal_access_func p_root_access; | ||
282 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | ||
283 | }; | ||
284 | |||
285 | #define path_root_bh(_path) ((_path)->p_node[0].bh) | ||
286 | #define path_root_el(_path) ((_path)->p_node[0].el) | ||
287 | #define path_root_access(_path)((_path)->p_root_access) | ||
288 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) | ||
289 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) | ||
290 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) | ||
291 | |||
292 | void ocfs2_reinit_path(struct ocfs2_path *path, int keep_root); | ||
293 | void ocfs2_free_path(struct ocfs2_path *path); | ||
294 | int ocfs2_find_path(struct ocfs2_caching_info *ci, | ||
295 | struct ocfs2_path *path, | ||
296 | u32 cpos); | ||
297 | struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path); | ||
298 | struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et); | ||
299 | int ocfs2_path_bh_journal_access(handle_t *handle, | ||
300 | struct ocfs2_caching_info *ci, | ||
301 | struct ocfs2_path *path, | ||
302 | int idx); | ||
303 | int ocfs2_journal_access_path(struct ocfs2_caching_info *ci, | ||
304 | handle_t *handle, | ||
305 | struct ocfs2_path *path); | ||
257 | #endif /* OCFS2_ALLOC_H */ | 306 | #endif /* OCFS2_ALLOC_H */ |