[Ocfs2-tools-devel] [PATCH] Check dx_tree corruptions
Goldwyn Rodrigues
rgoldwyn at suse.de
Tue May 10 10:51:53 PDT 2011
In case of corruption in the dx_tree where the dx_leaf pointer
is not pointing to the correct block, the filesystem turns read-only.
This goes undetected when a fsck is performed on the filesystem
because the primary directory setup is sane.
This patch traverses the dx_tree with a dummy iterator to verify that
the dx_tree is sane and sets the inode for re-indexing.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
diff --git a/fsck.ocfs2/pass2.c b/fsck.ocfs2/pass2.c
index 4b43a22..a1bfdef 100644
--- a/fsck.ocfs2/pass2.c
+++ b/fsck.ocfs2/pass2.c
@@ -698,6 +698,15 @@ static int corrupt_dirent_lengths(struct ocfs2_dir_entry *dirent, int left)
return 1;
}
+static int dummy_dx_iterator(ocfs2_filesys *fs,
+ struct ocfs2_dx_entry_list *entry_list,
+ struct ocfs2_dx_root_block *dx_root,
+ struct ocfs2_dx_leaf *dx_leaf,
+ void *priv_data)
+{
+ return 0;
+}
+
/* this could certainly be more clever to issue reads in groups */
static unsigned pass2_dir_block_iterate(o2fsck_dirblock_entry *dbe,
void *priv_data)
@@ -732,6 +741,30 @@ static unsigned pass2_dir_block_iterate(o2fsck_dirblock_entry *dbe,
verbosef("dir inode %"PRIu64" i_size %"PRIu64"\n",
dbe->e_ino, (uint64_t)di->i_size);
+ if ((ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(
+ dd->fs->fs_super))) &&
+ di->i_dyn_features & OCFS2_INDEXED_DIR_FL ) {
+ ret = ocfs2_dx_entries_iterate(dd->fs, di,
+ 0, dummy_dx_iterator, NULL);
+ if (ret) {
+ if (prompt(dd->ost, PY, PR_IV_DX_TREE,
+ "Directory inode %"PRIu64" "
+ "has corrupted index tree. "
+ "Rebuild index tree?", dbe->e_ino)) {
+
+ ret = o2fsck_try_add_reidx_dir(
+ &dd->re_idx_dirs, dbe->e_ino);
+ if (ret) {
+ com_err(whoami, ret, "while adding"
+ " block for directory inode %"
+ PRIu64" to rebuild "
+ "dir index", dbe->e_ino);
+ goto out;
+ }
+ }
+ }
+ }
+
}
verbosef("dir block %"PRIu64" block offs %"PRIu64" in ino\n",
--
Goldwyn
More information about the Ocfs2-tools-devel
mailing list