avoid ftruncate twice in buffered io

Summary:
in buffered io, the filesize_ is the real size.
Closes https://github.com/facebook/rocksdb/pull/1991

Differential Revision: D4711433

Pulled By: lightmark

fbshipit-source-id: ad604b9
main
Aaron Gao 8 years ago committed by Facebook Github Bot
parent d52f334cbd
commit 9272e12f19
  1. 9
      util/file_reader_writer.cc

@ -184,11 +184,14 @@ Status WritableFileWriter::Close() {
s = Flush(); // flush cache to OS
Status interim;
// In direct I/O mode we write whole pages so
// we need to let the file know where data ends.
Status interim = writable_file_->Truncate(filesize_);
if (!interim.ok() && s.ok()) {
s = interim;
if (use_direct_io()) {
interim = writable_file_->Truncate(filesize_);
if (!interim.ok() && s.ok()) {
s = interim;
}
}
TEST_KILL_RANDOM("WritableFileWriter::Close:0", rocksdb_kill_odds);

Loading…
Cancel
Save