* [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued
@ 2025-11-04 10:43 Christoph Hellwig
2025-11-04 16:59 ` Darrick J. Wong
2025-11-06 13:27 ` Carlos Maiolino
0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-11-04 10:43 UTC (permalink / raw)
To: cem; +Cc: djwong, linux-xfs
kmemleak occasionally reports leaking xfs_busy_extents structure
from xfs_scrub calls after running xfs/528 (but attributed to following
tests), which seems to be caused by not freeing the xfs_busy_extents
structure when tr.queued is 0 and xfs_trim_rtgroup_extents breaks out
of the main loop. Free the structure in this case.
Fixes: a3315d11305f ("xfs: use rtgroup busy extent list for FITRIM")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_discard.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index ee49f20875af..6917de832191 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -726,8 +726,10 @@ xfs_trim_rtgroup_extents(
break;
}
- if (!tr.queued)
+ if (!tr.queued) {
+ kfree(tr.extents);
break;
+ }
/*
* We hand the extent list to the discard function here so the
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued
2025-11-04 10:43 [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued Christoph Hellwig
@ 2025-11-04 16:59 ` Darrick J. Wong
2025-11-05 19:45 ` Christoph Hellwig
2025-11-06 13:27 ` Carlos Maiolino
1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2025-11-04 16:59 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: cem, linux-xfs
On Tue, Nov 04, 2025 at 05:43:01AM -0500, Christoph Hellwig wrote:
> kmemleak occasionally reports leaking xfs_busy_extents structure
> from xfs_scrub calls after running xfs/528 (but attributed to following
> tests), which seems to be caused by not freeing the xfs_busy_extents
> structure when tr.queued is 0 and xfs_trim_rtgroup_extents breaks out
> of the main loop. Free the structure in this case.
>
> Fixes: a3315d11305f ("xfs: use rtgroup busy extent list for FITRIM")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Yep, this fixes a memory leak. I wonder if you could combine the two
into:
if (error || !tr.queued) {
kfree(tr.extents);
break;
}
But I don't care passionately either way.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_discard.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index ee49f20875af..6917de832191 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -726,8 +726,10 @@ xfs_trim_rtgroup_extents(
> break;
> }
>
> - if (!tr.queued)
> + if (!tr.queued) {
> + kfree(tr.extents);
> break;
> + }
>
> /*
> * We hand the extent list to the discard function here so the
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued
2025-11-04 16:59 ` Darrick J. Wong
@ 2025-11-05 19:45 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-11-05 19:45 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Christoph Hellwig, cem, linux-xfs
On Tue, Nov 04, 2025 at 08:59:19AM -0800, Darrick J. Wong wrote:
> Yep, this fixes a memory leak. I wonder if you could combine the two
> into:
>
> if (error || !tr.queued) {
> kfree(tr.extents);
> break;
> }
>
> But I don't care passionately either way.
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
I'd rather keep the fix minimal for now, but yes, otherwise that would
work as well.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued
2025-11-04 10:43 [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued Christoph Hellwig
2025-11-04 16:59 ` Darrick J. Wong
@ 2025-11-06 13:27 ` Carlos Maiolino
1 sibling, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2025-11-06 13:27 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: djwong, linux-xfs
On Tue, 04 Nov 2025 05:43:01 -0500, Christoph Hellwig wrote:
> kmemleak occasionally reports leaking xfs_busy_extents structure
> from xfs_scrub calls after running xfs/528 (but attributed to following
> tests), which seems to be caused by not freeing the xfs_busy_extents
> structure when tr.queued is 0 and xfs_trim_rtgroup_extents breaks out
> of the main loop. Free the structure in this case.
>
>
> [...]
Applied to for-next, thanks!
[1/1] xfs: free xfs_busy_extents structure when no RT extents are queued
commit: d8a823c6f04ef03e3bd7249d2e796da903e7238d
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-06 13:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 10:43 [PATCH] xfs: free xfs_busy_extents structure when no RT extents are queued Christoph Hellwig
2025-11-04 16:59 ` Darrick J. Wong
2025-11-05 19:45 ` Christoph Hellwig
2025-11-06 13:27 ` Carlos Maiolino
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).