Re: [f2fs-dev] [PATCH 3/5] f2fs: control the memory footprint used by ino entries
On Sat, Nov 08, 2014 at 11:36:07PM -0800, Jaegeuk Kim wrote: This patch adds to control the memory footprint used by ino entries. This will conduct best effort, not strictly. Signed-off-by: Jaegeuk Kim jaeg...@kernel.org --- fs/f2fs/node.c| 28 ++-- fs/f2fs/node.h| 3 ++- fs/f2fs/segment.c | 3 ++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 44b8afe..4ea2c47 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -31,22 +31,38 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) { struct f2fs_nm_info *nm_i = NM_I(sbi); struct sysinfo val; + unsigned long avail_ram; unsigned long mem_size = 0; bool res = false; si_meminfo(val); - /* give 25%, 25%, 50% memory for each components respectively */ + + /* only uses low memory */ + avail_ram = val.totalram - val.totalhigh; + + /* give 25%, 25%, 50%, 50% memory for each components respectively */ Hi Jaegeuk, The memory usage of nm_i should be 100% but it's 125%. Mistake or intended? if (type == FREE_NIDS) { - mem_size = (nm_i-fcnt * sizeof(struct free_nid)) 12; - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 2); + mem_size = (nm_i-fcnt * sizeof(struct free_nid)) + PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 2); } else if (type == NAT_ENTRIES) { - mem_size = (nm_i-nat_cnt * sizeof(struct nat_entry)) 12; - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 2); + mem_size = (nm_i-nat_cnt * sizeof(struct nat_entry)) + PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 2); } else if (type == DIRTY_DENTS) { if (sbi-sb-s_bdi-dirty_exceeded) return false; mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 1); + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 1); + } else if (type == INO_ENTRIES) { + int i; + + if (sbi-sb-s_bdi-dirty_exceeded) + return false; + for (i = 0; i = UPDATE_INO; i++) + mem_size += (sbi-ino_num[i] * sizeof(struct ino_entry)) + PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 1); } return res; } diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index acb71e5..d10b644 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h @@ -106,7 +106,8 @@ static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne, enum mem_type { FREE_NIDS, /* indicates the free nid list */ NAT_ENTRIES,/* indicates the cached nat entry */ - DIRTY_DENTS /* indicates dirty dentry pages */ + DIRTY_DENTS,/* indicates dirty dentry pages */ + INO_ENTRIES,/* indicates inode entries */ }; struct nat_entry_set { diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 16721b5d..e094675 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -276,7 +276,8 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) { /* check the # of cached NAT entries and prefree segments */ if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || - excess_prefree_segs(sbi)) + excess_prefree_segs(sbi) || + available_free_memory(sbi, INO_ENTRIES)) f2fs_sync_fs(sbi-sb, true); } -- 2.1.1 -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] Don't merge not sended patches
Hi Jaegeuk, I've found new 2 patches when I pull f2fs-tools. The patches didn't show in mailing list. I think although patches is very trivial, it should be reported through our mailing list. Thanks, Changman -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] Don't merge not sended patches
Ya, I'll do as much as possible. I missed sending patches sometimes. But, here we have been facing with a problem that there have been no reviewers and no comments on f2fs-tools for a long time. Check the commit history. At least, thus, I hope we need to focus on activation of this mailing list first rather than saying *do something*. Thanks, On Mon, Nov 10, 2014 at 01:12:44PM +0900, Changman Lee wrote: Hi Jaegeuk, I've found new 2 patches when I pull f2fs-tools. The patches didn't show in mailing list. I think although patches is very trivial, it should be reported through our mailing list. Thanks, Changman -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/5] f2fs: control the memory footprint used by ino entries
On Mon, Nov 10, 2014 at 12:28:34PM +0900, Changman Lee wrote: On Sat, Nov 08, 2014 at 11:36:07PM -0800, Jaegeuk Kim wrote: This patch adds to control the memory footprint used by ino entries. This will conduct best effort, not strictly. Signed-off-by: Jaegeuk Kim jaeg...@kernel.org --- fs/f2fs/node.c| 28 ++-- fs/f2fs/node.h| 3 ++- fs/f2fs/segment.c | 3 ++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 44b8afe..4ea2c47 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -31,22 +31,38 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) { struct f2fs_nm_info *nm_i = NM_I(sbi); struct sysinfo val; + unsigned long avail_ram; unsigned long mem_size = 0; bool res = false; si_meminfo(val); - /* give 25%, 25%, 50% memory for each components respectively */ + + /* only uses low memory */ + avail_ram = val.totalram - val.totalhigh; + + /* give 25%, 25%, 50%, 50% memory for each components respectively */ Hi Jaegeuk, The memory usage of nm_i should be 100% but it's 125%. Mistake or intended? I contemplated whether this 100% was an exact number that we expected. The answer was NO, since this number was just an estimated one. There were no strict constrains to limit memory footprints even the previous codes were used whatever 25%, 25%, and 50%. So, here, I'd like to add additional threshold for INO_ENTRIES on a basis of the given threshold. In addition, I don't want to add any complex equations to satisfy 100% at all. It's meaningless. Thanks, if (type == FREE_NIDS) { - mem_size = (nm_i-fcnt * sizeof(struct free_nid)) 12; - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 2); + mem_size = (nm_i-fcnt * sizeof(struct free_nid)) + PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 2); } else if (type == NAT_ENTRIES) { - mem_size = (nm_i-nat_cnt * sizeof(struct nat_entry)) 12; - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 2); + mem_size = (nm_i-nat_cnt * sizeof(struct nat_entry)) + PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 2); } else if (type == DIRTY_DENTS) { if (sbi-sb-s_bdi-dirty_exceeded) return false; mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); - res = mem_size ((val.totalram * nm_i-ram_thresh / 100) 1); + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 1); + } else if (type == INO_ENTRIES) { + int i; + + if (sbi-sb-s_bdi-dirty_exceeded) + return false; + for (i = 0; i = UPDATE_INO; i++) + mem_size += (sbi-ino_num[i] * sizeof(struct ino_entry)) +PAGE_CACHE_SHIFT; + res = mem_size ((avail_ram * nm_i-ram_thresh / 100) 1); } return res; } diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index acb71e5..d10b644 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h @@ -106,7 +106,8 @@ static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne, enum mem_type { FREE_NIDS, /* indicates the free nid list */ NAT_ENTRIES,/* indicates the cached nat entry */ - DIRTY_DENTS /* indicates dirty dentry pages */ + DIRTY_DENTS,/* indicates dirty dentry pages */ + INO_ENTRIES,/* indicates inode entries */ }; struct nat_entry_set { diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 16721b5d..e094675 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -276,7 +276,8 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) { /* check the # of cached NAT entries and prefree segments */ if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || - excess_prefree_segs(sbi)) + excess_prefree_segs(sbi) || + available_free_memory(sbi, INO_ENTRIES)) f2fs_sync_fs(sbi-sb, true); } -- 2.1.1 -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH] f2fs: implement -o dirsync
If a mount option has dirsync, we should call checkpoint for all the directory operations. Signed-off-by: Jaegeuk Kim jaeg...@kernel.org --- fs/f2fs/namei.c | 24 1 file changed, 24 insertions(+) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 6312dd2..db3ee09 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -138,6 +138,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, stat_inc_inline_inode(inode); d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: handle_failed_inode(inode); @@ -164,6 +167,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, f2fs_unlock_op(sbi); d_instantiate(dentry, inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: clear_inode_flag(F2FS_I(inode), FI_INC_LINK); @@ -233,6 +239,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) f2fs_delete_entry(de, page, dir, inode); f2fs_unlock_op(sbi); + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); + /* In order to evict this inode, we set it dirty */ mark_inode_dirty(inode); fail: @@ -268,6 +277,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return err; out: handle_failed_inode(inode); @@ -304,6 +316,8 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) d_instantiate(dentry, inode); unlock_new_inode(inode); + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out_fail: @@ -346,8 +360,12 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, f2fs_unlock_op(sbi); alloc_nid_done(sbi, inode-i_ino); + d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: handle_failed_inode(inode); @@ -461,6 +479,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } f2fs_unlock_op(sbi); + + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; put_out_dir: @@ -600,6 +621,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, update_inode_page(new_dir); f2fs_unlock_op(sbi); + + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out_undo: /* Still we may fail to recover name info of f2fs_inode here */ -- 2.1.1 -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] Don't merge not sended patches
I agree. Next time, I'll remember to send the patches to this list. On Mon, Nov 10, 2014 at 01:12:44PM +0900, Changman Lee wrote: Hi Jaegeuk, I've found new 2 patches when I pull f2fs-tools. The patches didn't show in mailing list. I think although patches is very trivial, it should be reported through our mailing list. -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 4/5] f2fs: write node pages if checkpoint is not doing
On Sat, Nov 08, 2014 at 11:36:08PM -0800, Jaegeuk Kim wrote: It needs to write node pages if checkpoint is not doing in order to avoid memory pressure. Signed-off-by: Jaegeuk Kim jaeg...@kernel.org --- fs/f2fs/node.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 4ea2c47..6f514fb 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1314,10 +1314,12 @@ static int f2fs_write_node_page(struct page *page, return 0; } - if (wbc-for_reclaim) - goto redirty_out; - - down_read(sbi-node_write); + if (wbc-for_reclaim) { + if (!down_read_trylock(sbi-node_write)) + goto redirty_out; Previously, we skipped write_page for reclaim path, but from now on, we will write out node page to reclaim memory at any time except checkpoint. We should remember it may occur to break merging bio. Got it. Reviewed-by: Changman Lee cm224@samsung.com + } else { + down_read(sbi-node_write); + } set_page_writeback(page); write_node_page(sbi, page, fio, nid, ni.blk_addr, new_addr); set_node_addr(sbi, ni, new_addr, is_fsync_dnode(page)); -- 2.1.1 -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: implement -o dirsync
On Sun, Nov 09, 2014 at 10:24:22PM -0800, Jaegeuk Kim wrote: If a mount option has dirsync, we should call checkpoint for all the directory operations. Signed-off-by: Jaegeuk Kim jaeg...@kernel.org --- fs/f2fs/namei.c | 24 1 file changed, 24 insertions(+) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 6312dd2..db3ee09 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -138,6 +138,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, stat_inc_inline_inode(inode); d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: handle_failed_inode(inode); @@ -164,6 +167,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, f2fs_unlock_op(sbi); d_instantiate(dentry, inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: clear_inode_flag(F2FS_I(inode), FI_INC_LINK); @@ -233,6 +239,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) f2fs_delete_entry(de, page, dir, inode); f2fs_unlock_op(sbi); + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); + /* In order to evict this inode, we set it dirty */ mark_inode_dirty(inode); Let's move it below mark_inode_dirty. After sync, it's unnecessary inserting inode into dirty_list. fail: @@ -268,6 +277,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return err; out: handle_failed_inode(inode); @@ -304,6 +316,8 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) d_instantiate(dentry, inode); unlock_new_inode(inode); + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out_fail: @@ -346,8 +360,12 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, f2fs_unlock_op(sbi); alloc_nid_done(sbi, inode-i_ino); + d_instantiate(dentry, inode); unlock_new_inode(inode); + + if (IS_DIRSYNC(dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out: handle_failed_inode(inode); @@ -461,6 +479,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } f2fs_unlock_op(sbi); + + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; put_out_dir: @@ -600,6 +621,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, update_inode_page(new_dir); f2fs_unlock_op(sbi); + + if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) + f2fs_sync_fs(sbi-sb, 1); return 0; out_undo: /* Still we may fail to recover name info of f2fs_inode here */ -- 2.1.1 -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel