Skip to content

restore direct I/O flags for payload file operations#303

Merged
matthyx merged 1 commit intomainfrom
directio
Mar 29, 2026
Merged

restore direct I/O flags for payload file operations#303
matthyx merged 1 commit intomainfrom
directio

Conversation

@matthyx
Copy link
Copy Markdown
Contributor

@matthyx matthyx commented Mar 25, 2026

Summary by CodeRabbit

  • Chores
    • Improved registry storage handling so payload reads and writes automatically fall back when direct I/O is unsupported, reducing failures on affected systems.
    • Maintained existing error handling, decoding/migration, and locking behavior while increasing cross-platform reliability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

Added a helper that opens payload files with the direct-I/O flag and transparently retries without it when the kernel reports direct I/O is unsupported; replaced payload create/read open calls (including post-lock retry paths) to use this fallback while preserving surrounding logic. (≤50 words)

Changes

Cohort / File(s) Summary
Payload open fallback
pkg/registry/file/storage.go
Added openPayloadFileWithFallback and switched payload creation and read code paths (initial open and post-lock retry branches) to use it, so opens retry without O_DIRECT when that fails.
Direct I/O support check
pkg/registry/file/open_flag_linux.go, pkg/registry/file/open_flag_other.go
Added isDirectIOUnsupported(err error) bool: Linux checks errno for EINVAL or EOPNOTSUPP; non-Linux builds return false.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I tapped the disk with careful paws,
Tried the bold O_DIRECT because, why not?
If the kernel says no, I hop back and pause,
Then open gently, still keeping each dot. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: restoring direct I/O flags for payload file operations by adding fallback logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch directio

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/registry/file/storage.go`:
- Line 203: The payload file opens currently pass openFlagDirect unconditionally
on Linux which causes hard failures when filesystems return EINVAL for
unsupported O_DIRECT; extract the open logic into a helper (e.g.,
openFileWithDirectFallback or openPayloadFileWithFallback) that calls
s.appFs.OpenFile with the original flags and, on a platform-specific "direct I/O
unsupported" error (implement isDirectIOUnsupported alongside openFlagDirect to
map errno like EINVAL/EOPNOTSUPP on Linux), retries the open without
openFlagDirect; replace direct s.appFs.OpenFile calls (locations around
makePayloadPath(p) and the sites at the ranges reflected by lines 203, 447, 490,
982, 1015) to use the new helper to gracefully fall back to buffered I/O.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 44b49f9c-2904-4698-af65-f46acf29f4ef

📥 Commits

Reviewing files that changed from the base of the PR and between a53f3f7 and 3a03863.

📒 Files selected for processing (1)
  • pkg/registry/file/storage.go

@github-actions
Copy link
Copy Markdown

Summary:

  • License scan: failure
  • Credentials scan: failure
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: failure

@github-actions
Copy link
Copy Markdown

Summary:

  • License scan: failure
  • Credentials scan: failure
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: failure

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/registry/file/storage.go (1)

84-86: Consider adding a debug metric/log when fallback is triggered.

A lightweight counter/log on the retry path would improve runtime visibility into how often direct I/O is unavailable in real deployments.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/registry/file/storage.go` around lines 84 - 86, When the fallback to
s.appFs.OpenFile(...) is taken (inside the if err != nil &&
isDirectIOUnsupported(err) block), add a lightweight telemetry/logging action to
record this event: increment a counter metric (e.g., DirectIOFallback counter on
an existing metrics collector) and emit a debug-level log with context (path and
original error) so operators can see how often direct I/O is unavailable; update
the block around isDirectIOUnsupported(...) to call the metric increment and a
debug log before calling s.appFs.OpenFile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/registry/file/storage.go`:
- Around line 84-86: When the fallback to s.appFs.OpenFile(...) is taken (inside
the if err != nil && isDirectIOUnsupported(err) block), add a lightweight
telemetry/logging action to record this event: increment a counter metric (e.g.,
DirectIOFallback counter on an existing metrics collector) and emit a
debug-level log with context (path and original error) so operators can see how
often direct I/O is unavailable; update the block around
isDirectIOUnsupported(...) to call the metric increment and a debug log before
calling s.appFs.OpenFile.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 678a9982-2f8d-485e-98ac-95eca0573a25

📥 Commits

Reviewing files that changed from the base of the PR and between a407639 and 4462eed.

📒 Files selected for processing (3)
  • pkg/registry/file/open_flag_linux.go
  • pkg/registry/file/open_flag_other.go
  • pkg/registry/file/storage.go

@github-actions
Copy link
Copy Markdown

Summary:

  • License scan: failure
  • Credentials scan: failure
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: failure

@matthyx matthyx merged commit ad364e7 into main Mar 29, 2026
7 checks passed
@matthyx matthyx deleted the directio branch March 29, 2026 19:45
@matthyx matthyx moved this to To Archive in KS PRs tracking Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant