f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared

On a senario like writing out the first dirty page of the inode
as the inline data, we only cleared dirty flags of the pages, but
didn't clear the dirty tags of those pages in the radix tree.

If we don't clear the dirty tags of the pages in the radix tree, the
inodes which contain the pages will be marked with I_DIRTY_PAGES again
and again, and writepages() for the inodes will be invoked in every
writeback period. As a result, nothing will be done in every
writepages() for the inodes and it will just consume CPU time
meaninglessly.

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Daeho Jeong and committed by
Jaegeuk Kim
0abd8e70 b3a97a2a

+14
+7
fs/f2fs/dir.c
··· 705 struct f2fs_dentry_block *dentry_blk; 706 unsigned int bit_pos; 707 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len)); 708 int i; 709 710 f2fs_update_time(F2FS_I_SB(dir), REQ_TIME); ··· 737 738 if (bit_pos == NR_DENTRY_IN_BLOCK && 739 !truncate_hole(dir, page->index, page->index + 1)) { 740 clear_page_dirty_for_io(page); 741 ClearPagePrivate(page); 742 ClearPageUptodate(page);
··· 705 struct f2fs_dentry_block *dentry_blk; 706 unsigned int bit_pos; 707 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len)); 708 + struct address_space *mapping = page_mapping(page); 709 + unsigned long flags; 710 int i; 711 712 f2fs_update_time(F2FS_I_SB(dir), REQ_TIME); ··· 735 736 if (bit_pos == NR_DENTRY_IN_BLOCK && 737 !truncate_hole(dir, page->index, page->index + 1)) { 738 + spin_lock_irqsave(&mapping->tree_lock, flags); 739 + radix_tree_tag_clear(&mapping->page_tree, page_index(page), 740 + PAGECACHE_TAG_DIRTY); 741 + spin_unlock_irqrestore(&mapping->tree_lock, flags); 742 + 743 clear_page_dirty_for_io(page); 744 ClearPagePrivate(page); 745 ClearPageUptodate(page);
+7
fs/f2fs/inline.c
··· 202 { 203 void *src_addr, *dst_addr; 204 struct dnode_of_data dn; 205 int err; 206 207 set_new_dnode(&dn, inode, NULL, NULL, 0); ··· 224 memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode)); 225 kunmap_atomic(src_addr); 226 set_page_dirty(dn.inode_page); 227 228 set_inode_flag(inode, FI_APPEND_WRITE); 229 set_inode_flag(inode, FI_DATA_EXIST);
··· 202 { 203 void *src_addr, *dst_addr; 204 struct dnode_of_data dn; 205 + struct address_space *mapping = page_mapping(page); 206 + unsigned long flags; 207 int err; 208 209 set_new_dnode(&dn, inode, NULL, NULL, 0); ··· 222 memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode)); 223 kunmap_atomic(src_addr); 224 set_page_dirty(dn.inode_page); 225 + 226 + spin_lock_irqsave(&mapping->tree_lock, flags); 227 + radix_tree_tag_clear(&mapping->page_tree, page_index(page), 228 + PAGECACHE_TAG_DIRTY); 229 + spin_unlock_irqrestore(&mapping->tree_lock, flags); 230 231 set_inode_flag(inode, FI_APPEND_WRITE); 232 set_inode_flag(inode, FI_DATA_EXIST);