linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] f2fs: fix a memleak issue
@ 2017-02-27 13:02 Hou Pengyang
  2017-02-27 13:02 ` [PATCH 2/3] f2fs: add f2fs_drop_inode tracepoint Hou Pengyang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hou Pengyang @ 2017-02-27 13:02 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel

[fix: ae75f0ca76 f2fs: introduce free nid bitmap]
Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/node.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 6d43095..353c01d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -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;
 }
 
-- 
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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] f2fs: add f2fs_drop_inode tracepoint
  2017-02-27 13:02 [PATCH 1/3] f2fs: fix a memleak issue Hou Pengyang
@ 2017-02-27 13:02 ` Hou Pengyang
  2017-02-27 13:02 ` [PATCH 3/3] f2fs: fix a plint compile warning Hou Pengyang
  2017-02-27 13:52 ` [PATCH 1/3] f2fs: fix a memleak issue Kinglong Mee
  2 siblings, 0 replies; 5+ messages in thread
From: Hou Pengyang @ 2017-02-27 13:02 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/super.c             | 7 +++++--
 include/trace/events/f2fs.h | 7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 751e106..746296e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -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)
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index ff31ccf..c80fcad0 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -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),
-- 
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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] f2fs: fix a plint compile warning
  2017-02-27 13:02 [PATCH 1/3] f2fs: fix a memleak issue Hou Pengyang
  2017-02-27 13:02 ` [PATCH 2/3] f2fs: add f2fs_drop_inode tracepoint Hou Pengyang
@ 2017-02-27 13:02 ` Hou Pengyang
  2017-02-27 13:52 ` [PATCH 1/3] f2fs: fix a memleak issue Kinglong Mee
  2 siblings, 0 replies; 5+ messages in thread
From: Hou Pengyang @ 2017-02-27 13:02 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel

fix such pclint warning:
...
Loss of precision (arg. no. 2) (unsigned long long to unsigned int))

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 023f043..418fd98 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -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));
 }
-- 
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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] f2fs: fix a memleak issue
  2017-02-27 13:02 [PATCH 1/3] f2fs: fix a memleak issue Hou Pengyang
  2017-02-27 13:02 ` [PATCH 2/3] f2fs: add f2fs_drop_inode tracepoint Hou Pengyang
  2017-02-27 13:02 ` [PATCH 3/3] f2fs: fix a plint compile warning Hou Pengyang
@ 2017-02-27 13:52 ` Kinglong Mee
  2017-02-28  2:06   ` Hou Pengyang
  2 siblings, 1 reply; 5+ messages in thread
From: Kinglong Mee @ 2017-02-27 13:52 UTC (permalink / raw)
  To: Hou Pengyang; +Cc: jaegeuk, linux-f2fs-devel

On 2/27/2017 21:02, Hou Pengyang wrote:
> [fix: ae75f0ca76 f2fs: introduce free nid bitmap]
> Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
> ---
>  fs/f2fs/node.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 6d43095..353c01d 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -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;
>  }

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] f2fs: fix a memleak issue
  2017-02-27 13:52 ` [PATCH 1/3] f2fs: fix a memleak issue Kinglong Mee
@ 2017-02-28  2:06   ` Hou Pengyang
  0 siblings, 0 replies; 5+ messages in thread
From: Hou Pengyang @ 2017-02-28  2:06 UTC (permalink / raw)
  To: Kinglong Mee; +Cc: jaegeuk, linux-f2fs-devel

On 2017/2/27 21:52, Kinglong Mee wrote:
> On 2/27/2017 21:02, Hou Pengyang wrote:
>> [fix: ae75f0ca76 f2fs: introduce free nid bitmap]
>> Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
>> ---
>>   fs/f2fs/node.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index 6d43095..353c01d 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -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;
>>   }
>
> 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;
>          }
>
>
Yup, I missed it :)
Thank you,

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-28  2:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-27 13:02 [PATCH 1/3] f2fs: fix a memleak issue Hou Pengyang
2017-02-27 13:02 ` [PATCH 2/3] f2fs: add f2fs_drop_inode tracepoint Hou Pengyang
2017-02-27 13:02 ` [PATCH 3/3] f2fs: fix a plint compile warning Hou Pengyang
2017-02-27 13:52 ` [PATCH 1/3] f2fs: fix a memleak issue Kinglong Mee
2017-02-28  2:06   ` Hou Pengyang

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).