summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2023-05-18 10:14:12 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2023-06-12 13:04:08 -0700
commit901c12d144570ed2558f4a6806201453c5b01bea (patch)
treeb82bdee12cb1d3e739d25c918a7da5fb6624525c /fs/f2fs/super.c
parent458c15dfbce62c35fefd9ca637b20a051309c9f1 (diff)
downloadlinux-901c12d144570ed2558f4a6806201453c5b01bea.tar.gz
linux-901c12d144570ed2558f4a6806201453c5b01bea.tar.bz2
linux-901c12d144570ed2558f4a6806201453c5b01bea.zip
f2fs: flush error flags in workqueue
In IRQ context, it wakes up workqueue to record errors into on-disk superblock fields rather than in-memory fields. Fixes: 1aa161e43106 ("f2fs: fix scheduling while atomic in decompression path") Fixes: 95fa90c9e5a7 ("f2fs: support recording errors into superblock") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 6e770f82d39f..ee390c398e1c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3995,6 +3995,11 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
f2fs_down_write(&sbi->sb_lock);
spin_lock_irqsave(&sbi->error_lock, flags);
+ if (sbi->error_dirty) {
+ memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
+ MAX_F2FS_ERRORS);
+ sbi->error_dirty = false;
+ }
memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
spin_unlock_irqrestore(&sbi->error_lock, flags);
@@ -4034,12 +4039,10 @@ static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
return need_update;
}
-void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
+static void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
{
int err;
- f2fs_save_errors(sbi, error);
-
f2fs_down_write(&sbi->sb_lock);
if (!f2fs_update_errors(sbi))
@@ -4053,6 +4056,23 @@ out_unlock:
f2fs_up_write(&sbi->sb_lock);
}
+void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
+{
+ f2fs_save_errors(sbi, error);
+ f2fs_record_errors(sbi, error);
+}
+
+void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error)
+{
+ f2fs_save_errors(sbi, error);
+
+ if (!sbi->error_dirty)
+ return;
+ if (!test_bit(error, (unsigned long *)sbi->errors))
+ return;
+ schedule_work(&sbi->s_error_work);
+}
+
static bool system_going_down(void)
{
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF