ref: c622490a0e32bce12560e9e8b6034733ddab5aa3
parent: 2b928635d2a1258edcee77b315a2e66f41c6fd45
author: ngkaho1234 <[email protected]>
date: Fri Nov 20 11:01:06 EST 2015
ext4_journal: try to read jbd superblock when loading jbd.
--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -33,7 +33,7 @@
EXT4_SUPERBLOCK_SIZE);
}
-int jbd_sb_read(struct jbd_fs *jbd_fs, struct ext4_sblock *s)
+int jbd_sb_read(struct jbd_fs *jbd_fs, struct jbd_sb *s)
{
int rc;
struct ext4_fs *fs = jbd_fs->inode_ref.fs;
@@ -60,6 +60,15 @@
rc = ext4_fs_get_inode_ref(fs,
journal_ino,
&jbd_fs->inode_ref);
+ if (rc != EOK) {
+ memset(jbd_fs, 0, sizeof(struct jbd_fs));
+ return rc;
+ }
+ rc = jbd_sb_read(jbd_fs, &jbd_fs->sb);
+ if (rc != EOK) {
+ memset(jbd_fs, 0, sizeof(struct jbd_fs));
+ ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
+ }
return rc;
}
@@ -121,4 +130,12 @@
{
return ext4_block_set(jbd_fs->inode_ref.fs->bdev,
block);
+}
+
+int jbd_recovery(struct jbd_fs *jbd_fs)
+{
+ struct jbd_sb *sb = &jbd_fs->sb;
+ if (!sb->start)
+ return EOK;
+
}