Skip to content

Commit 3bdb7f1

Browse files
author
Jaegeuk Kim
committed
f2fs: don't set RO when shutting down f2fs
Shutdown does not check the error of thaw_super due to readonly, which causes a deadlock like below. f2fs_ioc_shutdown(F2FS_GOING_DOWN_FULLSYNC) issue_discard_thread - bdev_freeze - freeze_super - f2fs_stop_checkpoint() - f2fs_handle_critical_error - sb_start_write - set RO - waiting - bdev_thaw - thaw_super_locked - return -EINVAL, if sb_rdonly() - f2fs_stop_discard_thread -> wait for kthread_stop(discard_thread); Reported-by: "Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com> Reviewed-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent e07230d commit 3bdb7f1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fs/f2fs/super.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,9 +4159,15 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
41594159
if (shutdown)
41604160
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
41614161

4162-
/* continue filesystem operators if errors=continue */
4163-
if (continue_fs || f2fs_readonly(sb))
4162+
/*
4163+
* Continue filesystem operators if errors=continue. Should not set
4164+
* RO by shutdown, since RO bypasses thaw_super which can hang the
4165+
* system.
4166+
*/
4167+
if (continue_fs || f2fs_readonly(sb) || shutdown) {
4168+
f2fs_warn(sbi, "Stopped filesystem due to reason: %d", reason);
41644169
return;
4170+
}
41654171

41664172
f2fs_warn(sbi, "Remounting filesystem read-only");
41674173
/*

0 commit comments

Comments
 (0)