[Ocfs2-tools-devel] [PATCH 1/5] fsck.ocfs2: Check the validity of slot_map's inode before fsck
piaojun
piaojun at huawei.com
Thu Apr 2 05:25:22 PDT 2015
In main(), slot_map's inode should be checked if invalid before being
fixed, as fsck.ocfs2 can not handle this situation.
Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>
---
fsck.ocfs2/fsck.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 4b7d4b3..7a67c9e 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -675,6 +675,31 @@ bail:
return ret;
}
+static int check_system_file_if_valid(ocfs2_filesys *fs, int type,
+ int slot_num)
+{
+ errcode_t ret;
+ uint64_t blkno;
+ char *buf = NULL;
+
+ ret = ocfs2_lookup_system_inode(fs, type, slot_num,
+ &blkno);
+ if (ret)
+ goto out;
+
+ ret = ocfs2_malloc_block(fs->fs_io, &buf);
+ if (ret)
+ goto out;
+
+ ret = ocfs2_read_inode(fs, blkno, buf);
+
+out:
+ if (buf)
+ ocfs2_free(&buf);
+
+ return ret;
+}
+
int main(int argc, char **argv)
{
char *filename;
@@ -978,6 +1003,13 @@ int main(int argc, char **argv)
goto unlock;
}
+ ret = check_system_file_if_valid(ost->ost_fs, SLOT_MAP_SYSTEM_INODE, 0);
+ if (ret) {
+ com_err(whoami, ret, "while checking slot map.");
+ fsck_mask |= FSCK_ERROR;
+ goto unlock;
+ }
+
ret = o2fsck_slot_recovery(ost);
if (ret) {
printf("fsck encountered errors while recovering slot "
--
1.8.4.3
More information about the Ocfs2-tools-devel
mailing list