aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Klitzke <evan@eklitzke.org>2018-03-15 06:54:11 -0700
committerLuke Dashjr <luke-jr+git@utopios.org>2020-08-25 16:46:46 +0000
commit457490403853321d308c6ca6aaa90d6f8f29b4cf (patch)
tree698e6160ccd923c9472a57943671492f4b7ea594
parent220bb16cbee5b91d0bc0fcc6c71560d631295fa5 (diff)
Fix possible data race when committing block files
It was recently pointed out to me that calling fsync() or fdatasync() on a new file is not sufficient to ensure it's persisted to disk, a the existence of the file itself is stored in the directory inode. This means that ensuring that a new file is actually committed also requires an fsync() on the parent directory. This change ensures that we call fsync() on the blocks directory after committing new block files.
-rw-r--r--src/flatfile.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/flatfile.cpp b/src/flatfile.cpp
index 8a8f7b681c..11cf357f3d 100644
--- a/src/flatfile.cpp
+++ b/src/flatfile.cpp
@@ -92,6 +92,7 @@ bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
fclose(file);
return error("%s: failed to commit file %d", __func__, pos.nFile);
}
+ DirectoryCommit(m_dir);
fclose(file);
return true;