Direct I/O writable file should do fsync in Close()

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 https://github.com/facebook/rocksdb/pull/3500

Differential Revision: D6981482

Pulled By: siying

fbshipit-source-id: 7e2b591b7e5dd1b96fc0775515b8b9e6092980ef
main
Siying Dong 7 years ago committed by Facebook Github Bot
parent d08d05cb62
commit b3c5351335
  1. 3
      util/file_reader_writer.cc

@ -239,6 +239,9 @@ Status WritableFileWriter::Close() {
// we need to let the file know where data ends. // we need to let the file know where data ends.
if (use_direct_io()) { if (use_direct_io()) {
interim = writable_file_->Truncate(filesize_); interim = writable_file_->Truncate(filesize_);
if (interim.ok()) {
interim = writable_file_->Fsync();
}
if (!interim.ok() && s.ok()) { if (!interim.ok() && s.ok()) {
s = interim; s = interim;
} }

Loading…
Cancel
Save