* [PATCH] f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared
[not found] <CGME20170911072934epcas2p476a584e43b7f52cf1587e7366b52a257@epcas2p4.samsung.com>
@ 2017-09-11 7:30 ` Daeho Jeong
2017-09-12 1:53 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Daeho Jeong @ 2017-09-11 7:30 UTC (permalink / raw)
To: jaegeuk, linux-f2fs-devel; +Cc: Daeho Jeong
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>
---
fs/f2fs/dir.c | 7 +++++++
fs/f2fs/inline.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 37f9c7f..c0c933ad 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -705,6 +705,8 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
struct f2fs_dentry_block *dentry_blk;
unsigned int bit_pos;
int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
+ struct address_space *mapping = page_mapping(page);
+ unsigned long flags;
int i;
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,
if (bit_pos == NR_DENTRY_IN_BLOCK &&
!truncate_hole(dir, page->index, page->index + 1)) {
+ spin_lock_irqsave(&mapping->tree_lock, flags);
+ radix_tree_tag_clear(&mapping->page_tree, page_index(page),
+ PAGECACHE_TAG_DIRTY);
+ spin_unlock_irqrestore(&mapping->tree_lock, flags);
+
clear_page_dirty_for_io(page);
ClearPagePrivate(page);
ClearPageUptodate(page);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index c133a4f..8322e4e 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -202,6 +202,8 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
{
void *src_addr, *dst_addr;
struct dnode_of_data dn;
+ struct address_space *mapping = page_mapping(page);
+ unsigned long flags;
int err;
set_new_dnode(&dn, inode, NULL, NULL, 0);
@@ -223,6 +225,11 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
kunmap_atomic(src_addr);
set_page_dirty(dn.inode_page);
+ spin_lock_irqsave(&mapping->tree_lock, flags);
+ radix_tree_tag_clear(&mapping->page_tree, page_index(page),
+ PAGECACHE_TAG_DIRTY);
+ spin_unlock_irqrestore(&mapping->tree_lock, flags);
+
set_inode_flag(inode, FI_APPEND_WRITE);
set_inode_flag(inode, FI_DATA_EXIST);
--
1.9.1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared
2017-09-11 7:30 ` [PATCH] f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared Daeho Jeong
@ 2017-09-12 1:53 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2017-09-12 1:53 UTC (permalink / raw)
To: Daeho Jeong, jaegeuk, linux-f2fs-devel
On 2017/9/11 15:30, Daeho Jeong wrote:
> 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>
> ---
> fs/f2fs/dir.c | 7 +++++++
> fs/f2fs/inline.c | 7 +++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index 37f9c7f..c0c933ad 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -705,6 +705,8 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
> struct f2fs_dentry_block *dentry_blk;
> unsigned int bit_pos;
> int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
> + struct address_space *mapping = page_mapping(page);
> + unsigned long flags;
> int i;
>
> 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,
>
> if (bit_pos == NR_DENTRY_IN_BLOCK &&
> !truncate_hole(dir, page->index, page->index + 1)) {
> + spin_lock_irqsave(&mapping->tree_lock, flags);
> + radix_tree_tag_clear(&mapping->page_tree, page_index(page),
> + PAGECACHE_TAG_DIRTY);
> + spin_unlock_irqrestore(&mapping->tree_lock, flags);
> +
> clear_page_dirty_for_io(page);
> ClearPagePrivate(page);
> ClearPageUptodate(page);
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index c133a4f..8322e4e 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -202,6 +202,8 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> {
> void *src_addr, *dst_addr;
> struct dnode_of_data dn;
> + struct address_space *mapping = page_mapping(page);
> + unsigned long flags;
> int err;
>
> set_new_dnode(&dn, inode, NULL, NULL, 0);
> @@ -223,6 +225,11 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> kunmap_atomic(src_addr);
> set_page_dirty(dn.inode_page);
>
> + spin_lock_irqsave(&mapping->tree_lock, flags);
> + radix_tree_tag_clear(&mapping->page_tree, page_index(page),
> + PAGECACHE_TAG_DIRTY);
> + spin_unlock_irqrestore(&mapping->tree_lock, flags);
> +
> set_inode_flag(inode, FI_APPEND_WRITE);
> set_inode_flag(inode, FI_DATA_EXIST);
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-12 1:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170911072934epcas2p476a584e43b7f52cf1587e7366b52a257@epcas2p4.samsung.com>
2017-09-11 7:30 ` [PATCH] f2fs: clear radix tree dirty tag of pages whose dirty flag is cleared Daeho Jeong
2017-09-12 1:53 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).