From 2a3dd1e1b6bb8cabed7c5fc74c769a24695a7513 Mon Sep 17 00:00:00 2001 From: Coly Li Date: Thu, 11 Mar 2010 08:59:59 +0800 Subject: [PATCH 13/15] 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 Cc: Mark Fasheh --- 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 -- 1.6.4.2