fix(dd): handle O_DIRECT partial block writes#9016
Merged
sylvestre merged 1 commit intouutils:mainfrom Oct 27, 2025
Merged
Conversation
CodSpeed Performance ReportMerging #9016 will not alter performanceComparing Summary
Footnotes
|
f6b6d58 to
4d0e222
Compare
|
GNU testsuite comparison: |
|
I had a different approach in mind, but your is faster. |
sylvestre
reviewed
Oct 25, 2025
aa80de1 to
dda4422
Compare
Fix dd failures with 'IO Error: Invalid input' when using oflag=direct with partial blocks. The issue occurs because O_DIRECT requires proper alignment for all writes, but the final partial block may not meet these requirements. This fix: - Detects EINVAL errors that might be O_DIRECT alignment issues - Temporarily removes O_DIRECT flag using fcntl(F_SETFL) - Retries the write operation without the direct flag - Restores original flags (safer than GNU approach) - Only activates on Linux/Android platforms where O_DIRECT is supported Matches GNU dd behavior discovered through strace analysis.
dda4422 to
bcba024
Compare
|
GNU testsuite comparison: |
Contributor
kudos! |
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.
hey, got a fix for that dd oflag=direct "invalid input" error on this branch.
addresses issue #9003 where dd fails with 'IO Error: Invalid input' when using oflag=direct with partial blocks.
also related to issue #6078 about gnu test failures. turns out gnu dd temporarily removes the o_direct flag for blocks, but
we weren't doing that. added a simple helper function that detects the alignment error, removes the flag, retries the write, then puts it.
only affects linux/android where o_direct actually works. studied the codebase history, the original file write code
4621557 hasn't changed since so this builds on established patterns.