All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: zoned: free zone_cache when freeing zone_info
@ 2021-12-03 11:12 Johannes Thumshirn
  2021-12-06  4:33 ` Naohiro Aota
  2021-12-06 17:00 ` David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2021-12-03 11:12 UTC (permalink / raw)
  To: David Sterba; +Cc: Johannes Thumshirn, linux-btrfs, Naohiro Aota

Kmemleak was reporting the following memory leak on fstests btrfs/224 on my
zoned test setup:

 unreferenced object 0xffffc900001a9000 (size 4096):
   comm "mount", pid 1781, jiffies 4295339102 (age 5.740s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00  ................
     00 00 08 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000b0ef6261>] __vmalloc_node_range+0x240/0x3d0
     [<00000000aa06ac88>] vzalloc+0x3c/0x50
     [<000000001824c35c>] btrfs_get_dev_zone_info+0x426/0x7e0 [btrfs]
     [<0000000004ba8d9d>] btrfs_get_dev_zone_info_all_devices+0x52/0x80 [btrfs]
     [<0000000054bc27eb>] open_ctree+0x1022/0x1709 [btrfs]
     [<0000000074fe7dc0>] btrfs_mount_root.cold+0x13/0xe5 [btrfs]
     [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
     [<00000000ce480896>] vfs_get_tree+0x1b/0x80
     [<000000006423c6bd>] vfs_kern_mount.part.0+0x6c/0xa0
     [<000000003cf6fc28>] btrfs_mount+0x10d/0x380 [btrfs]
     [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
     [<00000000ce480896>] vfs_get_tree+0x1b/0x80
     [<00000000995da674>] path_mount+0x6b6/0xa10
     [<00000000a5b4b6ec>] __x64_sys_mount+0xde/0x110
     [<00000000fe985c23>] do_syscall_64+0x43/0x90
     [<00000000c6071ff4>] entry_SYSCALL_64_after_hwframe+0x44/0xae

The allocated object in question is the zone_cache.

Free it when freeing a btrfs_device's zone_info.

Cc: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/zoned.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index c917867a4261..fc9c6ae7bc00 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -612,6 +612,7 @@ void btrfs_destroy_dev_zone_info(struct btrfs_device *device)
 	bitmap_free(zone_info->active_zones);
 	bitmap_free(zone_info->seq_zones);
 	bitmap_free(zone_info->empty_zones);
+	vfree(zone_info->zone_cache);
 	kfree(zone_info);
 	device->zone_info = NULL;
 }
-- 
2.31.1


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

* Re: [PATCH] btrfs: zoned: free zone_cache when freeing zone_info
  2021-12-03 11:12 [PATCH] btrfs: zoned: free zone_cache when freeing zone_info Johannes Thumshirn
@ 2021-12-06  4:33 ` Naohiro Aota
  2021-12-06 17:00 ` David Sterba
  1 sibling, 0 replies; 4+ messages in thread
From: Naohiro Aota @ 2021-12-06  4:33 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs

On Fri, Dec 03, 2021 at 03:12:27AM -0800, Johannes Thumshirn wrote:
> Kmemleak was reporting the following memory leak on fstests btrfs/224 on my
> zoned test setup:
> 
>  unreferenced object 0xffffc900001a9000 (size 4096):
>    comm "mount", pid 1781, jiffies 4295339102 (age 5.740s)
>    hex dump (first 32 bytes):
>      00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00  ................
>      00 00 08 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
>    backtrace:
>      [<00000000b0ef6261>] __vmalloc_node_range+0x240/0x3d0
>      [<00000000aa06ac88>] vzalloc+0x3c/0x50
>      [<000000001824c35c>] btrfs_get_dev_zone_info+0x426/0x7e0 [btrfs]
>      [<0000000004ba8d9d>] btrfs_get_dev_zone_info_all_devices+0x52/0x80 [btrfs]
>      [<0000000054bc27eb>] open_ctree+0x1022/0x1709 [btrfs]
>      [<0000000074fe7dc0>] btrfs_mount_root.cold+0x13/0xe5 [btrfs]
>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>      [<000000006423c6bd>] vfs_kern_mount.part.0+0x6c/0xa0
>      [<000000003cf6fc28>] btrfs_mount+0x10d/0x380 [btrfs]
>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>      [<00000000995da674>] path_mount+0x6b6/0xa10
>      [<00000000a5b4b6ec>] __x64_sys_mount+0xde/0x110
>      [<00000000fe985c23>] do_syscall_64+0x43/0x90
>      [<00000000c6071ff4>] entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> The allocated object in question is the zone_cache.
> 
> Free it when freeing a btrfs_device's zone_info.
> 
> Cc: Naohiro Aota <naohiro.aota@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Ah, I forgot to do that.

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>

> ---
>  fs/btrfs/zoned.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index c917867a4261..fc9c6ae7bc00 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -612,6 +612,7 @@ void btrfs_destroy_dev_zone_info(struct btrfs_device *device)
>  	bitmap_free(zone_info->active_zones);
>  	bitmap_free(zone_info->seq_zones);
>  	bitmap_free(zone_info->empty_zones);
> +	vfree(zone_info->zone_cache);
>  	kfree(zone_info);
>  	device->zone_info = NULL;
>  }
> -- 
> 2.31.1
> 

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

* Re: [PATCH] btrfs: zoned: free zone_cache when freeing zone_info
  2021-12-03 11:12 [PATCH] btrfs: zoned: free zone_cache when freeing zone_info Johannes Thumshirn
  2021-12-06  4:33 ` Naohiro Aota
@ 2021-12-06 17:00 ` David Sterba
  2021-12-06 17:32   ` Johannes Thumshirn
  1 sibling, 1 reply; 4+ messages in thread
From: David Sterba @ 2021-12-06 17:00 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs, Naohiro Aota

On Fri, Dec 03, 2021 at 03:12:27AM -0800, Johannes Thumshirn wrote:
> Kmemleak was reporting the following memory leak on fstests btrfs/224 on my
> zoned test setup:
> 
>  unreferenced object 0xffffc900001a9000 (size 4096):
>    comm "mount", pid 1781, jiffies 4295339102 (age 5.740s)
>    hex dump (first 32 bytes):
>      00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00  ................
>      00 00 08 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
>    backtrace:
>      [<00000000b0ef6261>] __vmalloc_node_range+0x240/0x3d0
>      [<00000000aa06ac88>] vzalloc+0x3c/0x50
>      [<000000001824c35c>] btrfs_get_dev_zone_info+0x426/0x7e0 [btrfs]
>      [<0000000004ba8d9d>] btrfs_get_dev_zone_info_all_devices+0x52/0x80 [btrfs]
>      [<0000000054bc27eb>] open_ctree+0x1022/0x1709 [btrfs]
>      [<0000000074fe7dc0>] btrfs_mount_root.cold+0x13/0xe5 [btrfs]
>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>      [<000000006423c6bd>] vfs_kern_mount.part.0+0x6c/0xa0
>      [<000000003cf6fc28>] btrfs_mount+0x10d/0x380 [btrfs]
>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>      [<00000000995da674>] path_mount+0x6b6/0xa10
>      [<00000000a5b4b6ec>] __x64_sys_mount+0xde/0x110
>      [<00000000fe985c23>] do_syscall_64+0x43/0x90
>      [<00000000c6071ff4>] entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> The allocated object in question is the zone_cache.
> 
> Free it when freeing a btrfs_device's zone_info.
> 
> Cc: Naohiro Aota <naohiro.aota@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/zoned.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index c917867a4261..fc9c6ae7bc00 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -612,6 +612,7 @@ void btrfs_destroy_dev_zone_info(struct btrfs_device *device)
>  	bitmap_free(zone_info->active_zones);
>  	bitmap_free(zone_info->seq_zones);
>  	bitmap_free(zone_info->empty_zones);
> +	vfree(zone_info->zone_cache);
>  	kfree(zone_info);
>  	device->zone_info = NULL;

This is the exact sequence that's at the end of btrfs_get_dev_zone_info
(that had the vfree call), please clean it up so there's only the helper
called from btrfs_get_dev_zone_info.

The zone_cache is also pending for some stable backport so please add
the Fixes: tag. Thanks.

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

* Re: [PATCH] btrfs: zoned: free zone_cache when freeing zone_info
  2021-12-06 17:00 ` David Sterba
