Skip to content

Commit c307130

Browse files
zhangyi089tytso
authored andcommitted
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: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 29a511e commit c307130

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

fs/jbd2/journal.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,10 @@ static journal_t *journal_init_common(struct block_device *bdev,
15821582
journal->j_sb_buffer = bh;
15831583
journal->j_superblock = (journal_superblock_t *)bh->b_data;
15841584

1585+
err = load_superblock(journal);
1586+
if (err)
1587+
goto err_cleanup;
1588+
15851589
journal->j_shrink_transaction = NULL;
15861590
journal->j_shrinker.scan_objects = jbd2_journal_shrink_scan;
15871591
journal->j_shrinker.count_objects = jbd2_journal_shrink_count;
@@ -2056,13 +2060,7 @@ EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
20562060
int jbd2_journal_load(journal_t *journal)
20572061
{
20582062
int err;
2059-
journal_superblock_t *sb;
2060-
2061-
err = load_superblock(journal);
2062-
if (err)
2063-
return err;
2064-
2065-
sb = journal->j_superblock;
2063+
journal_superblock_t *sb = journal->j_superblock;
20662064

20672065
/*
20682066
* 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)
25232521

25242522
J_ASSERT (!(journal->j_flags & JBD2_LOADED));
25252523

2526-
err = load_superblock(journal);
2527-
if (err)
2528-
return err;
2529-
25302524
if (!journal->j_tail)
25312525
goto no_recovery;
25322526

0 commit comments

Comments
 (0)