f2fs: fix a memleak issue
Subsystems (2)
PATCH 1/3 f2fs: fix a memleak issue
--- fs/f2fs/node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/node.c +4 -1
@@ -2650,8 +2650,11 @@ int init_free_nid_cache(struct f2fs_sb_info *sbi) nm_i->nat_block_bitmap =f2fs_kvzalloc (nm_i->nat_blocks /8 ,GFP_KERNEL ); -if (!nm_i->nat_block_bitmap) +if (!nm_i->nat_block_bitmap) { +kvfree (nm_i->free_nid_bitmap);return -ENOMEM ; + } +return 0 ; }
Signature · 6 lines
2.10.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
PATCH 2/3 f2fs: add f2fs_drop_inode tracepoint
--- fs/f2fs/super.c | 7 +++++-- include/trace/events/f2fs.h | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-)
fs/f2fs/super.c +5 -2
@@ -624,6 +624,7 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)static int f2fs_drop_inode (struct inode *inode) { +int ret;/* * This is to avoid a deadlock condition like below. * writeback_single_inode(inode)
@@ -656,10 +657,12 @@ static int f2fs_drop_inode(struct inode *inode)spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); } +trace_f2fs_drop_inode (inode,0 );return 0 ; } - -return generic_drop_inode (inode); + ret =generic_drop_inode (inode); +trace_f2fs_drop_inode (inode, ret); +return ret; }int f2fs_inode_dirtied (struct inode *inode,bool sync)
include/trace/events/f2fs.h +7 -0
@@ -315,6 +315,13 @@ DEFINE_EVENT(f2fs__inode_exit, f2fs_unlink_exit,TP_ARGS (inode, ret) ); +DEFINE_EVENT (f2fs__inode_exit, f2fs_drop_inode, + + TP_PROTO(struct inode *inode, int ret), + +TP_ARGS (inode, ret) +); + DEFINE_EVENT(f2fs__inode, f2fs_truncate, TP_PROTO(struct inode *inode),
Signature · 6 lines
2.10.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
PATCH 3/3 f2fs: fix a plint compile warning
In reply to Hou Pengyangfix such pclint warning:
...
Loss of precision (arg. no. 2) (unsigned long long to unsigned int))
--- fs/f2fs/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +1 -1
@@ -1009,6 +1009,6 @@ void build_gc_manager(struct f2fs_sb_info *sbi) ovp_count =SM_I (sbi)->ovp_segments << sbi->log_blocks_per_seg; blocks_per_sec = sbi->blocks_per_seg * sbi->segs_per_sec; - sbi->fggc_threshold =div_u64 ((main_count - ovp_count) * blocks_per_sec, + sbi->fggc_threshold =div64_u64 ((main_count - ovp_count) * blocks_per_sec, (main_count - resv_count)); }
Signature · 6 lines
2.10.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Quoted 12 lines · Hou Pengyang
[fix: ae75f0ca76 f2fs: introduce free nid bitmap]Signed-off-by Hou Pengyang <[email protected]>--- fs/f2fs/node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/f2fs/node.c +0
-0@@ -2650,8 +2650,11 @@ int init_free_nid_cache(struct f2fs_sb_info *sbi)
fs/f2fs/node.c int init_free_nid_cache(struct f2fs_sb_info *sbi) · line 2659
Quoted 10 lines
fs/f2fs/node.c +4
-1nm_i->nat_block_bitmap =f2fs_kvzalloc (nm_i->nat_blocks /8 ,GFP_KERNEL ); -if (!nm_i->nat_block_bitmap) +if (!nm_i->nat_block_bitmap) { +kvfree (nm_i->free_nid_bitmap);return -ENOMEM ; + } +return 0 ; }
If building node manager fail, destroy_node_manager will be called, I think there isn't any memory leak exist, right?
err = build_node_manager(sbi);
if (err) {
f2fs_msg(sb, KERN_ERR,
"Failed to initialize F2FS node manager");
goto free_nm;
}thanks,
Kinglong Mee
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Quoted 27 lines · Kinglong Mee
Quoted 12 lines · Hou Pengyang
[fix: ae75f0ca76 f2fs: introduce free nid bitmap]Signed-off-by Hou Pengyang <[email protected]>--- fs/f2fs/node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/f2fs/node.c +0
-0@@ -2650,8 +2650,11 @@ int init_free_nid_cache(struct f2fs_sb_info *sbi)fs/f2fs/node.c int init_free_nid_cache(struct f2fs_sb_info *sbi) · line 2659
Quoted 10 lines
fs/f2fs/node.c +4
-1nm_i->nat_block_bitmap =f2fs_kvzalloc (nm_i->nat_blocks /8 ,GFP_KERNEL ); -if (!nm_i->nat_block_bitmap) +if (!nm_i->nat_block_bitmap) { +kvfree (nm_i->free_nid_bitmap);return -ENOMEM ; + } +return 0 ; }If building node manager fail,
destroy_node_managerwill be called, I think there isn't any memory leak exist, right?
Quoted 8 lines
err = build_node_manager(sbi);
if (err) {
f2fs_msg(sb, KERN_ERR,
"Failed to initialize F2FS node manager");
goto free_nm;
}Yup, I missed it :)
Thank you,
Quoted 4 lines
thanks,
Kinglong Mee
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot