Linux EXT4 FS development
 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 2/2] tune2fs/fuse2fs/debugfs: save error information during journal replay
Date: Fri, 17 Feb 2023 12:11:00 +0100	[thread overview]
Message-ID: <20230217111100.m36cuxqnvmr7fejx@quack3> (raw)
In-Reply-To: <20230217100922.588961-3-libaokun1@huawei.com>

On Fri 17-02-23 18:09:22, Baokun Li wrote:
> Saving error information during journal replay, as in the kernel,
> prevents information loss from making problems difficult to locate.
> We save these error information until someone uses e2fsck to check
> for and fix possible errors.
> 
> Signed-off-by: Baokun Li <libaokun1@huawei.com>

Looks good to me. Feel free to add:

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

								Honza

> ---
>  debugfs/journal.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/debugfs/journal.c b/debugfs/journal.c
> index 5bac0d3b..79e3fff8 100644
> --- a/debugfs/journal.c
> +++ b/debugfs/journal.c
> @@ -789,6 +789,8 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
>  	char *fsname;
>  	int fsflags;
>  	int fsblocksize;
> +	char *save;
> +	__u16 s_error_state;
>  
>  	if (!(fs->flags & EXT2_FLAG_RW))
>  		return EXT2_ET_FILE_RO;
> @@ -808,6 +810,12 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
>  	if (stats && stats->bytes_written)
>  		kbytes_written = stats->bytes_written >> 10;
>  
> +	save = malloc(EXT4_S_ERR_LEN);
> +	if (save)
> +		memcpy(save, ((char *) fs->super) + EXT4_S_ERR_START,
> +		       EXT4_S_ERR_LEN);
> +	s_error_state = fs->super->s_state & EXT2_ERROR_FS;
> +
>  	ext2fs_mmp_stop(fs);
>  	fsname = fs->device_name;
>  	fs->device_name = NULL;
> @@ -818,11 +826,15 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
>  	retval = ext2fs_open(fsname, fsflags, 0, fsblocksize, io_ptr, fsp);
>  	ext2fs_free_mem(&fsname);
>  	if (retval)
> -		return retval;
> +		goto outfree;
>  
>  	fs = *fsp;
>  	fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
>  	fs->super->s_kbytes_written += kbytes_written;
> +	fs->super->s_state |= s_error_state;
> +	if (save)
> +		memcpy(((char *) fs->super) + EXT4_S_ERR_START, save,
> +		       EXT4_S_ERR_LEN);
>  
>  	/* Set the superblock flags */
>  	ext2fs_clear_recover(fs, recover_retval != 0);
> @@ -832,6 +844,9 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
>  	 * the EXT2_ERROR_FS flag in the fs superblock if needed.
>  	 */
>  	retval = ext2fs_check_ext3_journal(fs);
> +
> +outfree:
> +	free(save);
>  	return retval ? retval : recover_retval;
>  }
>  
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2023-02-17 11:12 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
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 [this message]
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=20230217111100.m36cuxqnvmr7fejx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox