ocfs2-tools/0013-dx_dirs-try-to-install-dir-trailers-when-enable-inde.patch

132 lines
4.8 KiB
Diff
Raw Normal View History

From 947d4450eed4a18299d7b14b828a69533eb4a2ed Mon Sep 17 00:00:00 2001
From: Coly Li <coly.li@suse.de>
Date: Sun, 11 Apr 2010 16:10:10 +0800
Subject: [PATCH 13/30] dx_dirs: try to install dir trailers when enable indexed-dirs
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@suse.de>
Signed-off-by: Mark Fasheh <mfasheh@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 cfa0dd0..c26780e 100644
--- a/tunefs.ocfs2/feature_indexed_dirs.c
+++ b/tunefs.ocfs2/feature_indexed_dirs.c
@@ -65,6 +65,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..18380be 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
--
1.7.0.2