]> git.hungrycats.org Git - linux/commitdiff
remap-balance-leak: cover letter (draft for Zygo's review)
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 10 Nov 2026 04:28:19 +0000 (23:28 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 10 Nov 2026 04:28:19 +0000 (23:28 -0500)
The series is one patch.  The README convention (every series has a
cover, single-patch ones included) gives it a 0/1 cover; export.sh now
keeps it, so the patch becomes [PATCH 1/1].  Headers, shortlog and
diffstat are from an export.sh dry run against misc-next testing
5fa1c4f82174 (verified, no base-commit), so the next re-export changes
only the Date: lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
topics/remap-balance-leak/0000-cover-letter.patch [new file with mode: 0644]
topics/remap-balance-leak/0001-btrfs-free-queued-remap-chunks-when-balance-bails-ou.patch

diff --git a/topics/remap-balance-leak/0000-cover-letter.patch b/topics/remap-balance-leak/0000-cover-letter.patch
new file mode 100644 (file)
index 0000000..c55aadc
--- /dev/null
@@ -0,0 +1,37 @@
+From d0136e6493082d001aa33ed4174dae6062abb49a Mon Sep 17 00:00:00 2001
+From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
+Date: Mon, 9 Nov 2026 23:27:03 -0500
+Subject: [PATCH 0/1] btrfs: free queued remap chunks when balance bails out
+To: linux-btrfs@vger.kernel.org
+
+On a filesystem with the remap tree, a balance that stops early leaks
+memory.  __btrfs_balance() puts each METADATA_REMAP chunk it selects on
+a local list and relocates those chunks only after it has walked all the
+others, in balance_remap_chunks(), which also frees the list entries.  A
+walk that leaves the loop through the error label (a pause or cancel
+request, or an error during the walk) never gets there, and every entry
+queued so far is leaked: one small allocation per selected remap chunk,
+each time a balance is paused, canceled or fails.
+
+The patch frees the leftover entries at the error label.  Nothing else
+needs undoing: the block group lookup, its reference and the read-only
+count are all taken later, in balance_remap_chunks(), so a queued entry
+holds no block group and leaves none read-only.
+
+Tested on KASAN kernels by tracing the allocations and frees of the list
+entries while a full balance on a remap-tree filesystem is paused after
+its walk has queued a remap chunk, then remounted and resumed.  With the
+patch every entry is freed, the paused walk's at the error label;
+without it the paused walk's entry is never freed.  Only the pause is
+driven; cancel and the error exits leave through the same label.
+
+Zygo Blaxell (1):
+  btrfs: free queued remap chunks when balance bails out
+
+ fs/btrfs/volumes.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+
+-- 
+2.47.3
+
index 05ad794a32c18b7366015ea33e112232b0d3b2ef..addc1ba18542b3649c7ac816ddbe292a71a3b52c 100644 (file)
@@ -1,7 +1,7 @@
 From d0136e6493082d001aa33ed4174dae6062abb49a Mon Sep 17 00:00:00 2001
 From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
 Date: Tue, 13 Oct 2026 01:05:21 -0400
-Subject: [PATCH] btrfs: free queued remap chunks when balance bails out
+Subject: [PATCH 1/1] btrfs: free queued remap chunks when balance bails out
 To: linux-btrfs@vger.kernel.org
 
 __btrfs_balance() queues METADATA_REMAP chunks on a local list and
@@ -41,7 +41,6 @@ index 3d4ef6725de0e..788f60910acf5 100644
        if (enospc_errors) {
                btrfs_info(fs_info, "%d enospc errors during balance",
                           enospc_errors);
-
 -- 
 2.47.3