[Ocfs2-tools-devel] [PATCH] o2image: dx_dirs support

Mark Fasheh mfasheh at suse.com
Wed May 19 19:20:46 PDT 2010


O2image wasn't picking up the entire dx_tree. This adds detection of an
indexed dir to o2image so that it can traverse the tree in dx_root->dr_list
and record the meta data within.

Signed-off-by: Mark Fasheh <mfasheh at suse.com>
---
 o2image/o2image.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/o2image/o2image.c b/o2image/o2image.c
index dae649f..aa73dfb 100644
--- a/o2image/o2image.c
+++ b/o2image/o2image.c
@@ -169,6 +169,32 @@ out:
 	return ret;
 }
 
+static errcode_t traverse_dx_root(ocfs2_filesys *ofs, uint64_t blkno)
+{
+	errcode_t ret;
+	char *buf = NULL;
+	struct ocfs2_dx_root_block *dx_root;
+
+	ocfs2_image_mark_bitmap(ofs, blkno);
+
+	ret = ocfs2_malloc_block(ofs->fs_io, &buf);
+	if (ret)
+		goto out;
+
+	ret = ocfs2_read_dx_root(ofs, blkno, buf);
+	if (ret)
+		goto out;
+
+	dx_root = (struct ocfs2_dx_root_block *) buf;
+	if (!(dx_root->dr_flags & OCFS2_DX_FLAG_INLINE))
+		traverse_extents(ofs, &dx_root->dr_list);
+
+out:
+	if (buf)
+		ocfs2_free(&buf);
+	return ret;
+}
+
 static errcode_t traverse_inode(ocfs2_filesys *ofs, uint64_t inode)
 {
 	struct ocfs2_super_block *super;
@@ -234,9 +260,14 @@ static errcode_t traverse_inode(ocfs2_filesys *ofs, uint64_t inode)
 		ret = traverse_chains(ofs, &(di->id2.i_chain), dump_type);
 	else if (di->i_flags & OCFS2_DEALLOC_FL)
 		ret = mark_dealloc_bits(ofs, &(di->id2.i_dealloc));
-	else
+	else {
+		if (S_ISDIR(di->i_mode) &&
+		    (di->i_dyn_features & OCFS2_INDEXED_DIR_FL)) {
+			ret = traverse_dx_root(ofs, di->i_dx_root);
+		}
 		/* traverse extents for system files */
 		ret = traverse_extents(ofs, &(di->id2.i_list));
+	}
 
 	if (ret) {
 		com_err(program_name, ret, "while scanning inode %"PRIu64"",
-- 
1.6.4.2





More information about the Ocfs2-tools-devel mailing list