]> git.hungrycats.org Git - linux/commitdiff
balance-resume, dev-extent-defrag: recovered items bounded at mount; aligned-holes...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 6 Nov 2026 10:28:30 +0000 (05:28 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 6 Nov 2026 10:28:30 +0000 (05:28 -0500)
balance-resume cover: one sentence on recovered items (vrange added or
lowered, written back once at resume) and the legacy-test bullet.
dev-extent-defrag cover: name patch 2 (aligned holes) in the intro and
the testing paragraph.  Both TESTING.md: the 2026-11-06 round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
topics/balance-resume/0000-cover-letter.patch
topics/balance-resume/TESTING.md
topics/dev-extent-defrag/0000-cover-letter.patch
topics/dev-extent-defrag/TESTING.md

index 825591e93a0bb0f7596f93b0742b86e7e72bf620..eab277914f565c9c3be10f915ab0cff84d8f3672 100644 (file)
@@ -29,7 +29,12 @@ each chunk type is limited to the addresses below the next chunk to be
 allocated (a 0..end range when the request had no vrange, or the end of
 the vrange supplied by userspace, lowered to that address if it is
 higher).  Every block group that existed when the balance started stays
-selected until the balance relocates it.
+selected until the balance relocates it.  A balance item recovered at
+mount is limited the same way (a vrange is added where it has none, as
+in items written by older kernels, and an end beyond the next chunk is
+lowered), and if that changes the item, it is written back once when
+the balance resumes, so a resume that is interrupted again keeps the
+same bound.
 
 New chunks are normally allocated after the last chunk, but relocating the
 highest chunk into free space lower down deletes it without allocating
@@ -109,12 +114,19 @@ Testing (KASAN kernels):
    filesystem needs an --enable-experimental btrfs-progs with a mkfs fix
    for remap-tree to fix a NULL deref bug.
 
- - balance-resume-legacy-test.sh (patch 3 only): data balances paused
-   by a stock 6.12 kernel, then resumed on the patched kernel.  A plain
-   item must resume with usage=90, a convert item with soft, neither
-   with a vrange; an item with a user-given vrange, converting or not,
-   must resume unchanged (no soft, no usage); a balance started on the
-   patched kernel must get the vrange and no usage filter.
+ - balance-resume-legacy-test.sh: data balances paused by a stock 6.12
+   kernel, then resumed on the patched kernel.  Every item must show,
+   already before the resume, a vrange ending at the end of the last
+   chunk: added to a plain or convert item, lowered from a user-given
+   end of 1 TiB or U64_MAX.  With patch 3 a plain item also resumes with
+   usage=90 and a convert item with soft, and an item with a user-given
+   vrange, converting or not, with neither.  The resumed balance is
+   paused again and the filesystem remounted: it must resume with the
+   same bound, and must not relocate the chunks the first resume
+   allocated.  Every chunk the resumes allocate must start at or above
+   the end of the last chunk and stay near it; without the limit, the
+   resume of a 1 TiB item allocates its chunks from 1 TiB up.  A balance
+   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
index 575c0be1efaefde2bc70417689447848d1ec7754..ab59e1656db5cbcaf2e6ede74356390fe08f24c6 100644 (file)
@@ -19,7 +19,10 @@ the block groups that existed below the bound at the pause, each once,
 including the >= 90% full ones that usage=90 would skip, and never a
 chunk the interrupted run created; a legacy item must resume with
 usage=90 (soft for a convert), a legacy item with a vrange must resume
-unchanged, and a paused convert must resume without soft and relocate
+with no other change, and since 2026-11-06 every recovered item must be
+bounded as a new balance would be (a vrange added or lowered to the end
+of the last chunk, written back once at resume); a paused convert must
+resume without soft and relocate
 the target-profile chunks below the bound; a bail-out with queued remap
 chunks must free every entry.
 
@@ -169,6 +172,71 @@ chunk-allocation floor at the stored vend, so the resumed run allocates
 its chunks from 1 TiB up (highest chunk after the resume 1102732853248 /
 1104880336896, and the next balance's bound 1105954078720).  Harmless at
 1 TiB; a user-given vrange end near U64_MAX would put the floor there.
+Fixed in the 2026-11-06 round below.
+
+## 2026-11-06 round (fl1106: recovered items bounded at mount)
+
+Zygo (2026-11-06): a recovered item "should be limited to the
+filesystem's current end (same as if a new balance had been started)",
+and "Items with no vrange get a vrange added, because that's how newer
+kernels resume the balance if it is interrupted again".  Patch 2 now runs
+`limit_balance_to_existing_chunks()` in `btrfs_recover_balance()` before
+the floor is set (the floor is still 0, so the bound is the end of the
+last chunk): a type without a vrange gets 0..end, a vend above end is
+lowered.  If that changed the arguments, `btrfs_balance()` writes them to
+the existing item once when the resume starts (`update_balance_item()`,
+one transaction, before any relocation); an item from a patched kernel
+whose vend is already <= end is not written, so a balance started on a
+patched kernel still writes its item only at insert and delete.  Patch 3
+now decides the legacy filters at recovery, from the on-disk args, before
+the bound is added, and they are written back with it.
+
+A pause and resume without an unmount (ioctl resume) reuses the
+in-memory bctl, bounded at mount or at start, and the floor stays set
+through the pause (`reset_balance_state()` does not run for a paused
+balance), so no clamp is needed there; the ro->rw remount resume uses the
+bctl recovered at mount.  Checked in the code; `balance-resume-test.sh`
+covers the ioctl resume.
+
+Kernels: 6.18 zb64 candidate 876b62099832 (#319, KASAN inline + lockdep
++ BTRFS_ASSERT, bzImage md5 776c478274227a504d1517e3c653835d) on bhive
+and ahive; misc-next zb64 candidate d411e967283c (#68, same options, md5
+2bd866e69d3020906566b9d5fdb52bf5) on dhive and ehive.  Patch 2 alone:
+6.18 zb64 with patch 3 reverted (43931862c049, #6, md5
+d4add82f1212b4af056253e2031b7c54) on ahive.  Negative controls on the
+previous kernels #318 and #67.  Legacy items prepared by stock Debian
+6.12.115 on each rig (6.12 accepts vrange=0..U64_MAX).  Evidence:
+`raid56-wh-harness/forensics/fl1106-618/`, `forensics/fl1106-mn/`.
+
+`balance-resume-legacy-test.sh` now checks, for each variant: `balance
+status -v` after the mount and before the resume shows vrange=0..E (E =
+the end of the last chunk); the resume line shows the same bound and the
+patch 3 filters (or none with LEGACY_P3=0); the resumed balance is paused
+after one block group, the filesystem unmounted and mounted again, and
+the bound must be unchanged (a new bound would be higher); the second
+resume must not relocate the chunks the first one allocated; every chunk
+the resumes allocate starts at or above E and below E + the bytes
+allocated + the image size; for the vrange variants every data chunk
+below E is relocated; a new balance gets a vrange.  New variant
+`vrange-max` (vrange=0..18446744073709551615).
+
+| test | verifies | patch(es) | duration | result | kernel |
+|---|---|---|---|---|---|
+| `balance-resume-legacy-test.sh check plain` | legacy plain item: bounded at mount, usage=90, bound persisted across a second interruption | 2, 3 | 1 min | PASS on all four rigs, e.g. bhive "balance: resume -dusage=90,vrange=0..9685696512" | #319, #68 |
+| `... check convert` | legacy `-dconvert=dup` item: bounded, soft | 2, 3 | 1 min | PASS on all four ("-dconvert=dup,soft,vrange=0..7538212864" on bhive) | #319, #68 |
+| `... check vrange` | user-given vrange=0..1 TiB lowered to E; no usage, no soft; allocations near E | 2 | 1 min | PASS on all four (bhive "-dvrange=0..9685696512") | #319, #68 |
+| `... check convert-vrange` | `-dconvert=dup,vrange=0..1 TiB`: lowered, no soft | 2, 3 | 1 min | PASS on all four | #319, #68 |
+| `... check vrange-max` (new) | vrange end U64_MAX lowered to E | 2 | 2 min | PASS on all four (bhive "-dvrange=0..8611954688"; resume 2 relocated none of the 2 chunks resume 1 allocated) | #319, #68 |
+| same, all 5 variants, `LEGACY_P3=0` | patch 2 alone: bounded and persisted, args otherwise unchanged (no usage, no soft) | 2 | 6 min | PASS 5/5 | 6.18 #6 (patch 3 reverted), ahive |
+| legacy plain/convert/vrange/convert-vrange, negative control | the detector sees the unbounded resume | - | 1 min each | FAIL as expected on #318 (bhive, ahive) and #67 (dhive, ehive): no vrange added, 1 TiB kept, not persisted ("after the second interruption the bound is 'vrange=0..1099511627776'"), allocations reach 1105954078720; usage/soft assertions PASS.  `vrange-max` was not run on the controls | #318, #67 |
+| `balance-resume-convert-test.sh` x2, `balance-resume-test.sh`, `balance-resume-reuse-test.sh` | as above; the bound after a remount is expected to be min(stored end, end of last chunk) | 2 | 1-2 min each | PASS on all four (ahive convert run 2 SKIPped on timing, no "balance: start" line within 5 s; rerun x2 PASS); also PASS on the controls #318 (bhive) and #67 (dhive) | #319, #68 |
+| `remap-balance-resume-test.sh`, `remap-balance-leak-test.sh` | as above | 1, 2 | 2 min each | PASS on #68 (dhive, ehive) and #67 (dhive); SKIP on 6.18 as expected | #68 |
+
+Not covered: in the new-kernel tests the interrupted run always
+allocated, so the bound was never lowered at mount for an item written
+by a patched kernel (the clamp was a no-op there and no write-back
+happened); the lowering and the write-back are exercised by the legacy
+vrange variants.
 
 ## Not covered / open
 
index bad053eb2d37d17c399f06938225acb3b783f9c0..009bab2f63497a24e75181daad77143f98bb0ef6 100644 (file)
@@ -14,7 +14,10 @@ multiply, and the filesystem can end up with hundreds of thousands of
 dev extents at the minimum size.  With all three chunk sizes at 1 GiB
 and device sizes a multiple of 1 GiB plus the reserved 1 MiB, every dev
 extent and every hole is 1 GiB and the fragmentation cannot start.  Only
-the system chunk size needs a kernel change; that is this patch.
+the system chunk size needs a kernel change; that is patch 1.  Patch 2
+makes the chunk allocator prefer a dev extent hole that starts on the
+N GiB + 1 MiB grid over the first hole that fits, so the dev extents
+move onto that grid as they are balanced.
 
 The system value must be a multiple of 32 MiB (rounded down) and at
 least 32 MiB; data and metadata keep their 256 MiB granularity, and all
@@ -33,8 +36,7 @@ EPERM.  dev-extent-frag-test.sh fills a raid0/raid1 filesystem to full
 allocation, deletes most files, adds a device and balances, four rounds.
 With all three chunk sizes at 1 GiB every dev_extent is 1 GiB long and
 starts at N GiB + 1 MiB from the second or third round on (3 of 3 runs,
-with a separate patch that prefers aligned dev_extent holes when
-allocating chunks); with the system chunks left at 32 MiB the layout
+with patch 2); with the system chunks left at 32 MiB the layout
 never gets there and the 32 MiB dev_extents multiply.
 
 Zygo Blaxell (1):
index ec161f75e681c36f6c0ffc563bf953a69137b613..8dd200da42bc00f3066e09c4f59be2a480d9ce29 100644 (file)
@@ -10,6 +10,13 @@ stop leaving odd-sized holes.  A test must show the store accepts and rounds
 system values, rejects bad ones, and that new SYSTEM chunks (and their dev
 extents) are then allocated at the set size.
 
+Since 2026-11-06 the series has a second patch, "btrfs: prefer aligned
+dev_extent holes when allocating chunks" (until then a separate commit
+on the lanes): `find_free_dev_extent()` takes the first hole that is big
+enough and starts at N GiB + 1 MiB, else the first hole that fits as
+before.  The `dev-extent-frag-test.sh` grid results below were all
+measured with it applied.
+
 Kernel under test for the "Current" column: misc-next zb64 568c45b64012
 (uname 7.3.0-rc7+ #5, KASAN + PROVE_LOCKING) unless a row says otherwise.
 
@@ -39,8 +46,7 @@ of the dev and chunk trees, analysed by `devfrag-measure.py`; the dumps are
 kept), delete 80% of the files, add a device, full balance including
 system.  The criterion is Zygo's grid: every device reserves its first
 1 MiB, so a dev_extent is on the grid when it is 1 GiB long and starts at
