diff options
author | Chao Yu | 2023-01-09 11:44:51 +0800 |
---|---|---|
committer | Greg Kroah-Hartman | 2023-03-11 13:55:19 +0100 |
commit | 14e8bd4cfae3ffc921c64130777cdd1c7a2267c3 (patch) | |
tree | 3cf166f23e3788c47ceda5085d35a69cb4d7a693 | |
parent | e11707d5f86fe1b507b1c2d70258df7c2661454e (diff) |
f2fs: fix to abort atomic write only during do_exist()
[ Upstream commit ae267fc1cfe9f941afcb90dc963ee6448dae73cf ]
Commit 7a10f0177e11 ("f2fs: don't give partially written atomic data
from process crash") attempted to drop atomic write data after process
crash, however, f2fs_abort_atomic_write() may be called from noncrash
case, fix it by adding missed PF_EXITING check condition
f2fs_file_flush().
- application crashs
- do_exit
- exit_signals -- sets PF_EXITING
- exit_files
- put_files_struct
- close_files
- filp_close
- flush (f2fs_file_flush)
- check atomic_write_task && PF_EXITING
- f2fs_abort_atomic_write
Fixes: 7a10f0177e11 ("f2fs: don't give partially written atomic data from process crash")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | fs/f2fs/file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 88eecd7149cd..8a576c004b72 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1879,7 +1879,8 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id) * until all the writers close its file. Since this should be done * before dropping file lock, it needs to do in ->flush. */ - if (F2FS_I(inode)->atomic_write_task == current) + if (F2FS_I(inode)->atomic_write_task == current && + (current->flags & PF_EXITING)) f2fs_abort_atomic_write(inode, true); return 0; } |