for guesswork, and with the floor described below, this guarantees a
correct balance resume result.
-Patch 2 in this series removes the surprising heuristics and replaces
+Patch 1 in this series removes the surprising heuristics and replaces
them with a `vrange` filter, leaving the remaining filter parameters
unmodified. Before the balance item is written, the vrange filter of
each chunk type is limited to the addresses below the next chunk to be
introduced in 2012, so there is no compatibility issue arising from
its use.
-Patch 1 is an independent fix that showed up in LLM review:
-__btrfs_balance() queues METADATA_REMAP chunks on a local list that
-only balance_remap_chunks() frees, so every early exit from the walk
-(pause, cancel, errors) leaks the entries queued so far. It carries
-a Fixes tag and can go in on its own. Note that this patch only fixes
-the immediately visible memory leak; no other recovery is needed,
-because nothing is done to a queued chunk until balance_remap_chunks(),
-which undoes its own state on failure.
-
Patch 3 is optional. I offer it for completeness, but there's a tradeoff
that might not be worth the cost. It can be dropped without breaking
the rest of the series.
A balance item written by an older kernel has no vrange, so with patch
-2, a balance that starts on an old kernel and resumes on a new kernel
+1, a balance that starts on an old kernel and resumes on a new kernel
restarts from the beginning, redoing much of the work already done.
That behavior may be an unpleasant surprise for some users, so for each
chunk type without a `vrange` filter, patch 3 resumes with the old
started on the patched kernel must get the vrange and no usage filter.
Zygo Blaxell (3):
- btrfs: free queued remap chunks when balance bails out
btrfs: replace the balance resume heuristics with a vrange bound
+ btrfs: write the remaining balance limits back to the balance item
btrfs: keep the old resume filters for balance items without a vrange
fs/btrfs/fs.h | 6 ++
- fs/btrfs/volumes.c | 215 +++++++++++++++++++++++++++++++++++----------
+ fs/btrfs/volumes.c | 255 +++++++++++++++++++++++++++++++++++++--------
fs/btrfs/volumes.h | 6 ++
- 3 files changed, 181 insertions(+), 46 deletions(-)
+ 3 files changed, 221 insertions(+), 46 deletions(-)
--