Skip to content

feat: allow replicas on full disks reclaim the space and squash all data into the heads - #572

Open
apoorvajagtap wants to merge 7 commits into
longhorn:masterfrom
apoorvajagtap:task-13636
Open

feat: allow replicas on full disks reclaim the space and squash all data into the heads#572
apoorvajagtap wants to merge 7 commits into
longhorn:masterfrom
apoorvajagtap:task-13636

Conversation

@apoorvajagtap

@apoorvajagtap apoorvajagtap commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Issue longhorn/longhorn#13636

What this PR does / why we need it:

This PR so far:

  • Scan all snap & head files to build a sector location list/map that indicates which snap file contains the latest data chunk at a specific offset.
  • For each sector [offset, length], if there is the latest data in a snap based on the above sector location map, directly and blindly punches holes for all snaps older than the snap.
  • moves the data from the snap file to the head then punches hole for those specific sectors in the snap file.

Special notes for your reviewer:

Additional documentation or context

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 488 lines in your changes missing coverage. Please review.
✅ Project coverage is 2.96%. Comparing base (6e546b4) to head (b05bb44).

Files with missing lines Patch % Lines
pkg/local/replica/recoverer/sectormap/chain.go 0.00% 140 Missing ⚠️
pkg/local/replica/recoverer/prune/punch.go 0.00% 96 Missing ⚠️
.../local/replica/recoverer/sectormap/location_map.go 0.00% 53 Missing ⚠️
pkg/local/replica/recoverer/coalesce/coalesce.go 0.00% 48 Missing ⚠️
pkg/local/replica/recoverer_linux.go 0.00% 41 Missing ⚠️
cmd/local/subcmd/recover.go 0.00% 39 Missing ⚠️
pkg/local/replica/recoverer/sectormap/output.go 0.00% 39 Missing ⚠️
pkg/local/replica/recoverer/sectormap/load.go 0.00% 25 Missing ⚠️
pkg/local/replica/recoverer/common/common.go 0.00% 6 Missing ⚠️
cmd/local/longhornctl-local.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master    #572      +/-   ##
=========================================
- Coverage    3.32%   2.96%   -0.36%     
=========================================
  Files          43      52       +9     
  Lines        4064    4552     +488     
=========================================
  Hits          135     135              
- Misses       3926    4414     +488     
  Partials        3       3              
Flag Coverage Δ
unittests 2.96% <0.00%> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@apoorvajagtap apoorvajagtap changed the title Allows replicas on full disks reclaim the space and squash all data into the heads [WIP] Allows replicas on full disks reclaim the space and squash all data into the heads Aug 5, 2026
@apoorvajagtap
apoorvajagtap marked this pull request as draft August 5, 2026 08:41
@apoorvajagtap
apoorvajagtap force-pushed the task-13636 branch 3 times, most recently from 684faa7 to 217130e Compare August 6, 2026 15:54
@apoorvajagtap
apoorvajagtap marked this pull request as ready for review August 6, 2026 15:55
@apoorvajagtap apoorvajagtap changed the title [WIP] Allows replicas on full disks reclaim the space and squash all data into the heads Allows replicas on full disks reclaim the space and squash all data into the heads Aug 7, 2026
@apoorvajagtap

Copy link
Copy Markdown
Contributor Author

@derekbit @shuo-wu I also had to update the vendored packages. I've kept those changes in separate commits to make the review easier. Let me know if there's a preferred approach for handling vendored package updates. Thanks!

@derekbit

derekbit commented Aug 7, 2026

Copy link
Copy Markdown
Member

@derekbit @shuo-wu I also had to update the vendored packages. I've kept those changes in separate commits to make the review easier. Let me know if there's a preferred approach for handling vendored package updates. Thanks!

We usually put a commit for updating vendor packages in the same PR. The commit title can be chore(vendor): update dependencies.

@apoorvajagtap apoorvajagtap changed the title Allows replicas on full disks reclaim the space and squash all data into the heads feat: allow replicas on full disks reclaim the space and squash all data into the heads Aug 7, 2026
@apoorvajagtap
apoorvajagtap force-pushed the task-13636 branch 6 times, most recently from 1e30f3a to 46482f6 Compare August 14, 2026 12:46
@mergify

mergify Bot commented Aug 16, 2026

Copy link
Copy Markdown

This pull request is now in conflict. Could you fix it @apoorvajagtap? 🙏

Comment thread cmd/local/subcmd/recover.go Outdated
Comment thread cmd/local/subcmd/recover.go Outdated
Comment thread cmd/local/subcmd/recover.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/load.go
Comment thread pkg/local/replica/recoverer/sectormap/load.go
Comment thread pkg/local/replica/recoverer/sectormap/output.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/output.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/output.go Outdated
Comment thread pkg/local/replica/recoverer/prune/punch.go Outdated
Comment thread pkg/local/replica/recoverer/prune/punch.go
@apoorvajagtap
apoorvajagtap force-pushed the task-13636 branch 2 times, most recently from 90babc4 to 7afeaa9 Compare August 21, 2026 15:03
@apoorvajagtap

apoorvajagtap commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

The following are still WIP, I'll update the comment once all the comments are addressed.
#572 (comment)
#572 (comment)

If b/w permits in the meantime, please feel free to look through the latest commits with rest of the changes. Thanks!

The latest commits have all the reviews addressed. PTAL!

@apoorvajagtap
apoorvajagtap force-pushed the task-13636 branch 2 times, most recently from 11ce150 to a52484d Compare August 24, 2026 18:18
@apoorvajagtap
apoorvajagtap requested a review from shuo-wu August 25, 2026 05:11
Comment thread pkg/local/replica/recoverer/prune/punch.go Outdated
Comment thread pkg/local/replica/recoverer/prune/punch.go Outdated
Comment thread pkg/local/replica/recoverer_linux.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/location_map.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/chain.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/location_map.go Outdated
@apoorvajagtap

Copy link
Copy Markdown
Contributor Author

@shuo-wu The latest commit incorporates the suggestions.

I have added a temporary logic as per mentioned here. Let me know your thoughts (I see a scope for efficiency a little)

I just realised I missed addressing the naming for OwnerFiles, shall send that out in the final fix.
PS: At present I have kept the commits separate for easier review & backtracking. I shall squash those once we are positive. Thanks!

Comment thread pkg/local/replica/recoverer/sectormap/chain.go Outdated
Comment thread pkg/local/replica/recoverer/sectormap/chain.go
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Comment thread pkg/local/replica/recoverer/sectormap/chain.go Outdated
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>
Signed-off-by: Apoorva Jagtap <apoorva.jagtap@suse.com>

@shuo-wu shuo-wu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now

@mergify

mergify Bot commented Sep 6, 2026

Copy link
Copy Markdown

This pull request is now in conflict. Could you fix it @apoorvajagtap? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants