ext4: Fix memory leak in ext4_init_new_dir
PATCH 1/1 ext4: Fix memory leak in ext4_init_new_dir
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.
--- fs/ext4/namei.c | 1 - 1 file changed, 1 deletion(-)
fs/ext4/namei.c +0 -1
@@ -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 ;
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
Quoted 32 lines · Mel Gorman
Commit
a774f9c2"ext4: makeext4_init_dot_dotdotfor inline dir usage" is a preparation cleanup for later ext4 patches but there was a snag when moving code to the newly createdext4_init_new_dir()function.ext4_bread()is called twice butbrelse()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 <[email protected]>--- fs/ext4/namei.c | 1 - 1 file changed, 1 deletion(-)fs/ext4/namei.c +0
-2@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Tao Ma
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.
Signature · 2 lines
Mel Gorman SUSE Labs