Fix Fadvise on closed file when reads use mmap

Summary:
```PosixMmapReadableFile::fd_``` is closed after created, but needs to remain open for the lifetime of `PosixMmapReadableFile` since it is used whenever `InvalidateCache` is called.
Closes https://github.com/facebook/rocksdb/pull/2764

Differential Revision: D8152515

Pulled By: ajkr

fbshipit-source-id: b738a6a55ba4e392f9b0f374ff396a1e61c64f65
This commit is contained in:
奏之章 2018-05-25 10:47:56 -07:00 committed by Facebook Github Bot
parent 070319f7bb
commit 6e08916eb3
2 changed files with 2 additions and 1 deletions

4
env/env_posix.cc vendored
View File

@ -241,9 +241,9 @@ class PosixEnv : public Env {
size, options));
} else {
s = IOError("while mmap file for read", fname, errno);
}
}
close(fd);
}
}
} else {
if (options.use_direct_reads && !options.use_mmap_reads) {
#ifdef OS_MACOSX

1
env/io_posix.cc vendored
View File

@ -456,6 +456,7 @@ PosixMmapReadableFile::~PosixMmapReadableFile() {
fprintf(stdout, "failed to munmap %p length %" ROCKSDB_PRIszt " \n",
mmapped_region_, length_);
}
close(fd_);
}
Status PosixMmapReadableFile::Read(uint64_t offset, size_t n, Slice* result,