[Ocfs2-tools-devel] [PATCH 8/9] dx_dirs: set OCFS2_INDEXED_DIR_FL after indexed tree gets built

Coly Li coly.li at suse.de
Mon Apr 26 10:29:21 PDT 2010


In ocfs2_dx_dir_build(), current code set OCFS2_INDEXED_DIR_FL to
di->i_dyn_features before inserting dir entries into the indexed tree.
If there is any error during the insertion, the corresponded dirent will
be lost from the indexed tree. Though this error can be checked and
fixed in fsck.ocfs2, it should be fixed.

This patch modifies to set OCFS2_INDEXED_DIR_FL after
ocfs2_dir_iterate() returns successfully. If ocfs2_dir_iterate() returns
with error, ocfs2_dx_dir_build() will return error and stop to build the
indexed tree for a specific directory. In this case, no dirent will be
losted.

Thanks to Tao Ma to catch this.

Signed-off-by: Coly Li <coly.li at suse.de>
Cc: Mark Fasheh <mfasheh at suse.com>
Cc: Tao Ma <tao.ma at oracle.com>
---
 libocfs2/dir_indexed.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libocfs2/dir_indexed.c b/libocfs2/dir_indexed.c
index 08c43b7..eb872fd 100644
--- a/libocfs2/dir_indexed.c
+++ b/libocfs2/dir_indexed.c
@@ -1254,7 +1254,6 @@ errcode_t ocfs2_dx_dir_build(ocfs2_filesys *fs,
 	dx_root->dr_entries.de_count = ocfs2_dx_entries_per_root(fs->fs_blocksize);

 	di->i_dx_root = dr_blkno;
-	di->i_dyn_features |= OCFS2_INDEXED_DIR_FL;

 	ret = ocfs2_write_dx_root(fs, dr_blkno, dx_buf);
 	if (ret)
@@ -1274,14 +1273,20 @@ errcode_t ocfs2_dx_dir_build(ocfs2_filesys *fs,
 	if (ret)
 		goto out;

-	/* check quota for dx_leaf */
 	ret = ocfs2_read_dx_root(fs, dr_blkno, dx_buf);
 	if (ret)
 		goto out;
 	ret = ocfs2_read_inode(fs, dir, di_buf);
 	if (ret)
 		goto out;
+	/* set inode to use indexed-dirs */
+	di->i_dyn_features |= OCFS2_INDEXED_DIR_FL;

+	ret = ocfs2_write_inode(fs, dir, di_buf);
+	if(ret)
+		goto out;
+
+	/* check quota for dx_leaf */
 	change = ocfs2_clusters_to_bytes(fs,
 				dx_root->dr_clusters);
 	uid = di->i_uid;
-- 
1.7.0.2




More information about the Ocfs2-tools-devel mailing list