Repository navigation
dd: ignore a failed cache drop while copying - #14748
ChihweiLHBird wants to merge 1 commit into
Conversation
Merging this PR will not alter performance
|
|
GNU testsuite comparison: |
5b69be5 to
ae1248c
Compare
|
I looked into the CodSpeed report. The regression is real but small, and it comes from compiler register allocation rather than from any added work.
Cause. None of these benchmarks pass I couldn't find a variant of this fix reaches zero instructions increase. Another variant, adding a bunch of |
c77a8fa to
e99a685
Compare
| // Using len=0 in posix_fadvise means "to end of file" | ||
| if i.settings.iflags.nocache { | ||
| i.discard_cache(0, 0); | ||
| let file = i |
There was a problem hiding this comment.
almost the same block twice for input and output, could be a small helper taking the name and the result, no?
There was a problem hiding this comment.
I don't think building a helper for them is a good idea. i and o are different type, and the error messages in translate! macro are also different. Building a helper might make it looks much messy than the current shape
f200407 to
74118f5
Compare
74118f5 to
5650bed
Compare
|
|
||
| // TODO: Is there a way to discard filesystem cache on other targets? | ||
| #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "freebsd")))] | ||
| #[allow( |
There was a problem hiding this comment.
these wrappers are just pass-throughs now, could the non-linux stub live in Source/Dest::discard_cache instead? that would drop both #[allow]
There was a problem hiding this comment.
Moved. But it adds an extra stub inside Source/Dest
5650bed to
8279227
Compare
There was a problem hiding this comment.
🟡 Changes recommended
GNU-source provenance must be clarified and the changed output-side count=0 path needs regression coverage.
2 open findings
What changed in this PR
Updates dd cache-discard handling so advisory failures during copying are ignored while count=0 failures remain fatal.
Changes:
- Return cache-discard errors to callers.
- Preserve diagnostics for
count=0. - Add pipe-copy regression coverage.
| File | Description |
|---|---|
src/uu/dd/src/dd.rs |
Moves cache-error policy to callers. |
src/uu/dd/src/bufferedoutput.rs |
Propagates cache-discard results. |
tests/by-util/test_dd.rs |
Tests silent pipe copying with nocache. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8279227 to
40f78b8
Compare
40f78b8 to
f457f28
Compare
f457f28 to
fe75807
Compare
fe75807 to
ee528b4
Compare
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
ee528b4 to
cfd839d
Compare


Summary
iflag=nocacheandoflag=nocachediagnosed every failed cache drop, so copying from or to a pipe printedfailed to discard cache for: 'standard input': Illegal seekonce per read and exited 1 even though the copy succeeded. GNU ignores those failures while copying and diagnoses them only withcount=0.Source::discard_cacheandDest::discard_cachenow return the error,InputandOutputpass it through, and the callers decide:dd_copyignores it, thecount=0path reports it and sets the exit status.nocacheis accepted only on Linux and Android, so other targets are unaffected; the platform stub moved fromInput/OutputintoSource/Dest, which lets the wrappers be plain pass-throughs.Part of #14705 (
tests/dd/nocache.sh).Example
dd if=/dev/zero bs=1M count=1 status=none | dd iflag=nocache bs=1M of=/dev/nullBefore: one
failed to discard cacheline per read, exit 1. After: silent, exit 0, as GNU 9.12.count=0still diagnoses the failure: