75 lines
2.2 KiB
Diff
75 lines
2.2 KiB
Diff
|
|
From cc59b82532b7a47051b5c64d554bf9f978ad92d4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Baokun Li <libaokun1@huawei.com>
|
||
|
|
Date: Fri, 17 Feb 2023 18:09:22 +0800
|
||
|
|
Subject: [PATCH 2/2] tune2fs/fuse2fs/debugfs: save error information during
|
||
|
|
journal replay
|
||
|
|
|
||
|
|
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>
|
||
|
|
Reviewed-by: Jan Kara <jack@suse.cz>
|
||
|
|
Reviewed-by: zhanchengbin <zhanchengbin1@huawei.com>
|
||
|
|
---
|
||
|
|
debugfs/journal.c | 17 ++++++++++++++++-
|
||
|
|
1 file changed, 16 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/debugfs/journal.c b/debugfs/journal.c
|
||
|
|
index 095fff0..a3128b7 100644
|
||
|
|
--- a/debugfs/journal.c
|
||
|
|
+++ b/debugfs/journal.c
|
||
|
|
@@ -787,6 +787,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;
|
||
|
|
@@ -806,6 +808,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;
|
||
|
|
@@ -816,11 +824,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);
|
||
|
|
@@ -830,6 +842,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.41.0
|
||
|
|
|