All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix memory leaks in the test test_find_first_clear_extent_bit
@ 2019-08-03  8:53 fdmanana
  2019-08-05 18:05 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2019-08-03  8:53 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

The test creates an extent io tree and sets several ranges with the
CHUNK_ALLOCATED and CHUNK_TRIMMED bits, resulting in the allocation of
several extent state structures. However the test never clears those
ranges, resulting in memory leaks of the extent state structures.

This is detected when CONFIG_BTRFS_DEBUG is set once we remove the
btrfs module (rmmod btrfs):

[57399.787918] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
[57399.790155] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
[57399.791941] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
[57399.793753] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
[57399.795188] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
[57399.796453] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
[57399.797765] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
[57399.799049] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
[57399.800142] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
[57399.801126] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
[57399.802106] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
[57399.803119] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
[57399.804153] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
[57399.805196] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
[57399.806191] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1

The start and end offsets reported correspond exactly to the ranges
used by the test.

So fix that by clearing all the ranges when the test finishes.

Fixes: 1eaebb341d2b41 ("btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/tests/extent-io-tests.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 1bf6b5a79191..705a8a7eb815 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -514,6 +514,8 @@ static int test_find_first_clear_extent_bit(void)
 		"error handling beyond end of range search: start %llu end %llu",
 			start, end);
 
+	clear_extent_bits(&tree, 0, (u64)-1, CHUNK_TRIMMED | CHUNK_ALLOCATED);
+
 	return 0;
 }
 
-- 
2.11.0


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

* Re: [PATCH] Btrfs: fix memory leaks in the test test_find_first_clear_extent_bit
  2019-08-03  8:53 [PATCH] Btrfs: fix memory leaks in the test test_find_first_clear_extent_bit fdmanana
@ 2019-08-05 18:05 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2019-08-05 18:05 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Sat, Aug 03, 2019 at 09:53:16AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> The test creates an extent io tree and sets several ranges with the
> CHUNK_ALLOCATED and CHUNK_TRIMMED bits, resulting in the allocation of
> several extent state structures. However the test never clears those
> ranges, resulting in memory leaks of the extent state structures.
> 
> This is detected when CONFIG_BTRFS_DEBUG is set once we remove the
> btrfs module (rmmod btrfs):
> 
> [57399.787918] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
> [57399.790155] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
> [57399.791941] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
> [57399.793753] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
> [57399.795188] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
> [57399.796453] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
> [57399.797765] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
> [57399.799049] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
> [57399.800142] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
> [57399.801126] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
> [57399.802106] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
> [57399.803119] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
> [57399.804153] BTRFS: state leak: start 67108864 end 75497471 state 1 in tree 1 refs 1
> [57399.805196] BTRFS: state leak: start 33554432 end 67108863 state 33 in tree 1 refs 1
> [57399.806191] BTRFS: state leak: start 1048576 end 4194303 state 33 in tree 1 refs 1
> 
> The start and end offsets reported correspond exactly to the ranges
> used by the test.
> 
> So fix that by clearing all the ranges when the test finishes.
> 
> Fixes: 1eaebb341d2b41 ("btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Added to misc-next, thanks.

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

end of thread, other threads:[~2019-08-05 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-03  8:53 [PATCH] Btrfs: fix memory leaks in the test test_find_first_clear_extent_bit fdmanana
2019-08-05 18:05 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.