mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-09 19:13:28 +02:00
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.
This commit is contained in:
committed by
Luke Dashjr
parent
220bb16cbe
commit
4574904038
@@ -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;
|
||||
|
Reference in New Issue
Block a user