Skip to content

sync: allow target partition larger than source#406

Merged
deitch merged 1 commit into
diskfs:masterfrom
eriknordmark:sync-verify-target-larger-than-source
Jun 1, 2026
Merged

sync: allow target partition larger than source#406
deitch merged 1 commit into
diskfs:masterfrom
eriknordmark:sync-verify-target-larger-than-source

Conversation

@eriknordmark
Copy link
Copy Markdown
Contributor

Split out of #404 per review feedback.

verifyBlockCopy required both partitions' full ReadContents byte
count to equal expectedSize, so copying a smaller source into a larger
target failed even when the leading bytes matched — the normal shape
when growing a partition before a later swap-and-delete renames it into
place.

It now requires each side to hold at least expectedSize bytes, hashes
exactly expectedSize bytes per side via NewLimitWriter, and drops the
equality check on the target's full size. A smaller-than-expected
partition is still an error.

Adds an internal regression test (TestVerifyBlockCopyTargetLargerThanSource)
that copies an 8 MiB source into a 24 MiB target and confirms both the
clean-grow and corrupted-target cases.

Closes #403.

verifyBlockCopy required both partitions' full ReadContents byte count
to equal expectedSize, so copying a smaller source into a larger target
failed even when the leading bytes matched. That larger-target shape is
the normal one when growing a partition before a later swap-and-delete
renames it into place.

Require each side to hold at least expectedSize bytes, hash exactly
expectedSize bytes per side via NewLimitWriter, and drop the equality
check on the target's full size. A smaller-than-expected partition is
still treated as an error.

Closes diskfs#403.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eriknordmark eriknordmark marked this pull request as ready for review May 29, 2026 17:55
@deitch deitch merged commit 17393bf into diskfs:master Jun 1, 2026
20 checks passed
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.

sync.verifyBlockCopy fails when target partition is larger than source

2 participants