diff mbox series

[02/12] jbd2: move load_superblock() into journal_init_common()

Message ID 20230704134233.110812-3-yi.zhang@huaweicloud.com
State Superseded
Headers show
Series ext4,jbd2: cleanup journal load and initialization process | expand

Commit Message

Zhang Yi July 4, 2023, 1:42 p.m. UTC
From: Zhang Yi <yi.zhang@huawei.com>

Moving the call to load_superblock() from jbd2_journal_load() and
jbd2_journal_wipe() eraly into journal_init_common(), the journal
superblock gets read and the in-memory jounal_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 <yi.zhang@huawei.com>
---
 fs/jbd2/journal.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Jan Kara Aug. 3, 2023, 2:13 p.m. UTC | #1
On Tue 04-07-23 21:42:23, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> Moving the call to load_superblock() from jbd2_journal_load() and
  ^^ Move

> jbd2_journal_wipe() eraly into journal_init_common(), the journal
                      ^^^ early

> superblock gets read and the in-memory jounal_t structure gets
					  ^^ journal_t

> initialised after calling jbd2_journal_init_{dev,inode}, it's safe to
> do following initialization according to it.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>

Otherwise the patch looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jbd2/journal.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 48c44c7fccf4..b247d374e7a6 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -1582,6 +1582,10 @@ static journal_t *journal_init_common(struct block_device *bdev,
>  	journal->j_sb_buffer = bh;
>  	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_shrinker.scan_objects = jbd2_journal_shrink_scan;
>  	journal->j_shrinker.count_objects = jbd2_journal_shrink_count;
> @@ -2056,13 +2060,7 @@ EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
>  int jbd2_journal_load(journal_t *journal)
>  {
>  	int err;
> -	journal_superblock_t *sb;
> -
> -	err = load_superblock(journal);
> -	if (err)
> -		return err;
> -
> -	sb = journal->j_superblock;
> +	journal_superblock_t *sb = journal->j_superblock;
>  
>  	/*
>  	 * If this is a V2 superblock, then we have to check the
> @@ -2521,10 +2519,6 @@ int jbd2_journal_wipe(journal_t *journal, int write)
>  
>  	J_ASSERT (!(journal->j_flags & JBD2_LOADED));
>  
> -	err = load_superblock(journal);
> -	if (err)
> -		return err;
> -
>  	if (!journal->j_tail)
>  		goto no_recovery;
>  
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 48c44c7fccf4..b247d374e7a6 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1582,6 +1582,10 @@  static journal_t *journal_init_common(struct block_device *bdev,
 	journal->j_sb_buffer = bh;
 	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_shrinker.scan_objects = jbd2_journal_shrink_scan;
 	journal->j_shrinker.count_objects = jbd2_journal_shrink_count;
@@ -2056,13 +2060,7 @@  EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
 int jbd2_journal_load(journal_t *journal)
 {
 	int err;
-	journal_superblock_t *sb;
-
-	err = load_superblock(journal);
-	if (err)
-		return err;
-
-	sb = journal->j_superblock;
+	journal_superblock_t *sb = journal->j_superblock;
 
 	/*
 	 * If this is a V2 superblock, then we have to check the
@@ -2521,10 +2519,6 @@  int jbd2_journal_wipe(journal_t *journal, int write)
 
 	J_ASSERT (!(journal->j_flags & JBD2_LOADED));
 
-	err = load_superblock(journal);
-	if (err)
-		return err;
-
 	if (!journal->j_tail)
 		goto no_recovery;