Skip to content

statefile: use stable inode for write lock - #1149

Merged
Johan-Liebert1 merged 1 commit into
coreos:mainfrom
Rolv-Apneseth:stable_inode
Sep 1, 2026
Merged

statefile: use stable inode for write lock#1149
Johan-Liebert1 merged 1 commit into
coreos:mainfrom
Rolv-Apneseth:stable_inode

Conversation

@Rolv-Apneseth

Copy link
Copy Markdown
Member

The previous implementation used atomic_write_with_perms to create the lockfile, which replaces the file via rename on every call. This meant that concurrent callers could flock different inodes, defeating the purpose of the lock.

Let's replace that with OpenOptions create-or-open, which only creates the file if it doesn't already exist and opens the existing one otherwise, ensuring all callers lock the same inode. The lack of atomic writing here should not be an issue as the file has no content anyway.

Originally pointed out by the bot on #1138, see #1138 (comment)

The previous implementation used atomic_write_with_perms to create the
lockfile, which replaces the file via rename on every call. This meant
that concurrent callers could flock different inodes, defeating the
purpose of the lock.

Let's replace that with OpenOptions create-or-open, which only creates
the file if it doesn't already exist and opens the existing one
otherwise, ensuring all callers lock the same inode. The lack of atomic
writing here should not be an issue as the file has no content anyway.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 3d6696d1-578c-437a-b14b-8c86fd792990

📥 Commits

Reviewing files that changed from the base of the PR and between ebb58fb and 6074363.

📒 Files selected for processing (1)
  • src/backend/statefile.rs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: Tests, unstable toolchain (nightly)
  • GitHub Check: Tests, stable toolchain
  • GitHub Check: bootc-e2e (ubuntu-24.04-arm, 1)
  • GitHub Check: bootc-e2e (ubuntu-24.04, 1)
  • GitHub Check: bootc-e2e (ubuntu-24.04, 0)
  • GitHub Check: Tests (release), minimum supported toolchain
  • GitHub Check: bootc-e2e (ubuntu-24.04-arm, 0)
  • GitHub Check: Build on s390x
  • GitHub Check: Build on ppc64le
  • GitHub Check: Tests (release), stable toolchain
🧰 Additional context used
📓 Path-based instructions (1)
Backend and state-file changes affect persistent bootloader update state. Preserve compatibility with existing state and ensure updates remain atomic and recoverable after interruption.

⚙️ CodeRabbit configuration file

Files:

  • src/backend/statefile.rs
🔇 Additional comments (1)
src/backend/statefile.rs (1)

12-12: LGTM!

Also applies to: 84-91


📝 Walkthrough

Walkthrough

The statefile backend now creates and opens the write-lock file in one operation with write/create options and 0o644 permissions.

Changes

Lock File Acquisition

Layer / File(s) Summary
Configure lock-file creation and opening
src/backend/statefile.rs
acquire_write_lock uses OpenOptions and OpenOptionsExt to create and open the lock file through sysroot.open_with. The previous atomic write and separate open operations were removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 60743

The change makes lockfile creation reuse a stable inode so concurrent callers coordinate on the same lock; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: johan-liebert1

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required subsystem and lowercase description format. It uses imperative mood, describes the lock-file inode change, and has no trailing period.
Description check ✅ Passed The description directly explains the inode-locking issue and the change to OpenOptions create-or-open semantics.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Commit Message Convention ✅ Passed The PR adds one non-merge commit. Its subject is statefile: use stable inode for write lock; statefile is a component name, use is lowercase and imperative, and the description has no trailing p…
Full details: Commit Message Convention

Explanation

The PR adds one non-merge commit. Its subject is statefile: use stable inode for write lock; statefile is a component name, use is lowercase and imperative, and the description has no trailing period. The parent is a merge commit and is ignored.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@Johan-Liebert1
Johan-Liebert1 merged commit bc4244d into coreos:main Sep 1, 2026
14 of 15 checks passed
@Rolv-Apneseth
Rolv-Apneseth deleted the stable_inode branch September 1, 2026 08:44
@cgwalters

Copy link
Copy Markdown
Member

Ouch.

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