From: Fengnan Chang <[email protected]> For now, overwrite file with direct io use inplace policy, but not counted, fix it.
Signed-off-by: Fengnan Chang <[email protected]> --- fs/f2fs/data.c | 7 ++++++- fs/f2fs/f2fs.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index c1490b9a1345..b5d488c9f9f9 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1491,6 +1491,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, if (flag == F2FS_GET_BLOCK_DIO) f2fs_wait_on_block_writeback_range(inode, map->m_pblk, map->m_len); + if (!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && + map->m_may_create) + stat_add_inplace_blocks(sbi, map->m_len, true); goto out; } @@ -1553,7 +1556,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, goto sync_out; blkaddr = dn.data_blkaddr; set_inode_flag(inode, FI_APPEND_WRITE); - } + } else if (!create && !f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && + map->m_may_create) + stat_inc_inplace_blocks(sbi, true); } else { if (create) { if (unlikely(f2fs_cp_error(sbi))) { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3d4ee444db27..49230115d241 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3792,6 +3792,13 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) else \ (atomic_inc(&(sbi)->inplace_count[1])); \ } while (0) +#define stat_add_inplace_blocks(sbi, count, direct_io) \ + do { \ + if (direct_io) \ + (atomic_add(count, &(sbi)->inplace_count[0])); \ + else \ + (atomic_add(count, &(sbi)->inplace_count[1])); \ + } while (0) #define stat_update_max_atomic_write(inode) \ do { \ int cur = F2FS_I_SB(inode)->atomic_files; \ -- 2.32.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
