linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.de>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Tao Ma <boyu.mt@taobao.com>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ext4: Fix memory leak in ext4_init_new_dir
Date: Fri, 11 Jan 2013 10:06:39 +0000	[thread overview]
Message-ID: <20130111100639.GA3302@suse.de> (raw)

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;

             reply	other threads:[~2013-01-11 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 10:06 Mel Gorman [this message]
2013-01-11 10:12 ` [PATCH] ext4: Fix memory leak in ext4_init_new_dir Tao Ma
2013-01-11 10:30   ` Mel Gorman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130111100639.GA3302@suse.de \
    --to=mgorman@suse.de \
    --cc=boyu.mt@taobao.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).