2023-04-13 09:59:23

by Guoqing Cai

[permalink] [raw]
Subject: [PATCH v2] fs: jbd2: fix an incorrect warn log

In jbd2_journal_load(), when journal_reset fails, it prints an incorrect
warn log.

Fix this by changing the goto statement to return statement.

Also, return actual error code from jbd2_journal_recover() and journal_reset().

Signed-off-by: Guoqing Cai <[email protected]>
---
changelog:
- Add a warning log when journal_reset failed.
- Return the actual error code.
---
fs/jbd2/journal.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index e80c781731f8..147733dd5cc3 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2082,8 +2082,11 @@ int jbd2_journal_load(journal_t *journal)

/* Let the recovery code check whether it needs to recover any
* data from the journal. */
- if (jbd2_journal_recover(journal))
- goto recovery_error;
+ err = jbd2_journal_recover(journal);
+ if (err) {
+ pr_warn("JBD2: journal recovery failed\n");
+ return err;
+ }

if (journal->j_failed_commit) {
printk(KERN_ERR "JBD2: journal transaction %u on %s "
@@ -2100,15 +2103,14 @@ int jbd2_journal_load(journal_t *journal)
/* OK, we've finished with the dynamic journal bits:
* reinitialise the dynamic contents of the superblock in memory
* and reset them on disk. */
- if (journal_reset(journal))
- goto recovery_error;
+ err = journal_reset(journal);
+ if (err) {
+ pr_warn("JBD2: journal reset failed\n");
+ return err;
+ }

journal->j_flags |= JBD2_LOADED;
return 0;
-
-recovery_error:
- printk(KERN_WARNING "JBD2: recovery failed\n");
- return -EIO;
}

/**
--
2.40.0


2023-04-13 10:15:49

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH v2] fs: jbd2: fix an incorrect warn log

On Thu 13-04-23 17:57:39, Guoqing Cai wrote:
> In jbd2_journal_load(), when journal_reset fails, it prints an incorrect
> warn log.
>
> Fix this by changing the goto statement to return statement.
>
> Also, return actual error code from jbd2_journal_recover() and journal_reset().
>
> Signed-off-by: Guoqing Cai <[email protected]>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> changelog:
> - Add a warning log when journal_reset failed.
> - Return the actual error code.
> ---
> fs/jbd2/journal.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index e80c781731f8..147733dd5cc3 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -2082,8 +2082,11 @@ int jbd2_journal_load(journal_t *journal)
>
> /* Let the recovery code check whether it needs to recover any
> * data from the journal. */
> - if (jbd2_journal_recover(journal))
> - goto recovery_error;
> + err = jbd2_journal_recover(journal);
> + if (err) {
> + pr_warn("JBD2: journal recovery failed\n");
> + return err;
> + }
>
> if (journal->j_failed_commit) {
> printk(KERN_ERR "JBD2: journal transaction %u on %s "
> @@ -2100,15 +2103,14 @@ int jbd2_journal_load(journal_t *journal)
> /* OK, we've finished with the dynamic journal bits:
> * reinitialise the dynamic contents of the superblock in memory
> * and reset them on disk. */
> - if (journal_reset(journal))
> - goto recovery_error;
> + err = journal_reset(journal);
> + if (err) {
> + pr_warn("JBD2: journal reset failed\n");
> + return err;
> + }
>
> journal->j_flags |= JBD2_LOADED;
> return 0;
> -
> -recovery_error:
> - printk(KERN_WARNING "JBD2: recovery failed\n");
> - return -EIO;
> }
>
> /**
> --
> 2.40.0
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2023-08-03 15:11:09

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2] fs: jbd2: fix an incorrect warn log


On Thu, 13 Apr 2023 17:57:39 +0800, Guoqing Cai wrote:
> In jbd2_journal_load(), when journal_reset fails, it prints an incorrect
> warn log.
>
> Fix this by changing the goto statement to return statement.
>
> Also, return actual error code from jbd2_journal_recover() and journal_reset().
>
> [...]

Applied, thanks!

[1/1] fs: jbd2: fix an incorrect warn log
commit: 1d40165047456923fa4343d519353d9440cd68df

Best regards,
--
Theodore Ts'o <[email protected]>