Skip to content

Commit 901c12d

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: 1aa161e ("f2fs: fix scheduling while atomic in decompression path") Fixes: 95fa90c ("f2fs: support recording errors into superblock") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 458c15d commit 901c12d

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

fs/f2fs/compress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
744744

745745
/* Avoid f2fs_commit_super in irq context */
746746
if (!in_task)
747-
f2fs_save_errors(sbi, ERROR_FAIL_DECOMPRESSION);
747+
f2fs_handle_error_async(sbi, ERROR_FAIL_DECOMPRESSION);
748748
else
749749
f2fs_handle_error(sbi, ERROR_FAIL_DECOMPRESSION);
750750
goto out_release;

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,7 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag);
35633563
void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
35643564
bool irq_context);
35653565
void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error);
3566+
void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error);
35663567
int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
35673568
int f2fs_sync_fs(struct super_block *sb, int sync);
35683569
int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi);

fs/f2fs/super.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,6 +3995,11 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
39953995
f2fs_down_write(&sbi->sb_lock);
39963996

39973997
spin_lock_irqsave(&sbi->error_lock, flags);
3998+
if (sbi->error_dirty) {
3999+
memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
4000+
MAX_F2FS_ERRORS);
4001+
sbi->error_dirty = false;
4002+
}
39984003
memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
39994004
spin_unlock_irqrestore(&sbi->error_lock, flags);
40004005

@@ -4034,12 +4039,10 @@ static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
40344039
return need_update;
40354040
}
40364041

4037-
void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
4042+
static void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
40384043
{
40394044
int err;
40404045

4041-
f2fs_save_errors(sbi, error);
4042-
40434046
f2fs_down_write(&sbi->sb_lock);
40444047

40454048
if (!f2fs_update_errors(sbi))
@@ -4053,6 +4056,23 @@ void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
40534056
f2fs_up_write(&sbi->sb_lock);
40544057
}
40554058

4059+
void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
4060+
{
4061+
f2fs_save_errors(sbi, error);
4062+
f2fs_record_errors(sbi, error);
4063+
}
4064+
4065+
void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error)
4066+
{
4067+
f2fs_save_errors(sbi, error);
4068+
4069+
if (!sbi->error_dirty)
4070+
return;
4071+
if (!test_bit(error, (unsigned long *)sbi->errors))
4072+
return;
4073+
schedule_work(&sbi->s_error_work);
4074+
}
4075+
40564076
static bool system_going_down(void)
40574077
{
40584078
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF

0 commit comments

Comments
 (0)