fix(drivers): query real HVC block capacity instead of hardcoding 512 GiB - #13
Merged
Conversation
… GiB arcbox_hvc_blk hardcoded set_capacity to (sector_t)1<<30 (512 GiB) with 'VMM validates sector range' — but that only bounds I/O; the size the kernel and filesystem see was simply wrong. docker.img is an 8 TiB sparse file whose Btrfs metadata is grown to the visible size on each boot. Under VZ the guest saw 8 TiB; switching to the HV backend exposed only the hardcoded 512 GiB, so Btrfs refused to mount the data disk (open_ctree failed: total_bytes should be at most 549755813888 but found 8796093022208), permanently breaking Docker until the engine was switched back. Add ARCBOX_HVC_BLK_CAPACITY (0xC2000004) and query it per device, using the host's real capacity_sectors. Falls back to the previous fixed size when the host predates the call, so old-host/new-guest is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (permanent Docker corruption on VZ→HV switch)
arcbox_hvc_blkhardcodes the disk capacity:"VMM validates sector range" only bounds I/O — the size the kernel and filesystem see is just wrong.
docker.imgis an 8 TiB sparse file whose Btrfs metadata is grown (btrfs resize max) to the visible device size on each boot:total_bytes= 8 TiB.open_ctree failed: … total_bytes should be at most 549755813888 but found 8796093022208) → dockerd never starts → Docker permanently broken (host persistsbackend=hv, so restart/reboot never self-heals). Data is intact; switching back to VZ recovers.100% reproducible for any existing user who toggles HV.
Fix
Add
ARCBOX_HVC_BLK_CAPACITY(0xC2000004) and query it per device inarcbox_probe_one, using the host's realcapacity_sectors(already tracked host-side). Falls back to the previous fixed size whenres.a0 <= 0, so old-host / new-guest keeps the prior behavior; new-host / old-guest is unaffected. The host half is arcbox PR #453.Test plan
arcbox_hvc_flushHVC-call shape; CI builds arm64/x86 configs.