Skip to content

Commit

Permalink
Direct I/O writable file should do fsync in Close()
Browse files Browse the repository at this point in the history
Summary:
We don't do fsync() after truncate in direct I/O writeable file (in fact we don't do any fsync ever). This can cause metadata not persistent to disk after the file is generated. We call it instead.
Closes facebook#3500

Differential Revision: D6981482

Pulled By: siying

fbshipit-source-id: 7e2b591b7e5dd1b96fc0775515b8b9e6092980ef
  • Loading branch information
siying authored and facebook-github-bot committed Feb 14, 2018
1 parent d08d05c commit b3c5351
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions util/file_reader_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ Status WritableFileWriter::Close() {
// we need to let the file know where data ends.
if (use_direct_io()) {
interim = writable_file_->Truncate(filesize_);
if (interim.ok()) {
interim = writable_file_->Fsync();
}
if (!interim.ok() && s.ok()) {
s = interim;
}
Expand Down

0 comments on commit b3c5351

Please sign in to comment.