[Ocfs2-tools-devel] [PATCH] libocfs2: Sync paths in ocfs2_append_rec_to_path.

Tao Ma tao.ma at oracle.com
Thu Jan 7 23:57:39 PST 2010


In user space, we use different alloced buffers to store
different blocks which is unlike the kernel where we use
buffer heads. So we have to sync the same block in different
path by ourselves. So sync them in ocfs2_append_rec_to_path.

Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
 libocfs2/extent_tree.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/libocfs2/extent_tree.c b/libocfs2/extent_tree.c
index 499ce1b..5d64779 100644
--- a/libocfs2/extent_tree.c
+++ b/libocfs2/extent_tree.c
@@ -2839,7 +2839,7 @@ static int ocfs2_append_rec_to_path(ocfs2_filesys *fs,
 				    struct ocfs2_path *right_path,
 				    struct ocfs2_path **ret_left_path)
 {
-	int ret, next_free;
+	int ret, next_free, i;
 	struct ocfs2_extent_list *el;
 	struct ocfs2_path *left_path = NULL;
 
@@ -2887,6 +2887,22 @@ static int ocfs2_append_rec_to_path(ocfs2_filesys *fs,
 	if (ret)
 		goto out;
 
+	if (left_path) {
+		/*
+		 * Only needed in userspace.
+		 * In case we have changed some blocks in the right_path,
+		 * we have to update them also in the left_path since we
+		 * use different buffers other than buffer_head in kernel.
+		 */
+		i = 0;
+		while (i++ < left_path->p_tree_depth)
+			if (left_path->p_node[i].blkno ==
+			    right_path->p_node[i].blkno)
+				memcpy(left_path->p_node[i].buf,
+				       right_path->p_node[i].buf,
+				       fs->fs_blocksize);
+	}
+
 	*ret_left_path = left_path;
 	ret = 0;
 out:
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list