* [PATCH 1/6] f2fs: speed up shrinking extent_node cache
@ 2016-01-25 22:05 Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch speeds up extent_node shrinker by introducing linked list.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/extent_cache.c | 74 ++++++++++++++++++++++----------------------------
fs/f2fs/f2fs.h | 2 ++
2 files changed, 35 insertions(+), 41 deletions(-)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index ccd5c63..18311ff 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -32,7 +32,9 @@ static struct extent_node *__attach_extent_node(struct f2fs_sb_info *sbi,
return NULL;
en->ei = *ei;
+ en->et = et;
INIT_LIST_HEAD(&en->list);
+ INIT_LIST_HEAD(&en->vlist);
rb_link_node(&en->rb_node, parent, p);
rb_insert_color(&en->rb_node, &et->root);
@@ -129,7 +131,7 @@ static struct extent_node *__init_extent_tree(struct f2fs_sb_info *sbi,
}
static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi,
- struct extent_tree *et, bool free_all)
+ struct extent_tree *et)
{
struct rb_node *node, *next;
struct extent_node *en;
@@ -137,17 +139,19 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi,
node = rb_first(&et->root);
while (node) {
+ bool need_free = false;
+
next = rb_next(node);
en = rb_entry(node, struct extent_node, rb_node);
- if (free_all) {
- spin_lock(&sbi->extent_lock);
- if (!list_empty(&en->list))
- list_del_init(&en->list);
- spin_unlock(&sbi->extent_lock);
+ spin_lock(&sbi->extent_lock);
+ if (!list_empty(&en->list)) {
+ list_del_init(&en->list);
+ need_free = true;
}
+ spin_unlock(&sbi->extent_lock);
- if (free_all || list_empty(&en->list)) {
+ if (need_free) {
__detach_extent_node(sbi, et, en);
kmem_cache_free(extent_node_slab, en);
}
@@ -438,6 +442,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
while (en && en->ei.fofs < end) {
unsigned int org_end;
int parts = 0; /* # of parts current extent split into */
+ bool need_free = false;
next_en = en1 = NULL;
@@ -493,14 +498,16 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
/* update in global extent list */
spin_lock(&sbi->extent_lock);
- if (!parts && !list_empty(&en->list))
+ if (!parts && !list_empty(&en->list)) {
list_del(&en->list);
+ need_free = true;
+ }
if (en1)
list_add_tail(&en1->list, &sbi->extent_list);
spin_unlock(&sbi->extent_lock);
/* release extent node */
- if (!parts)
+ if (!parts && need_free)
kmem_cache_free(extent_node_slab, en);
en = next_en;
@@ -509,6 +516,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
/* 3. update extent in extent cache */
if (blkaddr) {
struct extent_node *den = NULL;
+ bool need_free = false;
set_extent_info(&ei, fofs, blkaddr, len);
en1 = __try_merge_extent_node(sbi, et, &ei, &den,
@@ -532,16 +540,18 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
else
list_move_tail(&en1->list, &sbi->extent_list);
}
- if (den && !list_empty(&den->list))
+ if (den && !list_empty(&den->list)) {
list_del(&den->list);
+ need_free = true;
+ }
spin_unlock(&sbi->extent_lock);
- if (den)
+ if (den && need_free)
kmem_cache_free(extent_node_slab, den);
}
if (is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT))
- __free_extent_tree(sbi, et, true);
+ __free_extent_tree(sbi, et);
write_unlock(&et->lock);
@@ -550,14 +560,12 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
{
- struct extent_tree *treevec[EXT_TREE_VEC_SIZE];
struct extent_tree *et, *next;
struct extent_node *en, *tmp;
- unsigned long ino = F2FS_ROOT_INO(sbi);
- unsigned int found;
unsigned int node_cnt = 0, tree_cnt = 0;
int remained;
bool do_free = false;
+ LIST_HEAD(victim_list);
if (!test_opt(sbi, EXTENT_CACHE))
return 0;
@@ -572,7 +580,7 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
list_for_each_entry_safe(et, next, &sbi->zombie_list, list) {
if (atomic_read(&et->node_cnt)) {
write_lock(&et->lock);
- node_cnt += __free_extent_tree(sbi, et, true);
+ node_cnt += __free_extent_tree(sbi, et);
write_unlock(&et->lock);
}
@@ -600,6 +608,8 @@ free_node:
if (!remained--)
break;
list_del_init(&en->list);
+ list_add_tail(&en->vlist, &victim_list);
+ tree_cnt++;
do_free = true;
}
spin_unlock(&sbi->extent_lock);
@@ -607,31 +617,13 @@ free_node:
if (do_free == false)
goto unlock_out;
- /*
- * reset ino for searching victims from beginning of global extent tree.
- */
- ino = F2FS_ROOT_INO(sbi);
-
- while ((found = radix_tree_gang_lookup(&sbi->extent_tree_root,
- (void **)treevec, ino, EXT_TREE_VEC_SIZE))) {
- unsigned i;
-
- ino = treevec[found - 1]->ino + 1;
- for (i = 0; i < found; i++) {
- struct extent_tree *et = treevec[i];
-
- if (!atomic_read(&et->node_cnt))
- continue;
-
- if (write_trylock(&et->lock)) {
- node_cnt += __free_extent_tree(sbi, et, false);
- write_unlock(&et->lock);
- }
-
- if (node_cnt + tree_cnt >= nr_shrink)
- goto unlock_out;
- }
+ list_for_each_entry_safe(en, tmp, &victim_list, vlist) {
+ write_lock(&en->et->lock);
+ __detach_extent_node(sbi, en->et, en);
+ write_unlock(&en->et->lock);
+ kmem_cache_free(extent_node_slab, en);
}
+
unlock_out:
up_write(&sbi->extent_tree_lock);
out:
@@ -650,7 +642,7 @@ unsigned int f2fs_destroy_extent_node(struct inode *inode)
return 0;
write_lock(&et->lock);
- node_cnt = __free_extent_tree(sbi, et, true);
+ node_cnt = __free_extent_tree(sbi, et);
write_unlock(&et->lock);
return node_cnt;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c4e723b..0bbbfed 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -353,7 +353,9 @@ struct extent_info {
struct extent_node {
struct rb_node rb_node; /* rb node located in rb-tree */
struct list_head list; /* node in global extent list of sbi */
+ struct list_head vlist; /* node in victim extent list */
struct extent_info ei; /* extent info */
+ struct extent_tree *et; /* extent tree pointer */
};
struct extent_tree {
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/6] f2fs: give scheduling point in shrinking path
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
@ 2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
It needs to give a chance to be rescheduled while shrinking slab entries.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/extent_cache.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 18311ff..af53503 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -593,6 +593,8 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
if (node_cnt + tree_cnt >= nr_shrink)
goto unlock_out;
+
+ cond_resched();
}
up_write(&sbi->extent_tree_lock);
@@ -622,6 +624,7 @@ free_node:
__detach_extent_node(sbi, en->et, en);
write_unlock(&en->et->lock);
kmem_cache_free(extent_node_slab, en);
+ cond_resched();
}
unlock_out:
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/6] f2fs: give scheduling point in shrinking path
@ 2016-01-25 22:05 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
It needs to give a chance to be rescheduled while shrinking slab entries.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/extent_cache.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 18311ff..af53503 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -593,6 +593,8 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
if (node_cnt + tree_cnt >= nr_shrink)
goto unlock_out;
+
+ cond_resched();
}
up_write(&sbi->extent_tree_lock);
@@ -622,6 +624,7 @@ free_node:
__detach_extent_node(sbi, en->et, en);
write_unlock(&en->et->lock);
kmem_cache_free(extent_node_slab, en);
+ cond_resched();
}
unlock_out:
--
2.6.3
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/6] f2fs: do f2fs_balance_fs when block is allocated
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
@ 2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
We should consider data block allocation to trigger f2fs_balance_fs.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f057ada..89a37ba 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -542,7 +542,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
struct dnode_of_data dn;
u64 start = F2FS_BYTES_TO_BLK(offset);
u64 len = F2FS_BYTES_TO_BLK(count);
- bool allocated;
+ bool allocated = false;
u64 end_offset;
int err = 0;
@@ -584,7 +584,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
}
return err;
@@ -594,7 +594,7 @@ sync_out:
f2fs_put_dnode(&dn);
out:
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
return err;
}
@@ -688,14 +688,14 @@ get_next:
if (dn.ofs_in_node >= end_offset) {
if (allocated)
sync_inode_page(&dn);
- allocated = false;
f2fs_put_dnode(&dn);
if (create) {
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
f2fs_lock_op(sbi);
}
+ allocated = false;
set_new_dnode(&dn, inode, NULL, NULL, 0);
err = get_dnode_of_data(&dn, pgofs, mode);
@@ -753,7 +753,7 @@ put_out:
unlock_out:
if (create) {
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
}
out:
trace_f2fs_map_blocks(inode, map, err);
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/6] f2fs: do f2fs_balance_fs when block is allocated
@ 2016-01-25 22:05 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
We should consider data block allocation to trigger f2fs_balance_fs.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f057ada..89a37ba 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -542,7 +542,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
struct dnode_of_data dn;
u64 start = F2FS_BYTES_TO_BLK(offset);
u64 len = F2FS_BYTES_TO_BLK(count);
- bool allocated;
+ bool allocated = false;
u64 end_offset;
int err = 0;
@@ -584,7 +584,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
}
return err;
@@ -594,7 +594,7 @@ sync_out:
f2fs_put_dnode(&dn);
out:
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
return err;
}
@@ -688,14 +688,14 @@ get_next:
if (dn.ofs_in_node >= end_offset) {
if (allocated)
sync_inode_page(&dn);
- allocated = false;
f2fs_put_dnode(&dn);
if (create) {
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
f2fs_lock_op(sbi);
}
+ allocated = false;
set_new_dnode(&dn, inode, NULL, NULL, 0);
err = get_dnode_of_data(&dn, pgofs, mode);
@@ -753,7 +753,7 @@ put_out:
unlock_out:
if (create) {
f2fs_unlock_op(sbi);
- f2fs_balance_fs(sbi, dn.node_changed);
+ f2fs_balance_fs(sbi, allocated);
}
out:
trace_f2fs_map_blocks(inode, map, err);
--
2.6.3
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
@ 2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
The sceanrio is:
1. create fully node blocks
2. flush node blocks
3. write inline_data for all the node blocks again
4. flush node blocks redundantly
So, this patch tries to flush inline_data when flushing node blocks.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 1 +
fs/f2fs/inline.c | 2 ++
fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
fs/f2fs/node.h | 15 +++++++++++++++
4 files changed, 57 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 89a37ba..260c0eb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1463,6 +1463,7 @@ restart:
if (pos + len <= MAX_INLINE_DATA) {
read_inline_data(page, ipage);
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
+ set_inline_node(ipage);
sync_inode_page(&dn);
} else {
err = f2fs_convert_inline_page(&dn, page);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 8df13e5..fc4d298 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -159,6 +159,7 @@ no_update:
/* clear inline data and flag after data writeback */
truncate_inline_inode(dn->inode_page, 0);
+ clear_inline_node(dn->inode_page);
clear_out:
stat_dec_inline_inode(dn->inode);
f2fs_clear_inline_inode(dn->inode);
@@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
sync_inode_page(&dn);
+ clear_inline_node(dn.inode_page);
f2fs_put_dnode(&dn);
return 0;
}
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 23b800d..94a6755 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
dn->node_changed = ret ? true: false;
}
+static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
+{
+ struct inode *inode;
+ struct page *page;
+
+ /* should flush inline_data before evict_inode */
+ inode = ilookup(sbi->sb, ino);
+ if (!inode)
+ return;
+
+ page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
+ if (!page)
+ goto iput_out;
+
+ if (!PageUptodate(page))
+ goto page_out;
+
+ if (!PageDirty(page))
+ goto page_out;
+
+ if (!clear_page_dirty_for_io(page))
+ goto page_out;
+
+ if (!f2fs_write_inline_data(inode, page))
+ inode_dec_dirty_pages(inode);
+page_out:
+ f2fs_put_page(page, 1);
+iput_out:
+ iput(inode);
+}
+
int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
struct writeback_control *wbc)
{
@@ -1221,6 +1252,14 @@ continue_unlock:
goto continue_unlock;
}
+ /* flush inline_data */
+ if (!ino && is_inline_node(page)) {
+ clear_inline_node(page);
+ unlock_page(page);
+ flush_inline_data(sbi, ino_of_node(page));
+ continue;
+ }
+
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 23bd992..1f4f9d4 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
#define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
#define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
+static inline int is_inline_node(struct page *page)
+{
+ return PageChecked(page);
+}
+
+static inline void set_inline_node(struct page *page)
+{
+ SetPageChecked(page);
+}
+
+static inline void clear_inline_node(struct page *page)
+{
+ ClearPageChecked(page);
+}
+
static inline void set_cold_node(struct inode *inode, struct page *page)
{
struct f2fs_node *rn = F2FS_NODE(page);
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
@ 2016-01-25 22:05 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
The sceanrio is:
1. create fully node blocks
2. flush node blocks
3. write inline_data for all the node blocks again
4. flush node blocks redundantly
So, this patch tries to flush inline_data when flushing node blocks.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 1 +
fs/f2fs/inline.c | 2 ++
fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
fs/f2fs/node.h | 15 +++++++++++++++
4 files changed, 57 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 89a37ba..260c0eb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1463,6 +1463,7 @@ restart:
if (pos + len <= MAX_INLINE_DATA) {
read_inline_data(page, ipage);
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
+ set_inline_node(ipage);
sync_inode_page(&dn);
} else {
err = f2fs_convert_inline_page(&dn, page);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 8df13e5..fc4d298 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -159,6 +159,7 @@ no_update:
/* clear inline data and flag after data writeback */
truncate_inline_inode(dn->inode_page, 0);
+ clear_inline_node(dn->inode_page);
clear_out:
stat_dec_inline_inode(dn->inode);
f2fs_clear_inline_inode(dn->inode);
@@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
sync_inode_page(&dn);
+ clear_inline_node(dn.inode_page);
f2fs_put_dnode(&dn);
return 0;
}
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 23b800d..94a6755 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
dn->node_changed = ret ? true: false;
}
+static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
+{
+ struct inode *inode;
+ struct page *page;
+
+ /* should flush inline_data before evict_inode */
+ inode = ilookup(sbi->sb, ino);
+ if (!inode)
+ return;
+
+ page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
+ if (!page)
+ goto iput_out;
+
+ if (!PageUptodate(page))
+ goto page_out;
+
+ if (!PageDirty(page))
+ goto page_out;
+
+ if (!clear_page_dirty_for_io(page))
+ goto page_out;
+
+ if (!f2fs_write_inline_data(inode, page))
+ inode_dec_dirty_pages(inode);
+page_out:
+ f2fs_put_page(page, 1);
+iput_out:
+ iput(inode);
+}
+
int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
struct writeback_control *wbc)
{
@@ -1221,6 +1252,14 @@ continue_unlock:
goto continue_unlock;
}
+ /* flush inline_data */
+ if (!ino && is_inline_node(page)) {
+ clear_inline_node(page);
+ unlock_page(page);
+ flush_inline_data(sbi, ino_of_node(page));
+ continue;
+ }
+
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 23bd992..1f4f9d4 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
#define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
#define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
+static inline int is_inline_node(struct page *page)
+{
+ return PageChecked(page);
+}
+
+static inline void set_inline_node(struct page *page)
+{
+ SetPageChecked(page);
+}
+
+static inline void clear_inline_node(struct page *page)
+{
+ ClearPageChecked(page);
+}
+
static inline void set_cold_node(struct inode *inode, struct page *page)
{
struct f2fs_node *rn = F2FS_NODE(page);
--
2.6.3
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/6] f2fs: don't need to sync node page at every time
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
` (2 preceding siblings ...)
2016-01-25 22:05 ` Jaegeuk Kim
@ 2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
4 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
In write_end, we don't need to sync inode page at every time.
Instead, we can expect f2fs_write_inode will update later.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 260c0eb..a6a6f08 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1627,7 +1627,6 @@ static int f2fs_write_end(struct file *file,
if (pos + copied > i_size_read(inode)) {
i_size_write(inode, pos + copied);
mark_inode_dirty(inode);
- update_inode_page(inode);
}
f2fs_put_page(page, 1);
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 6/6] f2fs: avoid needless sync_inode_page when reading inline_data
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
@ 2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
In write_begin, if there is an inline_data, f2fs loads it into 0'th data page.
Since it's the read path, we don't need to sync its inode page.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a6a6f08..4e992bf 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1464,7 +1464,6 @@ restart:
read_inline_data(page, ipage);
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
set_inline_node(ipage);
- sync_inode_page(&dn);
} else {
err = f2fs_convert_inline_page(&dn, page);
if (err)
--
2.6.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 6/6] f2fs: avoid needless sync_inode_page when reading inline_data
@ 2016-01-25 22:05 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-25 22:05 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
In write_begin, if there is an inline_data, f2fs loads it into 0'th data page.
Since it's the read path, we don't need to sync its inode page.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a6a6f08..4e992bf 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1464,7 +1464,6 @@ restart:
read_inline_data(page, ipage);
set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
set_inline_node(ipage);
- sync_inode_page(&dn);
} else {
err = f2fs_convert_inline_page(&dn, page);
if (err)
--
2.6.3
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
^ permalink raw reply related [flat|nested] 14+ messages in thread
* RE: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
2016-01-25 22:05 ` Jaegeuk Kim
@ 2016-01-26 5:41 ` Chao Yu
-1 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2016-01-26 5:41 UTC (permalink / raw)
To: 'Jaegeuk Kim'; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel
Hi Jaegeuk,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, January 26, 2016 6:05 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
>
> The sceanrio is:
> 1. create fully node blocks
> 2. flush node blocks
> 3. write inline_data for all the node blocks again
> 4. flush node blocks redundantly
>
> So, this patch tries to flush inline_data when flushing node blocks.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/data.c | 1 +
> fs/f2fs/inline.c | 2 ++
> fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
> fs/f2fs/node.h | 15 +++++++++++++++
> 4 files changed, 57 insertions(+)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 89a37ba..260c0eb 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1463,6 +1463,7 @@ restart:
> if (pos + len <= MAX_INLINE_DATA) {
> read_inline_data(page, ipage);
> set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> + set_inline_node(ipage);
> sync_inode_page(&dn);
> } else {
> err = f2fs_convert_inline_page(&dn, page);
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 8df13e5..fc4d298 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -159,6 +159,7 @@ no_update:
>
> /* clear inline data and flag after data writeback */
> truncate_inline_inode(dn->inode_page, 0);
> + clear_inline_node(dn->inode_page);
> clear_out:
> stat_dec_inline_inode(dn->inode);
> f2fs_clear_inline_inode(dn->inode);
> @@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
>
> sync_inode_page(&dn);
> + clear_inline_node(dn.inode_page);
> f2fs_put_dnode(&dn);
> return 0;
> }
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 23b800d..94a6755 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
> dn->node_changed = ret ? true: false;
> }
>
> +static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
> +{
> + struct inode *inode;
> + struct page *page;
> +
> + /* should flush inline_data before evict_inode */
> + inode = ilookup(sbi->sb, ino);
> + if (!inode)
> + return;
> +
> + page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
> + if (!page)
> + goto iput_out;
> +
> + if (!PageUptodate(page))
> + goto page_out;
> +
> + if (!PageDirty(page))
> + goto page_out;
> +
> + if (!clear_page_dirty_for_io(page))
> + goto page_out;
> +
> + if (!f2fs_write_inline_data(inode, page))
better to redirty the page when fail except -EAGAIN?
> + inode_dec_dirty_pages(inode);
> +page_out:
> + f2fs_put_page(page, 1);
> +iput_out:
> + iput(inode);
> +}
> +
> int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
> struct writeback_control *wbc)
> {
> @@ -1221,6 +1252,14 @@ continue_unlock:
> goto continue_unlock;
> }
>
> + /* flush inline_data */
> + if (!ino && is_inline_node(page)) {
> + clear_inline_node(page);
Should clear after flushed inline data? otherwise if we failed to flush
inline data, we will lose the change to flush it before node flush.
Thanks,
> + unlock_page(page);
> + flush_inline_data(sbi, ino_of_node(page));
> + continue;
> + }
> +
> if (!clear_page_dirty_for_io(page))
> goto continue_unlock;
>
> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> index 23bd992..1f4f9d4 100644
> --- a/fs/f2fs/node.h
> +++ b/fs/f2fs/node.h
> @@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
> #define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
> #define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
>
> +static inline int is_inline_node(struct page *page)
> +{
> + return PageChecked(page);
> +}
> +
> +static inline void set_inline_node(struct page *page)
> +{
> + SetPageChecked(page);
> +}
> +
> +static inline void clear_inline_node(struct page *page)
> +{
> + ClearPageChecked(page);
> +}
> +
> static inline void set_cold_node(struct inode *inode, struct page *page)
> {
> struct f2fs_node *rn = F2FS_NODE(page);
> --
> 2.6.3
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
@ 2016-01-26 5:41 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2016-01-26 5:41 UTC (permalink / raw)
To: 'Jaegeuk Kim'; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
Hi Jaegeuk,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, January 26, 2016 6:05 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
>
> The sceanrio is:
> 1. create fully node blocks
> 2. flush node blocks
> 3. write inline_data for all the node blocks again
> 4. flush node blocks redundantly
>
> So, this patch tries to flush inline_data when flushing node blocks.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/data.c | 1 +
> fs/f2fs/inline.c | 2 ++
> fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
> fs/f2fs/node.h | 15 +++++++++++++++
> 4 files changed, 57 insertions(+)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 89a37ba..260c0eb 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1463,6 +1463,7 @@ restart:
> if (pos + len <= MAX_INLINE_DATA) {
> read_inline_data(page, ipage);
> set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> + set_inline_node(ipage);
> sync_inode_page(&dn);
> } else {
> err = f2fs_convert_inline_page(&dn, page);
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 8df13e5..fc4d298 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -159,6 +159,7 @@ no_update:
>
> /* clear inline data and flag after data writeback */
> truncate_inline_inode(dn->inode_page, 0);
> + clear_inline_node(dn->inode_page);
> clear_out:
> stat_dec_inline_inode(dn->inode);
> f2fs_clear_inline_inode(dn->inode);
> @@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
>
> sync_inode_page(&dn);
> + clear_inline_node(dn.inode_page);
> f2fs_put_dnode(&dn);
> return 0;
> }
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 23b800d..94a6755 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
> dn->node_changed = ret ? true: false;
> }
>
> +static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
> +{
> + struct inode *inode;
> + struct page *page;
> +
> + /* should flush inline_data before evict_inode */
> + inode = ilookup(sbi->sb, ino);
> + if (!inode)
> + return;
> +
> + page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
> + if (!page)
> + goto iput_out;
> +
> + if (!PageUptodate(page))
> + goto page_out;
> +
> + if (!PageDirty(page))
> + goto page_out;
> +
> + if (!clear_page_dirty_for_io(page))
> + goto page_out;
> +
> + if (!f2fs_write_inline_data(inode, page))
better to redirty the page when fail except -EAGAIN?
> + inode_dec_dirty_pages(inode);
> +page_out:
> + f2fs_put_page(page, 1);
> +iput_out:
> + iput(inode);
> +}
> +
> int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
> struct writeback_control *wbc)
> {
> @@ -1221,6 +1252,14 @@ continue_unlock:
> goto continue_unlock;
> }
>
> + /* flush inline_data */
> + if (!ino && is_inline_node(page)) {
> + clear_inline_node(page);
Should clear after flushed inline data? otherwise if we failed to flush
inline data, we will lose the change to flush it before node flush.
Thanks,
> + unlock_page(page);
> + flush_inline_data(sbi, ino_of_node(page));
> + continue;
> + }
> +
> if (!clear_page_dirty_for_io(page))
> goto continue_unlock;
>
> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> index 23bd992..1f4f9d4 100644
> --- a/fs/f2fs/node.h
> +++ b/fs/f2fs/node.h
> @@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
> #define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
> #define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
>
> +static inline int is_inline_node(struct page *page)
> +{
> + return PageChecked(page);
> +}
> +
> +static inline void set_inline_node(struct page *page)
> +{
> + SetPageChecked(page);
> +}
> +
> +static inline void clear_inline_node(struct page *page)
> +{
> + ClearPageChecked(page);
> +}
> +
> static inline void set_cold_node(struct inode *inode, struct page *page)
> {
> struct f2fs_node *rn = F2FS_NODE(page);
> --
> 2.6.3
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
2016-01-26 5:41 ` Chao Yu
(?)
@ 2016-01-26 18:48 ` Jaegeuk Kim
2016-01-27 6:28 ` Chao Yu
-1 siblings, 1 reply; 14+ messages in thread
From: Jaegeuk Kim @ 2016-01-26 18:48 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel
Hi Chao,
On Tue, Jan 26, 2016 at 01:41:05PM +0800, Chao Yu wrote:
> Hi Jaegeuk,
>
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > Sent: Tuesday, January 26, 2016 6:05 AM
> > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > linux-f2fs-devel@lists.sourceforge.net
> > Cc: Jaegeuk Kim
> > Subject: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
> >
> > The sceanrio is:
> > 1. create fully node blocks
> > 2. flush node blocks
> > 3. write inline_data for all the node blocks again
> > 4. flush node blocks redundantly
> >
> > So, this patch tries to flush inline_data when flushing node blocks.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/data.c | 1 +
> > fs/f2fs/inline.c | 2 ++
> > fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
> > fs/f2fs/node.h | 15 +++++++++++++++
> > 4 files changed, 57 insertions(+)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 89a37ba..260c0eb 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -1463,6 +1463,7 @@ restart:
> > if (pos + len <= MAX_INLINE_DATA) {
> > read_inline_data(page, ipage);
> > set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> > + set_inline_node(ipage);
> > sync_inode_page(&dn);
> > } else {
> > err = f2fs_convert_inline_page(&dn, page);
> > diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> > index 8df13e5..fc4d298 100644
> > --- a/fs/f2fs/inline.c
> > +++ b/fs/f2fs/inline.c
> > @@ -159,6 +159,7 @@ no_update:
> >
> > /* clear inline data and flag after data writeback */
> > truncate_inline_inode(dn->inode_page, 0);
> > + clear_inline_node(dn->inode_page);
> > clear_out:
> > stat_dec_inline_inode(dn->inode);
> > f2fs_clear_inline_inode(dn->inode);
> > @@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> > set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> >
> > sync_inode_page(&dn);
> > + clear_inline_node(dn.inode_page);
> > f2fs_put_dnode(&dn);
> > return 0;
> > }
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index 23b800d..94a6755 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
> > dn->node_changed = ret ? true: false;
> > }
> >
> > +static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
> > +{
> > + struct inode *inode;
> > + struct page *page;
> > +
> > + /* should flush inline_data before evict_inode */
> > + inode = ilookup(sbi->sb, ino);
> > + if (!inode)
> > + return;
> > +
> > + page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
> > + if (!page)
> > + goto iput_out;
> > +
> > + if (!PageUptodate(page))
> > + goto page_out;
> > +
> > + if (!PageDirty(page))
> > + goto page_out;
> > +
> > + if (!clear_page_dirty_for_io(page))
> > + goto page_out;
> > +
> > + if (!f2fs_write_inline_data(inode, page))
>
> better to redirty the page when fail except -EAGAIN?
Agreed.
>
> > + inode_dec_dirty_pages(inode);
> > +page_out:
> > + f2fs_put_page(page, 1);
> > +iput_out:
> > + iput(inode);
> > +}
> > +
> > int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
> > struct writeback_control *wbc)
> > {
> > @@ -1221,6 +1252,14 @@ continue_unlock:
> > goto continue_unlock;
> > }
> >
> > + /* flush inline_data */
> > + if (!ino && is_inline_node(page)) {
> > + clear_inline_node(page);
>
> Should clear after flushed inline data? otherwise if we failed to flush
> inline data, we will lose the change to flush it before node flush.
My intention was just letting it go and flush by ->writepage later.
So, the above set_page_dirty() would handle this, right?
Thanks,
>
> Thanks,
>
> > + unlock_page(page);
> > + flush_inline_data(sbi, ino_of_node(page));
> > + continue;
> > + }
> > +
> > if (!clear_page_dirty_for_io(page))
> > goto continue_unlock;
> >
> > diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> > index 23bd992..1f4f9d4 100644
> > --- a/fs/f2fs/node.h
> > +++ b/fs/f2fs/node.h
> > @@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
> > #define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
> > #define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
> >
> > +static inline int is_inline_node(struct page *page)
> > +{
> > + return PageChecked(page);
> > +}
> > +
> > +static inline void set_inline_node(struct page *page)
> > +{
> > + SetPageChecked(page);
> > +}
> > +
> > +static inline void clear_inline_node(struct page *page)
> > +{
> > + ClearPageChecked(page);
> > +}
> > +
> > static inline void set_cold_node(struct inode *inode, struct page *page)
> > {
> > struct f2fs_node *rn = F2FS_NODE(page);
> > --
> > 2.6.3
> >
> >
> > ------------------------------------------------------------------------------
> > Site24x7 APM Insight: Get Deep Visibility into Application Performance
> > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> > Monitor end-to-end web transactions and take corrective actions now
> > Troubleshoot faster and improve end-user experience. Signup Now!
> > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
2016-01-26 18:48 ` [f2fs-dev] " Jaegeuk Kim
@ 2016-01-27 6:28 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2016-01-27 6:28 UTC (permalink / raw)
To: 'Jaegeuk Kim'; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel
Hi Jaegeuk,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Wednesday, January 27, 2016 2:48 AM
> To: Chao Yu
> Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
>
> Hi Chao,
>
> On Tue, Jan 26, 2016 at 01:41:05PM +0800, Chao Yu wrote:
> > Hi Jaegeuk,
> >
> > > -----Original Message-----
> > > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > > Sent: Tuesday, January 26, 2016 6:05 AM
> > > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > > linux-f2fs-devel@lists.sourceforge.net
> > > Cc: Jaegeuk Kim
> > > Subject: [f2fs-dev] [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data
> > >
> > > The sceanrio is:
> > > 1. create fully node blocks
> > > 2. flush node blocks
> > > 3. write inline_data for all the node blocks again
> > > 4. flush node blocks redundantly
> > >
> > > So, this patch tries to flush inline_data when flushing node blocks.
> > >
> > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > ---
> > > fs/f2fs/data.c | 1 +
> > > fs/f2fs/inline.c | 2 ++
> > > fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++
> > > fs/f2fs/node.h | 15 +++++++++++++++
> > > 4 files changed, 57 insertions(+)
> > >
> > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > > index 89a37ba..260c0eb 100644
> > > --- a/fs/f2fs/data.c
> > > +++ b/fs/f2fs/data.c
> > > @@ -1463,6 +1463,7 @@ restart:
> > > if (pos + len <= MAX_INLINE_DATA) {
> > > read_inline_data(page, ipage);
> > > set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> > > + set_inline_node(ipage);
> > > sync_inode_page(&dn);
> > > } else {
> > > err = f2fs_convert_inline_page(&dn, page);
> > > diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> > > index 8df13e5..fc4d298 100644
> > > --- a/fs/f2fs/inline.c
> > > +++ b/fs/f2fs/inline.c
> > > @@ -159,6 +159,7 @@ no_update:
> > >
> > > /* clear inline data and flag after data writeback */
> > > truncate_inline_inode(dn->inode_page, 0);
> > > + clear_inline_node(dn->inode_page);
> > > clear_out:
> > > stat_dec_inline_inode(dn->inode);
> > > f2fs_clear_inline_inode(dn->inode);
> > > @@ -233,6 +234,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
> > > set_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
> > >
> > > sync_inode_page(&dn);
> > > + clear_inline_node(dn.inode_page);
> > > f2fs_put_dnode(&dn);
> > > return 0;
> > > }
> > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > > index 23b800d..94a6755 100644
> > > --- a/fs/f2fs/node.c
> > > +++ b/fs/f2fs/node.c
> > > @@ -1154,6 +1154,37 @@ void sync_inode_page(struct dnode_of_data *dn)
> > > dn->node_changed = ret ? true: false;
> > > }
> > >
> > > +static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
> > > +{
> > > + struct inode *inode;
> > > + struct page *page;
> > > +
> > > + /* should flush inline_data before evict_inode */
> > > + inode = ilookup(sbi->sb, ino);
> > > + if (!inode)
> > > + return;
> > > +
> > > + page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0);
> > > + if (!page)
> > > + goto iput_out;
> > > +
> > > + if (!PageUptodate(page))
> > > + goto page_out;
> > > +
> > > + if (!PageDirty(page))
> > > + goto page_out;
> > > +
> > > + if (!clear_page_dirty_for_io(page))
> > > + goto page_out;
> > > +
> > > + if (!f2fs_write_inline_data(inode, page))
> >
> > better to redirty the page when fail except -EAGAIN?
>
> Agreed.
>
> >
> > > + inode_dec_dirty_pages(inode);
> > > +page_out:
> > > + f2fs_put_page(page, 1);
> > > +iput_out:
> > > + iput(inode);
> > > +}
> > > +
> > > int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
> > > struct writeback_control *wbc)
> > > {
> > > @@ -1221,6 +1252,14 @@ continue_unlock:
> > > goto continue_unlock;
> > > }
> > >
> > > + /* flush inline_data */
> > > + if (!ino && is_inline_node(page)) {
> > > + clear_inline_node(page);
> >
> > Should clear after flushed inline data? otherwise if we failed to flush
> > inline data, we will lose the change to flush it before node flush.
>
> My intention was just letting it go and flush by ->writepage later.
Hmm.. since it's rare scenario, so it's OK to me.
> So, the above set_page_dirty() would handle this, right?
Yes.
Please add
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Thanks,
>
> Thanks,
>
> >
> > Thanks,
> >
> > > + unlock_page(page);
> > > + flush_inline_data(sbi, ino_of_node(page));
> > > + continue;
> > > + }
> > > +
> > > if (!clear_page_dirty_for_io(page))
> > > goto continue_unlock;
> > >
> > > diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> > > index 23bd992..1f4f9d4 100644
> > > --- a/fs/f2fs/node.h
> > > +++ b/fs/f2fs/node.h
> > > @@ -379,6 +379,21 @@ static inline int is_node(struct page *page, int type)
> > > #define is_fsync_dnode(page) is_node(page, FSYNC_BIT_SHIFT)
> > > #define is_dent_dnode(page) is_node(page, DENT_BIT_SHIFT)
> > >
> > > +static inline int is_inline_node(struct page *page)
> > > +{
> > > + return PageChecked(page);
> > > +}
> > > +
> > > +static inline void set_inline_node(struct page *page)
> > > +{
> > > + SetPageChecked(page);
> > > +}
> > > +
> > > +static inline void clear_inline_node(struct page *page)
> > > +{
> > > + ClearPageChecked(page);
> > > +}
> > > +
> > > static inline void set_cold_node(struct inode *inode, struct page *page)
> > > {
> > > struct f2fs_node *rn = F2FS_NODE(page);
> > > --
> > > 2.6.3
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Site24x7 APM Insight: Get Deep Visibility into Application Performance
> > > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> > > Monitor end-to-end web transactions and take corrective actions now
> > > Troubleshoot faster and improve end-user experience. Signup Now!
> > > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> > > _______________________________________________
> > > Linux-f2fs-devel mailing list
> > > Linux-f2fs-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2016-01-27 6:29 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 22:05 [PATCH 1/6] f2fs: speed up shrinking extent_node cache Jaegeuk Kim
2016-01-25 22:05 ` [PATCH 2/6] f2fs: give scheduling point in shrinking path Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` [PATCH 3/6] f2fs: do f2fs_balance_fs when block is allocated Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
2016-01-25 22:05 ` [PATCH 4/6] f2fs: avoid multiple node page writes due to inline_data Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
2016-01-26 5:41 ` [f2fs-dev] " Chao Yu
2016-01-26 5:41 ` Chao Yu
2016-01-26 18:48 ` [f2fs-dev] " Jaegeuk Kim
2016-01-27 6:28 ` Chao Yu
2016-01-25 22:05 ` [PATCH 5/6] f2fs: don't need to sync node page at every time Jaegeuk Kim
2016-01-25 22:05 ` [PATCH 6/6] f2fs: avoid needless sync_inode_page when reading inline_data Jaegeuk Kim
2016-01-25 22:05 ` Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.