f2fs: Add trace_f2fs_fault_report
Subsystems (2)
PATCH v2 1/1 f2fs: Add trace_f2fs_fault_report
From: liujinbao1 <[email protected]>
Add trace_f2fs_fault_report to trigger reporting upon f2fs_bug_on, need_fsck, stop_checkpoint, and handle_eio. Since f2fs_bug_on and need_fsck can be triggered in hundreds of scenarios, define set_sbi_flag as a macro to help capture the effective fault function and line number.
--- fs/f2fs/f2fs.h | 18 +++++++++++++++++- fs/f2fs/super.c | 9 +++++++++ include/trace/events/f2fs.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +17 -1
@@ -97,6 +97,15 @@ extern const char *f2fs_fault_name[FAULT_MAX];#define DEFAULT_FAILURE_RETRY_COUNT 1#endif +enum { +REPORT_FAULT_NEED_FSCK , +REPORT_FAULT_STOP_CP , +REPORT_FAULT_MAX , +}; + +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data); +/* * For mount options */
@@ -2278,11 +2287,18 @@ static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type)return test_bit (type, &sbi->s_flag); } -static inline void set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) +static inline void __set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) {set_bit (type, &sbi->s_flag); } +#define set_sbi_flag (sbi, type) \ +do { \ + __set_sbi_flag(sbi, type); \ + if ((type) == SBI_NEED_FSCK) \ + f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__); \ +} while (0) +static inline void clear_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) {clear_bit (type, &sbi->s_flag);
fs/f2fs/super.c +9 -0
@@ -4724,9 +4724,18 @@ static void f2fs_handle_critical_error(struct f2fs_sb_info *sbi,*/ } +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data) +{ +trace_f2fs_fault_report (sb, err_code, func, data); +} +void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io,unsigned char reason) { +if (reason !=STOP_CP_REASON_SHUTDOWN ) +f2fs_fault_report (sbi->sb,REPORT_FAULT_STOP_CP , __func__, reason); +f2fs_build_fault_attr (sbi,0 ,0 ,FAULT_ALL );if (!end_io)f2fs_flush_merged_writes (sbi);
include/trace/events/f2fs.h +28 -0
@@ -2582,6 +2582,34 @@ DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore,TP_ARGS (sbi, lock_name, is_write, p, orig_prio, new_prio) ); +TRACE_EVENT (f2fs_fault_report, + + TP_PROTO(struct super_block *sb, unsigned int err_code, + const char *func, unsigned int data), + +TP_ARGS (sb, err_code, func, data), + +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(unsigned int, err_code) + __string(func, func) + __field(unsigned int, data) + ), + +TP_fast_assign ( + __entry->dev = sb->s_dev; + __entry->err_code = err_code; + __assign_str(func, func); + __entry->data = data; + ), + +TP_printk ("dev = (%d,%d), err_code = %u, func = %s, data = %u" , +show_dev (__entry->dev), + __entry->err_code, +__get_str (func), + __entry->data) +); +#endif /* _TRACE_F2FS_H */ /* This part must be outside protection */
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 41 lines · On 4/15/2026 7:42 PM, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Add
trace_f2fs_fault_reportto trigger reporting uponf2fs_bug_on,need_fsck,stop_checkpoint, andhandle_eio. Sincef2fs_bug_onandneed_fsckcan be triggered in hundreds of scenarios, defineset_sbi_flagas a macro to help capture the effective fault function and line number.Signed-off-by shengyong1 <[email protected]>Signed-off-by liujinbao1 <[email protected]>--- fs/f2fs/f2fs.h | 18 +++++++++++++++++- fs/f2fs/super.c | 9 +++++++++ include/trace/events/f2fs.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +10
-1@@ -97,6 +97,15 @@ extern const char *f2fs_fault_name[FAULT_MAX];#define DEFAULT_FAILURE_RETRY_COUNT 1#endif +enum { +REPORT_FAULT_NEED_FSCK , +REPORT_FAULT_STOP_CP , +REPORT_FAULT_MAX , +}; + +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data); +/* * For mount options */ @@ -2278,11 +2287,18 @@ static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type)return test_bit (type, &sbi->s_flag); } -static inline void set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) +static inline void __set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type)
fs/f2fs/f2fs.h static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type) · line 2300
Quoted 10 lines
fs/f2fs/f2fs.h +6
-0{set_bit (type, &sbi->s_flag); } +#define set_sbi_flag (sbi, type) \ +do { \ + __set_sbi_flag(sbi, type); \ + if ((type) == SBI_NEED_FSCK) \ + f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__); \ +} while (0)
It's minor, but, what about?
void f2fs_fault_report(struct super_block *sb, unsigned int err_code,
const char *func, unsigned int data);
static inline void set_sbi_flag(struct f2fs_sb_info *sbi, unsigned int type)
{
set_bit(type, &sbi->s_flag);
if ((type) == SBI_NEED_FSCK)
f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__);
}Thanks,
Quoted 56 lines
fs/f2fs/f2fs.h +1
-0+static inline void clear_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) {clear_bit (type, &sbi->s_flag);fs/f2fs/super.c +9
-0@@ -4724,9 +4724,18 @@ static void f2fs_handle_critical_error(struct f2fs_sb_info *sbi,*/ } +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data) +{ +trace_f2fs_fault_report (sb, err_code, func, data); +} +void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io,unsigned char reason) { +if (reason !=STOP_CP_REASON_SHUTDOWN ) +f2fs_fault_report (sbi->sb,REPORT_FAULT_STOP_CP , __func__, reason); +f2fs_build_fault_attr (sbi,0 ,0 ,FAULT_ALL );if (!end_io)f2fs_flush_merged_writes (sbi);include/trace/events/f2fs.h +21
-0@@ -2582,6 +2582,34 @@ DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore,TP_ARGS (sbi, lock_name, is_write, p, orig_prio, new_prio) ); +TRACE_EVENT(f2fs_fault_report, + + TP_PROTO(struct super_block *sb, unsigned int err_code, + const char *func, unsigned int data), + + TP_ARGS(sb, err_code, func, data), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, err_code) + __string(func, func) + __field(unsigned int, data) + ), + + TP_fast_assign( + __entry->dev = sb->s_dev; + __entry->err_code = err_code; + __assign_str(func, func); + __entry->data = data; + ), +
include/trace/events/f2fs.h DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore, · line 2615
Quoted 10 lines
include/trace/events/f2fs.h +7
-0+TP_printk ("dev = (%d,%d), err_code = %u, func = %s, data = %u" , +show_dev (__entry->dev), + __entry->err_code, +__get_str (func), + __entry->data) +); +#endif /* _TRACE_F2FS_H */ /* This part must be outside protection */
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 63 lines · On 4/17/2026 12:02 PM, liujinbao1 wrote:
Quoted 61 lines · Chao Yu
Quoted 38 lines · On 4/15/2026 7:42 PM, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Add
trace_f2fs_fault_reportto trigger reporting uponf2fs_bug_on,need_fsck,stop_checkpoint, andhandle_eio. Sincef2fs_bug_onandneed_fsckcan be triggered in hundreds of scenarios, defineset_sbi_flagas a macro to help capture the effective fault function and line number.Signed-off-by shengyong1 <[email protected]>Signed-off-by liujinbao1 <[email protected]>---
fs/f2fs/f2fs.h | 18 +++++++++++++++++- fs/f2fs/super.c | 9 +++++++++include/trace/events/f2fs.h| 28 ++++++++++++++++++++++++++++3 files changed, 54 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +8
-0@@ -97,6 +97,15 @@ extern const char *f2fs_fault_name[FAULT_MAX]; #define DEFAULT_FAILURE_RETRY_COUNT 1 #endif +enum { + REPORT_FAULT_NEED_FSCK, + REPORT_FAULT_STOP_CP, + REPORT_FAULT_MAX, +}; + +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, + const char *func, unsigned int data); + /** For mount options */ @@ -2278,11 +2287,18 @@ static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type) return test_bit(type, &sbi->s_flag); } -static inline void set_sbi_flag(struct f2fs_sb_info *sbi, unsigned int type)fs/f2fs/f2fs.h static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type) · line 2299
Quoted 10 lines
fs/f2fs/f2fs.h +6
-0+static inline void __set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) { set_bit(type, &sbi->s_flag); } +#define set_sbi_flag(sbi, type) \ +do { \ + __set_sbi_flag(sbi, type); \ + if ((type) == SBI_NEED_FSCK) \ + f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__); \ +} while (0)It's minor, but, what about?
void
f2fs_fault_report(struct super_block *sb, unsigned int err_code, const char *func, unsigned int data);
static inline voidset_sbi_flag(struct f2fs_sb_info *sbi, unsigned int type){
set_bit(type,&sbi->s_flag);
if ((type) ==SBI_NEED_FSCK)
f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__); }
Quoted 7 lines
Quoted 2 lines
Thanks,
The advantage of defining|set_sbi_flag|as a macro is that, when|f2fs_bug_on|and|need_fsck|are triggered,
the function name and line number where the fault occurred can be directly captured. If it were implemented as a function, the function and line number passed in would be invalid, leaving only the option to infer the fault location from the call stack.
Oh, right, I missed that.
Thanks,
Quoted 68 lines
But I'm fine with either approach — I'll go with your suggestion.
Thanks
Quoted 64 lines
Quoted 63 lines
fs/f2fs/f2fs.h +1
-0+ static inline void clear_sbi_flag(struct f2fs_sb_info *sbi, unsigned int type) { clear_bit(type, &sbi->s_flag);fs/f2fs/super.c +8
-0@@ -4724,9 +4724,18 @@ static void f2fs_handle_critical_error(struct f2fs_sb_info *sbi,*/ } +void f2fs_fault_report(struct super_block *sb, unsigned int err_code, + const char *func, unsigned int data) +{ + trace_f2fs_fault_report(sb, err_code, func, data); +} + void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io, unsigned char reason) { + if (reason != STOP_CP_REASON_SHUTDOWN) + f2fs_fault_report(sbi->sb, REPORT_FAULT_STOP_CP, __func__, reason); + f2fs_build_fault_attr(sbi, 0, 0, FAULT_ALL); if (!end_io) f2fs_flush_merged_writes(sbi);include/trace/events/f2fs.h +27
-0@@ -2582,6 +2582,34 @@ DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore, TP_ARGS(sbi, lock_name, is_write, p, orig_prio, new_prio) ); +TRACE_EVENT(f2fs_fault_report, + + TP_PROTO(struct super_block *sb, unsigned int err_code, + const char *func, unsigned int data), + + TP_ARGS(sb, err_code, func, data), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, err_code) + __string(func, func) + __field(unsigned int, data) + ), + + TP_fast_assign( + __entry->dev = sb->s_dev; + __entry->err_code = err_code; + __assign_str(func, func); + __entry->data = data; + ), + + TP_printk("dev = (%d,%d), err_code = %u, func = %s, data = %u", + show_dev(__entry->dev), + __entry->err_code, + __get_str(func), + __entry->data) +); + #endif /* _TRACE_F2FS_H */ /* This part must be outside protection */
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 9 lines · On 4/15/2026 7:42 PM, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Add
trace_f2fs_fault_reportto trigger reporting uponf2fs_bug_on,need_fsck,stop_checkpoint, andhandle_eio. Sincef2fs_bug_onandneed_fsckcan be triggered in hundreds of scenarios, defineset_sbi_flagas a macro to help capture the effective fault function and line number.Signed-off-by shengyong1 <[email protected]>Signed-off-by liujinbao1 <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
It seems this patch fails to build on linux-next. Could you please check?
Quoted 119 lines · On 04/15, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Add
trace_f2fs_fault_reportto trigger reporting uponf2fs_bug_on,need_fsck,stop_checkpoint, andhandle_eio. Sincef2fs_bug_onandneed_fsckcan be triggered in hundreds of scenarios, defineset_sbi_flagas a macro to help capture the effective fault function and line number.Signed-off-by shengyong1 <[email protected]>Signed-off-by liujinbao1 <[email protected]>--- fs/f2fs/f2fs.h | 18 +++++++++++++++++- fs/f2fs/super.c | 9 +++++++++ include/trace/events/f2fs.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +17
-1@@ -97,6 +97,15 @@ extern const char *f2fs_fault_name[FAULT_MAX];#define DEFAULT_FAILURE_RETRY_COUNT 1#endif +enum { +REPORT_FAULT_NEED_FSCK , +REPORT_FAULT_STOP_CP , +REPORT_FAULT_MAX , +}; + +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data); +/* * For mount options */ @@ -2278,11 +2287,18 @@ static inline bool is_sbi_flag_set(struct f2fs_sb_info *sbi, unsigned int type)return test_bit (type, &sbi->s_flag); } -static inline void set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) +static inline void __set_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) {set_bit (type, &sbi->s_flag); } +#define set_sbi_flag (sbi, type) \ +do { \ + __set_sbi_flag(sbi, type); \ + if ((type) == SBI_NEED_FSCK) \ + f2fs_fault_report(sbi->sb, REPORT_FAULT_NEED_FSCK, __func__, __LINE__); \ +} while (0) +static inline void clear_sbi_flag (struct f2fs_sb_info *sbi,unsigned int type) {clear_bit (type, &sbi->s_flag);fs/f2fs/super.c +9
-0@@ -4724,9 +4724,18 @@ static void f2fs_handle_critical_error(struct f2fs_sb_info *sbi,*/ } +void f2fs_fault_report (struct super_block *sb,unsigned int err_code, +const char *func,unsigned int data) +{ +trace_f2fs_fault_report (sb, err_code, func, data); +} +void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io,unsigned char reason) { +if (reason !=STOP_CP_REASON_SHUTDOWN ) +f2fs_fault_report (sbi->sb,REPORT_FAULT_STOP_CP , __func__, reason); +f2fs_build_fault_attr (sbi,0 ,0 ,FAULT_ALL );if (!end_io)f2fs_flush_merged_writes (sbi);include/trace/events/f2fs.h +28
-0@@ -2582,6 +2582,34 @@ DEFINE_EVENT(f2fs_priority_update, f2fs_priority_restore,TP_ARGS (sbi, lock_name, is_write, p, orig_prio, new_prio) ); +TRACE_EVENT (f2fs_fault_report, + + TP_PROTO(struct super_block *sb, unsigned int err_code, + const char *func, unsigned int data), + +TP_ARGS (sb, err_code, func, data), + +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(unsigned int, err_code) + __string(func, func) + __field(unsigned int, data) + ), + +TP_fast_assign ( + __entry->dev = sb->s_dev; + __entry->err_code = err_code; + __assign_str(func, func); + __entry->data = data; + ), + +TP_printk ("dev = (%d,%d), err_code = %u, func = %s, data = %u" , +show_dev (__entry->dev), + __entry->err_code, +__get_str (func), + __entry->data) +); +#endif /* _TRACE_F2FS_H */ /* This part must be outside protection */ Signature · 1 line
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel