Skip to content

Commit

Permalink
change the logic to WritableFileWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmark committed Mar 16, 2017
1 parent d514ecd commit 82a0ca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion util/file_reader_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ Status WritableFileWriter::Close() {

// 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 (use_direct_io()) {
Status interim = writable_file_->Truncate(filesize_);
}
if (!interim.ok() && s.ok()) {
s = interim;
}
Expand Down
12 changes: 5 additions & 7 deletions util/io_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,11 @@ Status PosixWritableFile::PositionedAppend(const Slice& data, uint64_t offset) {

Status PosixWritableFile::Truncate(uint64_t size) {
Status s;
if (use_direct_io()) {
int r = ftruncate(fd_, size);
if (r < 0) {
s = IOError(filename_, errno);
} else {
filesize_ = size;
}
int r = ftruncate(fd_, size);
if (r < 0) {
s = IOError(filename_, errno);
} else {
filesize_ = size;
}
return s;
}
Expand Down

0 comments on commit 82a0ca8

Please sign in to comment.