--- /dev/null
+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
+
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
if (enospc_errors) {
btrfs_info(fs_info, "%d enospc errors during balance",
enospc_errors);
-
--
2.47.3