From 3444d6a933ecbe9ccb5e24250f6a292ebbfc81d9 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Mon, 10 Feb 2025 18:01:37 +0800 Subject: [PATCH] ANDROID: vendor_hooks: add hooks for f2fs_printk Add vendor hooks in f2fs_printk so that the application can also capture and handle f2fs error messages. When the application captures f2fs error messages, it can report these errors and provide some prompts or restart the application. Bug: 395976123 Change-Id: I47d082a6dad2461119f7f14cdabfa7dcf208fe5e Signed-off-by: Rui Chen --- drivers/android/vendor_hooks.c | 1 + fs/f2fs/super.c | 5 ++++- include/trace/hooks/fs.h | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 98c329486bcc..6f2dc7fccaaf 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -134,6 +134,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_transfer_rsp_status); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_f2fs_down_read); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_improve_priority); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_restore_priority); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_printk); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_io_statistics); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_setup_dma_ops); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 3722d44418ce..d26adaeb4d14 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -39,6 +39,9 @@ #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS +#include + static struct kmem_cache *f2fs_inode_cachep; #ifdef CONFIG_F2FS_FAULT_INJECTION @@ -291,7 +294,7 @@ void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate, else printk("%c%cF2FS-fs (%s): %pV\n", KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); - + trace_android_vh_f2fs_printk(sbi, &vaf, level, limit_rate); va_end(args); } diff --git a/include/trace/hooks/fs.h b/include/trace/hooks/fs.h index eff712e6a503..016f951e92a3 100644 --- a/include/trace/hooks/fs.h +++ b/include/trace/hooks/fs.h @@ -8,6 +8,8 @@ #define _TRACE_HOOK_FS_H #include +struct f2fs_sb_info; +struct va_format; DECLARE_RESTRICTED_HOOK(android_rvh_f2fs_down_read, TP_PROTO(wait_queue_head_t *read_waiters, struct rw_semaphore *rwsem, bool *skip), @@ -21,6 +23,10 @@ DECLARE_HOOK(android_vh_f2fs_restore_priority, TP_PROTO(struct task_struct *p, int saved_prio), TP_ARGS(p, saved_prio)); +DECLARE_HOOK(android_vh_f2fs_printk, + TP_PROTO(struct f2fs_sb_info *sbi, struct va_format *vaf, int level, bool limit_rate), + TP_ARGS(sbi, vaf, level, limit_rate)); + #endif /* _TRACE_HOOK_FS_H */ /* This part must be outside protection */