Repository navigation
fix(receiver): honour -B / --block-size on every wire transport - #7301
Conversation
04552fa to
3f5c13b
Compare
|
Rebased onto master ( One conflict, in So the construct is ⚠ One commit was dropped: It was authored before the pin moved to 3.5.0, and its entire effect was It did contain one improvement worth preserving separately: it replaced the non-unique Verified on the rebased head: |
3f5c13b to
f07eb03
Compare
The generator sizes the blocks it checksums, so `-B` is only ever acted
on by the receiving side (generator.c:720-721, `if (block_size) blength =
block_size;`). oc plumbed the option to exactly one receiving side: the
local-copy executor. Every network transfer silently fell back to the
700-byte BLOCK_SIZE default, so an operator-tuned `-B` produced a
different block signature, a different delta token stream and a different
matched/literal split than upstream, in both directions and on both
transports.
Measured against rsync 3.5.0 (protocol 32), 4096-byte file, basis
differing only in bytes 0..49:
-B 2048 no -B (control)
upstream local/ssh/daemon 2048 / 2048 700 / 3396
oc local 2048 / 2048 700 / 3396
oc ssh push/pull 700 / 3396 700 / 3396
oc daemon push 700 / 3396 700 / 3396
oc's wire output WITH `-B 2048` was byte-for-byte its own no-`-B` output.
The control run is what makes that unambiguous: identical numbers with
and without the option means the option was never applied, not that it
happened to agree.
Three independent drops, one per decoder:
1. `crates/cli/src/frontend/server/run.rs` - the `--server` argv parser
captured `-B<digits>` into `ServerLongFlags::block_size` (so it would
not leak into the positional path list) and then never read it.
2. `crates/core/src/client/remote/flags.rs` - `block_size_override` never
crossed from `ClientConfig` into the in-process `ServerConfig`, so a
PULL (client is the receiver) had no value to apply either.
3. `crates/daemon/.../client_args/long_form_args.rs` - the daemon decodes
the client argv through its own parser, which had no `-B` arm at all.
And one emission divergence found alongside them: the daemon arg vector
emitted `--block-size=N`, an oc-only long spelling. Upstream emits the
short `-B%u` (options.c:2953-2954), which is what the SSH builder already
did. No upstream daemon parses the long form, so even a correct decoder
would not have seen it.
The fix keeps the resolution rule single-sourced. There is exactly one
block-length heuristic - `signature::block_size::calculate_block_length`,
which already takes the override - and the receiving side reached it
through `SignatureLayoutParams::new(basis_size, None, ..)`. Carrying
`block_size` on `ServerConfig` and threading it through `BasisFileConfig`
replaces that hardcoded `None`; the bound check that mirrors upstream's
`parse_size_arg(.., 0, max_blength, False)` lives once in
`transfer::config::parse_block_size_arg` and is called by both the
`--server` parser and the daemon parser.
A test pinned the defect and had to be fixed with it:
`block_size_forwarded_both_directions` asserted the daemon vector
contained `--block-size=4096`. That assertion was the bug's monument - it
locked in the spelling no peer parses. It now asserts `-B4096` and that
the long form is absent.
Tests:
- `tests/block_size_wire.rs` runs the same option across local, SSH push
and SSH pull in one loop, because a per-path test would have passed on
whichever path its author picked. Reverting either wiring site
independently turns it red.
- The no-`-B` case is the non-vacuity control (`assert_ne!` against the
`-B 2048` numbers) and doubles as a short-final-block pin: 5 x 700 plus
a 596-byte tail, all of it matched.
- Unit tests for the shared parser (protocol-dependent ceiling, `0` means
heuristic, junk rejected) and for the generator actually using the
value rather than merely storing it.
The default-block-size case looked like it pinned short-final-block matching, and the PR body claimed it did. It does not. The basis differs only in bytes 0..49, so the 596-byte tail is preceded by a four-block match run and is reachable by adjacency continuation alone - a build that could ONLY reach a short final block by adjacency would pass this case identically. It remains a correct non-vacuity control for the block-size question, which is all this file is for. Renamed and re-documented to claim exactly that and nothing more. Pinning standalone-tail reachability needs a fixture sharing ONLY the tail, which belongs with the tail-block work.
68251d0 to
603fde7
Compare
* fix(receiver): honour -B / --block-size on every wire transport
The generator sizes the blocks it checksums, so `-B` is only ever acted
on by the receiving side (generator.c:720-721, `if (block_size) blength =
block_size;`). oc plumbed the option to exactly one receiving side: the
local-copy executor. Every network transfer silently fell back to the
700-byte BLOCK_SIZE default, so an operator-tuned `-B` produced a
different block signature, a different delta token stream and a different
matched/literal split than upstream, in both directions and on both
transports.
Measured against rsync 3.5.0 (protocol 32), 4096-byte file, basis
differing only in bytes 0..49:
-B 2048 no -B (control)
upstream local/ssh/daemon 2048 / 2048 700 / 3396
oc local 2048 / 2048 700 / 3396
oc ssh push/pull 700 / 3396 700 / 3396
oc daemon push 700 / 3396 700 / 3396
oc's wire output WITH `-B 2048` was byte-for-byte its own no-`-B` output.
The control run is what makes that unambiguous: identical numbers with
and without the option means the option was never applied, not that it
happened to agree.
Three independent drops, one per decoder:
1. `crates/cli/src/frontend/server/run.rs` - the `--server` argv parser
captured `-B<digits>` into `ServerLongFlags::block_size` (so it would
not leak into the positional path list) and then never read it.
2. `crates/core/src/client/remote/flags.rs` - `block_size_override` never
crossed from `ClientConfig` into the in-process `ServerConfig`, so a
PULL (client is the receiver) had no value to apply either.
3. `crates/daemon/.../client_args/long_form_args.rs` - the daemon decodes
the client argv through its own parser, which had no `-B` arm at all.
And one emission divergence found alongside them: the daemon arg vector
emitted `--block-size=N`, an oc-only long spelling. Upstream emits the
short `-B%u` (options.c:2953-2954), which is what the SSH builder already
did. No upstream daemon parses the long form, so even a correct decoder
would not have seen it.
The fix keeps the resolution rule single-sourced. There is exactly one
block-length heuristic - `signature::block_size::calculate_block_length`,
which already takes the override - and the receiving side reached it
through `SignatureLayoutParams::new(basis_size, None, ..)`. Carrying
`block_size` on `ServerConfig` and threading it through `BasisFileConfig`
replaces that hardcoded `None`; the bound check that mirrors upstream's
`parse_size_arg(.., 0, max_blength, False)` lives once in
`transfer::config::parse_block_size_arg` and is called by both the
`--server` parser and the daemon parser.
A test pinned the defect and had to be fixed with it:
`block_size_forwarded_both_directions` asserted the daemon vector
contained `--block-size=4096`. That assertion was the bug's monument - it
locked in the spelling no peer parses. It now asserts `-B4096` and that
the long form is absent.
Tests:
- `tests/block_size_wire.rs` runs the same option across local, SSH push
and SSH pull in one loop, because a per-path test would have passed on
whichever path its author picked. Reverting either wiring site
independently turns it red.
- The no-`-B` case is the non-vacuity control (`assert_ne!` against the
`-B 2048` numbers) and doubles as a short-final-block pin: 5 x 700 plus
a 596-byte tail, all of it matched.
- Unit tests for the shared parser (protocol-dependent ceiling, `0` means
heuristic, junk rejected) and for the generator actually using the
value rather than merely storing it.
* test(block-size): the no-B control is not a short-final-block pin
The default-block-size case looked like it pinned short-final-block
matching, and the PR body claimed it did. It does not. The basis differs
only in bytes 0..49, so the 596-byte tail is preceded by a four-block
match run and is reachable by adjacency continuation alone - a build that
could ONLY reach a short final block by adjacency would pass this case
identically.
It remains a correct non-vacuity control for the block-size question,
which is all this file is for. Renamed and re-documented to claim exactly
that and nothing more. Pinning standalone-tail reachability needs a
fixture sharing ONLY the tail, which belongs with the tail-block work.
What
-B/--block-sizewas honoured only on the local-copy path. Every network transfer silently fell back to the 700-byteBLOCK_SIZEdefault (rsync.h:25), so an operator-tuned block size produced a different block signature, a different delta token stream and a different matched/literal split than upstream — in both directions, on both transports.Measured
Against rsync 3.5.0 (protocol 32). 4096-byte file, basis differing only in bytes 0..49:
-B 2048-B(control)oc's wire output with
-B 2048was byte-for-byte its own no--Boutput. The control column is what makes that unambiguous: identical numbers with and without the option mean the option was never applied, not that it happened to agree.After the fix every cell matches upstream, including oc-client-to-upstream-daemon and upstream-client-to-oc-daemon.
Why it happened: three decoders, three drops
The generator is the side that sizes the blocks it checksums (
generator.c:720-721,if (block_size) blength = block_size;), so-Bis only ever acted on by the receiving side. oc has three places that decode a peer's options into a receiving-side config, and the value was lost in all three:crates/cli/src/frontend/server/run.rs— the--serverargv parser captured-B<digits>intoServerLongFlags::block_size(so it would not leak into the positional path list) and then never read the field.crates/core/src/client/remote/flags.rs—block_size_overridenever crossed fromClientConfiginto the in-processServerConfig, so a PULL (client is the receiver) had no value to apply either.crates/daemon/.../client_args/long_form_args.rs— the daemon decodes the client argv through its own parser, which had no-Barm at all.Plus one emission divergence found alongside them: the daemon arg vector emitted
--block-size=N, an oc-only long spelling. Upstream emits the short-B%u(options.c:2953-2954), which the SSH builder already did. No upstream daemon parses the long form, so even a correct decoder would not have seen it.What the fix does not do
It does not add a second block-length rule. There is exactly one heuristic —
signature::block_size::calculate_block_length, which already accepts the override — and the receiving side was reaching it throughSignatureLayoutParams::new(basis_size, None, ..). Carryingblock_sizeonServerConfigand threading it throughBasisFileConfigreplaces that hardcodedNone. The bound check mirroring upstream'sparse_size_arg(.., 0, max_blength, False)lives once, intransfer::config::parse_block_size_arg, and is called by both the--serverparser and the daemon parser.Adding the field to
BasisFileConfigalso made the compiler enumerate every construction site (four incrates/transfer, seven more in its integration tests) rather than leaving it to grep.A test pinned the defect
block_size_forwarded_both_directionsasserted the daemon vector contained--block-size=4096. That assertion was the bug's monument: it locked in the spelling no peer parses. It now asserts-B4096and that the long form is absent, and is renamed accordingly.Tests
tests/block_size_wire.rsruns the same option across local, SSH push and SSH pull in one loop. A per-path test would have passed on whichever path its author happened to pick — that is precisely how this survived. Reverting either wiring site independently turns it red (verified both ways).-Bcase is the non-vacuity control (assert_ne!against the-B 2048numbers): 5 x 700 plus a 596-byte tail.It is not a short-final-block pin, though it looks like one — an earlier revision of this body claimed it was. The basis differs only in bytes 0..49, so the tail is preceded by a four-block match run and is reachable by adjacency continuation alone; a build that could only reach a short final block by adjacency would pass it identically. Pinning standalone-tail reachability needs a fixture sharing only the tail, which belongs with the tail-block work.
-Bat or above the file length is one dirty block, so the delta degenerates to a whole-file send.0means heuristic, junk rejected) and for the generator actually using the value rather than merely storing it.Verification
Plus the manual oracle matrix above against a real rsync 3.5.0 binary, on local, SSH (push and pull) and rsync:// daemon, at
-B512 / 700 / 2048 / 4096 and with no-B.Not covered here
The daemon end-to-end cell is verified by hand (script in the reproducer) but not yet in nextest — the suite has no reusable daemon harness for a delta-stats assertion. Follow-up task filed.