@ 2021-12-06 17:32   ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2021-12-06 17:32 UTC (permalink / raw)
  To: dsterba; +Cc: David Sterba, linux-btrfs, Naohiro Aota

On 06/12/2021 18:01, David Sterba wrote:
> On Fri, Dec 03, 2021 at 03:12:27AM -0800, Johannes Thumshirn wrote:
>> Kmemleak was reporting the following memory leak on fstests btrfs/224 on my
>> zoned test setup:
>>
>>  unreferenced object 0xffffc900001a9000 (size 4096):
>>    comm "mount", pid 1781, jiffies 4295339102 (age 5.740s)
>>    hex dump (first 32 bytes):
>>      00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00  ................
>>      00 00 08 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
>>    backtrace:
>>      [<00000000b0ef6261>] __vmalloc_node_range+0x240/0x3d0
>>      [<00000000aa06ac88>] vzalloc+0x3c/0x50
>>      [<000000001824c35c>] btrfs_get_dev_zone_info+0x426/0x7e0 [btrfs]
>>      [<0000000004ba8d9d>] btrfs_get_dev_zone_info_all_devices+0x52/0x80 [btrfs]
>>      [<0000000054bc27eb>] open_ctree+0x1022/0x1709 [btrfs]
>>      [<0000000074fe7dc0>] btrfs_mount_root.cold+0x13/0xe5 [btrfs]
>>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>>      [<000000006423c6bd>] vfs_kern_mount.part.0+0x6c/0xa0
>>      [<000000003cf6fc28>] btrfs_mount+0x10d/0x380 [btrfs]
>>      [<00000000a54ca18b>] legacy_get_tree+0x22/0x40
>>      [<00000000ce480896>] vfs_get_tree+0x1b/0x80
>>      [<00000000995da674>] path_mount+0x6b6/0xa10
>>      [<00000000a5b4b6ec>] __x64_sys_mount+0xde/0x110
>>      [<00000000fe985c23>] do_syscall_64+0x43/0x90
>>      [<00000000c6071ff4>] entry_SYSCALL_64_after_hwframe+0x44/0xae
>>
>> The allocated object in question is the zone_cache.
>>
>> Free it when freeing a btrfs_device's zone_info.
>>
>> Cc: Naohiro Aota <naohiro.aota@wdc.com>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> ---
>>  fs/btrfs/zoned.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
>> index c917867a4261..fc9c6ae7bc00 100644
>> --- a/fs/btrfs/zoned.c
>> +++ b/fs/btrfs/zoned.c
>> @@ -612,6 +612,7 @@ void btrfs_destroy_dev_zone_info(struct btrfs_device *device)
>>  	bitmap_free(zone_info->active_zones);
>>  	bitmap_free(zone_info->seq_zones);
>>  	bitmap_free(zone_info->empty_zones);
>> +	vfree(zone_info->zone_cache);
>>  	kfree(zone_info);
>>  	device->zone_info = NULL;
> 
> This is the exact sequence that's at the end of btrfs_get_dev_zone_info
> (that had the vfree call), please clean it up so there's only the helper
> called from btrfs_get_dev_zone_info.
> 
> The zone_cache is also pending for some stable backport so please add
> the Fixes: tag. Thanks.
> 

Will do

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

end of thread, other threads:[~2021-12-06 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 11:12 [PATCH] btrfs: zoned: free zone_cache when freeing zone_info Johannes Thumshirn
2021-12-06  4:33 ` Naohiro Aota
2021-12-06 17:00 ` David Sterba
2021-12-06 17:32   ` Johannes Thumshirn

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.