bcachefs: implement online filesystem shrinking#1073
Conversation
|
Nice work — the reconcile-based approach for online shrinking is the right direction. Some feedback: On-disk format: Adding The evacuation loop: The
Allocation cutoff: if (unlikely(ca->mi.target_nbuckets && bucket >= ca->mi.target_nbuckets)) {This replaces
This inline function does a division ( Commented-out code: The Style nits:
Testing: Good that you have ktest tests for this: https://github.com/jullanggit/ktest/tree/shrink. Consider adding cases for:
Overall this is solid WIP. The hard parts (cached data handling, journal, resume after crash) are acknowledged as TODOs, which is the right approach — get the happy path working first. — ProofOfConcept |
6303f5b to
990d039
Compare
|
Thank you for the review! I'll continue working on this, and will ping you once I feel like another review would help. |
a6d79f5 to
82c906f
Compare
| Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202602181006.rLTgu86r-lkp@intel.com/
this addition is backwards compatible because new fields are initialized to zero, which means no pending resize, and are not read by older kernels
avoids stripe reshuffling
also comment in outline of shrink path
…elying on ca->mi.target_nbuckets avoids possible edge cases if device is being removed mid-shrink etc.
This is done analogous to the remove alloc info path
Shrink still used a wall-clock no-progress deadline after moving to tail head plus aggregate backpointer tracking. That fixed the minute-scale outlier, but it kept the final ENOSPC heuristic tied to host speed and load. Keep the shrink-local tail snapshots, but replace the wall-clock deadline with counted reconcile work. Record how much work a completed reconcile kick actually scanned or processed, rescan the shrinking device whenever a completed kick found nothing to do, and only count completed no-progress kicks that did real reconcile work toward ENOSPC. Shrink still wakes once per second so it can rescan the tail instead of sitting behind one long reconcile kick, but the impossible-shrink heuristic itself is now based on completed no-progress work, not time.
A shrink tail can stay flat for many reconcile kicks while foreground IO or reconcile itself is still changing metadata. Counting those no-progress kicks as ENOSPC evidence can fail a shrink that would have completed on the next wave of writes. Tighten the heuristic so it only counts no-progress passes after a full device rescan and only when the journal stayed quiet across that pass. If the journal moved, force another device rescan from the current cutoff instead of claiming the tail is impossible to evacuate. That keeps ENOSPC on the stall path, but only after the blocker set has stopped moving for repeated full rescans.
c43a605 to
84ce651
Compare
|
Small helper PR for this branch: It is intentionally narrow: kernel brace style for the new pointer helper, avoids the hot-path divide in Related tools-side bridge: That tools PR is clean/green at head This does not try to solve the larger cached-data, progress/wakeup, journal/resume, or ktest follow-ups from Kent’s review. |
|
I took another pass on this because it is blocking the high-score shrink cluster ( Rebased helper branch:
What changed beyond the existing shrink stack:
Validation I ran:
I did not force-push |
This is already internally called by bch2_dev_remove_alloc
…ss into bch2_dev_remove_need_discard
…nto caller bch2_dev_remove_alloc() now does the same operations wheter it is passed a cutoff or not. Removing usage is not directly handled by both the shrink (as previously) and remove (new) caller.
explanation not needed
use helper macros and add comments
extracts some duplicate logic
…r_extent_reconcile_phys_update and update comments
Implement online filesystem shrinking through reconcile. Closes #781 once done.
This is hopefully complementary to #1070, which targets offline shrink.
Goal
A robust online shrinking implementation, that automatically resumes after restarts/crashes, as shrinking is a potentially long-running operation, and supports changing the target size mid-shrink.
Current state
Implementation
Reuses large parts of the device remove/evacuate paths
Documentation
Not yet written
Testing
See https://github.com/jullanggit/ktest/tree/shrink for the tests used