f2fs: call f2fs_handle_critical_error() to set cp_error flag
Chao Yu
maintainerPATCH v3 1/2 f2fs: call f2fs_handle_critical_error() to set cp_error flag
f2fs_handle_page_eio() is the only left place we set CP_ERROR_FLAG directly, it missed to update superblock.s_stop_reason, let's call f2fs_handle_critical_error() instead to fix that.
Introduce STOP_CP_REASON_READ_{META,NODE,DATA} stop_cp_reason enum variable to indicate which kind of data we failed to read.
---
v3:
- No changes.
fs/f2fs/f2fs.h | 21 +++++++++++++++++++-- include/linux/f2fs_fs.h | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +19 -2
@@ -5073,8 +5073,25 @@ static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi,return ;if (ofs == sbi->page_eio_ofs[type]) { -if (sbi->page_eio_cnt[type]++ ==MAX_RETRY_PAGE_EIO ) -set_ckpt_flags (sbi,CP_ERROR_FLAG ); +if (sbi->page_eio_cnt[type]++ ==MAX_RETRY_PAGE_EIO ) { +enum stop_cp_reason stop_reason; + +switch (type) { +case META : + stop_reason =STOP_CP_REASON_READ_META ; +break ; +case NODE : + stop_reason =STOP_CP_REASON_READ_NODE ; +break ; +case DATA : + stop_reason =STOP_CP_REASON_READ_DATA ; +break ; +default : +f2fs_bug_on (sbi,1 ); +return ; + } +f2fs_handle_critical_error (sbi, stop_reason); + } }else { sbi->page_eio_ofs[type] = ofs; sbi->page_eio_cnt[type] =0 ;
include/linux/f2fs_fs.h +3 -0
@@ -80,6 +80,9 @@ enum stop_cp_reason {STOP_CP_REASON_NO_SEGMENT ,STOP_CP_REASON_CORRUPTED_FREE_BITMAP ,STOP_CP_REASON_CORRUPTED_NID , +STOP_CP_REASON_READ_META , +STOP_CP_REASON_READ_NODE , +STOP_CP_REASON_READ_DATA , STOP_CP_REASON_MAX, };
Signature · 1 line
2.49.0
Chao Yu
maintainerPATCH v3 2/2 f2fs: use more generic f2fs_stop_checkpoint()
Let's use more generic f2fs_stop_checkpoint() instead of f2fs_handle_critical_error() to handle critical error in f2fs.
---
v3:
This patch depends on "f2fs: call f2fs_handle_critical_error() to set cp_error flag", so send it as a patchset.
fs/f2fs/checkpoint.c | 9 --------- fs/f2fs/f2fs.h | 3 +-- fs/f2fs/node.c | 2 +- fs/f2fs/super.c | 13 ++++++++++++- 4 files changed, 14 insertions(+), 13 deletions(-)
fs/f2fs/checkpoint.c +0 -9
@@ -232,15 +232,6 @@ static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)static struct kmem_cache *ino_entry_slab;struct kmem_cache *f2fs_inode_entry_slab; -void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io, -unsigned char reason) -{ -f2fs_build_fault_attr (sbi,0 ,0 ,FAULT_ALL ); -if (!end_io) -f2fs_flush_merged_writes (sbi); -f2fs_handle_critical_error (sbi, reason); -} -/* * We guarantee no failure on the returned page. */
fs/f2fs/f2fs.h +1 -2
@@ -3905,7 +3905,6 @@ int f2fs_do_quota_sync(struct super_block *sb, int type);loff_t max_file_blocks (struct inode *inode);void f2fs_quota_off_umount (struct super_block *sb);void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag); -void f2fs_handle_critical_error (struct f2fs_sb_info *sbi,unsigned char reason);void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error);int f2fs_commit_super (struct f2fs_sb_info *sbi,bool recover);int f2fs_sync_fs (struct super_block *sb,int sync);
@@ -5090,7 +5089,7 @@ static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi,f2fs_bug_on (sbi,1 );return ; } -f2fs_handle_critical_error (sbi, stop_reason); +f2fs_stop_checkpoint (sbi, false, stop_reason); } }else { sbi->page_eio_ofs[type] = ofs;
fs/f2fs/node.c +1 -1
@@ -1779,7 +1779,7 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submittedif (f2fs_sanity_check_node_footer (sbi, folio, nid,NODE_TYPE_REGULAR , false)) { -f2fs_handle_critical_error (sbi,STOP_CP_REASON_CORRUPTED_NID ); +f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_CORRUPTED_NID ); goto redirty_out; }
fs/f2fs/super.c +12 -1
@@ -4663,7 +4663,8 @@ static bool system_going_down(void) || system_state == SYSTEM_RESTART; } -void f2fs_handle_critical_error (struct f2fs_sb_info *sbi,unsigned char reason) +static void f2fs_handle_critical_error (struct f2fs_sb_info *sbi, +unsigned char reason) {struct super_block *sb = sbi->sb;bool shutdown = reason ==STOP_CP_REASON_SHUTDOWN ;
@@ -4720,6 +4721,16 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason)*/ } +void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io, +unsigned char reason) +{ +f2fs_build_fault_attr (sbi,0 ,0 ,FAULT_ALL ); +if (!end_io) +f2fs_flush_merged_writes (sbi); +f2fs_handle_critical_error (sbi, reason); +} + +static void f2fs_record_error_work (struct work_struct *work) { struct f2fs_sb_info *sbi = container_of(work,
Signature · 1 line
2.49.0
This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Mon, 23 Mar 2026 16:38:32 +0800 you wrote:
f2fs_handle_page_eio()is the only left place we setCP_ERROR_FLAGdirectly, it missed to update superblock.s_stop_reason, let's callf2fs_handle_critical_error()instead to fix that.Introduce STOP_CP_REASON_READ_{META,NODE,DATA}
stop_cp_reasonenum variable to indicate which kind of data we failed to read.[...]
Here is the summary with links:
- [f2fs-dev,v3,1/2] f2fs: call f2fs_handle_critical_error() to set cp_error flag
https://git.kernel.org/jaegeuk/f2fs/c/bd882ffdd48a - [f2fs-dev,v3,2/2] f2fs: use more generic f2fs_stop_checkpoint() https://git.kernel.org/jaegeuk/f2fs/c/be09d78b6d54
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html