[Ocfs2-tools-devel] [PATCH 13/15] dx_dirs v10: try to install dir trailers when enable indexed-dirs

Coly Li coly.li at suse.de
Wed Mar 24 12:52:01 PDT 2010


If metaecc feature is not enabled, previuos indexed-dirs patches in
ocfs2-tools does not install dir trailers and move the dir entries which
lie in the trailer area. This patch tries to install dir trailers when
enable indexed-dirs feature.

Signed-off-by: Coly Li <coly.li at suse.de>
Cc: Mark Fasheh <mfasheh at suse.com>
---
 tunefs.ocfs2/feature_indexed_dirs.c |    8 ++++++++
 tunefs.ocfs2/feature_metaecc.c      |   25 +++----------------------
 tunefs.ocfs2/libocfs2ne.h           |   25 +++++++++++++++++++++++++
 tunefs.ocfs2/o2ne_err.et            |    3 +++
 4 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/tunefs.ocfs2/feature_indexed_dirs.c b/tunefs.ocfs2/feature_indexed_dirs.c
index 45fed19..8892051 100644
--- a/tunefs.ocfs2/feature_indexed_dirs.c
+++ b/tunefs.ocfs2/feature_indexed_dirs.c
@@ -61,6 +61,14 @@ static errcode_t build_dx_dir(ocfs2_filesys *fs, struct ocfs2_dinode *di,
 			tcom_err(ret, "while rebulid indexed tree");
 		}
 	}
+
+	ret = tunefs_install_dir_trailer(fs, di, NULL);
+	if (ret) {
+		ret = TUNEFS_ET_INSTALL_DIR_TRAILER_FAILED;
+		tcom_err(ret, "while enable indexed-dirs");
+		goto bail;
+	}
+
 	ret = ocfs2_dx_dir_build(fs, di->i_blkno);
 	if (ret) {
 		ret = TUNEFS_ET_DX_DIRS_BUILD_FAILED;
diff --git a/tunefs.ocfs2/feature_metaecc.c b/tunefs.ocfs2/feature_metaecc.c
index 799b404..e6b48b5 100644
--- a/tunefs.ocfs2/feature_metaecc.c
+++ b/tunefs.ocfs2/feature_metaecc.c
@@ -68,25 +68,6 @@ struct tunefs_trailer_dirblock {
 	struct ocfs2_dir_entry *db_last;
 };

-/* A directory inode we're adding trailers to */
-struct tunefs_trailer_context {
-	struct list_head d_list;
-	uint64_t d_blkno;		/* block number of the dir */
-	struct ocfs2_dinode *d_di;	/* The directory's inode */
-	struct list_head d_dirblocks;	/* List of its dirblocks */
-	uint64_t d_bytes_needed;	/* How many new bytes will
-					   cover the dirents we are moving
-					   to make way for trailers */
-	uint64_t d_blocks_needed;	/* How many blocks covers
-					   d_bytes_needed */
-	char *d_new_blocks;		/* Buffer of new blocks to fill */
-	char *d_cur_block;		/* Which block we're filling in
-					   d_new_blocks */
-	struct ocfs2_dir_entry *d_next_dirent;	/* Next dentry to use */
-	errcode_t d_err;		/* Any processing error during
-					   iteration of the directory */
-};
-
 static void tunefs_trailer_context_free(struct tunefs_trailer_context *tc)
 {
 	struct tunefs_trailer_dirblock *db;
@@ -529,9 +510,9 @@ out:
 }


-static errcode_t tunefs_install_dir_trailer(ocfs2_filesys *fs,
-					    struct ocfs2_dinode *di,
-					    struct tunefs_trailer_context *tc)
+errcode_t tunefs_install_dir_trailer(ocfs2_filesys *fs,
+					struct ocfs2_dinode *di,
+					struct tunefs_trailer_context *tc)
 {
 	errcode_t ret = 0;
 	struct tunefs_trailer_context *our_tc = NULL;
diff --git a/tunefs.ocfs2/libocfs2ne.h b/tunefs.ocfs2/libocfs2ne.h
index a8e1e5e..82e1914 100644
--- a/tunefs.ocfs2/libocfs2ne.h
+++ b/tunefs.ocfs2/libocfs2ne.h
@@ -281,5 +281,30 @@ errcode_t tunefs_feature_run(ocfs2_filesys *master_fs,
 int tunefs_feature_main(int argc, char *argv[], struct tunefs_feature *feat);
 int tunefs_op_main(int argc, char *argv[], struct tunefs_operation *op);

+/* A directory inode we're adding trailers to */
+struct tunefs_trailer_context {
+	struct list_head d_list;
+	uint64_t d_blkno;		/* block number of the dir */
+	struct ocfs2_dinode *d_di;	/* The directory's inode */
+	struct list_head d_dirblocks;	/* List of its dirblocks */
+	uint64_t d_bytes_needed;	/* How many new bytes will
+					   cover the dirents we are moving
+					   to make way for trailers */
+	uint64_t d_blocks_needed;	/* How many blocks covers
+					   d_bytes_needed */
+	char *d_new_blocks;		/* Buffer of new blocks to fill */
+	char *d_cur_block;		/* Which block we're filling in
+					   d_new_blocks */
+	struct ocfs2_dir_entry *d_next_dirent;	/* Next dentry to use */
+	errcode_t d_err;		/* Any processing error during
+					   iteration of the directory */
+};
+
+/*
+ * called from feature_metaecc.c and feature_indexed_dirs.c
+ * to install dir trailers
+ */
+errcode_t tunefs_install_dir_trailer(ocfs2_filesys *fs, struct ocfs2_dinode *di,
+				struct tunefs_trailer_context *tc);

 #endif  /* _LIBTUNEFS_H */
diff --git a/tunefs.ocfs2/o2ne_err.et b/tunefs.ocfs2/o2ne_err.et
index 3561d8c..955c338 100644
--- a/tunefs.ocfs2/o2ne_err.et
+++ b/tunefs.ocfs2/o2ne_err.et
@@ -97,4 +97,7 @@ ec	TUNEFS_ET_DX_DIRS_TRUNCATE_FAILED,
 ec	TUNEFS_ET_DX_DIRS_BUILD_FAILED,
 	"Build directory indexed tree failed"

+ec	TUNEFS_ET_INSTALL_DIR_TRAILER_FAILED,
+	"Install directory trailer failed"
+
 	end
-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list