From fd1dc7a9514962a68c5f9b6a9872ccbf3f13f42c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 17 Sep 2014 18:55:11 +0400 Subject: [PATCH] Add loader for internal journal (we need to update mkfs to support this) For internal journal we need enhance mkfs to use ext2fs lib, that will allow us to create journal (with proper header). --- simple.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/simple.c b/simple.c index 8b562b0..e8506a4 100644 --- a/simple.c +++ b/simple.c @@ -737,6 +737,24 @@ static int simplefs_load_journal(struct super_block *sb, int devnum) return 0; } +static int simplefs_sb_load_journal(struct super_block *sb) +{ + struct journal_s *journal; + struct simplefs_super_block *sfs_sb = SIMPLEFS_SB(sb); + struct inode *journal_inode; + + journal_inode = simplefs_iget(sb, SIMPLEFS_JOURNAL_INODE_NUMBER); + journal = jbd2_journal_init_inode(journal_inode); + if (!journal) { + printk(KERN_ERR "Can't load journal\n"); + return 1; + } + journal->j_private = sb; + + sfs_sb->journal = journal; + + return 0; +} #define SIMPLEFS_OPT_JOURNAL_DEV 1 static const match_table_t tokens = { @@ -797,6 +815,8 @@ int simplefs_fill_super(struct super_block *sb, void *data, int silent) "simplefs seem to be formatted using a non-standard block size."); goto release; } + /** XXX: Avoid this hack, by adding one more sb wrapper, but non-disk */ + sb_disk->journal = NULL; printk(KERN_INFO "simplefs filesystem of version [%llu] formatted with a block size of [%llu] detected in the device.\n", @@ -840,6 +860,10 @@ int simplefs_fill_super(struct super_block *sb, void *data, int silent) if ((ret = simplefs_parse_options(sb, data))) goto release; + if (!sb_disk->journal && (ret = simplefs_sb_load_journal(sb))) { + goto release; + } + ret = 0; release: brelse(bh);