public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ye Bin <yebin@huaweicloud.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, jack@suse.cz,
	zhangxiaoxu5@huawei.com
Subject: Re: [PATCH v2 6/6] jbd2: remove the 'success' parameter from the jbd2_do_replay() function
Date: Mon, 30 Sep 2024 12:32:39 +0200	[thread overview]
Message-ID: <20240930103239.x46nb4txtlofcmfc@quack3> (raw)
In-Reply-To: <20240930005942.626942-7-yebin@huaweicloud.com>

On Mon 30-09-24 08:59:42, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
> 
> Keep 'success' internally to track if any error happened and then
> return it at the end in do_one_pass(). If jbd2_do_replay() return
> -ENOMEM then stop replay journal.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>

Nice. Feel free to add:

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

								Honza

> ---
>  fs/jbd2/recovery.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
> index 4f1e9ca34503..9192be7c19d8 100644
> --- a/fs/jbd2/recovery.c
> +++ b/fs/jbd2/recovery.c
> @@ -489,12 +489,11 @@ static __always_inline int jbd2_do_replay(journal_t *journal,
>  					  struct recovery_info *info,
>  					  struct buffer_head *bh,
>  					  unsigned long *next_log_block,
> -					  unsigned int next_commit_ID,
> -					  int *success)
> +					  unsigned int next_commit_ID)
>  {
>  	char *tagp;
>  	int flags;
> -	int err;
> +	int ret = 0;
>  	int tag_bytes = journal_tag_bytes(journal);
>  	int descr_csum_size = 0;
>  	unsigned long io_block;
> @@ -508,6 +507,7 @@ static __always_inline int jbd2_do_replay(journal_t *journal,
>  	tagp = &bh->b_data[sizeof(journal_header_t)];
>  	while (tagp - bh->b_data + tag_bytes <=
>  	       journal->j_blocksize - descr_csum_size) {
> +		int err;
>  
>  		memcpy(&tag, tagp, sizeof(tag));
>  		flags = be16_to_cpu(tag.t_flags);
> @@ -517,7 +517,7 @@ static __always_inline int jbd2_do_replay(journal_t *journal,
>  		err = jread(&obh, journal, io_block);
>  		if (err) {
>  			/* Recover what we can, but report failure at the end. */
> -			*success = err;
> +			ret = err;
>  			pr_err("JBD2: IO error %d recovering block %lu in log\n",
>  			      err, io_block);
>  		} else {
> @@ -539,7 +539,7 @@ static __always_inline int jbd2_do_replay(journal_t *journal,
>  					(journal_block_tag3_t *)tagp,
>  					obh->b_data, next_commit_ID)) {
>  				brelse(obh);
> -				*success = -EFSBADCRC;
> +				ret = -EFSBADCRC;
>  				pr_err("JBD2: Invalid checksum recovering data block %llu in journal block %lu\n",
>  				      blocknr, io_block);
>  				goto skip_write;
> @@ -580,7 +580,7 @@ static __always_inline int jbd2_do_replay(journal_t *journal,
>  			break;
>  	}
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int do_one_pass(journal_t *journal,
> @@ -719,9 +719,12 @@ static int do_one_pass(journal_t *journal,
>  			 * done here!
>  			 */
>  			err = jbd2_do_replay(journal, info, bh, &next_log_block,
> -					     next_commit_ID, &success);
> -			if (err)
> -				goto failed;
> +					     next_commit_ID);
> +			if (err) {
> +				if (err == -ENOMEM)
> +					goto failed;
> +				success = err;
> +			}
>  
>  			continue;
>  
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2024-09-30 10:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30  0:59 [PATCH v2 0/6] some cleanup and refactor for jbd2 journal recover Ye Bin
2024-09-30  0:59 ` [PATCH v2 1/6] jbd2: remove redundant judgments for check v1 checksum Ye Bin
2024-09-30  2:36   ` Zhang Yi
2024-09-30  0:59 ` [PATCH v2 2/6] jbd2: unified release of buffer_head in do_one_pass() Ye Bin
2024-09-30  2:36   ` Zhang Yi
2024-09-30  0:59 ` [PATCH v2 3/6] jbd2: refactor JBD2_COMMIT_BLOCK process " Ye Bin
2024-09-30  2:37   ` Zhang Yi
2024-09-30  0:59 ` [PATCH v2 4/6] jbd2: factor out jbd2_do_replay() Ye Bin
2024-09-30  2:40   ` Zhang Yi
2024-09-30 10:30   ` Jan Kara
2024-09-30  0:59 ` [PATCH v2 5/6] jbd2: remove useless 'block_error' variable Ye Bin
2024-09-30  2:41   ` Zhang Yi
2024-09-30  0:59 ` [PATCH v2 6/6] jbd2: remove the 'success' parameter from the jbd2_do_replay() function Ye Bin
2024-09-30  2:43   ` Zhang Yi
2024-09-30 10:32   ` Jan Kara [this message]
2024-11-07 15:13 ` [PATCH v2 0/6] some cleanup and refactor for jbd2 journal recover Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240930103239.x46nb4txtlofcmfc@quack3 \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yebin@huaweicloud.com \
    --cc=zhangxiaoxu5@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox