From 0af314b295f70fdf107524b08063f4d36fb4eeb6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 14 Mar 2022 11:54:00 +0100 Subject: [PATCH] Add comment for fsync --- src/model/block.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/model/block.rs b/src/model/block.rs index 8329bb6f..a41daa64 100644 --- a/src/model/block.rs +++ b/src/model/block.rs @@ -902,6 +902,11 @@ impl BlockManagerLocked { fs::remove_file(to_delete).await?; } + // We want to ensure that when this function returns, data is properly persisted + // to disk. The first step is the sync_all above that does an fsync on the data file. + // Now, we do an fsync on the containing directory, to ensure that the rename + // is persisted properly. See: + // http://thedjbway.b0llix.net/qmail/syncdir.html let dir = fs::OpenOptions::new() .read(true) .mode(0)