Skip to content

Conversation

@naoNao89
Copy link
Contributor

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.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 25, 2025

CodSpeed Performance Report

Merging #9016 will not alter performance

Comparing naoNao89:fix/dd-oflag-direct-isolated (bcba024) with main (21ee64c)

Summary

✅ 106 untouched
⏩ 73 skipped1

Footnotes

  1. 73 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@naoNao89 naoNao89 force-pushed the fix/dd-oflag-direct-isolated branch 6 times, most recently from f6b6d58 to 4d0e222 Compare October 25, 2025 14:51
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/dd/direct is no longer failing!

@romanstingler
Copy link

I had a different approach in mind, but your is faster.
Tested and works.
Nice

@naoNao89 naoNao89 force-pushed the fix/dd-oflag-direct-isolated branch 5 times, most recently from aa80de1 to dda4422 Compare October 26, 2025 00:02
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.
@naoNao89 naoNao89 force-pushed the fix/dd-oflag-direct-isolated branch from dda4422 to bcba024 Compare October 26, 2025 00:09
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/dd/direct is no longer failing!

@naoNao89 naoNao89 requested a review from sylvestre October 26, 2025 00:53
@sylvestre
Copy link
Contributor

Congrats! The gnu test tests/dd/direct is no longer failing!

kudos!

@sylvestre sylvestre merged commit c85d8b5 into uutils:main Oct 27, 2025
121 checks passed
@naoNao89 naoNao89 deleted the fix/dd-oflag-direct-isolated branch October 28, 2025 01:28
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.

3 participants