fsck.f2fs: trigger repairing if filesystem was forced to stop
PATCH 2/2 fsck.f2fs: trigger repairing if filesystem has inconsistent errors
In reply to Chao YuIn auto/preen mode, let's trigger repairing if filesystem has inconsistent errors.
Signed-off-by Chao Yu <[email protected]>
--- fsck/fsck.c | 8 ++++++-- fsck/fsck.h | 1 + fsck/mount.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++- include/f2fs_fs.h | 26 +++++++++++++++++++++++- 4 files changed, 83 insertions(+), 4 deletions(-)
fsck/fsck.c +6 -2
@@ -3368,10 +3368,14 @@ int fsck_verify(struct f2fs_sb_info *sbi)write_checkpoints (sbi); } -if (c.abnormal_stop) { +if (c.abnormal_stop)memset (sb->s_stop_reason,0 ,MAX_STOP_REASON ); + +if (c.fs_errors) +memset (sb->s_errors,0 ,MAX_F2FS_ERRORS ); + +if (c.abnormal_stop || c.fs_errors)update_superblock (sb,SB_MASK_ALL ); - }/* to return FSCK_ERROR_CORRECTED */ ret =0 ;
fsck/fsck.h +1 -0
@@ -238,6 +238,7 @@ extern void update_nat_blkaddr(struct f2fs_sb_info *, nid_t, nid_t, block_t);extern void print_raw_sb_info (struct f2fs_super_block *);extern bool is_checkpoint_stop (struct f2fs_super_block *,bool ); +extern bool is_inconsistent_error (struct f2fs_super_block *);extern pgoff_t current_nat_addr (struct f2fs_sb_info *,nid_t ,int *);extern u32 get_free_segments (struct f2fs_sb_info *);
fsck/mount.c +51 -1
82 lines not on this page · raw message
include/f2fs_fs.h +25 -1
@@ -510,6 +510,7 @@ struct f2fs_configuration {int bug_on;int force_stop;int abnormal_stop; +int fs_errors;int bug_nat_bits;bool quota_fixed;int alloc_failed;
@@ -773,6 +774,28 @@ enum stop_cp_reason {#define MAX_STOP_REASON 32 +/* detail reason for EFSCORRUPTED */ +enum f2fs_error { +ERROR_CORRUPTED_CLUSTER , +ERROR_FAIL_DECOMPRESSION , +ERROR_INVALID_BLKADDR , +ERROR_CORRUPTED_DIRENT , +ERROR_CORRUPTED_INODE , +ERROR_INCONSISTENT_SUMMARY , +ERROR_INCONSISTENT_FOOTER , +ERROR_INCONSISTENT_SUM_TYPE , +ERROR_CORRUPTED_JOURNAL , +ERROR_INCONSISTENT_NODE_COUNT , +ERROR_INCONSISTENT_BLOCK_COUNT , +ERROR_INVALID_CURSEG , +ERROR_INCONSISTENT_SIT , +ERROR_CORRUPTED_VERITY_XATTR , +ERROR_CORRUPTED_XATTR , +ERROR_MAX , +}; + +#define MAX_F2FS_ERRORS 16 +struct f2fs_super_block {__le32 magic;/* Magic Number */ __le16 major_ver;/* Major Version */
@@ -818,7 +841,8 @@ struct f2fs_super_block {__le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ __u8 s_stop_reason[MAX_STOP_REASON ];/* stop checkpoint reason */ -__u8 reserved[274 ];/* valid reserved region */ +__u8 s_errors[MAX_F2FS_ERRORS ];/* reason of image corrupts */ +__u8 reserved[258 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ };
Signature · 8 lines
2.36.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 1/2 fsck.f2fs: trigger repairing if filesystem was forced to stop
In auto/preen mode, let's trigger repairing if filesystem was forced to stop.
Signed-off-by Chao Yu <[email protected]>
--- fsck/fsck.c | 7 +++++++ fsck/fsck.h | 1 + fsck/mount.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ include/f2fs_fs.h | 19 ++++++++++++++++++- 4 files changed, 73 insertions(+), 1 deletion(-)
fsck/fsck.c +7 -0
@@ -3351,6 +3351,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)/* fix global metadata */ if (force || (c.fix_on &&f2fs_dev_is_writable ())) {struct f2fs_checkpoint *cp =F2FS_CKPT (sbi); +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);if (force || c.bug_on || c.bug_nat_bits || c.quota_fixed) {/* flush nats to write_nit_bits below */
@@ -3366,6 +3367,12 @@ int fsck_verify(struct f2fs_sb_info *sbi) is_set_ckpt_flags(cp, CP_QUOTA_NEED_FSCK_FLAG)) {write_checkpoints (sbi); } + +if (c.abnormal_stop) { +memset (sb->s_stop_reason,0 ,MAX_STOP_REASON ); +update_superblock (sb,SB_MASK_ALL ); + } +/* to return FSCK_ERROR_CORRECTED */ ret =0 ; }
fsck/fsck.h +1 -0
@@ -237,6 +237,7 @@ extern void update_data_blkaddr(struct f2fs_sb_info *, nid_t, u16, block_t);extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t );extern void print_raw_sb_info (struct f2fs_super_block *); +extern bool is_checkpoint_stop (struct f2fs_super_block *,bool );extern pgoff_t current_nat_addr (struct f2fs_sb_info *,nid_t ,int *);extern u32 get_free_segments (struct f2fs_sb_info *);
fsck/mount.c +47 -0
75 lines not on this page · raw message
include/f2fs_fs.h +18 -1
@@ -508,6 +508,8 @@ struct f2fs_configuration {int force;int defset;int bug_on; +int force_stop; +int abnormal_stop;int bug_nat_bits;bool quota_fixed;int alloc_failed;
@@ -757,6 +759,20 @@ struct f2fs_device {static_assert (sizeof (struct f2fs_device ) ==68 ,"" ); +/* reason of stop_checkpoint */ +enum stop_cp_reason { +STOP_CP_REASON_SHUTDOWN , +STOP_CP_REASON_FAULT_INJECT , +STOP_CP_REASON_META_PAGE , +STOP_CP_REASON_WRITE_FAIL , +STOP_CP_REASON_CORRUPTED_SUMMARY , +STOP_CP_REASON_UPDATE_INODE , +STOP_CP_REASON_FLUSH_FAIL , +STOP_CP_REASON_MAX , +}; + +#define MAX_STOP_REASON 32 +struct f2fs_super_block {__le32 magic;/* Magic Number */ __le16 major_ver;/* Major Version */
@@ -801,7 +817,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__u8 s_stop_reason[MAX_STOP_REASON ];/* stop checkpoint reason */ +__u8 reserved[274 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ };
Signature · 8 lines
2.36.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel