summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2024-02-22 20:18:50 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2024-02-29 08:34:34 -0800
commit7d009e048d7cfcc21d400f2aba4c8bacbdebbd47 (patch)
tree6264c4453ec9f002f6754d970419dc9224b53e6b /fs/f2fs/file.c
parentf9e28904e6442019043a8e94ec6747a064d06003 (diff)
downloadlinux-7d009e048d7cfcc21d400f2aba4c8bacbdebbd47.tar.gz
linux-7d009e048d7cfcc21d400f2aba4c8bacbdebbd47.tar.bz2
linux-7d009e048d7cfcc21d400f2aba4c8bacbdebbd47.zip
f2fs: fix to handle segment allocation failure correctly
If CONFIG_F2FS_CHECK_FS is off, and for very rare corner case that we run out of free segment, we should not panic kernel, instead, let's handle such error correctly in its caller. Signed-off-by: Chao Yu <chao@kernel.org> Tested-by: Zhiguo Niu <zhiguo.niu@unisoc.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 891fa359f7e0..6371bd33bf6d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2262,8 +2262,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
case F2FS_GOING_DOWN_METASYNC:
/* do checkpoint only */
ret = f2fs_sync_fs(sb, 1);
- if (ret)
+ if (ret) {
+ if (ret == -EIO)
+ ret = 0;
goto out;
+ }
f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN);
break;
case F2FS_GOING_DOWN_NOSYNC:
@@ -2279,6 +2282,8 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
set_sbi_flag(sbi, SBI_IS_DIRTY);
/* do checkpoint only */
ret = f2fs_sync_fs(sb, 1);
+ if (ret == -EIO)
+ ret = 0;
goto out;
default:
ret = -EINVAL;