From: Siying Dong Date: Wed, 14 Feb 2018 00:20:13 +0000 (-0800) Subject: Direct I/O writable file should do fsync in Close() X-Git-Tag: rocksdb-5.10.3~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ad79400af15531dec4357664a9c90957505af1a;p=rocksdb.git 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 --- diff --git a/util/file_reader_writer.cc b/util/file_reader_writer.cc index f46b78fa0..3fc02bee3 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; }