All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Baokun Li <libaokun1@huawei.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
	adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com,
	yangerkun@huawei.com, yukuai3@huawei.com
Subject: Re: [PATCH 1/2] e2fsck: save EXT2_ERROR_FS flag during journal replay
Date: Fri, 17 Feb 2023 12:10:49 +0100	[thread overview]
Message-ID: <20230217111049.itrmawqzjvtjpmf7@quack3> (raw)
In-Reply-To: <20230217100922.588961-2-libaokun1@huawei.com>

On Fri 17-02-23 18:09:21, Baokun Li wrote:
> When repairing a file system with s_errno missing from the journal
> superblock but the file system superblock contains the ERROR_FS flag,
> the ERROR_FS flag on the file system image is overwritten after the
> journal replay, followed by a reload of the file system data from disk
> and the ERROR_FS flag in memory is overwritten. Also s_errno is not set
> and the ERROR_FS flag is not reset. Therefore, when checked later, no
> forced check is performed, which makes it possible to have some errors
> hidden in the disk image, which may make it read-only when using the
> file system. So we save the ERROR_FS flag to the superblock after the
> journal replay, instead of just relying on the jsb->s_errno to do this.
> 
> Signed-off-by: Baokun Li <libaokun1@huawei.com>

Looks good to me. Feel free to add:

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

								Honza

> ---
>  e2fsck/journal.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/e2fsck/journal.c b/e2fsck/journal.c
> index c7868d89..0144aa45 100644
> --- a/e2fsck/journal.c
> +++ b/e2fsck/journal.c
> @@ -1683,6 +1683,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
>  	errcode_t	retval, recover_retval;
>  	io_stats	stats = 0;
>  	unsigned long long kbytes_written = 0;
> +	__u16 s_error_state;
>  
>  	printf(_("%s: recovering journal\n"), ctx->device_name);
>  	if (ctx->options & E2F_OPT_READONLY) {
> @@ -1705,6 +1706,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
>  		ctx->fs->io->manager->get_stats(ctx->fs->io, &stats);
>  	if (stats && stats->bytes_written)
>  		kbytes_written = stats->bytes_written >> 10;
> +	s_error_state = ctx->fs->super->s_state & EXT2_ERROR_FS;
>  
>  	ext2fs_mmp_stop(ctx->fs);
>  	ext2fs_free(ctx->fs);
> @@ -1721,6 +1723,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)
>  	ctx->fs->now = ctx->now;
>  	ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
>  	ctx->fs->super->s_kbytes_written += kbytes_written;
> +	ctx->fs->super->s_state |= s_error_state;
>  
>  	/* Set the superblock flags */
>  	e2fsck_clear_recover(ctx, recover_retval != 0);
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2023-02-17 11:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 10:09 [PATCH 0/2] e2fsprogs: avoid error information loss during journal replay Baokun Li
2023-02-17 10:09 ` [PATCH 1/2] e2fsck: save EXT2_ERROR_FS flag " Baokun Li
2023-02-17 11:10   ` Jan Kara [this message]
2023-06-06  9:10   ` zhanchengbin
2023-02-17 10:09 ` [PATCH 2/2] tune2fs/fuse2fs/debugfs: save error information " Baokun Li
2023-02-17 11:11   ` Jan Kara
2023-06-06  9:11   ` zhanchengbin
2023-12-07 16:05 ` [PATCH 0/2] e2fsprogs: avoid error information loss " 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=20230217111049.itrmawqzjvtjpmf7@quack3 \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=libaokun1@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.