[Ocfs2-tools-devel] [PATCH] Fix indexed directories
Goldwyn Rodrigues
rgoldwyn at gmail.com
Thu Jun 28 13:45:10 PDT 2012
Detect if iteration of an indexed directory failed. If failed, clear the
index flags, and add it to the reindexing list.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
fsck.ocfs2/fsck.ocfs2.checks.8.in | 5 +++++
fsck.ocfs2/pass1.c | 12 ++++++++----
fsck.ocfs2/pass2.c | 14 +++++++++++---
3 files changed, 24 insertions(+), 7 deletions(-)
Index: ocfs2-tools/fsck.ocfs2/pass2.c
===================================================================
--- ocfs2-tools.orig/fsck.ocfs2/pass2.c 2011-02-17 19:38:51.000000000 +0100
+++ ocfs2-tools/fsck.ocfs2/pass2.c 2012-05-30 23:06:38.000000000 +0200
@@ -732,6 +732,13 @@ static unsigned pass2_dir_block_iterate(
verbosef("dir inode %"PRIu64" i_size %"PRIu64"\n",
dbe->e_ino, (uint64_t)di->i_size);
+ /* Set the flag for index rebuilding */
+ if (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super))
+ && !(di->i_dyn_features & OCFS2_INLINE_DATA_FL)
+ && !(di->i_dyn_features & OCFS2_INDEXED_DIR_FL)) {
+ ret_flags |= OCFS2_DIRENT_CHANGED;
+ }
+
}
verbosef("dir block %"PRIu64" block offs %"PRIu64" in ino\n",
@@ -896,9 +903,10 @@ next:
goto out;
}
- if (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super)) &&
- !(di->i_dyn_features & OCFS2_INLINE_DATA_FL) &&
- (di->i_dyn_features & OCFS2_INDEXED_DIR_FL)) {
+ if (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super))
+ && !(di->i_dyn_features & OCFS2_INLINE_DATA_FL)
+ && !(di->i_dyn_features & OCFS2_INDEXED_DIR_FL)) {
+ di->i_dyn_features |= OCFS2_INDEXED_DIR_FL;
ret = o2fsck_try_add_reidx_dir(&dd->re_idx_dirs, dbe->e_ino);
if (ret) {
com_err(whoami, ret, "while adding block for "
Index: ocfs2-tools/fsck.ocfs2/fsck.ocfs2.checks.8.in
===================================================================
--- ocfs2-tools.orig/fsck.ocfs2/fsck.ocfs2.checks.8.in 2011-02-17
19:38:51.000000000 +0100
+++ ocfs2-tools/fsck.ocfs2/fsck.ocfs2.checks.8.in 2012-05-30
05:14:51.000000000 +0200
@@ -1137,6 +1137,11 @@ index entry will cause lookups on this n
Answering yes will rebuild the directory index, restoring the missing entry.
+.SS "DX_TREE_CORRUPT"
+The index tree of the directory is corrupt.
+
+Answering yes will rebuild the directory index, in pass 2.
+
.SH "SEE ALSO"
.BR fsck.ocfs2(8)
Index: ocfs2-tools/fsck.ocfs2/pass1.c
===================================================================
--- ocfs2-tools.orig/fsck.ocfs2/pass1.c 2011-02-17 19:38:51.000000000 +0100
+++ ocfs2-tools/fsck.ocfs2/pass1.c 2012-05-30 23:16:32.000000000 +0200
@@ -888,10 +888,14 @@ static errcode_t o2fsck_check_blocks(ocf
}
ret = o2fsck_check_dx_dir(ost, di);
- if (ret) {
- com_err(whoami, ret, "while iterating over the dir indexed "
- "tree for directory inode %"PRIu64, (uint64_t)di->i_blkno);
- goto out;
+ if (ret && prompt(ost, PY, PR_DX_TREE_CORRUPT,
+ "Inode %"PRIu64" has invalid dx tree. "
+ "Reset for later rebuild?", (uint64_t)di->i_blkno)) {
+ ocfs2_dx_dir_truncate(fs, di->i_blkno);
+ di->i_dx_root = 0ULL;
+ di->i_dyn_features &= ~OCFS2_INDEXED_DIR_FL;
+ o2fsck_write_inode(ost, di->i_blkno, di);
+ ret = 0;
}
if (S_ISLNK(di->i_mode))
More information about the Ocfs2-tools-devel
mailing list