Skip to content

podstorage: fsync storage root before and after creating .bootc_labeled#2066

Open
andrewdunndev wants to merge 1 commit intobootc-dev:mainfrom
andrewdunndev:fix/fsync-bootc-labeled
Open

podstorage: fsync storage root before and after creating .bootc_labeled#2066
andrewdunndev wants to merge 1 commit intobootc-dev:mainfrom
andrewdunndev:fix/fsync-bootc-labeled

Conversation

@andrewdunndev
Copy link
Contributor

Adds fsync calls to ensure_labeled() in podstorage to improve crash resilience around the .bootc_labeled stamp file, as suggested in #1210.

The storage root directory is synced after relabeling (so the label writes are durable before the stamp is created) and again after creating and labeling the stamp file (so the directory entry is persisted). This prevents a crash from leaving the system in a state where the stamp exists but the relabeling writes were lost, which would cause the relabeling to be silently skipped on next boot.

Uses the existing reopen_as_ownedfd() + rustix::fs::fsync() pattern to work around the O_PATH fd limitation on cap-std directories.

Closes #1210

Sync the storage root directory after relabeling to ensure the label
writes are durable before creating the stamp file, and again after
creating and labeling the stamp file to persist the directory entry.
This avoids a crash leaving the system in a state where the stamp
exists but the relabeling writes were lost.

Closes: bootc-dev#1210
Signed-off-by: Andrew Dunn <andrew@dunn.dev>
@bootc-bot bootc-bot bot requested a review from gursewak1997 March 13, 2026 19:16
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces fsync calls to ensure_labeled() to improve crash resilience, which is a good improvement. The implementation correctly adds fsync before creating the .bootc_labeled stamp file and after labeling it to ensure data durability. My only suggestion is to refactor the duplicated fsync logic into a helper function to improve code maintainability.

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.

Sync before/after creating .bootc_labeled

1 participant