[Ocfs2-tools-devel] [PATCH 04/10] libocfs2: Add more functions for ocfs2_path creation.
Tao Ma
tao.ma at oracle.com
Wed Sep 30 07:27:41 PDT 2009
Add ocfs2_new_path_from_path and ocfs2_new_path_from_et.
Remove fs from ocfs2_new_path and ocfs2_new_inode_path
since we never use fs when creating a ocfs2_path.
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
libocfs2/extent_tree.c | 48 +++++++++++++++++++++++++-----------------------
1 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/libocfs2/extent_tree.c b/libocfs2/extent_tree.c
index 07c0e46..34a31fd 100644
--- a/libocfs2/extent_tree.c
+++ b/libocfs2/extent_tree.c
@@ -256,19 +256,19 @@ static inline void ocfs2_path_insert_eb(struct ocfs2_path *path, int index,
path->p_node[index].el = &eb->h_list;
}
-static struct ocfs2_path *ocfs2_new_path(ocfs2_filesys* fs, char *buf,
- struct ocfs2_extent_list *root_el)
+static struct ocfs2_path *ocfs2_new_path(char *buf,
+ struct ocfs2_extent_list *root_el,
+ uint64_t blkno)
{
errcode_t ret = 0;
struct ocfs2_path *path = NULL;
- struct ocfs2_dinode *di = (struct ocfs2_dinode *)buf;
assert(root_el->l_tree_depth < OCFS2_MAX_PATH_DEPTH);
ret = ocfs2_malloc0(sizeof(*path), &path);
if (path) {
path->p_tree_depth = root_el->l_tree_depth;
- path->p_node[0].blkno = di->i_blkno;
+ path->p_node[0].blkno = blkno;
path->p_node[0].buf = buf;
path->p_node[0].el = root_el;
}
@@ -279,14 +279,22 @@ static struct ocfs2_path *ocfs2_new_path(ocfs2_filesys* fs, char *buf,
/*
* Allocate and initialize a new path based on a disk inode tree.
*/
-static struct ocfs2_path *ocfs2_new_inode_path(ocfs2_filesys *fs,
- struct ocfs2_dinode *di)
+static struct ocfs2_path *ocfs2_new_inode_path(struct ocfs2_dinode *di)
{
- struct ocfs2_extent_list *el = &di->id2.i_list;
+ return ocfs2_new_path((char *)di, &di->id2.i_list, di->i_blkno);
+}
- return ocfs2_new_path(fs, (char *)di, el);
+static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path)
+{
+ return ocfs2_new_path(path_root_buf(path), path_root_el(path),
+ path_root_blkno(path));
}
+static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et)
+{
+ return ocfs2_new_path(et->et_root_buf, et->et_root_el,
+ et->et_root_blkno);
+}
/* Write all the extent block information to the disk.
* We write all paths furthur down than subtree_index.
* The caller will handle writing the sub_index.
@@ -1061,7 +1069,7 @@ int ocfs2_find_leaf(ocfs2_filesys *fs, struct ocfs2_dinode *di,
assert(el->l_tree_depth > 0);
- path = ocfs2_new_inode_path(fs, di);
+ path = ocfs2_new_inode_path(di);
if (!path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -1493,8 +1501,7 @@ static int ocfs2_rotate_tree_right(ocfs2_filesys *fs,
*ret_left_path = NULL;
- left_path = ocfs2_new_path(fs, path_root_buf(right_path),
- path_root_el(right_path));
+ left_path = ocfs2_new_path_from_path(right_path);
if (!left_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -1930,8 +1937,7 @@ static int __ocfs2_rotate_tree_left(ocfs2_filesys *fs,
if (ret)
goto out;
- left_path = ocfs2_new_path(fs, path_root_buf(path),
- path_root_el(path));
+ left_path = ocfs2_new_path_from_path(path);
if (!left_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -1939,8 +1945,7 @@ static int __ocfs2_rotate_tree_left(ocfs2_filesys *fs,
ocfs2_cp_path(fs, left_path, path);
- right_path = ocfs2_new_path(fs, path_root_buf(path),
- path_root_el(path));
+ right_path = ocfs2_new_path_from_path(path);
if (!right_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -2030,8 +2035,7 @@ static int ocfs2_remove_rightmost_path(ocfs2_filesys *fs,
* We have a path to the left of this one - it needs
* an update too.
*/
- left_path = ocfs2_new_path(fs, path_root_buf(path),
- path_root_el(path));
+ left_path = ocfs2_new_path_from_path(path);
if (!left_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -2686,7 +2690,7 @@ static int ocfs2_figure_insert_type(struct insert_ctxt *ctxt,
return 0;
}
- path = ocfs2_new_inode_path(fs, di);
+ path = ocfs2_new_inode_path(di);
if (!path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -2893,9 +2897,7 @@ static int ocfs2_append_rec_to_path(ocfs2_filesys *fs,
* leftmost leaf.
*/
if (left_cpos) {
- left_path = ocfs2_new_path(fs,
- path_root_buf(right_path),
- path_root_el(right_path));
+ left_path = ocfs2_new_path_from_path(right_path);
if (!left_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -3062,7 +3064,7 @@ static int ocfs2_do_insert_extent(struct insert_ctxt* ctxt,
goto out_update_clusters;
}
- right_path = ocfs2_new_inode_path(fs, di);
+ right_path = ocfs2_new_inode_path(di);
if (!right_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
@@ -3769,7 +3771,7 @@ int ocfs2_mark_extent_written(ocfs2_filesys *fs, struct ocfs2_dinode *di,
}
}
- left_path = ocfs2_new_inode_path(fs, di);
+ left_path = ocfs2_new_inode_path(di);
if (!left_path) {
ret = OCFS2_ET_NO_MEMORY;
goto out;
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list