diff options
author | Chao Yu <chao@kernel.org> | 2024-08-12 22:12:42 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2024-08-21 00:56:27 +0000 |
commit | a4d7f2b3238fd5f76b9e6434a0bd5d2e29049cff (patch) | |
tree | cc87a5cacdca630753fb58fd42784728df49f73d /fs/f2fs | |
parent | 8c1b787938fd86bab27a1492fa887408c75fec2b (diff) | |
download | lwn-a4d7f2b3238fd5f76b9e6434a0bd5d2e29049cff.tar.gz lwn-a4d7f2b3238fd5f76b9e6434a0bd5d2e29049cff.zip |
f2fs: fix to wait page writeback before setting gcing flag
Soft IRQ Thread
- f2fs_write_end_io
- f2fs_defragment_range
- set_page_private_gcing
- type = WB_DATA_TYPE(page, false);
: assign type w/ F2FS_WB_CP_DATA
due to page_private_gcing() is true
- dec_page_count() w/ wrong type
- end_page_writeback()
Value of F2FS_WB_CP_DATA reference count may become negative under above
race condition, the root cause is we missed to wait page writeback before
setting gcing page private flag, let's fix it.
Fixes: 2d1fe8a86bf5 ("f2fs: fix to tag gcing flag on page during file defragment")
Fixes: 4961acdd65c9 ("f2fs: fix to tag gcing flag on page during block migration")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 082e81ba09b9..73f70a7a2567 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2807,6 +2807,8 @@ do_map: goto clear_out; } + f2fs_wait_on_page_writeback(page, DATA, true, true); + set_page_dirty(page); set_page_private_gcing(page); f2fs_put_page(page, 1); @@ -4207,6 +4209,8 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) /* It will never fail, when page has pinned above */ f2fs_bug_on(F2FS_I_SB(inode), !page); + f2fs_wait_on_page_writeback(page, DATA, true, true); + set_page_dirty(page); set_page_private_gcing(page); f2fs_put_page(page, 1); |