From b3c535133598716ad19727d602ab886813240b9c Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Tue, 13 Feb 2018 16:20:13 -0800 Subject: [PATCH] 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 --- util/file_reader_writer.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/file_reader_writer.cc b/util/file_reader_writer.cc index 448efa7e3..677cf2076 100644 --- a/util/file_reader_writer.cc +++ b/util/file_reader_writer.cc @@ -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; }