xfs: free xfs_busy_extents structure when no RT extents are queued
PATCH 1/1 xfs: free xfs_busy_extents structure when no RT extents are queued
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.
--- fs/xfs/xfs_discard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/xfs/xfs_discard.c +3 -1
@@ -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
Signature · 1 line
2.47.3
Quoted 8 lines · Christoph Hellwig
kmemleak occasionally reports leaking
xfs_busy_extentsstructure fromxfs_scrubcalls after running xfs/528 (but attributed to following tests), which seems to be caused by not freeing thexfs_busy_extentsstructure when tr.queued is 0 andxfs_trim_rtgroup_extentsbreaks 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 <[email protected]>
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.
--D
Quoted 24 lines
--- fs/xfs/xfs_discard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/xfs/xfs_discard.c +3
-1@@ -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 Signature · 1 line
2.47.3
Quoted 10 lines · Darrick J. Wong
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" <[email protected]>
I'd rather keep the fix minimal for now, but yes, otherwise that would work as well.
Quoted 8 lines · Christoph Hellwig
kmemleak occasionally reports leaking
xfs_busy_extentsstructure fromxfs_scrubcalls after running xfs/528 (but attributed to following tests), which seems to be caused by not freeing thexfs_busy_extentsstructure when tr.queued is 0 andxfs_trim_rtgroup_extentsbreaks 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,
Signature · 1 line
Carlos Maiolino <[email protected]>