linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix memory leak in ext4_init_new_dir
@ 2013-01-11 10:06 Mel Gorman
  2013-01-11 10:12 ` Tao Ma
  0 siblings, 1 reply; 3+ messages in thread
From: Mel Gorman @ 2013-01-11 10:06 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Tao Ma, linux-ext4, linux-kernel

Commit a774f9c2 "ext4: make ext4_init_dot_dotdot for inline dir usage"
is a preparation cleanup for later ext4 patches but there was a snag
when moving code to the newly created ext4_init_new_dir() function.
ext4_bread() is called twice but brelse() is only called one leading to a
memory leak. The user-visible effect is that after a compile-orientated
benchmark 0% of memory could be allocated as transparent huge pages.
This patch deletes the extra call and after it is applied, 76% of memory
could be allocated after the same test.

Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 fs/ext4/namei.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 8990165..d068885 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2368,7 +2368,6 @@ static int ext4_init_new_dir(handle_t *handle, struct inode *dir,
 	}
 
 	inode->i_size = EXT4_I(inode)->i_disksize = blocksize;
-	dir_block = ext4_bread(handle, inode, 0, 1, &err);
 	if (!(dir_block = ext4_bread(handle, inode, 0, 1, &err))) {
 		if (!err) {
 			err = -EIO;

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

* Re: [PATCH] ext4: Fix memory leak in ext4_init_new_dir
  2013-01-11 10:06 [PATCH] ext4: Fix memory leak in ext4_init_new_dir Mel Gorman
@ 2013-01-11 10:12 ` Tao Ma
  2013-01-11 10:30   ` Mel Gorman
  0 siblings, 1 reply; 3+ messages in thread
From: Tao Ma @ 2013-01-11 10:12 UTC (permalink / raw)
  To: Mel Gorman; +Cc: Theodore Ts'o, Tao Ma, linux-ext4, linux-kernel

Hi Mel,

Thanks for the report.

This bug is already spotted by Guo Chao and the patch has been accepted
by Ted already.

Thanks,
Tao
On 01/11/2013 06:06 PM, Mel Gorman wrote:
> Commit a774f9c2 "ext4: make ext4_init_dot_dotdot for inline dir usage"
> is a preparation cleanup for later ext4 patches but there was a snag
> when moving code to the newly created ext4_init_new_dir() function.
> ext4_bread() is called twice but brelse() is only called one leading to a
> memory leak. The user-visible effect is that after a compile-orientated
> benchmark 0% of memory could be allocated as transparent huge pages.
> This patch deletes the extra call and after it is applied, 76% of memory
> could be allocated after the same test.
> 
> Signed-off-by: Mel Gorman <mgorman@suse.de>
> ---
>  fs/ext4/namei.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 8990165..d068885 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2368,7 +2368,6 @@ static int ext4_init_new_dir(handle_t *handle, struct inode *dir,
>  	}
>  
>  	inode->i_size = EXT4_I(inode)->i_disksize = blocksize;
> -	dir_block = ext4_bread(handle, inode, 0, 1, &err);
>  	if (!(dir_block = ext4_bread(handle, inode, 0, 1, &err))) {
>  		if (!err) {
>  			err = -EIO;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


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

* Re: [PATCH] ext4: Fix memory leak in ext4_init_new_dir
  2013-01-11 10:12 ` Tao Ma
@ 2013-01-11 10:30   ` Mel Gorman
  0 siblings, 0 replies; 3+ messages in thread
From: Mel Gorman @ 2013-01-11 10:30 UTC (permalink / raw)
  To: Tao Ma; +Cc: Theodore Ts'o, Tao Ma, linux-ext4, linux-kernel

On Fri, Jan 11, 2013 at 06:12:17PM +0800, Tao Ma wrote:
> Hi Mel,
> 
> Thanks for the report.
> 
> This bug is already spotted by Guo Chao and the patch has been accepted
> by Ted already.
> 

Ah grand, I see now that it was merged for 3.8-rc3. Thanks for the heads up.

-- 
Mel Gorman
SUSE Labs

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

end of thread, other threads:[~2013-01-11 10:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 10:06 [PATCH] ext4: Fix memory leak in ext4_init_new_dir Mel Gorman
2013-01-11 10:12 ` Tao Ma
2013-01-11 10:30   ` Mel Gorman

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