-N GiB + 1 MiB -- the same rule as the lane's "prefer aligned dev_extent
-holes when allocating chunks" patch.  Each measurement reports the on-grid
+N GiB + 1 MiB -- the same rule as patch 2.  Each measurement reports the on-grid
 fraction per device and per block group type, aligned holes, and lists
 the off-grid extents.  uniform PASSes when the last fully allocated round
 is entirely on the grid.
@@ -84,6 +90,23 @@ chunks prevent it; it tests the mechanism, not the long-term effect.
 Shown to fail without the patch: on the misc-next base 0c48d26d46bd
 every system write is EPERM (FAIL 11), data and metadata unchanged.
 
+## 2026-11-06 round (fl1106: patch 2 moved into the series)
+
+The aligned-holes commit moved, unchanged in content, from the linear
+part of each lane above the testing merge into this topic, after the
+sysfs patch; only its subject and message are new.  Both lanes' integrated
+trees are identical before and after the move (apart from an unrelated
+balance-resume change).  Kernels: 6.18 #319 (bhive, ahive) and misc-next
+#68 (dhive, ehive), KASAN + lockdep + BTRFS_ASSERT; per-commit buildcheck
+of the topic on both lanes: no failures, no new warnings.  Evidence:
+`raid56-wh-harness/forensics/fl1106-618/`, `forensics/fl1106-mn/`.
+
+| test | patch(es) | duration | result | kernel |
+|---|---|---|---|---|
+| `sys-chunk-size-test.sh` | 1 | 10 s | PASS on all four | #319, #68 |
+| `dev-extent-frag-test.sh` uniform x2 per rig | 1, 2 | 6-12 min each | PASS 8/8: every run entirely on the grid from round 2 or 3 on (96/96 in round 3 everywhere) | #319, #68 |
+| `dev-extent-frag-test.sh` nosys x1 per rig | (control) | 11 min | report only: round 3 on grid 40/110 (bhive), 29/120 (ahive), 26/110 (dhive), 51/106 (ehive); the SYSTEM extents are never on the grid | #319, #68 |
+
 ## Not covered / open
 
 - Fragmentation with raid5/raid6/raid10 data, more rounds, and the vary