diff --git a/crates/lib/src/podstorage.rs b/crates/lib/src/podstorage.rs index 2ff34073e..7d826b2ce 100644 --- a/crates/lib/src/podstorage.rs +++ b/crates/lib/src/podstorage.rs @@ -235,6 +235,14 @@ impl CStorage { ) .context("labeling storage root")?; + // fsync so relabel writes are durable before creating the stamp file + rustix::fs::fsync( + self.storage_root + .reopen_as_ownedfd() + .context("Reopening as owned fd")?, + ) + .context("fsync")?; + self.storage_root.create(LABELED)?; // Label the stamp file itself to match the storage directory context @@ -247,6 +255,14 @@ impl CStorage { ) .context("labeling stamp file")?; + // fsync to persist the stamp file entry + rustix::fs::fsync( + self.storage_root + .reopen_as_ownedfd() + .context("Reopening as owned fd")?, + ) + .context("fsync")?; + Ok(()) }