f2fs: fix to account FS_CP_DATA_IO correctly
[ Upstream commit d80afefb17e01aa0c46a8eebc01882e0ebd8b0f6 ] f2fs_inode_info.cp_task was introduced for FS_CP_DATA_IO accounting since commitb0af6d491a
("f2fs: add app/fs io stat"). However, cp_task usage coverage has been increased due to below commits: commit040d2bb318
("f2fs: fix to avoid deadloop if data_flush is on") commit186857c5a1
("f2fs: fix potential recursive call when enabling data_flush") So that, if data_flush mountoption is on, when data flush was triggered from background, the IO from data flush will be accounted as checkpoint IO type incorrectly. In order to fix this issue, this patch splits cp_task into two: a) cp_task: used for IO accounting b) wb_task: used to avoid deadlock Fixes:040d2bb318
("f2fs: fix to avoid deadloop if data_flush is on") Fixes:186857c5a1
("f2fs: fix potential recursive call when enabling data_flush") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
0b8230d44c
commit
b60aa21e2f
@@ -1047,7 +1047,8 @@ void f2fs_remove_dirty_inode(struct inode *inode)
|
||||
spin_unlock(&sbi->inode_lock[type]);
|
||||
}
|
||||
|
||||
int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
|
||||
int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type,
|
||||
bool from_cp)
|
||||
{
|
||||
struct list_head *head;
|
||||
struct inode *inode;
|
||||
@@ -1082,11 +1083,15 @@ retry:
|
||||
if (inode) {
|
||||
unsigned long cur_ino = inode->i_ino;
|
||||
|
||||
F2FS_I(inode)->cp_task = current;
|
||||
if (from_cp)
|
||||
F2FS_I(inode)->cp_task = current;
|
||||
F2FS_I(inode)->wb_task = current;
|
||||
|
||||
filemap_fdatawrite(inode->i_mapping);
|
||||
|
||||
F2FS_I(inode)->cp_task = NULL;
|
||||
F2FS_I(inode)->wb_task = NULL;
|
||||
if (from_cp)
|
||||
F2FS_I(inode)->cp_task = NULL;
|
||||
|
||||
iput(inode);
|
||||
/* We need to give cpu to another writers. */
|
||||
@@ -1215,7 +1220,7 @@ retry_flush_dents:
|
||||
/* write all the dirty dentry pages */
|
||||
if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
|
||||
f2fs_unlock_all(sbi);
|
||||
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE);
|
||||
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE, true);
|
||||
if (err)
|
||||
return err;
|
||||
cond_resched();
|
||||
|
Reference in New Issue
Block a user