aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2024-04-03 23:07:53 +0000
committerJaegeuk Kim <jaegeuk@kernel.org>2024-04-04 19:52:53 +0000
commit4dc79245adfbb116cc3ed5ef080390741d8e119f (patch)
tree6caca7243ad3943aac58b7d4ff0f110743f2a0d2
parent197080156f27b6bf8cf198e9313dfbb94769c736 (diff)
downloadlinux-dev-test.tar.gz
f2fs: don't set RO when shutting down f2fsdev-test
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> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/super.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index df9765b41dac1..ba6288e870c5c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4135,9 +4135,16 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
if (shutdown)
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
- /* continue filesystem operators if errors=continue */
- if (continue_fs || f2fs_readonly(sb))
+ /*
+ * Continue filesystem operators if errors=continue. Should not set
+ * RO by shutdown, since RO bypasses thaw_super which can hang the
+ * system.
+ */
+ if (continue_fs || f2fs_readonly(sb) ||
+ reason == STOP_CP_REASON_SHUTDOWN) {
+ f2fs_warn(sbi, "Stopped filesystem due to readon: %d", reason);
return;
+ }
f2fs_warn(sbi, "Remounting filesystem read-only");
/*