Commit c3071308 authored by Zhang Yi's avatar Zhang Yi Committed by Theodore Ts'o

jbd2: move load_superblock() into journal_init_common()

Move the call to load_superblock() from jbd2_journal_load() and
jbd2_journal_wipe() early into journal_init_common(), the journal
superblock gets read and the in-memory journal_t structure gets
initialised after calling jbd2_journal_init_{dev,inode}, it's safe to
do following initialization according to it.
Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230811063610.2980059-3-yi.zhang@huaweicloud.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 29a511e4
...@@ -1582,6 +1582,10 @@ static journal_t *journal_init_common(struct block_device *bdev, ...@@ -1582,6 +1582,10 @@ static journal_t *journal_init_common(struct block_device *bdev,
journal->j_sb_buffer = bh; journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data; journal->j_superblock = (journal_superblock_t *)bh->b_data;
err = load_superblock(journal);
if (err)
goto err_cleanup;
journal->j_shrink_transaction = NULL; journal->j_shrink_transaction = NULL;
journal->j_shrinker.scan_objects = jbd2_journal_shrink_scan; journal->j_shrinker.scan_objects = jbd2_journal_shrink_scan;
journal->j_shrinker.count_objects = jbd2_journal_shrink_count; journal->j_shrinker.count_objects = jbd2_journal_shrink_count;
...@@ -2056,13 +2060,7 @@ EXPORT_SYMBOL(jbd2_journal_update_sb_errno); ...@@ -2056,13 +2060,7 @@ EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
int jbd2_journal_load(journal_t *journal) int jbd2_journal_load(journal_t *journal)
{ {
int err; int err;
journal_superblock_t *sb; journal_superblock_t *sb = journal->j_superblock;
err = load_superblock(journal);
if (err)
return err;
sb = journal->j_superblock;
/* /*
* If this is a V2 superblock, then we have to check the * If this is a V2 superblock, then we have to check the
...@@ -2523,10 +2521,6 @@ int jbd2_journal_wipe(journal_t *journal, int write) ...@@ -2523,10 +2521,6 @@ int jbd2_journal_wipe(journal_t *journal, int write)
J_ASSERT (!(journal->j_flags & JBD2_LOADED)); J_ASSERT (!(journal->j_flags & JBD2_LOADED));
err = load_superblock(journal);
if (err)
return err;
if (!journal->j_tail) if (!journal->j_tail)
goto no_recovery; goto no_recovery;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment