]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
f2fs: don't set RO when shutting down f2fs
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 3 Apr 2024 23:07:53 +0000 (23:07 +0000)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Fri, 2 Aug 2024 14:27:13 +0000 (16:27 +0200)
BugLink: https://bugs.launchpad.net/bugs/2075154
[ Upstream commit 3bdb7f161697e2d5123b89fe1778ef17a44858e7 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/f2fs/super.c

index c6a26526c3044466e8cc88a1c13059f933e65ac5..fd5dca1e50637560712ab30ab6df9ef13a7e6300 100644 (file)
@@ -4123,9 +4123,15 @@ 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) || shutdown) {
+               f2fs_warn(sbi, "Stopped filesystem due to reason: %d", reason);
                return;
+       }
 
        f2fs_warn(sbi, "Remounting filesystem read-only");
        /*