[PATCH] f2fs: add fsnotify_sb_error() in f2fs_save_errors

Yangtao Li posted 1 patch 2 years, 9 months ago
fs/f2fs/super.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] f2fs: add fsnotify_sb_error() in f2fs_save_errors
Posted by Yangtao Li 2 years, 9 months ago
When an EFSCORRUPTED error occurs in f2fs, report the error to
userspace monitoring tools.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 51812f459581..42d5aa504afe 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -28,6 +28,7 @@
 #include <linux/part_stat.h>
 #include <linux/zstd.h>
 #include <linux/lz4.h>
+#include <linux/fsnotify.h>
 
 #include "f2fs.h"
 #include "node.h"
@@ -4000,6 +4001,8 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag)
 		sbi->error_dirty = true;
 	}
 	spin_unlock_irqrestore(&sbi->error_lock, flags);
+
+	fsnotify_sb_error(sbi->sb, NULL, EFSCORRUPTED);
 }
 
 static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
-- 
2.39.0
Re: [PATCH] f2fs: add fsnotify_sb_error() in f2fs_save_errors
Posted by Chao Yu 2 years, 8 months ago
On 2023/5/11 17:13, Yangtao Li wrote:
> When an EFSCORRUPTED error occurs in f2fs, report the error to
> userspace monitoring tools.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/super.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 51812f459581..42d5aa504afe 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -28,6 +28,7 @@
>   #include <linux/part_stat.h>
>   #include <linux/zstd.h>
>   #include <linux/lz4.h>
> +#include <linux/fsnotify.h>
>   
>   #include "f2fs.h"
>   #include "node.h"
> @@ -4000,6 +4001,8 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag)
>   		sbi->error_dirty = true;
>   	}
>   	spin_unlock_irqrestore(&sbi->error_lock, flags);
> +
> +	fsnotify_sb_error(sbi->sb, NULL, EFSCORRUPTED);

Can we call this function in irq context?

- f2fs_decompress_cluster
  - f2fs_save_errors

Thanks,

>   }
>   
>   static bool f2fs_update_errors(struct f2fs_sb_info *sbi)