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
This commit is contained in:
Siying Dong 2018-02-13 16:20:13 -08:00 committed by Facebook Github Bot
parent d08d05cb62
commit b3c5351335

View File

@ -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;
}