diff options
author | Evan Klitzke <evan@eklitzke.org> | 2018-03-15 06:54:11 -0700 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2020-08-25 16:46:46 +0000 |
commit | 457490403853321d308c6ca6aaa90d6f8f29b4cf (patch) | |
tree | 698e6160ccd923c9472a57943671492f4b7ea594 /src/flatfile.cpp | |
parent | 220bb16cbee5b91d0bc0fcc6c71560d631295fa5 (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.
Diffstat (limited to 'src/flatfile.cpp')
-rw-r--r-- | src/flatfile.cpp | 1 |
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; |