Skip to content

Commit 0abd8e7

Browse files
daehojeongJaegeuk Kim
authored andcommitted
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 <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent b3a97a2 commit 0abd8e7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

fs/f2fs/dir.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
705705
struct f2fs_dentry_block *dentry_blk;
706706
unsigned int bit_pos;
707707
int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
708+
struct address_space *mapping = page_mapping(page);
709+
unsigned long flags;
708710
int i;
709711

710712
f2fs_update_time(F2FS_I_SB(dir), REQ_TIME);
@@ -735,6 +737,11 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
735737

736738
if (bit_pos == NR_DENTRY_IN_BLOCK &&
737739
!truncate_hole(dir, page->index, page->index + 1)) {
740+
spin_lock_irqsave(&mapping->tree_lock, flags);
741+
radix_tree_tag_clear(&mapping->page_tree, page_index(page),
742+
PAGECACHE_TAG_DIRTY);
743+
spin_unlock_irqrestore(&mapping->tree_lock, flags);
744+
738745
clear_page_dirty_for_io(page);
739746
ClearPagePrivate(page);
740747
ClearPageUptodate(page);

fs/f2fs/inline.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
202202
{
203203
void *src_addr, *dst_addr;
204204
struct dnode_of_data dn;
205+
struct address_space *mapping = page_mapping(page);
206+
unsigned long flags;
205207
int err;
206208

207209
set_new_dnode(&dn, inode, NULL, NULL, 0);
@@ -223,6 +225,11 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
223225
kunmap_atomic(src_addr);
224226
set_page_dirty(dn.inode_page);
225227

228+
spin_lock_irqsave(&mapping->tree_lock, flags);
229+
radix_tree_tag_clear(&mapping->page_tree, page_index(page),
230+
PAGECACHE_TAG_DIRTY);
231+
spin_unlock_irqrestore(&mapping->tree_lock, flags);
232+
226233
set_inode_flag(inode, FI_APPEND_WRITE);
227234
set_inode_flag(inode, FI_DATA_EXIST);
228235

0 commit comments

Comments
 (0)