Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1469683 > unrolled thread

[PATCH 0/6 linux-next] ext4: fix extent leaking and clean-up

Started byFabian Frederick <fabf@skynet.be>
First post2016-08-24 22:10 +0200
Last post2016-08-24 22:10 +0200
Articles 4 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/6 linux-next] ext4: fix extent leaking and clean-up Fabian Frederick <fabf@skynet.be> - 2016-08-24 22:10 +0200
    [PATCH 5/6 linux-next] ext4: remove unused definition Fabian Frederick <fabf@skynet.be> - 2016-08-24 22:10 +0200
    [PATCH 6/6 linux-next] ext4: fix memory leak in ext4_insert_range() Fabian Frederick <fabf@skynet.be> - 2016-08-24 22:10 +0200
    [PATCH 2/6 linux-next] ext4: remove unneeded test in ext4_alloc_file_blocks() Fabian Frederick <fabf@skynet.be> - 2016-08-24 22:10 +0200

#1469683 — [PATCH 0/6 linux-next] ext4: fix extent leaking and clean-up

FromFabian Frederick <fabf@skynet.be>
Date2016-08-24 22:10 +0200
Subject[PATCH 0/6 linux-next] ext4: fix extent leaking and clean-up
Message-ID<s9MEN-7el-13@gated-at.bofh.it>
Last patch of this small patchset fixes an extent path memory leak.
The rest is some clean-up.

Fabian Frederick (6):
  ext4: avoid EXT4_INODE_EXTENTS double checking
  ext4: remove unneeded test in ext4_alloc_file_blocks()
  ext4: create EXT4_MAX_BLOCKS() macro
  ext4: use bool for check in ext4_ext_space_()
  ext4: remove unused definition
  ext4: fix memory leak in ext4_insert_range()

 fs/ext4/ext4.h    |  3 +++
 fs/ext4/extents.c | 70 ++++++++++++++++++++-----------------------------------
 fs/ext4/file.c    |  3 +--
 fs/ext4/ioctl.c   |  2 --
 4 files changed, 29 insertions(+), 49 deletions(-)

-- 
2.8.1

[toc] | [next] | [standalone]


#1469684 — [PATCH 5/6 linux-next] ext4: remove unused definition

FromFabian Frederick <fabf@skynet.be>
Date2016-08-24 22:10 +0200
Subject[PATCH 5/6 linux-next] ext4: remove unused definition
Message-ID<s9MEN-7el-25@gated-at.bofh.it>
In reply to#1469683
MAX_32_NUM isn't used in ext4

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/ext4/ioctl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 10686fd..5a708c87 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -19,8 +19,6 @@
 #include "ext4_jbd2.h"
 #include "ext4.h"
 
-#define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
-
 /**
  * Swap memory between @a and @b for @len bytes.
  *
-- 
2.8.1

[toc] | [prev] | [next] | [standalone]


#1469687 — [PATCH 6/6 linux-next] ext4: fix memory leak in ext4_insert_range()

FromFabian Frederick <fabf@skynet.be>
Date2016-08-24 22:10 +0200
Subject[PATCH 6/6 linux-next] ext4: fix memory leak in ext4_insert_range()
Message-ID<s9MEO-7el-31@gated-at.bofh.it>
In reply to#1469683
Running xfstests generic/013 with kmemleak gives the following:

unreferenced object 0xffff8801d3d27de0 (size 96):
  comm "fsstress", pid 4941, jiffies 4294860168 (age 53.485s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff818eaaf3>] kmemleak_alloc+0x23/0x40
    [<ffffffff81179805>] __kmalloc+0xf5/0x1d0
    [<ffffffff8122ef5c>] ext4_find_extent+0x1ec/0x2f0
    [<ffffffff8123530c>] ext4_insert_range+0x34c/0x4a0
    [<ffffffff81235942>] ext4_fallocate+0x4e2/0x8b0
    [<ffffffff81181334>] vfs_fallocate+0x134/0x210
    [<ffffffff8118203f>] SyS_fallocate+0x3f/0x60
    [<ffffffff818efa9b>] entry_SYSCALL_64_fastpath+0x13/0x8f
    [<ffffffffffffffff>] 0xffffffffffffffff

Problem seems mitigated by dropping refs and freeing path
when there's no path[depth].p_ext

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5b0913d..2774df4 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5711,6 +5711,9 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 			up_write(&EXT4_I(inode)->i_data_sem);
 			goto out_stop;
 		}
+	} else {
+		ext4_ext_drop_refs(path);
+		kfree(path);
 	}
 
 	ret = ext4_es_remove_extent(inode, offset_lblk,
-- 
2.8.1

[toc] | [prev] | [next] | [standalone]


#1469689 — [PATCH 2/6 linux-next] ext4: remove unneeded test in ext4_alloc_file_blocks()

FromFabian Frederick <fabf@skynet.be>
Date2016-08-24 22:10 +0200
Subject[PATCH 2/6 linux-next] ext4: remove unneeded test in ext4_alloc_file_blocks()
Message-ID<s9MEN-7el-27@gated-at.bofh.it>
In reply to#1469683
ext4_alloc_file_blocks() is called from ext4_zero_range() and
ext4_fallocate() both already testing EXT4_INODE_EXTENTS
We can call ext_depth(inode) unconditionnally.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/ext4/extents.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5d9f99a..4f1cca8 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4693,13 +4693,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 	 * credits to insert 1 extent into extent tree
 	 */
 	credits = ext4_chunk_trans_blocks(inode, len);
-	/*
-	 * We can only call ext_depth() on extent based inodes
-	 */
-	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-		depth = ext_depth(inode);
-	else
-		depth = -1;
+	depth = ext_depth(inode);
 
 retry:
 	while (ret >= 0 && len) {
-- 
2.8.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web